summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/objsize.ll
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-01-06 13:11:05 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-01-06 13:11:05 +0000
commit240d42d18559a1f75558951ada556baaf289c7f0 (patch)
treeb9fca9b40ab24d9627e20e4ea40a95c497ff4378 /test/Transforms/InstCombine/objsize.ll
parent783a5c2b695015a5a2dfc48ee28b9936d0077542 (diff)
downloadllvm-240d42d18559a1f75558951ada556baaf289c7f0.tar.gz
llvm-240d42d18559a1f75558951ada556baaf289c7f0.tar.bz2
llvm-240d42d18559a1f75558951ada556baaf289c7f0.tar.xz
InstCombine: If we call llvm.objectsize on a malloc call we can replace it with the size passed to malloc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122959 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/objsize.ll')
-rw-r--r--test/Transforms/InstCombine/objsize.ll16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll
index 043525b755..9950e5f4cc 100644
--- a/test/Transforms/InstCombine/objsize.ll
+++ b/test/Transforms/InstCombine/objsize.ll
@@ -160,3 +160,19 @@ define i32 @test7() {
ret i32 %objsize
}
+define i32 @test8(i32 %x) {
+; CHECK: @test8
+ %alloc = call noalias i8* @malloc(i32 %x) nounwind
+ %objsize = call i32 @llvm.objectsize.i32(i8* %alloc, i1 false) nounwind readonly
+; CHECK-NEXT: ret i32 %x
+ ret i32 %objsize
+}
+
+define i32 @test9(i32 %x) {
+; CHECK: @test9
+ %alloc = call noalias i8* @malloc(i32 %x) nounwind
+ %gep = getelementptr inbounds i8* %alloc, i32 16
+ %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
+; CHECK-NOT: ret i32 %x
+ ret i32 %objsize
+}