Index: llvm/trunk/lib/Analysis/LoopAnalysisManager.cpp =================================================================== --- llvm/trunk/lib/Analysis/LoopAnalysisManager.cpp +++ llvm/trunk/lib/Analysis/LoopAnalysisManager.cpp @@ -141,8 +141,6 @@ PA.preserve(); PA.preserve(); PA.preserve(); - if (EnableMSSALoopDependency) - PA.preserve(); // FIXME: What we really want to do here is preserve an AA category, but that // concept doesn't exist yet. PA.preserve(); Index: llvm/trunk/lib/Transforms/Scalar/LICM.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/LICM.cpp +++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp @@ -294,6 +294,8 @@ PA.preserve(); PA.preserve(); + if (EnableMSSALoopDependency) + PA.preserve(); return PA; } Index: llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp +++ llvm/trunk/lib/Transforms/Scalar/LoopInstSimplify.cpp @@ -233,6 +233,8 @@ auto PA = getLoopPassPreservedAnalyses(); PA.preserveSet(); + if (EnableMSSALoopDependency) + PA.preserve(); return PA; } Index: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp +++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp @@ -54,7 +54,10 @@ if (AR.MSSA && VerifyMemorySSA) AR.MSSA->verifyMemorySSA(); - return getLoopPassPreservedAnalyses(); + auto PA = getLoopPassPreservedAnalyses(); + if (EnableMSSALoopDependency) + PA.preserve(); + return PA; } namespace { Index: llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ llvm/trunk/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -701,7 +701,10 @@ if (DeleteCurrentLoop) LPMU.markLoopAsDeleted(L, "loop-simplifycfg"); - return getLoopPassPreservedAnalyses(); + auto PA = getLoopPassPreservedAnalyses(); + if (EnableMSSALoopDependency) + PA.preserve(); + return PA; } namespace { Index: llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp =================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ llvm/trunk/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -2861,7 +2861,11 @@ // Historically this pass has had issues with the dominator tree so verify it // in asserts builds. assert(AR.DT.verify(DominatorTree::VerificationLevel::Fast)); - return getLoopPassPreservedAnalyses(); + + auto PA = getLoopPassPreservedAnalyses(); + if (EnableMSSALoopDependency) + PA.preserve(); + return PA; } namespace { Index: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp =================================================================== --- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp +++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp @@ -396,11 +396,13 @@ // No need to re-run if we require again from a fresh loop pass manager. FPM.addPass(createFunctionToLoopPassAdaptor( RequireAnalysisLoopPass())); - // For 'f', preserve most things but not the specific loop analyses. + auto PA = getLoopPassPreservedAnalyses(); + if (EnableMSSALoopDependency) + PA.preserve(); EXPECT_CALL(MFPHandle, run(HasName("f"), _)) .InSequence(FSequence) - .WillOnce(Return(getLoopPassPreservedAnalyses())); + .WillOnce(Return(PA)); EXPECT_CALL(MLAHandle, invalidate(HasName("loop.0.0"), _, _)) .InSequence(FSequence) .WillOnce(DoDefault()); @@ -475,6 +477,8 @@ EXPECT_CALL(MMPHandle, run(_, _)).WillOnce(InvokeWithoutArgs([] { auto PA = getLoopPassPreservedAnalyses(); PA.preserve(); + if (EnableMSSALoopDependency) + PA.preserve(); return PA; })); // All the loop analyses from both functions get invalidated before we @@ -803,6 +807,8 @@ // the fact that they were preserved. EXPECT_CALL(MFPHandle, run(HasName("f"), _)).WillOnce(InvokeWithoutArgs([] { auto PA = getLoopPassPreservedAnalyses(); + if (EnableMSSALoopDependency) + PA.preserve(); PA.preserveSet>(); return PA; })); @@ -824,6 +830,8 @@ // Which means that no extra invalidation occurs and cached values are used. EXPECT_CALL(MFPHandle, run(HasName("g"), _)).WillOnce(InvokeWithoutArgs([] { auto PA = getLoopPassPreservedAnalyses(); + if (EnableMSSALoopDependency) + PA.preserve(); PA.preserveSet>(); return PA; }));