[PATCH] D29145: [NewGVN] Skip uses in unreachable blocks

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 13:38:08 PST 2017


davide created this revision.

Fixes https://llvm.org/bugs/show_bug.cgi?id=31758
Otherwise we ask for a domtree node that's not there, and we crash.


https://reviews.llvm.org/D29145

Files:
  lib/Transforms/Scalar/NewGVN.cpp
  test/Transforms/NewGVN/pr31758.ll


Index: test/Transforms/NewGVN/pr31758.ll
===================================================================
--- /dev/null
+++ test/Transforms/NewGVN/pr31758.ll
@@ -0,0 +1,37 @@
+; RUN: opt -newgvn %s -S -o - | FileCheck %s
+
+%struct.dipsy = type {}
+%struct.fluttershy = type { %struct.dipsy* }
+%struct.patatino = type {}
+
+define void @tinkywinky() {
+bb:
+  br label %bb90
+
+bb90:
+  %tmp = getelementptr inbounds %struct.fluttershy, %struct.fluttershy* undef, i64 0, i32 0
+  %tmp91 = bitcast %struct.dipsy** %tmp to %struct.patatino**
+  %tmp92 = load %struct.patatino*, %struct.patatino** %tmp91, align 8
+  %tmp99 = getelementptr inbounds %struct.patatino, %struct.patatino* %tmp92
+  %tmp134 = getelementptr inbounds %struct.fluttershy, %struct.fluttershy* undef, i64 0, i32 0
+  %tmp135 = bitcast %struct.dipsy** %tmp134 to %struct.patatino**
+  %tmp136 = load %struct.patatino*, %struct.patatino** %tmp135, align 8
+  br label %bb90
+
+bb138:
+  %tmp139 = getelementptr inbounds %struct.patatino, %struct.patatino* %tmp136
+  br label %bb138
+}
+
+; CHECK-LABEL: tinkywinky
+; CHECK-NEXT: bb:
+; CHECK-NEXT:   br label %bb90
+; CHECK-NEXT
+; CHECK:  bb90:
+; CHECK:  %tmp91 = bitcast %struct.dipsy** undef to %struct.patatino**
+; CHECK-NEXT:  %tmp92 = load %struct.patatino*, %struct.patatino** %tmp91, align 8
+; CHECK-NEXT:  %tmp136 = load %struct.patatino*, %struct.patatino** %tmp91, align 8
+; CHECK-NEXT:  br label %bb90
+; CHECK:  bb138:
+; CHECK-NEXT:  br label %bb138
+; CHECK-NEXT: }
Index: lib/Transforms/Scalar/NewGVN.cpp
===================================================================
--- lib/Transforms/Scalar/NewGVN.cpp
+++ lib/Transforms/Scalar/NewGVN.cpp
@@ -1938,6 +1938,12 @@
           IBlock = I->getParent();
           VD.LocalNum = InstrDFS.lookup(I);
         }
+
+        // Skip uses in unreachable blocks, as we're going
+        // to delete them.
+        if (ReachableBlocks.count(IBlock) == 0)
+          continue;
+
         DomTreeNode *DomNode = DT->getNode(IBlock);
         VD.DFSIn = DomNode->getDFSNumIn();
         VD.DFSOut = DomNode->getDFSNumOut();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29145.85798.patch
Type: text/x-patch
Size: 2111 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170125/8bb8ab44/attachment.bin>


More information about the llvm-commits mailing list