1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

Add method to check to see if two _Instructions_ dominate each other

llvm-svn: 2616
This commit is contained in:
Chris Lattner 2002-05-13 22:03:16 +00:00
parent 1b769f2a94
commit 2735171cf5
3 changed files with 35 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "llvm/Pass.h"
#include <set>
class Instruction;
//===----------------------------------------------------------------------===//
//
@ -95,6 +96,12 @@ public:
return getDominators(B).count(A) != 0;
}
// dominates - Return true if A dominates B. This performs the special checks
// neccesary if A and B are in the same basic block.
//
bool dominates(Instruction *A, Instruction *B) const;
// getAnalysisUsage - This obviously provides a dominator set, but it also
// uses the UnifyFunctionExitNode pass if building post-dominators
//

View File

@ -31,6 +31,20 @@ bool DominatorSet::runOnFunction(Function *F) {
return false;
}
// dominates - Return true if A dominates B. This performs the special checks
// neccesary if A and B are in the same basic block.
//
bool DominatorSet::dominates(Instruction *A, Instruction *B) const {
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*/;
// A dominates B if it is found first in the basic block...
return *I == A;
}
// calcForwardDominatorSet - This method calculates the forward dominator sets
// for the specified function.

View File

@ -31,6 +31,20 @@ bool DominatorSet::runOnFunction(Function *F) {
return false;
}
// dominates - Return true if A dominates B. This performs the special checks
// neccesary if A and B are in the same basic block.
//
bool DominatorSet::dominates(Instruction *A, Instruction *B) const {
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*/;
// A dominates B if it is found first in the basic block...
return *I == A;
}
// calcForwardDominatorSet - This method calculates the forward dominator sets
// for the specified function.