aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-03-14 19:46:02 +0000
committerChris Lattner <sabre@nondot.org>2010-03-14 19:46:02 +0000
commitc4a3f23b9251b07785cca646ad27b426dfa23230 (patch)
tree6adeeb5dca53861a24b22b89cebb1ed796f19454
parent25e0ab9ae5507b0589be852f54693dec66796f0e (diff)
downloadexternal_llvm-c4a3f23b9251b07785cca646ad27b426dfa23230.zip
external_llvm-c4a3f23b9251b07785cca646ad27b426dfa23230.tar.gz
external_llvm-c4a3f23b9251b07785cca646ad27b426dfa23230.tar.bz2
fix ShrinkDemandedOps to not leave dead nodes around,
fixing PR6607 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98512 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp6
-rw-r--r--test/CodeGen/X86/crash.ll19
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index f6828ae..72e61d3 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -509,6 +509,12 @@ void SelectionDAGISel::ShrinkDemandedOps() {
InWorklist.erase(N);
if (N->use_empty() && N != CurDAG->getRoot().getNode()) {
+ // Deleting this node may make its operands dead, add them to the worklist
+ // if they aren't already there.
+ for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
+ if (InWorklist.insert(N->getOperand(i).getNode()))
+ Worklist.push_back(N->getOperand(i).getNode());
+
CurDAG->DeleteNode(N);
continue;
}
diff --git a/test/CodeGen/X86/crash.ll b/test/CodeGen/X86/crash.ll
index b75d265..cfa1270 100644
--- a/test/CodeGen/X86/crash.ll
+++ b/test/CodeGen/X86/crash.ll
@@ -71,3 +71,22 @@ return: ; preds = %if.else, %entry
}
declare i32 @safe(i32)
+
+; PR6607
+define fastcc void @test5(i32 %FUNC) nounwind {
+foo:
+ %0 = load i8* undef, align 1 ; <i8> [#uses=3]
+ %1 = sext i8 %0 to i32 ; <i32> [#uses=2]
+ %2 = zext i8 %0 to i32 ; <i32> [#uses=1]
+ %tmp1.i5037 = urem i32 %2, 10 ; <i32> [#uses=1]
+ %tmp.i5038 = icmp ugt i32 %tmp1.i5037, 15 ; <i1> [#uses=1]
+ %3 = zext i1 %tmp.i5038 to i8 ; <i8> [#uses=1]
+ %4 = icmp slt i8 %0, %3 ; <i1> [#uses=1]
+ %5 = add nsw i32 %1, 256 ; <i32> [#uses=1]
+ %storemerge.i.i57 = select i1 %4, i32 %5, i32 %1 ; <i32> [#uses=1]
+ %6 = shl i32 %storemerge.i.i57, 16 ; <i32> [#uses=1]
+ %7 = sdiv i32 %6, -256 ; <i32> [#uses=1]
+ %8 = trunc i32 %7 to i8 ; <i8> [#uses=1]
+ store i8 %8, i8* undef, align 1
+ ret void
+}