[DSE,MSSA] Delete instructions after printing it.
authorFlorian Hahn <flo@fhahn.com>
Mon, 15 Jun 2020 14:59:09 +0000 (15:59 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 15 Jun 2020 15:01:36 +0000 (16:01 +0100)
Also enables a now-passing test case, that exposed a crash caused by the
wrong order.

llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/MSSA/atomic-todo.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/atomic.ll

index 45b7814..2b77d06 100644 (file)
@@ -1945,9 +1945,9 @@ bool eliminateDeadStoresMemorySSA(Function &F, AliasAnalysis &AA,
     // Check if we're storing a value that we just loaded.
     if (auto *Load = dyn_cast<LoadInst>(SI->getOperand(0))) {
       if (storeIsNoop(MSSA, Load, KillingDef)) {
-        State.deleteDeadInstruction(SI);
         LLVM_DEBUG(dbgs() << "DSE: Remove Dead Store:\n  DEAD: " << *SI
                           << '\n');
+        State.deleteDeadInstruction(SI);
         NumNoopStores++;
         MadeChange = true;
         continue;
index 2a1fbde..d27ac81 100644 (file)
@@ -11,16 +11,6 @@ target triple = "x86_64-apple-macosx10.7.0"
 @x = common global i32 0, align 4
 @y = common global i32 0, align 4
 
-; DSE no-op unordered atomic store (allowed)
-define void @test6() {
-; CHECK-LABEL: test6
-; CHECK-NOT: store
-; CHECK: ret void
-  %x = load atomic i32, i32* @x unordered, align 4
-  store atomic i32 %x, i32* @x unordered, align 4
-  ret void
-}
-
 ; DSE across monotonic load (allowed as long as the eliminated store isUnordered)
 define i32 @test9() {
 ; CHECK-LABEL: test9
index 8a45153..73f6dd3 100644 (file)
@@ -42,6 +42,16 @@ define void @test5() {
   ret void
 }
 
+; DSE no-op unordered atomic store (allowed)
+define void @test6() {
+; CHECK-LABEL: test6
+; CHECK-NOT: store
+; CHECK: ret void
+  %x = load atomic i32, i32* @x unordered, align 4
+  store atomic i32 %x, i32* @x unordered, align 4
+  ret void
+}
+
 ; DSE seq_cst store (be conservative; DSE doesn't have infrastructure
 ; to reason about atomic operations).
 define void @test7() {