summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
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
commit900d46ff39de8a4d28cbcbcd864a650f778c5214 (patch)
treeb4594e83c4e42b31de909c9224de3b4f1bd6cb61 /llvm/lib/Transforms/Utils
parent61fdef6086e72cdb2e148f9c1c2e87e2ed4b589d (diff)
downloadbcm5719-llvm-900d46ff39de8a4d28cbcbcd864a650f778c5214.tar.gz
bcm5719-llvm-900d46ff39de8a4d28cbcbcd864a650f778c5214.zip
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 llvm-svn: 208920
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index ab60a400e53..e01d0c38ec4 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/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
OpenPOWER on IntegriCloud