[PATCH] D137553: [MemorySSA] Delete dead MemoryUseOrDef for CallInst when clone loop basicblock
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 9 00:18:59 PST 2022
StephenFan updated this revision to Diff 474173.
StephenFan added a comment.
Relax assertion.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137553/new/
https://reviews.llvm.org/D137553
Files:
llvm/lib/Analysis/MemorySSA.cpp
llvm/test/Transforms/SimpleLoopUnswitch/pr58719.ll
Index: llvm/test/Transforms/SimpleLoopUnswitch/pr58719.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SimpleLoopUnswitch/pr58719.ll
@@ -0,0 +1,21 @@
+; RUN: opt -passes="require<globals-aa>,cgscc(instcombine),function(loop-mssa(loop-simplifycfg)),recompute-globalsaa,function(loop-mssa(simple-loop-unswitch<nontrivial>),print<memoryssa>)" -disable-output < %s
+
+; Check that don't crash if the Alias Analysis returns better results than
+; before when cloning loop's memoryssa.
+define void @f(ptr %p) {
+entry:
+ %0 = load i16, ptr %p, align 1
+ ret void
+}
+
+define void @g(i1 %tobool.not) {
+entry:
+ br label %for.cond
+
+for.cond: ; preds = %if.then, %for.cond, %entry
+ br i1 %tobool.not, label %if.then, label %for.cond
+
+if.then: ; preds = %for.cond
+ call void @f()
+ br label %for.cond
+}
Index: llvm/lib/Analysis/MemorySSA.cpp
===================================================================
--- llvm/lib/Analysis/MemorySSA.cpp
+++ llvm/lib/Analysis/MemorySSA.cpp
@@ -1760,10 +1760,12 @@
Use = isa<MemoryUse>(Template);
#if !defined(NDEBUG)
ModRefInfo ModRef = AAP->getModRefInfo(I, None);
- bool DefCheck, UseCheck;
+ bool DefCheck;
DefCheck = isModSet(ModRef) || isOrdered(I);
- UseCheck = isRefSet(ModRef);
- assert(Def == DefCheck && (Def || Use == UseCheck) && "Invalid template");
+ // Use set is not checked since AA may return better results as a result of
+ // other transforms.
+ // FIXME: Would Def value always be consistent after transforms?
+ assert(Def == DefCheck && "Invalid template");
#endif
} else {
// Find out what affect this instruction has on memory.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137553.474173.patch
Type: text/x-patch
Size: 1792 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221109/d7b97070/attachment.bin>
More information about the llvm-commits
mailing list