[llvm] r293122 - [NewGVN] Skip uses in unreachable blocks.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 25 16:42:42 PST 2017
Author: davide
Date: Wed Jan 25 18:42:42 2017
New Revision: 293122
URL: http://llvm.org/viewvc/llvm-project?rev=293122&view=rev
Log:
[NewGVN] Skip uses in unreachable blocks.
Otherwise we ask for a domtree node that's not there, and we crash.
Differential Revision: https://reviews.llvm.org/D29145
Added:
llvm/trunk/test/Transforms/NewGVN/pr31758.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=293122&r1=293121&r2=293122&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Wed Jan 25 18:42:42 2017
@@ -1936,6 +1936,12 @@ void NewGVN::convertDenseToDFSOrdered(
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();
Added: llvm/trunk/test/Transforms/NewGVN/pr31758.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/NewGVN/pr31758.ll?rev=293122&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/NewGVN/pr31758.ll (added)
+++ llvm/trunk/test/Transforms/NewGVN/pr31758.ll Wed Jan 25 18:42:42 2017
@@ -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: }
More information about the llvm-commits
mailing list