Add a verifyAnalysis to LoopInfo, LoopSimplify, and LCSSA form that verify

that these passes are properly preserved.

Fix several transformation passes that claimed to preserve LoopSimplify
form but weren't.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80926 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-09-03 16:31:42 +00:00
parent c8b26880fd
commit 8fc5ad3369
10 changed files with 287 additions and 143 deletions

View File

@ -58,6 +58,7 @@ namespace {
DominatorTree *DT;
std::vector<BasicBlock*> LoopBlocks;
PredIteratorCache PredCache;
Loop *L;
virtual bool runOnLoop(Loop *L, LPPassManager &LPM);
@ -72,9 +73,9 @@ namespace {
AU.setPreservesCFG();
AU.addRequiredID(LoopSimplifyID);
AU.addPreservedID(LoopSimplifyID);
AU.addRequired<LoopInfo>();
AU.addRequiredTransitive<LoopInfo>();
AU.addPreserved<LoopInfo>();
AU.addRequired<DominatorTree>();
AU.addRequiredTransitive<DominatorTree>();
AU.addPreserved<ScalarEvolution>();
AU.addPreserved<DominatorTree>();
@ -86,6 +87,17 @@ namespace {
AU.addPreserved<DominanceFrontier>();
}
private:
/// verifyAnalysis() - Verify loop nest.
virtual void verifyAnalysis() const {
#ifndef NDEBUG
// Sanity check: Check basic loop invariants.
L->verifyLoop();
// Check the special guarantees that LCSSA makes.
assert(L->isLCSSAForm());
#endif
}
void getLoopValuesUsedOutsideLoop(Loop *L,
SetVector<Instruction*> &AffectedValues,
const SmallVector<BasicBlock*, 8>& exitBlocks);
@ -107,7 +119,8 @@ Pass *llvm::createLCSSAPass() { return new LCSSA(); }
const PassInfo *const llvm::LCSSAID = &X;
/// runOnFunction - Process all loops in the function, inner-most out.
bool LCSSA::runOnLoop(Loop *L, LPPassManager &LPM) {
bool LCSSA::runOnLoop(Loop *l, LPPassManager &LPM) {
L = l;
PredCache.clear();
LI = &LPM.getAnalysis<LoopInfo>();