summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-03 21:19:58 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-03 21:19:58 +0000
commitd2b71e7fa9ff1cfd889a16bbf583bdce200236f9 (patch)
treee29c3fc369f5d0cab4c735f7b9c7dbef39cd4390 /llvm/test/Transforms/InstCombine
parent64e7ead1d817540a4ba4887da6c8a049788beee7 (diff)
downloadbcm5719-llvm-d2b71e7fa9ff1cfd889a16bbf583bdce200236f9.tar.gz
bcm5719-llvm-d2b71e7fa9ff1cfd889a16bbf583bdce200236f9.zip
add support for calloc to objectsize lowering
llvm-svn: 156102
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
-rw-r--r--llvm/test/Transforms/InstCombine/objsize.ll20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/objsize.ll b/llvm/test/Transforms/InstCombine/objsize.ll
index 28ceb68b49a..6b5c0f56eb1 100644
--- a/llvm/test/Transforms/InstCombine/objsize.ll
+++ b/llvm/test/Transforms/InstCombine/objsize.ll
@@ -158,3 +158,23 @@ define i32 @test7() {
ret i32 %objsize
}
+declare noalias i8* @calloc(i32, i32) nounwind
+
+define i32 @test8() {
+; CHECK: @test8
+ %alloc = call noalias i8* @calloc(i32 5, i32 7) nounwind
+ %gep = getelementptr inbounds i8* %alloc, i32 5
+ %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false) nounwind readonly
+; CHECK: ret i32 30
+ ret i32 %objsize
+}
+
+; test for overflow in calloc
+define i32 @test9() {
+; CHECK: @test9
+ %alloc = call noalias i8* @calloc(i32 100000000, i32 100000000) nounwind
+ %gep = getelementptr inbounds i8* %alloc, i32 2
+ %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 true) nounwind readonly
+; CHECK: ret i32 0
+ ret i32 %objsize
+}
OpenPOWER on IntegriCloud