[llvm] r185754 - Stop putting operations after a tail call.

Duncan Sands duncan.sands at gmail.com
Sun Jul 7 07:17:58 PDT 2013


Hi Tim,

On 06/07/13 14:58, Tim Northover wrote:
> Author: tnorthover
> Date: Sat Jul  6 07:58:45 2013
> New Revision: 185754
>
> URL: http://llvm.org/viewvc/llvm-project?rev=185754&view=rev
> Log:
> Stop putting operations after a tail call.
>
> This prevents the emission of DAG-generated vreg definitions after a
> tail call be dropping them entirely (on the grounds that nothing could
> use them anyway, and they interfere with O0 CodeGen).

presumably the idea here is that the tail call is emitted as a jump, so control
never returns to the function.  However is this guaranteed to be the case for
all architectures?  What I'm imagining (it may be crazy) is that some targets
might still generate a call for the tail call, and just use the tail-callness
to avoid setting up parameters again.

Ciao, Duncan.

>
> Added:
>      llvm/trunk/test/CodeGen/ARM/fast-tail-call.ll
> Modified:
>      llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=185754&r1=185753&r2=185754&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sat Jul  6 07:58:45 2013
> @@ -5357,6 +5357,10 @@ void SelectionDAGBuilder::LowerCallTo(Im
>       // As a special case, a null chain means that a tail call has been emitted and
>       // the DAG root is already updated.
>       HasTailCall = true;
> +
> +    // Since there's no actual continuation from this block, nothing can be
> +    // relying on us setting vregs for them.
> +    PendingExports.clear();
>     } else {
>       DAG.setRoot(Result.second);
>     }
>
> Added: llvm/trunk/test/CodeGen/ARM/fast-tail-call.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-tail-call.ll?rev=185754&view=auto
> ==============================================================================
> --- llvm/trunk/test/CodeGen/ARM/fast-tail-call.ll (added)
> +++ llvm/trunk/test/CodeGen/ARM/fast-tail-call.ll Sat Jul  6 07:58:45 2013
> @@ -0,0 +1,16 @@
> +; RUN: llc -mtriple=thumbv7-linux-gnueabi -O0 -arm-tail-calls < %s | FileCheck %s
> +
> +; Primarily a non-crash test: Thumbv7 Linux does not have FastISel support,
> +; which led (via a convoluted route) to DAG nodes after a TC_RETURN that
> +; couldn't possibly work.
> +
> +declare i8* @g(i8*)
> +
> +define i8* @f(i8* %a) {
> +entry:
> +  %0 = tail call i8* @g(i8* %a)
> +  ret i8* %0
> +; CHECK: b g
> +; CHECK-NOT: ldr
> +; CHECK-NOT: str
> +}
>
>
> _______________________________________________
> 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