aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-06 06:47:52 +0000
committerChris Lattner <sabre@nondot.org>2005-05-06 06:47:52 +0000
commit1b49141821e98e4321bfe6234c7001c836b2a289 (patch)
treeed068a1ae69260d69f5433b3ba75af0ba6a81227 /lib/Transforms/Utils/InlineFunction.cpp
parent2f4251bfbe2a6d3820534f024d4e4a2a6abf310b (diff)
Implement Transforms/Inline/inline-tail.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21736 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 97ee58f71a..4513f54aa8 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -46,6 +46,12 @@ bool llvm::InlineFunction(CallSite CS) {
CalledFunc->isExternal() || // call, or call to a vararg function!
CalledFunc->getFunctionType()->isVarArg()) return false;
+
+ // If the call to the callee is a non-tail call, we must clear the 'tail'
+ // flags on any calls that we inline.
+ bool MustClearTailCallFlags =
+ isa<CallInst>(TheCall) || !cast<CallInst>(TheCall)->isTailCall();
+
BasicBlock *OrigBB = TheCall->getParent();
Function *Caller = OrigBB->getParent();
@@ -101,6 +107,15 @@ bool llvm::InlineFunction(CallSite CS) {
}
}
+ // If we are inlining tail call instruction through an invoke or
+ if (MustClearTailCallFlags) {
+ for (Function::iterator BB = FirstNewBlock, E = Caller->end();
+ BB != E; ++BB)
+ for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+ if (CallInst *CI = dyn_cast<CallInst>(I))
+ CI->setTailCall(false);
+ }
+
// If we are inlining for an invoke instruction, we must make sure to rewrite
// any inlined 'unwind' instructions into branches to the invoke exception
// destination, and call instructions into invoke instructions.
@@ -124,7 +139,7 @@ bool llvm::InlineFunction(CallSite CS) {
// require no special handling...
if (CallInst *CI = dyn_cast<CallInst>(I)) {
// Convert this function call into an invoke instruction... if it's
- // not an intrinsic function call (which are known to not throw).
+ // not an intrinsic function call (which are known to not unwind).
if (CI->getCalledFunction() &&
CI->getCalledFunction()->getIntrinsicID()) {
++I;