[PATCH] D50911: Update MemorySSA in LoopSimplifyCFG.
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 17 10:35:42 PDT 2018
asbirlea created this revision.
asbirlea added reviewers: bogner, chandlerc.
Herald added subscribers: george.burgess.iv, Prazek, jlebar, sanjoy.
Add MemorySSA as a dependency to LoopSimplifyCFG and preserve it.
Disabled by default until all passes preserve MemorySSA.
Repository:
rL LLVM
https://reviews.llvm.org/D50911
Files:
lib/Transforms/Scalar/LoopSimplifyCFG.cpp
test/Transforms/LoopSimplifyCFG/merge-header.ll
test/Transforms/LoopSimplifyCFG/scev.ll
Index: test/Transforms/LoopSimplifyCFG/scev.ll
===================================================================
--- test/Transforms/LoopSimplifyCFG/scev.ll
+++ test/Transforms/LoopSimplifyCFG/scev.ll
@@ -1,5 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -loop-simplifycfg -verify-scev < %s | FileCheck %s
+; RUN: opt -S -loop-simplifycfg -verify-scev -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
; Verify that the scev information is still valid. Verification should not fail
Index: test/Transforms/LoopSimplifyCFG/merge-header.ll
===================================================================
--- test/Transforms/LoopSimplifyCFG/merge-header.ll
+++ test/Transforms/LoopSimplifyCFG/merge-header.ll
@@ -1,5 +1,6 @@
; RUN: opt -S -loop-simplifycfg < %s | FileCheck %s
; RUN: opt -S -passes='require<domtree>,loop(simplify-cfg)' < %s | FileCheck %s
+; RUN: opt -S -loop-simplifycfg -enable-mssa-loop-dependency=true -verify-memoryssa < %s | FileCheck %s
; CHECK-LABEL: foo
; CHECK: entry:
Index: lib/Transforms/Scalar/LoopSimplifyCFG.cpp
===================================================================
--- lib/Transforms/Scalar/LoopSimplifyCFG.cpp
+++ 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 @@
#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 @@
continue;
// Merge Succ into Pred and delete it.
- MergeBlockIntoPredecessor(Succ, &DTU, &LI);
+ MergeBlockIntoPredecessor(Succ, &DTU, &LI, MSSAU);
SE.forgetTopmostLoop(&L);
@@ -72,7 +74,10 @@
PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR,
LPMUpdater &) {
- if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE))
+ std::unique_ptr<MemorySSAUpdater> MSSAU;
+ if (EnableMSSALoopDependency && AR.MSSA)
+ MSSAU = make_unique<MemorySSAUpdater>(AR.MSSA);
+ if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE, MSSAU.get()))
return PreservedAnalyses::all();
return getLoopPassPreservedAnalyses();
@@ -93,10 +98,21 @@
DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
- return simplifyLoopCFG(*L, DT, LI, SE);
+ std::unique_ptr<MemorySSAUpdater> MSSAU;
+ if (EnableMSSALoopDependency) {
+ MemorySSA *MSSA = &getAnalysis<MemorySSAWrapperPass>().getMSSA();
+ MSSAU = make_unique<MemorySSAUpdater>(MSSA);
+ if (VerifyMemorySSA)
+ MSSA->verifyMemorySSA();
+ }
+ return simplifyLoopCFG(*L, DT, LI, SE, MSSAU.get());
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
+ if (EnableMSSALoopDependency) {
+ AU.addRequired<MemorySSAWrapperPass>();
+ AU.addPreserved<MemorySSAWrapperPass>();
+ }
AU.addPreserved<DependenceAnalysisWrapperPass>();
getLoopAnalysisUsage(AU);
}
@@ -107,6 +123,7 @@
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50911.161287.patch
Type: text/x-patch
Size: 4169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180817/5f48c2b4/attachment.bin>
More information about the llvm-commits
mailing list