[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp
Devang Patel
dpatel at apple.com
Thu Jun 7 16:53:01 PDT 2007
Changes in directory llvm/lib/VMCore:
Dominators.cpp updated: 1.107 -> 1.108
---
Log message:
Add instruction level dominates(A,B) interface.
---
Diffs of the changes: (+23 -0)
Dominators.cpp | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+)
Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.107 llvm/lib/VMCore/Dominators.cpp:1.108
--- llvm/lib/VMCore/Dominators.cpp:1.107 Thu Jun 7 12:47:21 2007
+++ llvm/lib/VMCore/Dominators.cpp Thu Jun 7 18:52:40 2007
@@ -324,6 +324,29 @@
DFSInfoValid = true;
}
+// dominates - Return true if A dominates B. THis performs the
+// special checks necessary if A and B are in the same basic block.
+bool DominatorTreeBase::dominates(Instruction *A, Instruction *B) {
+ BasicBlock *BBA = A->getParent(), *BBB = B->getParent();
+ if (BBA != BBB) return dominates(BBA, BBB);
+
+ // 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;
+ } else {
+ // A post-dominates B if B is found first in the basic block.
+ return &*I == B;
+ }
+}
// DominatorTreeBase::reset - Free all of the tree node memory.
//
More information about the llvm-commits
mailing list