summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2014-05-15 21:10:46 +0000
committerReid Kleckner <reid@kleckner.net>2014-05-15 21:10:46 +0000
commit48ea98d1d228dfc58f9662473a4253c052c44b03 (patch)
treec9ac261563698d551e1f7db7e438746d34045617 /lib/Transforms/Utils/InlineFunction.cpp
parentcf7cfd8208f2ca52e86a9c0fb1fa73d1f5b553e3 (diff)
downloadllvm-48ea98d1d228dfc58f9662473a4253c052c44b03.tar.gz
llvm-48ea98d1d228dfc58f9662473a4253c052c44b03.tar.bz2
llvm-48ea98d1d228dfc58f9662473a4253c052c44b03.tar.xz
Don't insert lifetime.end markers between a musttail call and ret
The allocas going out of scope are immediately killed by the return instruction. This is a resend of r208912, which was committed accidentally. Reviewers: chandlerc Differential Revision: http://reviews.llvm.org/D3792 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208920 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index ab60a400e5..e01d0c38ec 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -755,8 +755,13 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
}
builder.CreateLifetimeStart(AI, AllocaSize);
- for (ReturnInst *RI : Returns)
+ for (ReturnInst *RI : Returns) {
+ // Don't insert llvm.lifetime.end calls between a musttail call and a
+ // return. The return kills all local allocas.
+ if (InlinedMustTailCalls && getPrecedingMustTailCall(RI))
+ continue;
IRBuilder<>(RI).CreateLifetimeEnd(AI, AllocaSize);
+ }
}
}
@@ -774,8 +779,13 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI,
// Insert a call to llvm.stackrestore before any return instructions in the
// inlined function.
- for (ReturnInst *RI : Returns)
+ for (ReturnInst *RI : Returns) {
+ // Don't insert llvm.stackrestore calls between a musttail call and a
+ // return. The return will restore the stack pointer.
+ if (InlinedMustTailCalls && getPrecedingMustTailCall(RI))
+ continue;
IRBuilder<>(RI).CreateCall(StackRestore, SavedPtr);
+ }
}
// If we are inlining for an invoke instruction, we must make sure to rewrite