diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-01-06 13:11:05 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-01-06 13:11:05 +0000 |
commit | 799b011276e969b0428904a27c697f93b87411fa (patch) | |
tree | 4ea2c8e271275ff87d5de71f55d6530a9302c913 /llvm/test/Transforms | |
parent | a76cc117e0c129cc9e2b9b52f8327b295cc8ad3f (diff) | |
download | bcm5719-llvm-799b011276e969b0428904a27c697f93b87411fa.tar.gz bcm5719-llvm-799b011276e969b0428904a27c697f93b87411fa.zip |
InstCombine: If we call llvm.objectsize on a malloc call we can replace it with the size passed to malloc.
llvm-svn: 122959
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/InstCombine/objsize.ll | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/objsize.ll b/llvm/test/Transforms/InstCombine/objsize.ll index 043525b7555..9950e5f4cc6 100644 --- a/llvm/test/Transforms/InstCombine/objsize.ll +++ b/llvm/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 +} |