diff options
| author | Alina Sbirlea <asbirlea@google.com> | 2018-10-24 22:46:45 +0000 |
|---|---|---|
| committer | Alina Sbirlea <asbirlea@google.com> | 2018-10-24 22:46:45 +0000 |
| commit | ad4d018202d7f967c56b6adcfc283f7273b9d356 (patch) | |
| tree | 9e10f57e88dffe7575e33d94fd61fe0e58e2f559 /llvm/lib/Transforms/Scalar | |
| parent | c8ae09673969e7b179fe419d780d1d0f2d2c2c19 (diff) | |
| download | bcm5719-llvm-ad4d018202d7f967c56b6adcfc283f7273b9d356.tar.gz bcm5719-llvm-ad4d018202d7f967c56b6adcfc283f7273b9d356.zip | |
Update MemorySSA in LoopRotate.
Summary:
Teach LoopRotate to preserve MemorySSA.
Enable tests for correctness, dependency disabled by default.
Subscribers: sanjoy, jlebar, Prazek, george.burgess.iv, llvm-commits
Differential Revision: https://reviews.llvm.org/D51718
llvm-svn: 345216
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopRotation.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index eeaad39dc1d..fd22128f7fe 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -15,6 +15,8 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/InstructionSimplify.h" #include "llvm/Analysis/LoopPass.h" +#include "llvm/Analysis/MemorySSA.h" +#include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/Support/Debug.h" @@ -40,12 +42,19 @@ PreservedAnalyses LoopRotatePass::run(Loop &L, LoopAnalysisManager &AM, const DataLayout &DL = L.getHeader()->getModule()->getDataLayout(); const SimplifyQuery SQ = getBestSimplifyQuery(AR, DL); - bool Changed = LoopRotation(&L, &AR.LI, &AR.TTI, &AR.AC, &AR.DT, &AR.SE, SQ, - false, Threshold, false); + Optional<MemorySSAUpdater> MSSAU; + if (AR.MSSA) + MSSAU = MemorySSAUpdater(AR.MSSA); + bool Changed = LoopRotation(&L, &AR.LI, &AR.TTI, &AR.AC, &AR.DT, &AR.SE, + MSSAU.hasValue() ? MSSAU.getPointer() : nullptr, + SQ, false, Threshold, false); if (!Changed) return PreservedAnalyses::all(); + if (AR.MSSA && VerifyMemorySSA) + AR.MSSA->verifyMemorySSA(); + return getLoopPassPreservedAnalyses(); } @@ -68,6 +77,10 @@ public: void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<AssumptionCacheTracker>(); AU.addRequired<TargetTransformInfoWrapperPass>(); + if (EnableMSSALoopDependency) { + AU.addRequired<MemorySSAWrapperPass>(); + AU.addPreserved<MemorySSAWrapperPass>(); + } getLoopAnalysisUsage(AU); } @@ -84,8 +97,14 @@ public: auto *SEWP = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>(); auto *SE = SEWP ? &SEWP->getSE() : nullptr; const SimplifyQuery SQ = getBestSimplifyQuery(*this, F); - return LoopRotation(L, LI, TTI, AC, DT, SE, SQ, false, MaxHeaderSize, - false); + Optional<MemorySSAUpdater> MSSAU; + if (EnableMSSALoopDependency) { + MemorySSA *MSSA = &getAnalysis<MemorySSAWrapperPass>().getMSSA(); + MSSAU = MemorySSAUpdater(MSSA); + } + return LoopRotation(L, LI, TTI, AC, DT, SE, + MSSAU.hasValue() ? MSSAU.getPointer() : nullptr, SQ, + false, MaxHeaderSize, false); } }; } @@ -96,6 +115,7 @@ INITIALIZE_PASS_BEGIN(LoopRotateLegacyPass, "loop-rotate", "Rotate Loops", INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) INITIALIZE_PASS_DEPENDENCY(LoopPass) INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) +INITIALIZE_PASS_DEPENDENCY(MemorySSAWrapperPass) INITIALIZE_PASS_END(LoopRotateLegacyPass, "loop-rotate", "Rotate Loops", false, false) |

