[llvm-commits] [llvm] r94937 - in /llvm/trunk: lib/Transforms/Scalar/TailRecursionElimination.cpp test/Transforms/TailCallElim/no-return-calls.ll
Chris Lattner
clattner at apple.com
Mon Feb 1 21:36:32 PST 2010
On Jan 30, 2010, at 4:59 PM, Evan Cheng wrote:
> Author: evancheng
> Date: Sat Jan 30 18:59:31 2010
> New Revision: 94937
>
> URL: http://llvm.org/viewvc/llvm-project?rev=94937&view=rev
> Log:
> Do not mark no-return calls tail calls. It'll screw up special calls like longjmp and it doesn't make much sense for performance reason. If my logic is faulty, please let me know.
Hey Evan,
This isn't the right patch. The 'tail' flag means that the callee doesn't access the caller's stack, not that it satisfies all the arbitrary requirements that codegen has for tailcalls. If codegen doesn't handling this form of tailcall, it should be the one that avoids transforming it.
-Chris
>
> Added:
> llvm/trunk/test/Transforms/TailCallElim/no-return-calls.ll
> Modified:
> llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=94937&r1=94936&r2=94937&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Sat Jan 30 18:59:31 2010
> @@ -184,10 +184,11 @@
> if (!FunctionContainsEscapingAllocas)
> for (Function::iterator BB = F.begin(), E = F.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();
> - MadeChange = true;
> - }
> + if (CallInst *CI = dyn_cast<CallInst>(I))
> + if (!CI->doesNotReturn()) {
> + CI->setTailCall();
> + MadeChange = true;
> + }
>
> return MadeChange;
> }
>
> Added: llvm/trunk/test/Transforms/TailCallElim/no-return-calls.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/no-return-calls.ll?rev=94937&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/TailCallElim/no-return-calls.ll (added)
> +++ llvm/trunk/test/Transforms/TailCallElim/no-return-calls.ll Sat Jan 30 18:59:31 2010
> @@ -0,0 +1,12 @@
> +; RUN: opt < %s -tailcallelim -S | FileCheck %s
> +
> +define void @t() nounwind ssp {
> +entry:
> +; CHECK: entry:
> +; CHECK: %0 = call i32 @foo()
> +; CHECK: ret void
> + %0 = call i32 @foo() nounwind noreturn
> + ret void
> +}
> +
> +declare i32 @foo()
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list