[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp
Owen Anderson
resistor at mac.com
Sat Apr 14 16:49:46 PDT 2007
Changes in directory llvm/lib/VMCore:
Dominators.cpp updated: 1.92 -> 1.93
---
Log message:
Make ETForest depend on DomTree rather than IDom. This is the first step
in the long process that will be fixing PR 217: http://llvm.org/PR217 .
---
Diffs of the changes: (+11 -8)
Dominators.cpp | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.92 llvm/lib/VMCore/Dominators.cpp:1.93
--- llvm/lib/VMCore/Dominators.cpp:1.92 Mon Apr 9 01:44:42 2007
+++ llvm/lib/VMCore/Dominators.cpp Sat Apr 14 18:49:24 2007
@@ -899,15 +899,15 @@
BasicBlock *BBA = A->getParent(), *BBB = B->getParent();
if (BBA != BBB) return dominates(BBA, BBB);
- // Loop through the basic block until we find A or B.
- BasicBlock::iterator I = BBA->begin();
- for (; &*I != A && &*I != B; ++I) /*empty*/;
-
// It is not possible to determine dominance between two PHI nodes
// based on their ordering.
if (isa<PHINode>(A) && isa<PHINode>(B))
return false;
+ // Loop through the basic block until we find A or B.
+ BasicBlock::iterator I = BBA->begin();
+ for (; &*I != A && &*I != B; ++I) /*empty*/;
+
if(!IsPostDominators) {
// A dominates B if it is found first in the basic block.
return &*I == A;
@@ -929,7 +929,7 @@
// Haven't calculated this node yet? Get or calculate the node for the
// immediate dominator.
- BasicBlock *IDom = getAnalysis<ImmediateDominators>()[BB];
+ BasicBlock *IDom = getAnalysis<DominatorTree>().getNode(BB)->getIDom()->getBlock();
// If we are unreachable, we may not have an immediate dominator.
if (!IDom)
@@ -945,15 +945,17 @@
}
}
-void ETForest::calculate(const ImmediateDominators &ID) {
+void ETForest::calculate(const DominatorTree &DT) {
assert(Roots.size() == 1 && "ETForest should have 1 root block!");
BasicBlock *Root = Roots[0];
Nodes[Root] = new ETNode(Root); // Add a node for the root
Function *F = Root->getParent();
// Loop over all of the reachable blocks in the function...
- for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
- if (BasicBlock *ImmDom = ID.get(I)) { // Reachable block.
+ for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
+ DominatorTree::Node* node = DT.getNode(I);
+ if (node && node->getIDom()) { // Reachable block.
+ BasicBlock* ImmDom = node->getIDom()->getBlock();
ETNode *&BBNode = Nodes[I];
if (!BBNode) { // Haven't calculated this node yet?
// Get or calculate the node for the immediate dominator
@@ -965,6 +967,7 @@
BBNode->setFather(IDomNode);
}
}
+ }
// Make sure we've got nodes around for every block
for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
More information about the llvm-commits
mailing list