Index: include/llvm/Transforms/Utils/MemorySSA.h =================================================================== --- include/llvm/Transforms/Utils/MemorySSA.h +++ include/llvm/Transforms/Utils/MemorySSA.h @@ -494,7 +494,6 @@ class MemorySSA { public: MemorySSA(Function &, AliasAnalysis *, DominatorTree *); - MemorySSA(MemorySSA &&); ~MemorySSA(); MemorySSAWalker *getWalker(); @@ -672,9 +671,9 @@ static char PassID; public: - typedef MemorySSA Result; + typedef std::unique_ptr Result; - MemorySSA run(Function &F, AnalysisManager &AM); + Result run(Function &F, AnalysisManager &AM); }; /// \brief Printer pass for \c MemorySSA. @@ -782,6 +781,8 @@ /// the walker it uses or returns. virtual void invalidateInfo(MemoryAccess *) {} + virtual void verify(const MemorySSA *MSSA) { assert(MSSA == this->MSSA); } + protected: friend class MemorySSA; // For updating MSSA pointer in MemorySSA move // constructor. Index: lib/Transforms/Utils/MemorySSA.cpp =================================================================== --- lib/Transforms/Utils/MemorySSA.cpp +++ lib/Transforms/Utils/MemorySSA.cpp @@ -1025,6 +1025,8 @@ #endif return Result; } + + void verify(const MemorySSA *MSSA) { assert(MSSA == &this->MSSA); } }; struct RenamePassData { @@ -1104,6 +1106,11 @@ /// earliest-MemoryAccess-we-can-optimize-to". This is necessary if we're /// going to have DT updates, if we remove MemoryAccesses, etc. void resetClobberWalker() { Walker.reset(); } + + void verify(const MemorySSA *MSSA) override { + MemorySSAWalker::verify(MSSA); + Walker.verify(MSSA); + } }; /// \brief Rename a single basic block into MemorySSA form. @@ -1231,19 +1238,6 @@ buildMemorySSA(); } -MemorySSA::MemorySSA(MemorySSA &&MSSA) - : AA(MSSA.AA), DT(MSSA.DT), F(MSSA.F), - ValueToMemoryAccess(std::move(MSSA.ValueToMemoryAccess)), - PerBlockAccesses(std::move(MSSA.PerBlockAccesses)), - LiveOnEntryDef(std::move(MSSA.LiveOnEntryDef)), - BlockNumberingValid(std::move(MSSA.BlockNumberingValid)), - BlockNumbering(std::move(MSSA.BlockNumbering)), - Walker(std::move(MSSA.Walker)), NextID(MSSA.NextID) { - // Update the Walker MSSA pointer so it doesn't point to the moved-from MSSA - // object any more. - Walker->MSSA = this; -} - MemorySSA::~MemorySSA() { // Drop all our references for (const auto &Pair : PerBlockAccesses) @@ -1822,6 +1816,7 @@ verifyDefUses(F); verifyDomination(F); verifyOrdering(F); + Walker->verify(this); } /// \brief Verify that the order and existence of MemoryAccesses matches the @@ -2105,23 +2100,24 @@ char MemorySSAAnalysis::PassID; -MemorySSA MemorySSAAnalysis::run(Function &F, AnalysisManager &AM) { +std::unique_ptr +MemorySSAAnalysis::run(Function &F, AnalysisManager &AM) { auto &DT = AM.getResult(F); auto &AA = AM.getResult(F); - return MemorySSA(F, &AA, &DT); + return make_unique(F, &AA, &DT); } PreservedAnalyses MemorySSAPrinterPass::run(Function &F, FunctionAnalysisManager &AM) { OS << "MemorySSA for function: " << F.getName() << "\n"; - AM.getResult(F).print(OS); + AM.getResult(F)->print(OS); return PreservedAnalyses::all(); } PreservedAnalyses MemorySSAVerifierPass::run(Function &F, FunctionAnalysisManager &AM) { - AM.getResult(F).verifyMemorySSA(); + AM.getResult(F)->verifyMemorySSA(); return PreservedAnalyses::all(); }