From: Erik Pilkington Date: Tue, 12 Feb 2019 21:55:38 +0000 (+0000) Subject: Fix auto-upgrade for the new parameter to llvm.objectsize X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2d0b1b5542de55d6502f38b73575681cb337583a;p=llvm Fix auto-upgrade for the new parameter to llvm.objectsize r352664 added a 'dynamic' parameter to objectsize, but the AutoUpgrade changes were incomplete. Also, fix an off-by-one error I made in the upgrade logic that is now no longer unreachable. Differential revision: https://reviews.llvm.org/D58071 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353884 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index fbbb5240017..8ebe55a1ea3 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -743,7 +743,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { // address space. if (Name.startswith("objectsize.")) { Type *Tys[2] = { F->getReturnType(), F->arg_begin()->getType() }; - if (F->arg_size() == 2 || + if (F->arg_size() == 2 || F->arg_size() == 3 || F->getName() != Intrinsic::getName(Intrinsic::objectsize, Tys)) { rename(F); NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::objectsize, @@ -3461,7 +3461,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { ? Builder.getFalse() : CI->getArgOperand(2); Value *Dynamic = - CI->getNumArgOperands() < 3 ? Builder.getFalse() : CI->getArgOperand(3); + CI->getNumArgOperands() < 4 ? Builder.getFalse() : CI->getArgOperand(3); NewCall = Builder.CreateCall( NewFn, {CI->getArgOperand(0), CI->getArgOperand(1), NullIsUnknownSize, Dynamic}); break; diff --git a/test/Bitcode/objectsize-upgrade-7.0.ll b/test/Bitcode/objectsize-upgrade-7.0.ll new file mode 100644 index 00000000000..a7e6d497676 --- /dev/null +++ b/test/Bitcode/objectsize-upgrade-7.0.ll @@ -0,0 +1,12 @@ +; RUN: llvm-dis < %s.bc | FileCheck %s + +; Bitcode compatibility test for 'dynamic' parameter to llvm.objectsize. + +define void @callit(i8* %ptr) { + %sz = call i64 @llvm.objectsize.i64.p0i8(i8* %ptr, i1 false, i1 true) + ; CHECK: %sz = call i64 @llvm.objectsize.i64.p0i8(i8* %ptr, i1 false, i1 true, i1 false) + ret void +} + +declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1) +; CHECK: declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1, i1) diff --git a/test/Bitcode/objectsize-upgrade-7.0.ll.bc b/test/Bitcode/objectsize-upgrade-7.0.ll.bc new file mode 100644 index 00000000000..115c69dfb9d Binary files /dev/null and b/test/Bitcode/objectsize-upgrade-7.0.ll.bc differ