summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2007-12-16 15:51:49 +0000
committerDuncan Sands <baldrick@free.fr>2007-12-16 15:51:49 +0000
commit8e4847ee957a7c7c434a72fdb7a6010004ca86f4 (patch)
tree7f801143756656ede3dc607b2abb2472097e0151 /llvm/lib/Transforms
parentfcf20857319a52bf9141b470443cd4e9fbb00964 (diff)
downloadbcm5719-llvm-8e4847ee957a7c7c434a72fdb7a6010004ca86f4.tar.gz
bcm5719-llvm-8e4847ee957a7c7c434a72fdb7a6010004ca86f4.zip
Make instcombine promote inline asm calls to 'nounwind'
calls. Remove special casing of inline asm from the inliner. There is a potential problem: the verifier rejects invokes of inline asm (not sure why). If an asm call is not marked "nounwind" in some .ll, and instcombine is not run, but the inliner is run, then an illegal module will be created. This is bad but I'm not sure what the best approach is. I'm tempted to remove the check in the verifier... llvm-svn: 45073
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp13
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp5
2 files changed, 15 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.
OpenPOWER on IntegriCloud