[llvm] r370835 - [RISCV] Enable tail call opt for variadic function

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 19:03:37 PDT 2019


Author: jimlin
Date: Tue Sep  3 19:03:36 2019
New Revision: 370835

URL: http://llvm.org/viewvc/llvm-project?rev=370835&view=rev
Log:
[RISCV] Enable tail call opt for variadic function

Summary: Tail call opt can treat variadic function call the same as normal function call

Reviewers: mgrang, asb, lenary, lewis-revill

Reviewed By: lenary

Subscribers: luismarques, pzheng, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, s.egerton, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D66278

Modified:
    llvm/trunk/lib/Target/RISCV/RISCVISelLowering.cpp
    llvm/trunk/test/CodeGen/RISCV/tail-calls.ll

Modified: llvm/trunk/lib/Target/RISCV/RISCVISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCVISelLowering.cpp?rev=370835&r1=370834&r2=370835&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/RISCV/RISCVISelLowering.cpp Tue Sep  3 19:03:36 2019
@@ -1946,7 +1946,6 @@ bool RISCVTargetLowering::isEligibleForT
 
   auto &Callee = CLI.Callee;
   auto CalleeCC = CLI.CallConv;
-  auto IsVarArg = CLI.IsVarArg;
   auto &Outs = CLI.Outs;
   auto &Caller = MF.getFunction();
   auto CallerCC = Caller.getCallingConv();
@@ -1963,10 +1962,6 @@ bool RISCVTargetLowering::isEligibleForT
   if (Caller.hasFnAttribute("interrupt"))
     return false;
 
-  // Do not tail call opt functions with varargs.
-  if (IsVarArg)
-    return false;
-
   // Do not tail call opt if the stack is used to pass parameters.
   if (CCInfo.getNextStackOffset() != 0)
     return false;

Modified: llvm/trunk/test/CodeGen/RISCV/tail-calls.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/RISCV/tail-calls.ll?rev=370835&r1=370834&r2=370835&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/RISCV/tail-calls.ll (original)
+++ llvm/trunk/test/CodeGen/RISCV/tail-calls.ll Tue Sep  3 19:03:36 2019
@@ -47,14 +47,14 @@ entry:
   ret void
 }
 
-; Do not tail call optimize functions with varargs.
+; Do not tail call optimize functions with varargs passed by stack.
 declare i32 @callee_varargs(i32, ...)
 define void @caller_varargs(i32 %a, i32 %b) nounwind {
 ; CHECK-LABEL: caller_varargs
 ; CHECK-NOT: tail callee_varargs
 ; CHECK: call callee_varargs
 entry:
-  %call = tail call i32 (i32, ...) @callee_varargs(i32 %a, i32 %b, i32 %b, i32 %a)
+  %call = tail call i32 (i32, ...) @callee_varargs(i32 %a, i32 %b, i32 %b, i32 %a, i32 %a, i32 %b, i32 %b, i32 %a, i32 %a)
   ret void
 }
 




More information about the llvm-commits mailing list