summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-11-05 10:48:42 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-11-05 10:48:42 +0000
commit336b88dac8054d6ed6cda6d6198b7d4bb026b3e1 (patch)
tree4e80528d8c3de8610e00ce96e8dc26b972fb4a06 /test
parentc09b770c13594ce6fd91820b31f934aadddc1bcd (diff)
downloadllvm-336b88dac8054d6ed6cda6d6198b7d4bb026b3e1.tar.gz
llvm-336b88dac8054d6ed6cda6d6198b7d4bb026b3e1.tar.bz2
llvm-336b88dac8054d6ed6cda6d6198b7d4bb026b3e1.tar.xz
Do simple cross-block DSE when we encounter a free statement. Fixes PR11240.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143808 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/DeadStoreElimination/free.ll26
1 files changed, 22 insertions, 4 deletions
diff --git a/test/Transforms/DeadStoreElimination/free.ll b/test/Transforms/DeadStoreElimination/free.ll
index aa3f0ab938..168bd95e53 100644
--- a/test/Transforms/DeadStoreElimination/free.ll
+++ b/test/Transforms/DeadStoreElimination/free.ll
@@ -2,6 +2,9 @@
target datalayout = "e-p:64:64:64"
+declare void @free(i8* nocapture)
+declare noalias i8* @malloc(i64)
+
; CHECK: @test
; CHECK-NEXT: bitcast
; CHECK-NEXT: @free
@@ -26,10 +29,10 @@ define void @test2({i32, i32}* %P) {
ret void
}
-; CHECK: @test4
+; CHECK: @test3
; CHECK-NOT: store
; CHECK: ret void
-define void @test4() {
+define void @test3() {
%m = call i8* @malloc(i64 24)
store i8 0, i8* %m
%m1 = getelementptr i8* %m, i64 1
@@ -38,5 +41,20 @@ define void @test4() {
ret void
}
-declare void @free(i8*)
-declare i8* @malloc(i64)
+; PR11240
+; CHECK: @test4
+; CHECK-NOT: store
+; CHECK: ret void
+define void @test4(i1 %x) nounwind {
+entry:
+ %alloc1 = tail call noalias i8* @malloc(i64 4) nounwind
+ br i1 %x, label %skipinit1, label %init1
+
+init1:
+ store i8 1, i8* %alloc1
+ br label %skipinit1
+
+skipinit1:
+ tail call void @free(i8* %alloc1) nounwind
+ ret void
+}