diff --git a/lib/Transforms/IPO/PartialSpecialization.cpp b/lib/Transforms/IPO/PartialSpecialization.cpp index a2a1a626551..0e1fdb9915a 100644 --- a/lib/Transforms/IPO/PartialSpecialization.cpp +++ b/lib/Transforms/IPO/PartialSpecialization.cpp @@ -65,7 +65,7 @@ SpecializeFunction(Function* F, DenseSet deleted; for (DenseMap::iterator repb = replacements.begin(), repe = replacements.end(); - repb != repe; ++ repb) + repb != repe; ++repb) deleted.insert(cast(repb->first)->getArgNo()); Function* NF = CloneFunction(F, replacements); @@ -74,7 +74,7 @@ SpecializeFunction(Function* F, for (Value::use_iterator ii = F->use_begin(), ee = F->use_end(); ii != ee; ) { - Value::use_iterator i = ii;; + Value::use_iterator i = ii; ++ii; if (isa(i) || isa(i)) { CallSite CS(cast(i)); @@ -85,16 +85,19 @@ SpecializeFunction(Function* F, if (!deleted.count(x)) args.push_back(CS.getArgument(x)); Value* NCall; - if (isa(i)) + if (CallInst *CI = dyn_cast(i)) { NCall = CallInst::Create(NF, args.begin(), args.end(), - CS.getInstruction()->getName(), - CS.getInstruction()); - else - NCall = InvokeInst::Create(NF, cast(i)->getNormalDest(), - cast(i)->getUnwindDest(), + CI->getName(), CI); + cast(NCall)->setTailCall(CI->isTailCall()); + cast(NCall)->setCallingConv(CI->getCallingConv()); + } else { + InvokeInst *II = cast(i); + NCall = InvokeInst::Create(NF, II->getNormalDest(), + II->getUnwindDest(), args.begin(), args.end(), - CS.getInstruction()->getName(), - CS.getInstruction()); + II->getName(), II); + cast(NCall)->setCallingConv(II->getCallingConv()); + } CS.getInstruction()->replaceAllUsesWith(NCall); CS.getInstruction()->eraseFromParent(); }