[llvm] dc97138 - [MemorySSA] Verify clobbering within reachable blocks.

Alina Sbirlea via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 16 17:50:10 PDT 2020


Author: Alina Sbirlea
Date: 2020-10-16T17:46:28-07:00
New Revision: dc9713812355220058e7089dd5c882b76351a6d5

URL: https://github.com/llvm/llvm-project/commit/dc9713812355220058e7089dd5c882b76351a6d5
DIFF: https://github.com/llvm/llvm-project/commit/dc9713812355220058e7089dd5c882b76351a6d5.diff

LOG: [MemorySSA] Verify clobbering within reachable blocks.

Resolves PR45976.

Added: 
    llvm/test/Analysis/MemorySSA/pr45976.ll

Modified: 
    llvm/lib/Analysis/MemorySSA.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index 14fa11988362..016a37d284a9 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -465,10 +465,15 @@ checkClobberSanity(const MemoryAccess *Start, MemoryAccess *ClobberAt,
       }
 
       assert(isa<MemoryPhi>(MA));
-      Worklist.append(
-          upward_defs_begin({const_cast<MemoryAccess *>(MA), MAP.second},
-                            MSSA.getDomTree()),
-          upward_defs_end());
+
+      // Add reachable phi predecessors
+      for (auto ItB = upward_defs_begin(
+                    {const_cast<MemoryAccess *>(MA), MAP.second},
+                    MSSA.getDomTree()),
+                ItE = upward_defs_end();
+           ItB != ItE; ++ItB)
+        if (MSSA.getDomTree().isReachableFromEntry(ItB.getPhiArgBlock()))
+          Worklist.emplace_back(*ItB);
     }
   }
 

diff  --git a/llvm/test/Analysis/MemorySSA/pr45976.ll b/llvm/test/Analysis/MemorySSA/pr45976.ll
new file mode 100644
index 000000000000..306a46dc2609
--- /dev/null
+++ b/llvm/test/Analysis/MemorySSA/pr45976.ll
@@ -0,0 +1,52 @@
+; RUN: opt -licm -S < %s | FileCheck %s
+; REQUIRES: asserts
+
+ at global1 = external global i64, align 8
+ at global2 = external global [3 x [8 x [8 x { i32, i64, i8, i8, i16, i32 }]]], align 8
+
+; CHECK-LABEL: @f0()
+define void @f0() {
+bb:
+  br label %bb18.i
+
+bb18.i:                                           ; preds = %bb49.us.i.us, %bb
+  tail call void @f1()
+  br i1 undef, label %.exit.loopexit, label %bb49.preheader.i
+
+bb49.preheader.i:                                 ; preds = %bb18.i
+  br i1 undef, label %bb49.us.preheader.i, label %bb78.loopexit3.i
+
+bb49.us.preheader.i:                              ; preds = %bb49.preheader.i
+  br label %bb49.us.i.us
+
+bb49.us.i.preheader:                              ; No predecessors!
+  br label %.exit
+
+bb49.us.i.us:                                     ; preds = %bb49.us.preheader.i
+  br label %bb18.i
+
+bb78.loopexit3.i:                                 ; preds = %bb49.preheader.i
+  store i64 0, i64* @global1, align 8
+  br label %.exit
+
+.exit.loopexit:                                   ; preds = %bb18.i
+  br label %.exit
+
+.exit:                                            ; preds = %.exit.loopexit, %bb78.loopexit3.i, %bb49.us.i.preheader
+  br i1 undef, label %bb4.i.us.preheader, label %bb4.i
+
+bb4.i.us.preheader:                               ; preds = %.exit
+  br label %bb4.i.us
+
+bb4.i.us:                                         ; preds = %bb4.i.us, %bb4.i.us.preheader
+  store i32 0, i32* undef, align 4
+  store i32 undef, i32* getelementptr inbounds ([3 x [8 x [8 x { i32, i64, i8, i8, i16, i32 }]]], [3 x [8 x [8 x { i32, i64, i8, i8, i16, i32 }]]]* @global2, i64 0, i64 0, i64 6, i64 6, i32 0), align 8
+  br label %bb4.i.us
+
+bb4.i:                                            ; preds = %.exit
+  ret void
+}
+
+declare void @f1()
+
+


        


More information about the llvm-commits mailing list