Index: llvm/lib/IR/AutoUpgrade.cpp =================================================================== --- llvm/lib/IR/AutoUpgrade.cpp +++ llvm/lib/IR/AutoUpgrade.cpp @@ -743,7 +743,7 @@ // 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 @@ ? 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; Index: llvm/test/Bitcode/objectsize-upgrade-7.0.ll =================================================================== --- /dev/null +++ llvm/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)