[PATCH] D65418: [MemorySSA] Set LoopSimplify to preserve MemorySSA in the NPM, if analysis exists.

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 14:00:21 PDT 2019


asbirlea created this revision.
asbirlea added a reviewer: chandlerc.
Herald added subscribers: george.burgess.iv, Prazek, jlebar, mehdi_amini.
Herald added a project: LLVM.

LoopSimplify is preserved in the legacy pass manager, but not in the new pass manager.
Update LoopSimplify to preserve MemorySSA conditionally when the analysis is available (same behavior as the legacy pass manager).


Repository:
  rL LLVM

https://reviews.llvm.org/D65418

Files:
  lib/Transforms/Utils/LoopSimplify.cpp
  unittests/Transforms/Scalar/LoopPassManagerTest.cpp


Index: unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===================================================================
--- unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -293,8 +293,7 @@
     // those.
     FAM.registerPass([&] { return AAManager(); });
     FAM.registerPass([&] { return AssumptionAnalysis(); });
-    if (EnableMSSALoopDependency)
-      FAM.registerPass([&] { return MemorySSAAnalysis(); });
+    FAM.registerPass([&] { return MemorySSAAnalysis(); });
     FAM.registerPass([&] { return ScalarEvolutionAnalysis(); });
     FAM.registerPass([&] { return TargetLibraryAnalysis(); });
     FAM.registerPass([&] { return TargetIRAnalysis(); });
Index: lib/Transforms/Utils/LoopSimplify.cpp
===================================================================
--- lib/Transforms/Utils/LoopSimplify.cpp
+++ lib/Transforms/Utils/LoopSimplify.cpp
@@ -835,12 +835,19 @@
   DominatorTree *DT = &AM.getResult<DominatorTreeAnalysis>(F);
   ScalarEvolution *SE = AM.getCachedResult<ScalarEvolutionAnalysis>(F);
   AssumptionCache *AC = &AM.getResult<AssumptionAnalysis>(F);
+  auto *MSSAAnalysis = AM.getCachedResult<MemorySSAAnalysis>(F);
+  std::unique_ptr<MemorySSAUpdater> MSSAU;
+  if (MSSAAnalysis) {
+    auto *MSSA = &MSSAAnalysis->getMSSA();
+    MSSAU = make_unique<MemorySSAUpdater>(MSSA);
+  }
+
 
   // Note that we don't preserve LCSSA in the new PM, if you need it run LCSSA
-  // after simplifying the loops. MemorySSA is not preserved either.
+  // after simplifying the loops. MemorySSA is preserved if it exists.
   for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I)
     Changed |=
-        simplifyLoop(*I, DT, LI, SE, AC, nullptr, /*PreserveLCSSA*/ false);
+        simplifyLoop(*I, DT, LI, SE, AC, MSSAU.get(), /*PreserveLCSSA*/ false);
 
   if (!Changed)
     return PreservedAnalyses::all();
@@ -853,6 +860,7 @@
   PA.preserve<SCEVAA>();
   PA.preserve<ScalarEvolutionAnalysis>();
   PA.preserve<DependenceAnalysis>();
+  PA.preserve<MemorySSAAnalysis>();
   // BPI maps conditional terminators to probabilities, LoopSimplify can insert
   // blocks, but it does so only by splitting existing blocks and edges. This
   // results in the interesting property that all new terminators inserted are


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65418.212222.patch
Type: text/x-patch
Size: 2317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190729/8cba6057/attachment.bin>


More information about the llvm-commits mailing list