]> granicus.if.org Git - llvm/commitdiff
[MemorySSA] LCSSA preserves MemorySSA.
authorAlina Sbirlea <asbirlea@google.com>
Tue, 23 Apr 2019 20:59:44 +0000 (20:59 +0000)
committerAlina Sbirlea <asbirlea@google.com>
Tue, 23 Apr 2019 20:59:44 +0000 (20:59 +0000)
Summary:
Enabling MemorySSA in the old pass manager leads to MemorySSA being run
twice due to the fact that LCSSA and LoopSimplify do not preserve
MemorySSA. This is the first step to address that: target LCSSA.

LCSSA does not make any changes that invalidate MemorySSA, so it
preserves it by design. It must preserve AA as well, for this to hold.

After this patch, MemorySSA is still run twice in the old pass manager.
Step two follows: target LoopSimplify.

Subscribers: mehdi_amini, jlebar, Prazek, llvm-commits, george.burgess.iv, chandlerc

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60832

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359032 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopAnalysisManager.h
include/llvm/Analysis/MemorySSA.h
lib/Analysis/LoopAnalysisManager.cpp
lib/Analysis/MemorySSA.cpp
lib/Transforms/Utils/LCSSA.cpp

index b87d981ec1eef8c5bda30716b74926df0e06bd12..368a810cfa678fa4dcc97ca8440f24adb7dc6c70 100644 (file)
@@ -61,9 +61,6 @@ struct LoopStandardAnalysisResults {
   MemorySSA *MSSA;
 };
 
-/// Enables memory ssa as a dependency for loop passes.
-extern cl::opt<bool> EnableMSSALoopDependency;
-
 /// Extern template declaration for the analysis set for this IR unit.
 extern template class AllAnalysesOn<Loop>;
 
index ab1ffa2334c369aafcdb3135e3b6f488b55b7219..8812da6016ab1fb885173619e69a4fd77ff936fd 100644 (file)
 
 namespace llvm {
 
+/// Enables memory ssa as a dependency for loop passes.
+extern cl::opt<bool> EnableMSSALoopDependency;
+
 class Function;
 class Instruction;
 class MemoryAccess;
index 8ae92e17399cd0fb1f7bb315dd8adfb6362a6a78..d0cfb3e734212270e6d2a7217f8cb1df939d63ad 100644 (file)
 using namespace llvm;
 
 namespace llvm {
-/// Enables memory ssa as a dependency for loop passes in legacy pass manager.
-cl::opt<bool> EnableMSSALoopDependency(
-    "enable-mssa-loop-dependency", cl::Hidden, cl::init(false),
-    cl::desc("Enable MemorySSA dependency for loop pass manager"));
-
 // Explicit template instantiations and specialization definitions for core
 // template typedefs.
 template class AllAnalysesOn<Loop>;
index cd6235de685fbc8dabf63f344280f4c7de10ff3d..271d56d3ecd43c0e615966909def44a7ec13f7c8 100644 (file)
@@ -81,6 +81,11 @@ bool llvm::VerifyMemorySSA = true;
 #else
 bool llvm::VerifyMemorySSA = false;
 #endif
+/// Enables memory ssa as a dependency for loop passes in legacy pass manager.
+cl::opt<bool> llvm::EnableMSSALoopDependency(
+    "enable-mssa-loop-dependency", cl::Hidden, cl::init(false),
+    cl::desc("Enable MemorySSA dependency for loop pass manager"));
+
 static cl::opt<bool, true>
     VerifyMemorySSAX("verify-memoryssa", cl::location(VerifyMemorySSA),
                      cl::Hidden, cl::desc("Enable verification of MemorySSA."));
index 5ddb7381a56896f0902c14a6eaa08bc1438e8f81..29e7c5260f46174736f15460320cd9945af104e3 100644 (file)
@@ -34,9 +34,9 @@
 #include "llvm/Analysis/BranchProbabilityInfo.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"
@@ -45,6 +45,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;
@@ -444,6 +445,7 @@ struct LCSSAWrapperPass : public FunctionPass {
     AU.addPreserved<ScalarEvolutionWrapperPass>();
     AU.addPreserved<SCEVAAWrapperPass>();
     AU.addPreserved<BranchProbabilityInfoWrapperPass>();
+    AU.addPreserved<MemorySSAWrapperPass>();
 
     // This is needed to perform LCSSA verification inside LPPassManager
     AU.addRequired<LCSSAVerificationPass>();
@@ -490,5 +492,6 @@ PreservedAnalyses LCSSAPass::run(Function &F, FunctionAnalysisManager &AM) {
   // BPI maps terminators to probabilities, since we don't modify the CFG, no
   // updates are needed to preserve it.
   PA.preserve<BranchProbabilityAnalysis>();
+  PA.preserve<MemorySSAAnalysis>();
   return PA;
 }