summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/objsize.ll
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-07-06 23:09:25 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-07-06 23:09:25 +0000
commitfa0dffcceedb408c42716a3877c4357371a0fb55 (patch)
tree3b7e47b6ef22fcf58b8dd071f6c5582819e65870 /llvm/test/Transforms/InstCombine/objsize.ll
parent9877f689f282b19ca697aa8c6fecd752a84dbddd (diff)
downloadbcm5719-llvm-fa0dffcceedb408c42716a3877c4357371a0fb55.tar.gz
bcm5719-llvm-fa0dffcceedb408c42716a3877c4357371a0fb55.zip
teach instcombine to remove allocated buffers even if there are stores, memcpy/memmove/memset, and objectsize users.
This means we can do cheap DSE for heap memory. Nothing is done if the pointer excapes or has a load. The churn in the tests is mostly due to objectsize, since we want to make sure we don't delete the malloc call before evaluating the objectsize (otherwise it becomes -1/0) llvm-svn: 159876
Diffstat (limited to 'llvm/test/Transforms/InstCombine/objsize.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/objsize.ll14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/test/Transforms/InstCombine/objsize.ll b/llvm/test/Transforms/InstCombine/objsize.ll
index 2d2d6c286df..ac488faea37 100644
--- a/llvm/test/Transforms/InstCombine/objsize.ll
+++ b/llvm/test/Transforms/InstCombine/objsize.ll
@@ -121,7 +121,7 @@ entry:
; rdar://7782496
@s = external global i8*
-define void @test5(i32 %n) nounwind ssp {
+define i8* @test5(i32 %n) nounwind ssp {
; CHECK: @test5
entry:
%0 = tail call noalias i8* @malloc(i32 20) nounwind
@@ -130,7 +130,7 @@ entry:
; CHECK-NOT: @llvm.objectsize
; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false)
%3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind
- ret void
+ ret i8* %0
}
define void @test6(i32 %n) nounwind ssp {
@@ -149,22 +149,24 @@ declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind
declare noalias i8* @malloc(i32) nounwind
-define i32 @test7() {
+define i32 @test7(i8** %esc) {
; CHECK: @test7
%alloc = call noalias i8* @malloc(i32 48) nounwind
+ store i8* %alloc, i8** %esc
%gep = getelementptr inbounds i8* %alloc, i32 16
%objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
-; CHECK-NEXT: ret i32 32
+; CHECK: ret i32 32
ret i32 %objsize
}
declare noalias i8* @calloc(i32, i32) nounwind
-define i32 @test8() {
+define i32 @test8(i8** %esc) {
; CHECK: @test8
%alloc = call noalias i8* @calloc(i32 5, i32 7) nounwind
+ store i8* %alloc, i8** %esc
%gep = getelementptr inbounds i8* %alloc, i32 5
%objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
-; CHECK-NEXT: ret i32 30
+; CHECK: ret i32 30
ret i32 %objsize
}
OpenPOWER on IntegriCloud