diff options
author | Owen Anderson <resistor@mac.com> | 2007-04-14 23:49:24 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2007-04-14 23:49:24 +0000 |
commit | 690c684fc60883171c01da12d826fda6b5678aa8 (patch) | |
tree | 451d3d81c32455a988b1a5836894d978ef3bbaa3 | |
parent | 01015d4a0e75ee75a13bae102772ba1b0bf81796 (diff) | |
download | llvm-690c684fc60883171c01da12d826fda6b5678aa8.tar.gz llvm-690c684fc60883171c01da12d826fda6b5678aa8.tar.bz2 llvm-690c684fc60883171c01da12d826fda6b5678aa8.tar.xz |
Make ETForest depend on DomTree rather than IDom. This is the first step
in the long process that will be fixing PR 217.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36034 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Analysis/Dominators.h | 10 | ||||
-rw-r--r-- | lib/VMCore/Dominators.cpp | 19 |
2 files changed, 16 insertions, 13 deletions
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 03a579f5c8..6826b94254 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -422,7 +422,7 @@ public: virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequired<ImmediateDominators>(); + AU.addRequired<DominatorTree>(); } //===--------------------------------------------------------------------===// // API to update Forest information based on modifications @@ -480,13 +480,13 @@ public: virtual bool runOnFunction(Function &F) { reset(); // Reset from the last time we were run... - ImmediateDominators &ID = getAnalysis<ImmediateDominators>(); - Roots = ID.getRoots(); - calculate(ID); + DominatorTree &DT = getAnalysis<DominatorTree>(); + Roots = DT.getRoots(); + calculate(DT); return false; } - void calculate(const ImmediateDominators &ID); + void calculate(const DominatorTree &DT); ETNode *getNodeForBlock(BasicBlock *BB); }; diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 707f133303..da8d36d902 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -899,15 +899,15 @@ bool ETForestBase::dominates(Instruction *A, Instruction *B) { 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 @@ ETNode *ETForest::getNodeForBlock(BasicBlock *BB) { // 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 @@ ETNode *ETForest::getNodeForBlock(BasicBlock *BB) { } } -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 @@ void ETForest::calculate(const ImmediateDominators &ID) { 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) { |