diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-06 18:07:48 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2008-05-06 18:07:48 +0000 |
commit | 73d866efda92d25b74611f6c0348c8f8d9824e93 (patch) | |
tree | 490f49b9485e49dd27f9b4005109d4b37d251064 /llvm/tools/llvmc2/CompilationGraph.cpp | |
parent | 7701512231d505be8cfbd97a8620e75360a72d73 (diff) | |
download | bcm5719-llvm-73d866efda92d25b74611f6c0348c8f8d9824e93.tar.gz bcm5719-llvm-73d866efda92d25b74611f6c0348c8f8d9824e93.zip |
Utilize topological sort in CompilationGraph::Build().
This makes more interesting graph topologies possible. Currently all tests pass,
but more testing is needed.
llvm-svn: 50744
Diffstat (limited to 'llvm/tools/llvmc2/CompilationGraph.cpp')
-rw-r--r-- | llvm/tools/llvmc2/CompilationGraph.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/llvm/tools/llvmc2/CompilationGraph.cpp b/llvm/tools/llvmc2/CompilationGraph.cpp index 8f3918f9e4d..a130ee54574 100644 --- a/llvm/tools/llvmc2/CompilationGraph.cpp +++ b/llvm/tools/llvmc2/CompilationGraph.cpp @@ -234,6 +234,40 @@ int CompilationGraph::Build (const sys::Path& TempDir) { // For all join nodes in topological order: for (std::vector<const Node*>::iterator B = JTV.begin(), E = JTV.end(); B != E; ++B) { + // TOFIX: more testing, merge some parts with PassThroughGraph. + sys::Path Out; + const Node* CurNode = *B; + JoinTool* JT = &dynamic_cast<JoinTool&>(*CurNode->ToolPtr.getPtr()); + bool IsLast = false; + + if (JT->JoinListEmpty()) + continue; + + if (!CurNode->HasChildren() || JT->IsLast()) { + if (OutputFilename.empty()) { + Out.set("a"); + Out.appendSuffix(JT->OutputSuffix()); + } + else + Out.set(OutputFilename); + IsLast = true; + } + else { + Out = TempDir; + Out.appendComponent("tmp"); + Out.appendSuffix(JT->OutputSuffix()); + Out.makeUnique(true, NULL); + Out.eraseFromDisk(); + } + + if (JT->GenerateAction(Out).Execute() != 0) + throw std::runtime_error("Tool returned error code!"); + + if (!IsLast) { + const Node* NextNode = &getNode(ChooseEdge(CurNode->OutEdges, + CurNode->Name())->ToolName()); + PassThroughGraph(Out, NextNode, TempDir); + } } return 0; @@ -276,7 +310,7 @@ void CompilationGraph::writeGraph() { std::ofstream O("CompilationGraph.dot"); if (O.good()) { - llvm::WriteGraph(this, "CompilationGraph"); + llvm::WriteGraph(this, "compilation-graph"); O.close(); } else { |