forked from OSchip/llvm-project
[LoopUnswitch] Require DominatorTree info.
Summary: We should either require the DT info to be available, or check if it's available in every place we use DT (and we already miss such check in one place, which causes failures in some cases). As other loop passes preserve DT and it's usually available, it makes sense to just require it here. There is no regression test, because the bug only shows up if pass manager decides to clean DT info right before LoopUnswitch. If loop-unswitch is run separately, DT is available, so bug isn't exposed. Reviewers: chandlerc, hfinkel Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13036 llvm-svn: 248230
This commit is contained in:
parent
7167585c94
commit
9f3aea6e1f
|
@ -193,6 +193,7 @@ namespace {
|
||||||
AU.addPreserved<LoopInfoWrapperPass>();
|
AU.addPreserved<LoopInfoWrapperPass>();
|
||||||
AU.addRequiredID(LCSSAID);
|
AU.addRequiredID(LCSSAID);
|
||||||
AU.addPreservedID(LCSSAID);
|
AU.addPreservedID(LCSSAID);
|
||||||
|
AU.addRequired<DominatorTreeWrapperPass>();
|
||||||
AU.addPreserved<DominatorTreeWrapperPass>();
|
AU.addPreserved<DominatorTreeWrapperPass>();
|
||||||
AU.addPreserved<ScalarEvolutionWrapperPass>();
|
AU.addPreserved<ScalarEvolutionWrapperPass>();
|
||||||
AU.addRequired<TargetTransformInfoWrapperPass>();
|
AU.addRequired<TargetTransformInfoWrapperPass>();
|
||||||
|
@ -412,23 +413,19 @@ bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) {
|
||||||
*L->getHeader()->getParent());
|
*L->getHeader()->getParent());
|
||||||
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
|
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
|
||||||
LPM = &LPM_Ref;
|
LPM = &LPM_Ref;
|
||||||
DominatorTreeWrapperPass *DTWP =
|
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||||
getAnalysisIfAvailable<DominatorTreeWrapperPass>();
|
|
||||||
DT = DTWP ? &DTWP->getDomTree() : nullptr;
|
|
||||||
currentLoop = L;
|
currentLoop = L;
|
||||||
Function *F = currentLoop->getHeader()->getParent();
|
Function *F = currentLoop->getHeader()->getParent();
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
do {
|
do {
|
||||||
assert(!DT || currentLoop->isLCSSAForm(*DT));
|
assert(currentLoop->isLCSSAForm(*DT));
|
||||||
redoLoop = false;
|
redoLoop = false;
|
||||||
Changed |= processCurrentLoop();
|
Changed |= processCurrentLoop();
|
||||||
} while(redoLoop);
|
} while(redoLoop);
|
||||||
|
|
||||||
if (Changed) {
|
// FIXME: Reconstruct dom info, because it is not preserved properly.
|
||||||
// FIXME: Reconstruct dom info, because it is not preserved properly.
|
if (Changed)
|
||||||
if (DT)
|
DT->recalculate(*F);
|
||||||
DT->recalculate(*F);
|
|
||||||
}
|
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,8 +1193,7 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
|
||||||
// domtree here -- instead we force it to do a full recomputation
|
// domtree here -- instead we force it to do a full recomputation
|
||||||
// after the pass is complete -- but we do need to inform it of
|
// after the pass is complete -- but we do need to inform it of
|
||||||
// new blocks.
|
// new blocks.
|
||||||
if (DT)
|
DT->addNewBlock(Abort, NewSISucc);
|
||||||
DT->addNewBlock(Abort, NewSISucc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SimplifyCode(Worklist, L);
|
SimplifyCode(Worklist, L);
|
||||||
|
|
Loading…
Reference in New Issue