diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-10 23:17:35 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-05-10 23:17:35 +0000 |
commit | f573030391ce1f67e4d656dd941cb86cd91ee9ba (patch) | |
tree | 3a4241f1a7e46eee377247982c6b59bc3c7289af /llvm/test/Transforms/InstCombine/objsize.ll | |
parent | d9fc53509e8c0d8abf5aee0d6dbe492bdc8298a3 (diff) | |
download | bcm5719-llvm-f573030391ce1f67e4d656dd941cb86cd91ee9ba.tar.gz bcm5719-llvm-f573030391ce1f67e4d656dd941cb86cd91ee9ba.zip |
objectsize: add support for GEPs with non-constant indexes
add an additional parameter to InstCombiner::EmitGEPOffset() to force it to *not* emit operations with NUW flag
llvm-svn: 156585
Diffstat (limited to 'llvm/test/Transforms/InstCombine/objsize.ll')
-rw-r--r-- | llvm/test/Transforms/InstCombine/objsize.ll | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/objsize.ll b/llvm/test/Transforms/InstCombine/objsize.ll index 524a28f614b..1e62a935487 100644 --- a/llvm/test/Transforms/InstCombine/objsize.ll +++ b/llvm/test/Transforms/InstCombine/objsize.ll @@ -168,3 +168,28 @@ define i32 @test8() { ; CHECK-NEXT: ret i32 30 ret i32 %objsize } + +; CHECK: @test9 +define i32 @test9(i32 %x, i32 %y) nounwind { + %a = alloca [3 x [4 x double]], align 8 + %1 = getelementptr inbounds [3 x [4 x double]]* %a, i32 0, i32 %x + %2 = getelementptr inbounds [4 x double]* %1, i32 0, i32 %y + %3 = bitcast double* %2 to i8* + %objsize = call i32 @llvm.objectsize.i32(i8* %3, i1 false, i32 2) + ret i32 %objsize +; CHECK-NEXT: shl i32 %x, 5 +; CHECK-NEXT: shl i32 %y, 3 +; CHECK-NEXT: add i32 +; CHECK-NEXT: sub i32 96, +; CHECK-NEXT: icmp ugt i32 {{.*}}, 96 +; CHECK-NEXT: select i1 {{.*}}, i32 0, +} + +; CHECK: @overflow +define i32 @overflow() { + %alloc = call noalias i8* @malloc(i32 21) nounwind + %gep = getelementptr inbounds i8* %alloc, i32 50 + %objsize = call i32 @llvm.objectsize.i32(i8* %gep, i1 false, i32 0) nounwind readonly +; CHECK-NEXT: ret i32 0 + ret i32 %objsize +} |