diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 6 |
3 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 653d35e34f4..aa9e932fc52 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7972,6 +7972,19 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) { } } + if (isa<InlineAsm>(Callee) && !CS.isNoUnwind()) { + // Inline asm calls cannot throw - mark them 'nounwind'. + const ParamAttrsList *PAL = CS.getParamAttrs(); + uint16_t RAttributes = PAL ? PAL->getParamAttrs(0) : 0; + RAttributes |= ParamAttr::NoUnwind; + + ParamAttrsVector modVec; + modVec.push_back(ParamAttrsWithIndex::get(0, RAttributes)); + PAL = ParamAttrsList::getModified(PAL, modVec); + CS.setParamAttrs(PAL); + Changed = true; + } + return Changed ? CS.getInstruction() : 0; } diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index e9f6b28e98b..3d31f71300a 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -69,9 +69,8 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock, if (!isa<CallInst>(I)) continue; CallInst *CI = cast<CallInst>(I); - // If this call cannot unwind or is an inline asm, don't - // convert it to an invoke. - if (CI->isNoUnwind() || isa<InlineAsm>(CI->getCalledValue())) + // If this call cannot unwind, don't convert it to an invoke. + if (CI->isNoUnwind()) continue; // Convert this function call into an invoke instruction. diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 5207ea52f49..511a0e851a1 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -65,6 +65,12 @@ bool CallSite::onlyReadsMemory() const { else return cast<InvokeInst>(I)->onlyReadsMemory(); } +bool CallSite::isNoUnwind() const { + if (CallInst *CI = dyn_cast<CallInst>(I)) + return CI->isNoUnwind(); + else + return cast<InvokeInst>(I)->isNoUnwind(); +} |