summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/objsize.ll
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-05-11 18:25:29 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-05-11 18:25:29 +0000
commit12c807873a5988d900c8032e7d98f8f07da5c628 (patch)
tree2ba3766c2d300a1609144f515825493dc60f5420 /test/Transforms/InstCombine/objsize.ll
parent2f6ae41f14af87d1019d771b101580381cdfc44f (diff)
downloadllvm-12c807873a5988d900c8032e7d98f8f07da5c628.tar.gz
llvm-12c807873a5988d900c8032e7d98f8f07da5c628.tar.bz2
llvm-12c807873a5988d900c8032e7d98f8f07da5c628.tar.xz
objectsize: add a few more tests and fix a bug
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/objsize.ll')
-rw-r--r--test/Transforms/InstCombine/objsize.ll55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/objsize.ll b/test/Transforms/InstCombine/objsize.ll
index 1e62a93548..e33385e6cc 100644
--- a/test/Transforms/InstCombine/objsize.ll
+++ b/test/Transforms/InstCombine/objsize.ll
@@ -185,6 +185,61 @@ define i32 @test9(i32 %x, i32 %y) nounwind {
; CHECK-NEXT: select i1 {{.*}}, i32 0,
}
+; CHECK: @test10
+define i32 @test10(i32 %x, i32 %y) nounwind {
+ %alloc = call noalias i8* @calloc(i32 %x, i32 %y) nounwind
+ %gep = getelementptr inbounds i8* %alloc, i32 5
+ %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false, i32 2)
+ ret i32 %objsize
+; CHECK-NEXT: mul i32
+; CHECK-NEXT: add i32 {{.*}}, -5
+; CHECK-NEXT: icmp ult i32 {{.*}}, 5
+; CHECK-NEXT: select i1
+; CHECK-NEXT: ret
+}
+
+; CHECK: @test11
+define i32 @test11(i32 %x, i32 %y) nounwind {
+ %alloc = call i8* @malloc(i32 %x)
+ %allocd = bitcast i8* %alloc to double*
+ %gep = getelementptr double* %allocd, i32 %y
+ %gepi8 = bitcast double* %gep to i8*
+ %objsize = call i32 @llvm.objectsize.i32(i8* %gepi8, i1 false, i32 2)
+ ret i32 %objsize
+; CHECK-NEXT: shl i32
+; CHECK-NEXT: sub i32
+; CHECK-NEXT: icmp ugt i32
+; CHECK-NEXT: select i1
+; CHECK-NEXT: ret
+}
+
+; CHECK: @test12
+define i32 @test12(i32 %x) nounwind {
+ %alloc = alloca i32, i32 %x, align 16
+ %gep = getelementptr i32* %alloc, i32 7
+ %gepi8 = bitcast i32* %gep to i8*
+ %objsize = call i32 @llvm.objectsize.i32(i8* %gepi8, i1 false, i32 2)
+ ret i32 %objsize
+; CHECK-NEXT: shl i32
+; CHECK-NEXT: add i32 {{.*}}, -28
+; CHECK-NEXT: icmp ult i32 {{.*}}, 28
+; CHECK-NEXT: select i1
+; CHECK-NEXT: ret
+}
+
+; CHECK: @test13
+define i32 @test13(i32 %x, i32 %y) nounwind {
+ %alloc = call i8* @calloc(i32 %x, i32 %y)
+ %alloc2 = call i8* @malloc(i32 %x)
+ %objsize = call i32 @llvm.objectsize.i32(i8* %alloc, i1 false, i32 1)
+ %objsize2 = call i32 @llvm.objectsize.i32(i8* %alloc2, i1 false, i32 1)
+ %add = add i32 %objsize, %objsize2
+ ret i32 %add
+; CHECK: objectsize
+; CHECK: objectsize
+; CHECK: add
+}
+
; CHECK: @overflow
define i32 @overflow() {
%alloc = call noalias i8* @malloc(i32 21) nounwind