[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Jan 14 12:55:21 PST 2006
Changes in directory llvm/lib/VMCore:
Dominators.cpp updated: 1.67 -> 1.68
---
Log message:
Change ET-Forest to automatically recalculate its DFSnum's if too many slow
queries are made.
Patch by Daniel Berlin!
---
Diffs of the changes: (+22 -5)
Dominators.cpp | 27 ++++++++++++++++++++++-----
1 files changed, 22 insertions(+), 5 deletions(-)
Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.67 llvm/lib/VMCore/Dominators.cpp:1.68
--- llvm/lib/VMCore/Dominators.cpp:1.67 Mon Jan 9 01:58:01 2006
+++ llvm/lib/VMCore/Dominators.cpp Sat Jan 14 14:55:09 2006
@@ -812,6 +812,21 @@
Nodes.clear();
}
+void ETForestBase::updateDFSNumbers()
+{
+ int dfsnum = 0;
+ // Iterate over all nodes in depth first order.
+ for (unsigned i = 0, e = Roots.size(); i != e; ++i)
+ for (df_iterator<BasicBlock*> I = df_begin(Roots[i]),
+ E = df_end(Roots[i]); I != E; ++I) {
+ BasicBlock *BB = *I;
+ if (!getNode(BB)->hasFather())
+ getNode(BB)->assignDFSNumber(dfsnum);
+ }
+ SlowQueries = 0;
+ DFSInfoValid = true;
+}
+
ETNode *ETForest::getNodeForBlock(BasicBlock *BB) {
ETNode *&BBNode = Nodes[BB];
if (BBNode) return BBNode;
@@ -855,12 +870,14 @@
}
}
- int dfsnum = 0;
- for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
- if (!getNodeForBlock(I)->hasFather())
- getNodeForBlock(I)->assignDFSNumber(dfsnum);
+ // Make sure we've got nodes around for every block
+ for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
+ ETNode *&BBNode = Nodes[I];
+ if (!BBNode)
+ BBNode = new ETNode(I);
}
- DFSInfoValid = true;
+
+ updateDFSNumbers ();
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list