diff options
author | Alina Sbirlea <asbirlea@google.com> | 2018-08-22 20:10:21 +0000 |
---|---|---|
committer | Alina Sbirlea <asbirlea@google.com> | 2018-08-22 20:10:21 +0000 |
commit | 8b83d685442096a620e6aa521c0aeef37a24d1f3 (patch) | |
tree | cba41f40cf1ee657a299e9479154baec5b1a6f25 /llvm/lib/Transforms | |
parent | c1a216b251d03a1d39a6779eeed7d346a7485d03 (diff) | |
download | bcm5719-llvm-8b83d685442096a620e6aa521c0aeef37a24d1f3.tar.gz bcm5719-llvm-8b83d685442096a620e6aa521c0aeef37a24d1f3.zip |
Update MemorySSA in LoopSimplifyCFG.
Summary:
Add MemorySSA as a dependency to LoopSimplifyCFG and preserve it.
Disabled by default until all passes preserve MemorySSA.
Reviewers: bogner, chandlerc
Subscribers: sanjoy, jlebar, Prazek, george.burgess.iv, llvm-commits
Differential Revision: https://reviews.llvm.org/D50911
llvm-svn: 340445
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp index 65e051c4a7a..ed37fc8825d 100644 --- a/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp +++ b/llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp @@ -24,6 +24,8 @@ #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" +#include "llvm/Analysis/MemorySSA.h" +#include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" #include "llvm/Analysis/TargetTransformInfo.h" @@ -40,7 +42,7 @@ using namespace llvm; #define DEBUG_TYPE "loop-simplifycfg" static bool simplifyLoopCFG(Loop &L, DominatorTree &DT, LoopInfo &LI, - ScalarEvolution &SE) { + ScalarEvolution &SE, MemorySSAUpdater *MSSAU) { bool Changed = false; DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager); // Copy blocks into a temporary array to avoid iterator invalidation issues @@ -59,7 +61,7 @@ static bool simplifyLoopCFG(Loop &L, DominatorTree &DT, LoopInfo &LI, continue; // Merge Succ into Pred and delete it. - MergeBlockIntoPredecessor(Succ, &DTU, &LI); + MergeBlockIntoPredecessor(Succ, &DTU, &LI, MSSAU); SE.forgetTopmostLoop(&L); @@ -72,7 +74,11 @@ static bool simplifyLoopCFG(Loop &L, DominatorTree &DT, LoopInfo &LI, PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &) { - if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE)) + Optional<MemorySSAUpdater> MSSAU; + if (EnableMSSALoopDependency && AR.MSSA) + MSSAU = MemorySSAUpdater(AR.MSSA); + if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE, + MSSAU.hasValue() ? MSSAU.getPointer() : nullptr)) return PreservedAnalyses::all(); return getLoopPassPreservedAnalyses(); @@ -93,10 +99,22 @@ public: DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo(); ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE(); - return simplifyLoopCFG(*L, DT, LI, SE); + Optional<MemorySSAUpdater> MSSAU; + if (EnableMSSALoopDependency) { + MemorySSA *MSSA = &getAnalysis<MemorySSAWrapperPass>().getMSSA(); + MSSAU = MemorySSAUpdater(MSSA); + if (VerifyMemorySSA) + MSSA->verifyMemorySSA(); + } + return simplifyLoopCFG(*L, DT, LI, SE, + MSSAU.hasValue() ? MSSAU.getPointer() : nullptr); } void getAnalysisUsage(AnalysisUsage &AU) const override { + if (EnableMSSALoopDependency) { + AU.addRequired<MemorySSAWrapperPass>(); + AU.addPreserved<MemorySSAWrapperPass>(); + } AU.addPreserved<DependenceAnalysisWrapperPass>(); getLoopAnalysisUsage(AU); } @@ -107,6 +125,7 @@ char LoopSimplifyCFGLegacyPass::ID = 0; INITIALIZE_PASS_BEGIN(LoopSimplifyCFGLegacyPass, "loop-simplifycfg", "Simplify loop CFG", false, false) INITIALIZE_PASS_DEPENDENCY(LoopPass) +INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) INITIALIZE_PASS_END(LoopSimplifyCFGLegacyPass, "loop-simplifycfg", "Simplify loop CFG", false, false) |