[PATCH] D141185: [MemorySSA] Don't check def set when cloning memoryaccesses

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 20:07:22 PST 2023


StephenFan updated this revision to Diff 487653.
StephenFan added a comment.

Replace attribute to noinline.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141185/new/

https://reviews.llvm.org/D141185

Files:
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/test/Transforms/SimpleLoopUnswitch/pr59546.ll


Index: llvm/test/Transforms/SimpleLoopUnswitch/pr59546.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SimpleLoopUnswitch/pr59546.ll
@@ -0,0 +1,41 @@
+; RUN: opt -passes="scc-oz-module-inliner,function(loop-mssa(no-op-loop)),recompute-globalsaa,function(loop-mssa(simple-loop-unswitch<nontrivial>))" -disable-output < %s
+; Check that don't crash if the Alias Analysis returns better results than
+; before when cloning loop's memoryssa.
+
+ at a = internal global i16 0
+
+define void @h() {
+entry:
+  br label %end
+
+body:                                       ; No predecessors!
+  call void @g(ptr null)
+  br label %end
+
+end:                                        ; preds = %while.body, %entry
+  ret void
+}
+
+define internal void @g(ptr %a) #0 {
+entry:
+  br label %while.cond
+
+while.cond:                                       ; preds = %while.body, %entry
+  %0 = load i16, ptr %a, align 1
+  %tobool.not = icmp eq i16 %0, 0
+  br i1 %tobool.not, label %while.end, label %while.body
+
+while.body:                                       ; preds = %while.cond
+  call void @f()
+  br label %while.cond
+
+while.end:                                        ; preds = %while.cond
+  ret void
+}
+
+define internal void @f() #0 {
+  store i16 0, ptr @a, align 1
+  ret void
+}
+
+attributes #0 = { noinline }
Index: llvm/lib/Analysis/MemorySSA.cpp
===================================================================
--- llvm/lib/Analysis/MemorySSA.cpp
+++ llvm/lib/Analysis/MemorySSA.cpp
@@ -1758,10 +1758,10 @@
     bool DefCheck, UseCheck;
     DefCheck = isModSet(ModRef) || isOrdered(I);
     UseCheck = isRefSet(ModRef);
-    // 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");
+    // Memory accesses should only be reduced and can not be increased since AA
+    // just might return better results as a result of some transformations.
+    assert(Def == DefCheck ||
+           !DefCheck && "Memory accesses should only be reduced");
     if (!Def && Use != UseCheck) {
       // New Access should not have more power than template access
       assert(!UseCheck && "Invalid template");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141185.487653.patch
Type: text/x-patch
Size: 2337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230110/93e3fbaa/attachment.bin>


More information about the llvm-commits mailing list