Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp @@ -4211,7 +4211,8 @@ } } - I = InvokeInst::Create(Callee, NormalBB, UnwindBB, Ops, OperandBundles); + I = InvokeInst::Create(FTy, Callee, NormalBB, UnwindBB, Ops, + OperandBundles); OperandBundles.clear(); InstructionList.push_back(I); cast(I)->setCallingConv( Index: llvm/trunk/lib/IR/IRBuilder.cpp =================================================================== --- llvm/trunk/lib/IR/IRBuilder.cpp +++ llvm/trunk/lib/IR/IRBuilder.cpp @@ -83,7 +83,7 @@ return CI; } -static InvokeInst *createInvokeHelper(Value *Invokee, BasicBlock *NormalDest, +static InvokeInst *createInvokeHelper(Function *Invokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef Ops, IRBuilderBase *Builder, Index: llvm/trunk/lib/IR/Instructions.cpp =================================================================== --- llvm/trunk/lib/IR/Instructions.cpp +++ llvm/trunk/lib/IR/Instructions.cpp @@ -711,9 +711,9 @@ Instruction *InsertPt) { std::vector Args(II->arg_begin(), II->arg_end()); - auto *NewII = InvokeInst::Create(II->getCalledValue(), II->getNormalDest(), - II->getUnwindDest(), Args, OpB, - II->getName(), InsertPt); + auto *NewII = InvokeInst::Create(II->getFunctionType(), II->getCalledValue(), + II->getNormalDest(), II->getUnwindDest(), + Args, OpB, II->getName(), InsertPt); NewII->setCallingConv(II->getCallingConv()); NewII->SubclassOptionalData = II->SubclassOptionalData; NewII->setAttributes(II->getAttributes()); Index: llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp =================================================================== --- llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -936,7 +936,7 @@ NewCS = IRB.CreateCall(NewFT, IRB.CreateBitCast(JT, NewFTPtr), Args); else NewCS = IRB.CreateInvoke( - IRB.CreateBitCast(JT, NewFTPtr), + NewFT, IRB.CreateBitCast(JT, NewFTPtr), cast(CS.getInstruction())->getNormalDest(), cast(CS.getInstruction())->getUnwindDest(), Args); NewCS.setCallingConv(CS.getCallingConv()); Index: llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp =================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ llvm/trunk/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -1724,8 +1724,8 @@ CallSite NewCS; if (InvokeInst *II = dyn_cast(CS.getInstruction())) { - NewCS = IRB.CreateInvoke(Func, II->getNormalDest(), II->getUnwindDest(), - Args); + NewCS = IRB.CreateInvoke(NewFT, Func, II->getNormalDest(), + II->getUnwindDest(), Args); } else { NewCS = IRB.CreateCall(NewFT, Func, Args); } Index: llvm/trunk/lib/Transforms/Utils/Local.cpp =================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp +++ llvm/trunk/lib/Transforms/Utils/Local.cpp @@ -1980,8 +1980,9 @@ // can potentially be avoided with a cleverer API design that we do not have // as of this time. - InvokeInst *II = InvokeInst::Create(CI->getCalledValue(), Split, UnwindEdge, - InvokeArgs, OpBundles, CI->getName(), BB); + InvokeInst *II = + InvokeInst::Create(CI->getFunctionType(), CI->getCalledValue(), Split, + UnwindEdge, InvokeArgs, OpBundles, CI->getName(), BB); II->setDebugLoc(CI->getDebugLoc()); II->setCallingConv(CI->getCallingConv()); II->setAttributes(CI->getAttributes()); Index: llvm/trunk/unittests/IR/InstructionsTest.cpp =================================================================== --- llvm/trunk/unittests/IR/InstructionsTest.cpp +++ llvm/trunk/unittests/IR/InstructionsTest.cpp @@ -565,14 +565,15 @@ TEST(InstructionsTest, AlterInvokeBundles) { LLVMContext C; Type *Int32Ty = Type::getInt32Ty(C); - Type *FnTy = FunctionType::get(Int32Ty, Int32Ty, /*isVarArg=*/false); + FunctionType *FnTy = FunctionType::get(Int32Ty, Int32Ty, /*isVarArg=*/false); Value *Callee = Constant::getNullValue(FnTy->getPointerTo()); Value *Args[] = {ConstantInt::get(Int32Ty, 42)}; std::unique_ptr NormalDest(BasicBlock::Create(C)); std::unique_ptr UnwindDest(BasicBlock::Create(C)); OperandBundleDef OldBundle("before", UndefValue::get(Int32Ty)); - std::unique_ptr Invoke(InvokeInst::Create( - Callee, NormalDest.get(), UnwindDest.get(), Args, OldBundle, "result")); + std::unique_ptr Invoke( + InvokeInst::Create(FnTy, Callee, NormalDest.get(), UnwindDest.get(), Args, + OldBundle, "result")); AttrBuilder AB; AB.addAttribute(Attribute::Cold); Invoke->setAttributes(