diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopPassManager.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopPassManager.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp index 3fe8e7259114..f4fce4871331 100644 --- a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp +++ b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp @@ -14,6 +14,7 @@ #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" #include "llvm/Analysis/TargetLibraryInfo.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/TimeProfiler.h" using namespace llvm; @@ -26,10 +27,6 @@ PreservedAnalyses PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater &>::run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U) { - - if (DebugLogging) - dbgs() << "Starting Loop pass manager run.\n"; - // Runs loop-nest passes only when the current loop is a top-level one. PreservedAnalyses PA = (L.isOutermost() && !LoopNestPasses.empty()) ? runWithLoopNestPasses(L, AM, AR, U) @@ -44,9 +41,6 @@ PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, // be preserved, but unrolling should invalidate the parent loop's analyses. PA.preserveSet<AllAnalysesOn<Loop>>(); - if (DebugLogging) - dbgs() << "Finished Loop pass manager run.\n"; - return PA; } @@ -114,6 +108,11 @@ LoopPassManager::runWithLoopNestPasses(Loop &L, LoopAnalysisManager &AM, // Check if the current pass preserved the loop-nest object or not. IsLoopNestPtrValid &= PassPA->getChecker<LoopNestAnalysis>().preserved(); + // After running the loop pass, the parent loop might change and we need to + // notify the updater, otherwise U.ParentL might gets outdated and triggers + // assertion failures in addSiblingLoops and addChildLoops. + U.setParentLoop(L.getParentLoop()); + // FIXME: Historically, the pass managers all called the LLVM context's // yield function here. We don't have a generic way to acquire the // context and it isn't yet clear what the right pattern is for yielding @@ -158,6 +157,11 @@ LoopPassManager::runWithoutLoopNestPasses(Loop &L, LoopAnalysisManager &AM, // aggregate preserved set for this pass manager. PA.intersect(std::move(*PassPA)); + // After running the loop pass, the parent loop might change and we need to + // notify the updater, otherwise U.ParentL might gets outdated and triggers + // assertion failures in addSiblingLoops and addChildLoops. + U.setParentLoop(L.getParentLoop()); + // FIXME: Historically, the pass managers all called the LLVM context's // yield function here. We don't have a generic way to acquire the // context and it isn't yet clear what the right pattern is for yielding @@ -281,8 +285,17 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, else PI.runAfterPass<Loop>(*Pass, *L, PassPA); - // FIXME: We should verify the set of analyses relevant to Loop passes - // are preserved. +#ifndef NDEBUG + // LoopAnalysisResults should always be valid. + // Note that we don't LAR.SE.verify() because that can change observed SE + // queries. See PR44815. + if (VerifyDomInfo) + LAR.DT.verify(); + if (VerifyLoopInfo) + LAR.LI.verify(LAR.DT); + if (LAR.MSSA && VerifyMemorySSA) + LAR.MSSA->verifyMemorySSA(); +#endif // If the loop hasn't been deleted, we need to handle invalidation here. if (!Updater.skipCurrentLoop()) @@ -314,12 +327,6 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function &F, PA.preserve<BlockFrequencyAnalysis>(); if (UseMemorySSA) PA.preserve<MemorySSAAnalysis>(); - // FIXME: What we really want to do here is preserve an AA category, but - // that concept doesn't exist yet. - PA.preserve<AAManager>(); - PA.preserve<BasicAA>(); - PA.preserve<GlobalsAA>(); - PA.preserve<SCEVAA>(); return PA; } |
