From: Michael Zolotukhin Date: Tue, 22 Sep 2015 00:22:47 +0000 (+0000) Subject: [LoopUnswitch] Require DominatorTree info. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9e242e684e8810a89261b6165c33be0d83574fa8;p=oota-llvm.git [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248230 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index a00603bd22f..abd8994023d 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -193,6 +193,7 @@ namespace { AU.addPreserved(); AU.addRequiredID(LCSSAID); AU.addPreservedID(LCSSAID); + AU.addRequired(); AU.addPreserved(); AU.addPreserved(); AU.addRequired(); @@ -412,23 +413,19 @@ bool LoopUnswitch::runOnLoop(Loop *L, LPPassManager &LPM_Ref) { *L->getHeader()->getParent()); LI = &getAnalysis().getLoopInfo(); LPM = &LPM_Ref; - DominatorTreeWrapperPass *DTWP = - getAnalysisIfAvailable(); - DT = DTWP ? &DTWP->getDomTree() : nullptr; + DT = &getAnalysis().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::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, // 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);