Convert the verifier over to use ETForest instead of DominatorSet. Patch

by Daniel Berlin


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25242 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-01-12 06:17:59 +00:00
parent a5959bfdfa
commit 0b2192c99b

View File

@ -68,7 +68,7 @@ namespace { // Anonymous namespace for class
VerifierFailureAction action; VerifierFailureAction action;
// What to do if verification fails. // What to do if verification fails.
Module *Mod; // Module we are verifying right now Module *Mod; // Module we are verifying right now
DominatorSet *DS; // Dominator set, caution can be null! ETForest *EF; // ET-Forest, caution can be null!
std::stringstream msgs; // A stringstream to collect messages std::stringstream msgs; // A stringstream to collect messages
/// InstInThisBlock - when verifying a basic block, keep track of all of the /// InstInThisBlock - when verifying a basic block, keep track of all of the
@ -79,17 +79,17 @@ namespace { // Anonymous namespace for class
Verifier() Verifier()
: Broken(false), RealPass(true), action(AbortProcessAction), : Broken(false), RealPass(true), action(AbortProcessAction),
DS(0), msgs( std::ios::app | std::ios::out ) {} EF(0), msgs( std::ios::app | std::ios::out ) {}
Verifier( VerifierFailureAction ctn ) Verifier( VerifierFailureAction ctn )
: Broken(false), RealPass(true), action(ctn), DS(0), : Broken(false), RealPass(true), action(ctn), EF(0),
msgs( std::ios::app | std::ios::out ) {} msgs( std::ios::app | std::ios::out ) {}
Verifier(bool AB ) Verifier(bool AB )
: Broken(false), RealPass(true), : Broken(false), RealPass(true),
action( AB ? AbortProcessAction : PrintMessageAction), DS(0), action( AB ? AbortProcessAction : PrintMessageAction), EF(0),
msgs( std::ios::app | std::ios::out ) {} msgs( std::ios::app | std::ios::out ) {}
Verifier(DominatorSet &ds) Verifier(ETForest &ef)
: Broken(false), RealPass(false), action(PrintMessageAction), : Broken(false), RealPass(false), action(PrintMessageAction),
DS(&ds), msgs( std::ios::app | std::ios::out ) {} EF(&ef), msgs( std::ios::app | std::ios::out ) {}
bool doInitialization(Module &M) { bool doInitialization(Module &M) {
@ -106,7 +106,7 @@ namespace { // Anonymous namespace for class
bool runOnFunction(Function &F) { bool runOnFunction(Function &F) {
// Get dominator information if we are being run by PassManager // Get dominator information if we are being run by PassManager
if (RealPass) DS = &getAnalysis<DominatorSet>(); if (RealPass) EF = &getAnalysis<ETForest>();
visit(F); visit(F);
InstsInThisBlock.clear(); InstsInThisBlock.clear();
@ -139,7 +139,7 @@ namespace { // Anonymous namespace for class
virtual void getAnalysisUsage(AnalysisUsage &AU) const { virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll(); AU.setPreservesAll();
if (RealPass) if (RealPass)
AU.addRequired<DominatorSet>(); AU.addRequired<ETForest>();
} }
/// abortIfBroken - If the module is broken and we are supposed to abort on /// abortIfBroken - If the module is broken and we are supposed to abort on
@ -582,7 +582,7 @@ void Verifier::visitInstruction(Instruction &I) {
for (Value::use_iterator UI = I.use_begin(), UE = I.use_end(); for (Value::use_iterator UI = I.use_begin(), UE = I.use_end();
UI != UE; ++UI) UI != UE; ++UI)
Assert1(*UI != (User*)&I || Assert1(*UI != (User*)&I ||
!DS->dominates(&BB->getParent()->getEntryBlock(), BB), !EF->dominates(&BB->getParent()->getEntryBlock(), BB),
"Only PHI nodes may reference their own value!", &I); "Only PHI nodes may reference their own value!", &I);
} }
@ -633,20 +633,20 @@ void Verifier::visitInstruction(Instruction &I) {
// If they are in the same basic block, make sure that the definition // If they are in the same basic block, make sure that the definition
// comes before the use. // comes before the use.
Assert2(InstsInThisBlock.count(Op) || Assert2(InstsInThisBlock.count(Op) ||
!DS->dominates(&BB->getParent()->getEntryBlock(), BB), !EF->dominates(&BB->getParent()->getEntryBlock(), BB),
"Instruction does not dominate all uses!", Op, &I); "Instruction does not dominate all uses!", Op, &I);
} }
// Definition must dominate use unless use is unreachable! // Definition must dominate use unless use is unreachable!
Assert2(DS->dominates(OpBlock, BB) || Assert2(EF->dominates(OpBlock, BB) ||
!DS->dominates(&BB->getParent()->getEntryBlock(), BB), !EF->dominates(&BB->getParent()->getEntryBlock(), BB),
"Instruction does not dominate all uses!", Op, &I); "Instruction does not dominate all uses!", Op, &I);
} else { } else {
// PHI nodes are more difficult than other nodes because they actually // PHI nodes are more difficult than other nodes because they actually
// "use" the value in the predecessor basic blocks they correspond to. // "use" the value in the predecessor basic blocks they correspond to.
BasicBlock *PredBB = cast<BasicBlock>(I.getOperand(i+1)); BasicBlock *PredBB = cast<BasicBlock>(I.getOperand(i+1));
Assert2(DS->dominates(OpBlock, PredBB) || Assert2(EF->dominates(OpBlock, PredBB) ||
!DS->dominates(&BB->getParent()->getEntryBlock(), PredBB), !EF->dominates(&BB->getParent()->getEntryBlock(), PredBB),
"Instruction does not dominate all uses!", Op, &I); "Instruction does not dominate all uses!", Op, &I);
} }
} }