diff options
Diffstat (limited to 'contrib/llvm/lib/Analysis/LoopPass.cpp')
-rw-r--r-- | contrib/llvm/lib/Analysis/LoopPass.cpp | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/contrib/llvm/lib/Analysis/LoopPass.cpp b/contrib/llvm/lib/Analysis/LoopPass.cpp index 9af717bafdca..07a151ce0fce 100644 --- a/contrib/llvm/lib/Analysis/LoopPass.cpp +++ b/contrib/llvm/lib/Analysis/LoopPass.cpp @@ -142,8 +142,17 @@ void LPPassManager::getAnalysisUsage(AnalysisUsage &Info) const { void LPPassManager::markLoopAsDeleted(Loop &L) { assert((&L == CurrentLoop || CurrentLoop->contains(&L)) && "Must not delete loop outside the current loop tree!"); - if (&L == CurrentLoop) + // If this loop appears elsewhere within the queue, we also need to remove it + // there. However, we have to be careful to not remove the back of the queue + // as that is assumed to match the current loop. + assert(LQ.back() == CurrentLoop && "Loop queue back isn't the current loop!"); + LQ.erase(std::remove(LQ.begin(), LQ.end(), &L), LQ.end()); + + if (&L == CurrentLoop) { CurrentLoopDeleted = true; + // Add this loop back onto the back of the queue to preserve our invariants. + LQ.push_back(&L); + } } /// run - Execute all of the passes scheduled for execution. Keep track of @@ -151,7 +160,10 @@ void LPPassManager::markLoopAsDeleted(Loop &L) { bool LPPassManager::runOnFunction(Function &F) { auto &LIWP = getAnalysis<LoopInfoWrapperPass>(); LI = &LIWP.getLoopInfo(); + Module &M = *F.getParent(); +#if 0 DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); +#endif bool Changed = false; // Collect inherited analysis from Module level pass manager. @@ -181,6 +193,8 @@ bool LPPassManager::runOnFunction(Function &F) { } // Walk Loops + unsigned InstrCount = 0; + bool EmitICRemark = M.shouldEmitInstrCountChangedRemark(); while (!LQ.empty()) { CurrentLoopDeleted = false; CurrentLoop = LQ.back(); @@ -198,8 +212,11 @@ bool LPPassManager::runOnFunction(Function &F) { { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); TimeRegion PassTimer(getPassTimer(P)); - + if (EmitICRemark) + InstrCount = initSizeRemarkInfo(M); Changed |= P->runOnLoop(CurrentLoop, *this); + if (EmitICRemark) + emitInstrCountChangedRemark(P, M, InstrCount); } if (Changed) @@ -225,8 +242,12 @@ bool LPPassManager::runOnFunction(Function &F) { // is that LPPassManager might run passes which do not require LCSSA // form (LoopPassPrinter for example). We should skip verification for // such passes. + // FIXME: Loop-sink currently break LCSSA. Fix it and reenable the + // verification! +#if 0 if (mustPreserveAnalysisID(LCSSAVerificationPass::ID)) - CurrentLoop->isRecursivelyLCSSAForm(*DT, *LI); + assert(CurrentLoop->isRecursivelyLCSSAForm(*DT, *LI)); +#endif // Then call the regular verifyAnalysis functions. verifyPreservedAnalysis(P); @@ -351,13 +372,13 @@ bool LoopPass::skipLoop(const Loop *L) const { return false; // Check the opt bisect limit. LLVMContext &Context = F->getContext(); - if (!Context.getOptBisect().shouldRunPass(this, *L)) + if (!Context.getOptPassGate().shouldRunPass(this, *L)) return true; // Check for the OptimizeNone attribute. if (F->hasFnAttribute(Attribute::OptimizeNone)) { // FIXME: Report this to dbgs() only once per function. - DEBUG(dbgs() << "Skipping pass '" << getPassName() - << "' in function " << F->getName() << "\n"); + LLVM_DEBUG(dbgs() << "Skipping pass '" << getPassName() << "' in function " + << F->getName() << "\n"); // FIXME: Delete loop from pass manager's queue? return true; } |