diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 7307ff813a2..65e816e2e81 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -188,7 +188,8 @@ bool ADCE::doADCE() { // after it to the normal destination. std::vector Args(II->op_begin()+3, II->op_end()); std::string Name = II->getName(); II->setName(""); - Instruction *NewCall = new CallInst(F, Args, Name, II); + CallInst *NewCall = new CallInst(F, Args, Name, II); + NewCall->setCallingConv(II->getCallingConv()); II->replaceAllUsesWith(NewCall); new BranchInst(II->getNormalDest(), II); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 2077b329160..218910feb20 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4271,10 +4271,12 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (InvokeInst *II = dyn_cast(Caller)) { NC = new InvokeInst(Callee, II->getNormalDest(), II->getUnwindDest(), Args, Caller->getName(), Caller); + cast(II)->setCallingConv(II->getCallingConv()); } else { NC = new CallInst(Callee, Args, Caller->getName(), Caller); if (cast(Caller)->isTailCall()) cast(NC)->setTailCall(); + cast(NC)->setCallingConv(cast(Caller)->getCallingConv()); } // Insert a cast of the return type as necessary...