[llvm] r319218 - [PowerPC] Allow tail calls of fastcc functions from C CallingConv functions.

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 14:33:04 PST 2017


Hi Sean,

I've temporarily reverted this here:

echristo at athyra ~/s/llvm> git svn dcommit
Committing to https://llvm.org/svn/llvm-project/llvm/trunk ...
M lib/Target/PowerPC/PPCISelLowering.cpp
M test/CodeGen/PowerPC/duplicate-returns-for-tailcall.ll
Committed r320106

since we were showing it as breaking asan and ubsan tests. Unfortunately
this wasn't on the bots as they're currently down, but it was evident with
an asan build.

I've approved patches to get the external bots up so we'll see if we can
reproduce there and I'll work with you on getting some sort of test case
here.

-eric

On Tue, Nov 28, 2017 at 12:26 PM Sean Fertile via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: sfertile
> Date: Tue Nov 28 12:25:58 2017
> New Revision: 319218
>
> URL: http://llvm.org/viewvc/llvm-project?rev=319218&view=rev
> Log:
> [PowerPC] Allow tail calls of fastcc functions from C CallingConv
> functions.
>
> Allow fastcc callees to be tail-called from ccc callers.
>
> Differential Revision: https://reviews.llvm.org/D40355
>
> Modified:
>     llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
>     llvm/trunk/test/CodeGen/PowerPC/duplicate-returns-for-tailcall.ll
>
> Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=319218&r1=319217&r2=319218&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
> +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Tue Nov 28 12:25:58
> 2017
> @@ -4397,13 +4397,18 @@ hasSameArgumentList(const Function *Call
>  static bool
>  areCallingConvEligibleForTCO_64SVR4(CallingConv::ID CallerCC,
>                                      CallingConv::ID CalleeCC) {
> -  // Tail or Sibling call optimization (TCO/SCO) needs callee and caller
> to
> -  // have the same calling convention.
> -  if (CallerCC != CalleeCC)
> +  // tail calls are possible with fastcc and ccc.
> +  auto isTailCallableCC  = [] (CallingConv::ID CC){
> +      return  CC == CallingConv::C || CC == CallingConv::Fast;
> +  };
> +  if (!isTailCallableCC(CallerCC) || !isTailCallableCC(CalleeCC))
>      return false;
>
> -  // Tail or Sibling calls can be done with fastcc/ccc.
> -  return (CallerCC == CallingConv::Fast || CallerCC == CallingConv::C);
> +  // We can safely tail call both fastcc and ccc callees from a c calling
> +  // convention caller. If the caller is fastcc, we may have less stack
> space
> +  // then a non-fastcc caller with the same signature so disable
> tail-calls in
> +  // that case.
> +  return CallerCC == CallingConv::C || CallerCC == CalleeCC;
>  }
>
>  bool
>
> Modified: llvm/trunk/test/CodeGen/PowerPC/duplicate-returns-for-tailcall.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/duplicate-returns-for-tailcall.ll?rev=319218&r1=319217&r2=319218&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/CodeGen/PowerPC/duplicate-returns-for-tailcall.ll
> (original)
> +++ llvm/trunk/test/CodeGen/PowerPC/duplicate-returns-for-tailcall.ll Tue
> Nov 28 12:25:58 2017
> @@ -42,10 +42,10 @@ if.end4:
>  if.then6:                                         ; preds = %if.end4
>    %call7 = tail call fastcc signext i32 @call3(i32 signext %a, i32
> signext %b, i32 signext %c)
>    br label %return
> -; No duplication here because the calling convention mismatch means we
> won't tail-call
> +; tail calling a fastcc function from a ccc function is supported.
>  ; CHECK_LABEL: if.then13:
> -; CHECK:       tail call fastcc signext i32 @call3
> -; CHECK-NEXT:  br
> +; CHECK:       %[[T2:[a-zA-Z0-9]+]] = tail call fastcc signext i32 @call3
> +; CHECK-NEXT:  ret i32 %[[T2]]
>
>  return:                                           ; preds = %if.end4,
> %if.then6, %if.then2, %if.then
>    %retval.0 = phi i32 [ %call, %if.then ], [ %call3, %if.then2 ], [
> %call7, %if.then6 ], [ %c, %if.end4 ]
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171207/db4be904/attachment.html>


More information about the llvm-commits mailing list