diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-04-21 20:48:47 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-04-21 20:48:47 +0000 |
commit | 9b2cc647eba3b64295e34f43534344ac12c94346 (patch) | |
tree | bcafcd160de3a2482f3f1c12b1681d7ab46ef455 /llvm/lib/Transforms | |
parent | eb038915ab3ace23cd2a82df688126f780c6ecae (diff) | |
download | bcm5719-llvm-9b2cc647eba3b64295e34f43534344ac12c94346.tar.gz bcm5719-llvm-9b2cc647eba3b64295e34f43534344ac12c94346.zip |
Fix PR7272 in -tailcallelim instead of the inliner
The -tailcallelim pass should be checking if byval or inalloca args can
be captured before marking calls as tail calls. This was the real root
cause of PR7272.
With a better fix in place, revert the inliner change from r105255. The
test case it introduced still passes and has been moved to
test/Transforms/Inline/byval-tail-call.ll.
Reviewers: chandlerc
Differential Revision: http://reviews.llvm.org/D3403
llvm-svn: 206789
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index 6d02777d091..2f77f9c404f 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -204,6 +204,15 @@ bool TailCallElim::runOnFunction(Function &F) { } } + // If any byval or inalloca args are captured, exit. They are also allocated + // in our stack frame. + for (Argument &Arg : F.args()) { + if (Arg.hasByValOrInAllocaAttr()) + PointerMayBeCaptured(&Arg, &ACT); + if (ACT.Captured) + return false; + } + // Second pass, change any tail recursive calls to loops. // // FIXME: The code generator produces really bad code when an 'escaping diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 5692d91c86e..73d40f70b3c 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -586,15 +586,8 @@ bool llvm::InlineFunction(CallSite CS, InlineFunctionInfo &IFI, if (CS.isByValArgument(ArgNo)) { ActualArg = HandleByValArgument(ActualArg, TheCall, CalledFunc, IFI, CalledFunc->getParamAlignment(ArgNo+1)); - - // Calls that we inline may use the new alloca, so we need to clear - // their 'tail' flags if HandleByValArgument introduced a new alloca and - // the callee has calls. - if (ActualArg != *AI) { - MustClearTailCallFlags = true; + if (ActualArg != *AI) ByValInit.push_back(std::make_pair(ActualArg, (Value*) *AI)); - } - } VMap[I] = ActualArg; |