Index: include/llvm/Analysis/LoopAnalysisManager.h =================================================================== --- include/llvm/Analysis/LoopAnalysisManager.h +++ include/llvm/Analysis/LoopAnalysisManager.h @@ -61,9 +61,6 @@ MemorySSA *MSSA; }; -/// Enables memory ssa as a dependency for loop passes. -extern cl::opt EnableMSSALoopDependency; - /// Extern template declaration for the analysis set for this IR unit. extern template class AllAnalysesOn; Index: include/llvm/Analysis/MemorySSA.h =================================================================== --- include/llvm/Analysis/MemorySSA.h +++ include/llvm/Analysis/MemorySSA.h @@ -104,6 +104,9 @@ namespace llvm { +/// Enables memory ssa as a dependency for loop passes. +extern cl::opt EnableMSSALoopDependency; + class Function; class Instruction; class MemoryAccess; Index: lib/Analysis/MemorySSA.cpp =================================================================== --- lib/Analysis/MemorySSA.cpp +++ lib/Analysis/MemorySSA.cpp @@ -914,6 +914,7 @@ : MSSA(MSSA), AA(AA), DT(DT) {} AliasAnalysisType *getAA() { return &AA; } + /// Finds the nearest clobber for the given query, optimizing phis if /// possible. MemoryAccess *findClobber(MemoryAccess *Start, UpwardsMemoryQuery &Q, Index: lib/Transforms/Utils/LCSSA.cpp =================================================================== --- lib/Transforms/Utils/LCSSA.cpp +++ lib/Transforms/Utils/LCSSA.cpp @@ -33,9 +33,9 @@ #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/LoopPass.h" +#include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" -#include "llvm/Transforms/Utils/Local.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" @@ -44,6 +44,7 @@ #include "llvm/IR/PredIteratorCache.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils.h" +#include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/LoopUtils.h" #include "llvm/Transforms/Utils/SSAUpdater.h" using namespace llvm; @@ -442,6 +443,7 @@ AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); + AU.addPreserved(); // This is needed to perform LCSSA verification inside LPPassManager AU.addRequired(); @@ -485,5 +487,9 @@ PA.preserve(); PA.preserve(); PA.preserve(); + // In the new pass manager, LCSSA must mark the AAManager as preserved too, in + // order to correctly preserve MemorySSA. + PA.preserve(); + PA.preserve(); return PA; }