[llvm] r248230 - [LoopUnswitch] Require DominatorTree info.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 17:22:48 PDT 2015
Author: mzolotukhin
Date: Mon Sep 21 19:22:47 2015
New Revision: 248230
URL: http://llvm.org/viewvc/llvm-project?rev=248230&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=248230&r1=248229&r2=248230&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Mon Sep 21 19:22:47 2015
@@ -193,6 +193,7 @@ namespace {
AU.addPreserved<LoopInfoWrapperPass>();
AU.addRequiredID(LCSSAID);
AU.addPreservedID(LCSSAID);
+ AU.addRequired<DominatorTreeWrapperPass>();
AU.addPreserved<DominatorTreeWrapperPass>();
AU.addPreserved<ScalarEvolutionWrapperPass>();
AU.addRequired<TargetTransformInfoWrapperPass>();
@@ -412,23 +413,19 @@ bool LoopUnswitch::runOnLoop(Loop *L, LP
*L->getHeader()->getParent());
LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
LPM = &LPM_Ref;
- DominatorTreeWrapperPass *DTWP =
- getAnalysisIfAvailable<DominatorTreeWrapperPass>();
- DT = DTWP ? &DTWP->getDomTree() : nullptr;
+ DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
currentLoop = L;
Function *F = currentLoop->getHeader()->getParent();
bool Changed = false;
do {
- assert(!DT || currentLoop->isLCSSAForm(*DT));
+ assert(currentLoop->isLCSSAForm(*DT));
redoLoop = false;
Changed |= processCurrentLoop();
} while(redoLoop);
- if (Changed) {
- // FIXME: Reconstruct dom info, because it is not preserved properly.
- if (DT)
- DT->recalculate(*F);
- }
+ // FIXME: Reconstruct dom info, because it is not preserved properly.
+ if (Changed)
+ DT->recalculate(*F);
return Changed;
}
@@ -1196,8 +1193,7 @@ void LoopUnswitch::RewriteLoopBodyWithCo
// domtree here -- instead we force it to do a full recomputation
// after the pass is complete -- but we do need to inform it of
// new blocks.
- if (DT)
- DT->addNewBlock(Abort, NewSISucc);
+ DT->addNewBlock(Abort, NewSISucc);
}
SimplifyCode(Worklist, L);
More information about the llvm-commits
mailing list