Index: lib/Transforms/Scalar/GVNHoist.cpp =================================================================== --- lib/Transforms/Scalar/GVNHoist.cpp +++ lib/Transforms/Scalar/GVNHoist.cpp @@ -199,17 +199,15 @@ // cases reduce critical path (by exposing more ILP). class GVNHoist { public: - GVNHoist(DominatorTree *Dt, AliasAnalysis *Aa, MemoryDependenceResults *Md, - bool OptForMinSize) - : DT(Dt), AA(Aa), MD(Md), OptForMinSize(OptForMinSize), + GVNHoist(DominatorTree *DT, AliasAnalysis *AA, MemoryDependenceResults *MD, + MemorySSA *MSSA, bool OptForMinSize) + : DT(DT), AA(AA), MD(MD), MSSA(MSSA), OptForMinSize(OptForMinSize), HoistingGeps(OptForMinSize), HoistedCtr(0) {} bool run(Function &F) { VN.setDomTree(DT); VN.setAliasAnalysis(AA); VN.setMemDep(MD); bool Res = false; - MemorySSA M(F, AA, DT); - MSSA = &M; // Perform DFS Numbering of instructions. unsigned BBI = 0; for (const BasicBlock *BB : depth_first(&F.getEntryBlock())) { @@ -246,11 +244,11 @@ DominatorTree *DT; AliasAnalysis *AA; MemoryDependenceResults *MD; + MemorySSA *MSSA; const bool OptForMinSize; const bool HoistingGeps; DenseMap DFSNumber; BBSideEffectsSet BBSideEffects; - MemorySSA *MSSA; int HoistedCtr; enum InsKind { Unknown, Scalar, Load, Store }; @@ -932,8 +930,9 @@ auto &DT = getAnalysis().getDomTree(); auto &AA = getAnalysis().getAAResults(); auto &MD = getAnalysis().getMemDep(); + auto &MSSA = getAnalysis().getMSSA(); - GVNHoist G(&DT, &AA, &MD, F.optForMinSize()); + GVNHoist G(&DT, &AA, &MD, &MSSA, F.optForMinSize()); return G.run(F); } @@ -941,7 +940,9 @@ AU.addRequired(); AU.addRequired(); AU.addRequired(); + AU.addRequired(); AU.addPreserved(); + AU.addPreserved(); } }; } // namespace @@ -951,13 +952,14 @@ DominatorTree &DT = AM.getResult(F); AliasAnalysis &AA = AM.getResult(F); MemoryDependenceResults &MD = AM.getResult(F); - - GVNHoist G(&DT, &AA, &MD, F.optForMinSize()); + MemorySSA &MSSA = AM.getResult(F).getMSSA(); + GVNHoist G(&DT, &AA, &MD, &MSSA, F.optForMinSize()); if (!G.run(F)) return PreservedAnalyses::all(); PreservedAnalyses PA; PA.preserve(); + PA.preserve(); return PA; } @@ -965,6 +967,7 @@ INITIALIZE_PASS_BEGIN(GVNHoistLegacyPass, "gvn-hoist", "Early GVN Hoisting of Expressions", false, false) INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass) +INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) INITIALIZE_PASS_END(GVNHoistLegacyPass, "gvn-hoist",