Utilize topological sort in CompilationGraph::Build().

This makes more interesting graph topologies possible. Currently all tests pass,
but more testing is needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50744 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvmc2/llvmc.cpp b/tools/llvmc2/llvmc.cpp
index aeb8b33..87c0e41 100644
--- a/tools/llvmc2/llvmc.cpp
+++ b/tools/llvmc2/llvmc.cpp
@@ -38,7 +38,7 @@
 cl::opt<bool> VerboseMode("v",
                           cl::desc("Enable verbose mode"));
 cl::opt<bool> WriteGraph("write-graph",
-                         cl::desc("Write CompilationGraph.dot file"),
+                         cl::desc("Write compilation-graph.dot file"),
                          cl::Hidden);
 cl::opt<bool> ViewGraph("view-graph",
                          cl::desc("Show compilation graph in GhostView"),
@@ -72,7 +72,8 @@
 
     if (WriteGraph) {
       graph.writeGraph();
-      return 0;
+      if (!ViewGraph)
+        return 0;
     }
 
     if (ViewGraph) {
@@ -80,7 +81,6 @@
       return 0;
     }
 
-
     if (InputFilenames.empty()) {
       std::cerr << "No input files.\n";
       return 1;