[PATCH] D66278: [RISCV] Enable tail call opt for variadic function

Jim Lin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 19:04:33 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb77aa1d2486f: [RISCV] Enable tail call opt for variadic function (authored by Jim).
Herald added a subscriber: hiraditya.

Changed prior to commit:
  https://reviews.llvm.org/D66278?vs=216762&id=218577#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66278/new/

https://reviews.llvm.org/D66278

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


Index: llvm/test/CodeGen/RISCV/tail-calls.ll
===================================================================
--- llvm/test/CodeGen/RISCV/tail-calls.ll
+++ llvm/test/CodeGen/RISCV/tail-calls.ll
@@ -47,14 +47,14 @@
   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
 }
 
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1946,7 +1946,6 @@
 
   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 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66278.218577.patch
Type: text/x-patch
Size: 1524 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190904/6df69716/attachment.bin>


More information about the llvm-commits mailing list