diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-05-15 20:39:13 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-05-15 20:39:13 +0000 |
commit | 24a50c5797d0d2a79348cc484ed8cf65ca52d530 (patch) | |
tree | 9e19fdaed6cc40ac425b14a5cb371af418ebb6b2 /lib/Transforms/Utils | |
parent | 44623e8781332f730872af3bbb332d54a574034f (diff) | |
download | llvm-24a50c5797d0d2a79348cc484ed8cf65ca52d530.tar.gz llvm-24a50c5797d0d2a79348cc484ed8cf65ca52d530.tar.bz2 llvm-24a50c5797d0d2a79348cc484ed8cf65ca52d530.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.
Reviewers: chandlerc
Differential Revision: http://reviews.llvm.org/D3630
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index a3b9da588e..5b7a5dc88d 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -758,8 +758,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); + } } } @@ -777,8 +782,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 |