[llvm-commits] [llvm] r50744 - in /llvm/trunk/tools/llvmc2: CompilationGraph.cpp Tool.h llvmc.cpp
Mikhail Glushenkov
foldr at codedgers.com
Tue May 6 11:07:48 PDT 2008
Author: foldr
Date: Tue May 6 13:07:48 2008
New Revision: 50744
URL: http://llvm.org/viewvc/llvm-project?rev=50744&view=rev
Log:
Utilize topological sort in CompilationGraph::Build().
This makes more interesting graph topologies possible. Currently all tests pass,
but more testing is needed.
Modified:
llvm/trunk/tools/llvmc2/CompilationGraph.cpp
llvm/trunk/tools/llvmc2/Tool.h
llvm/trunk/tools/llvmc2/llvmc.cpp
Modified: llvm/trunk/tools/llvmc2/CompilationGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/CompilationGraph.cpp?rev=50744&r1=50743&r2=50744&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/CompilationGraph.cpp (original)
+++ llvm/trunk/tools/llvmc2/CompilationGraph.cpp Tue May 6 13:07:48 2008
@@ -234,6 +234,40 @@
// 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 @@
std::ofstream O("CompilationGraph.dot");
if (O.good()) {
- llvm::WriteGraph(this, "CompilationGraph");
+ llvm::WriteGraph(this, "compilation-graph");
O.close();
}
else {
Modified: llvm/trunk/tools/llvmc2/Tool.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/Tool.h?rev=50744&r1=50743&r2=50744&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/Tool.h (original)
+++ llvm/trunk/tools/llvmc2/Tool.h Tue May 6 13:07:48 2008
@@ -55,16 +55,17 @@
// Join tools have an input file list associated with them.
class JoinTool : public Tool {
public:
- void AddToJoinList(const llvm::sys::Path& P) { JoinList.push_back(P); }
- void ClearJoinList() { JoinList.clear(); }
+ void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
+ void ClearJoinList() { JoinList_.clear(); }
+ bool JoinListEmpty() const { return JoinList_.empty(); }
Action GenerateAction(const llvm::sys::Path& outFile) const
- { return GenerateAction(JoinList, outFile); }
- // We shouldn't shadow GenerateAction from the base class.
+ { return GenerateAction(JoinList_, outFile); }
+ // We shouldn't shadow base class's version of GenerateAction.
using Tool::GenerateAction;
private:
- PathVector JoinList;
+ PathVector JoinList_;
};
}
Modified: llvm/trunk/tools/llvmc2/llvmc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc2/llvmc.cpp?rev=50744&r1=50743&r2=50744&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc2/llvmc.cpp (original)
+++ llvm/trunk/tools/llvmc2/llvmc.cpp Tue May 6 13:07:48 2008
@@ -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;
More information about the llvm-commits
mailing list