diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-09-21 22:30:50 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-09-21 22:30:50 +0000 |
| commit | 22151ce5e91a0b40f31bb1bb6e82aec514ef063d (patch) | |
| tree | 10b53c6a06c4a9c6015e301ebf1339c181f51576 /llvm/lib | |
| parent | 7d08da6b2afa96f3c1ea63907f5e34d11e80cce9 (diff) | |
| download | bcm5719-llvm-22151ce5e91a0b40f31bb1bb6e82aec514ef063d.tar.gz bcm5719-llvm-22151ce5e91a0b40f31bb1bb6e82aec514ef063d.zip | |
move DominatorTree::dominates for instructions out of line,
no functionality change.
llvm-svn: 82490
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Dominators.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Dominators.cpp b/llvm/lib/VMCore/Dominators.cpp index bb73aaf705d..6d0e23d6427 100644 --- a/llvm/lib/VMCore/Dominators.cpp +++ b/llvm/lib/VMCore/Dominators.cpp @@ -52,6 +52,25 @@ void DominatorTree::print(raw_ostream &OS, const Module *) const { DT->print(OS); } +// dominates - Return true if A dominates B. This performs the +// special checks necessary if A and B are in the same basic block. +bool DominatorTree::dominates(const Instruction *A, const Instruction *B) const{ + const 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::const_iterator I = BBA->begin(); + for (; &*I != A && &*I != B; ++I) + /*empty*/; + + return &*I == A; +} + //===----------------------------------------------------------------------===// |

