summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/CodeGenPrepare/basic.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-19 03:02:34 +0000
committerChris Lattner <sabre@nondot.org>2010-12-19 03:02:34 +0000
commit583ec6fa447fd3a478c38917d8e7a6f6fb7c7a90 (patch)
tree6a69161f59a880a9aaa3532f47232888047a8ee0 /llvm/test/Transforms/CodeGenPrepare/basic.ll
parent2b43f2df2b91142d55bef8971ff56db635c5b8ba (diff)
downloadbcm5719-llvm-583ec6fa447fd3a478c38917d8e7a6f6fb7c7a90.tar.gz
bcm5719-llvm-583ec6fa447fd3a478c38917d8e7a6f6fb7c7a90.zip
first step to fixing PR8642: don't fold away empty basic blocks
which have trapping constant exprs in them due to PHI nodes. Eliminating them can cause the constant expr to be evalutated on new paths if the input edges are critical. llvm-svn: 122164
Diffstat (limited to 'llvm/test/Transforms/CodeGenPrepare/basic.ll')
-rw-r--r--llvm/test/Transforms/CodeGenPrepare/basic.ll31
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/test/Transforms/CodeGenPrepare/basic.ll b/llvm/test/Transforms/CodeGenPrepare/basic.ll
new file mode 100644
index 00000000000..04b4f34bc33
--- /dev/null
+++ b/llvm/test/Transforms/CodeGenPrepare/basic.ll
@@ -0,0 +1,31 @@
+; RUN: opt -codegenprepare %s -S | FileCheck %s
+; PR8642
+
+%0 = type <{ %1, %1 }>
+%1 = type { i8, i8, i8, i8 }
+
+@g_2 = global %0 <{ %1 { i8 1, i8 0, i8 0, i8 undef }, %1 { i8 2, i8 0, i8 0, i8 undef } }>, align 4
+@g_4 = global %1 { i8 3, i8 0, i8 0, i8 undef }, align 4
+
+; CGP shouldn't fold away the empty cond.false.i block, because the constant
+; expr that will get dropped into it could trap.
+define i16 @test1(i8** %argv, i1 %c) nounwind ssp {
+entry:
+ br i1 %c, label %cond.end.i, label %cond.false.i
+
+cond.false.i: ; preds = %entry
+ br label %foo.exit
+
+cond.end.i: ; preds = %entry
+ store i8* null, i8** %argv
+ br label %foo.exit
+
+foo.exit: ; preds = %cond.end.i, %cond.false.i
+ %call1 = phi i16 [ trunc (i32 srem (i32 1, i32 zext (i1 icmp eq (%1* bitcast (i8* getelementptr inbounds (%0* @g_2, i64 0, i32 1, i32 0) to %1*), %1* @g_4) to i32)) to i16), %cond.false.i ], [ 1, %cond.end.i ]
+ ret i16 %call1
+
+; CHECK: @test1
+; CHECK: cond.false.i:
+; CHECK-NEXT: br label %foo.exit
+}
+
OpenPOWER on IntegriCloud