From be4fd315655a1be889dc319c7ff3f89e40922e02 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Mon, 4 Nov 2019 12:33:28 +0000 Subject: 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. --- test/Intrinsics/objectsize.leq80.ll | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test/Intrinsics/objectsize.leq80.ll') 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 -- cgit 1.4.1