diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 39aaebbedd8..acaf1f4d010 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -601,6 +601,18 @@ public: return CI; } + InvokeInst *TransferAttributes(InvokeInst *II, const Value* Callee) const { + if (const GlobalAlias *GA = dyn_cast(Callee)) + Callee = GA->getAliasedGlobal(); + + if (const Function *F = dyn_cast(Callee)) { + II->setCallingConv(F->getCallingConv()); + II->setAttributes(F->getAttributes()); + } + + return II; + } + CallInst *CreateCall(Value *Callee, const char *Name = "") { return Insert(TransferAttributes(CallInst::Create(Callee), Callee), Name); }