about summary refs log tree commit diff homepage
path: root/test/Intrinsics/objectsize.leq80.ll
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2019-11-04 12:33:28 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-11-07 11:51:58 +0000
commitbe4fd315655a1be889dc319c7ff3f89e40922e02 (patch)
tree1c20cee0b0bc15fbe9f6d54e1a3130f4459bb9db /test/Intrinsics/objectsize.leq80.ll
parent5c148a6184adfed5438534b97a88fe10bc1cde37 (diff)
downloadklee-be4fd315655a1be889dc319c7ff3f89e40922e02.tar.gz
Handle llvm.objectsize explicitly
llvm.objectsize is used in several optimisation during compile time. Lowering
these intrinsics took a conservative approach returning always the value for
unknown. Instead, lower to the object's real size, if possible. Otherwise,
a conservative value is used.

Since LLVM 4.0, the function `llvm::lowerObjectSizeCall()` does exactly
this. Use this function or preserve the old behaviour for older LLVM versions.
Diffstat (limited to 'test/Intrinsics/objectsize.leq80.ll')
-rw-r--r--test/Intrinsics/objectsize.leq80.ll9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/Intrinsics/objectsize.leq80.ll b/test/Intrinsics/objectsize.leq80.ll
index f1bcdf62..19a20334 100644
--- a/test/Intrinsics/objectsize.leq80.ll
+++ b/test/Intrinsics/objectsize.leq80.ll
@@ -20,7 +20,14 @@ continue.block:
   %2 = load i8*, i8** %a, align 8
   %3 = call i64 @llvm.objectsize.i64.p0i8(i8* %2, i1 false, i1 false)
   %cmp1 = icmp ne i64 %3, -1
-  br i1 %cmp1, label %abort.block, label %exit.block
+  br i1 %cmp1, label %abort.block, label %continue.block2
+
+continue.block2:
+; allocate one byte
+  %b = alloca i8, align 8
+  %4 = call i64 @llvm.objectsize.i64.p0i8(i8* %b, i1 false, i1 false)
+  %cmp2 = icmp ne i64 %4, 1
+  br i1 %cmp2, label %abort.block, label %exit.block
 
 exit.block:
   ret i32 0