[llvm-commits] [llvm] r59097 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Tue Nov 11 16:05:17 PST 2008
Author: foldr
Date: Tue Nov 11 18:05:17 2008
New Revision: 59097
URL: http://llvm.org/viewvc/llvm-project?rev=59097&view=rev
Log:
Add a bit of lazy evaluation to PopulateCompilationGraph().
Only the tools that are mentioned in the compilation graph definition
are now inserted by PopulateCompilationGraph(). This should cut down
plugin loading time a little.
Modified:
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=59097&r1=59096&r2=59097&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Nov 11 18:05:17 2008
@@ -1595,26 +1595,33 @@
{
ListInit* edges = CompilationGraph->getValueAsListInit("edges");
- // Generate code
O << "namespace {\n\n";
O << "void PopulateCompilationGraphLocal(CompilationGraph& G) {\n";
- // Insert vertices
+ // Insert vertices.
+ // Only tools mentioned in the graph definition are inserted.
- RecordVector Tools = Records.getAllDerivedDefinitions("Tool");
- if (Tools.empty())
- throw std::string("No tool definitions found!");
+ llvm::StringSet<> ToolsInGraph;
+
+ for (unsigned i = 0; i < edges->size(); ++i) {
+ Record* Edge = edges->getElementAsRecord(i);
+ Record* A = Edge->getValueAsDef("a");
+ Record* B = Edge->getValueAsDef("b");
- for (RecordVector::iterator B = Tools.begin(), E = Tools.end(); B != E; ++B) {
- const std::string& Name = (*B)->getName();
- if (Name != "root")
- O << Indent1 << "G.insertNode(new "
- << Name << "());\n";
+ if (A->getName() != "root")
+ ToolsInGraph.insert(A->getName());
+ if (B->getName() != "root")
+ ToolsInGraph.insert(B->getName());
}
+ for (llvm::StringSet<>::iterator B = ToolsInGraph.begin(),
+ E = ToolsInGraph.end(); B != E; ++B)
+ O << Indent1 << "G.insertNode(new " << B->first() << "());\n";
+
O << '\n';
- // Insert edges
+ // Insert edges.
+
for (unsigned i = 0; i < edges->size(); ++i) {
Record* Edge = edges->getElementAsRecord(i);
Record* A = Edge->getValueAsDef("a");
More information about the llvm-commits
mailing list