aboutsummaryrefslogtreecommitdiffstats
path: root/test
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
commit252ef566e8734b6bcf46434d0a7954c9eda0bd96 (patch)
treeb71231a8b801496ddd368cc3b642544a33bad547 /test
parent1d61f283fad2e49d3e50a3585aac4cc9183a0d28 (diff)
downloadexternal_llvm-252ef566e8734b6bcf46434d0a7954c9eda0bd96.tar.gz
external_llvm-252ef566e8734b6bcf46434d0a7954c9eda0bd96.tar.bz2
external_llvm-252ef566e8734b6bcf46434d0a7954c9eda0bd96.zip
add support for calloc to objectsize lowering
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/InstCombine/objsize.ll20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll
index 28ceb68b49..6b5c0f56eb 100644
--- a/test/Transforms/InstCombine/objsize.ll
+++ b/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
+}