[PATCH] D66278: [RISCV] Enable tail call opt for variadic function
Jim Lin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 01:30:55 PDT 2019
Jim created this revision.
Jim added reviewers: mgrang, asb, lenary, lewis-revill.
Herald added subscribers: llvm-commits, s.egerton, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.
Herald added a project: LLVM.
Tail call opt can treat variadic function call the same as normal function call
Repository:
rL LLVM
https://reviews.llvm.org/D66278
Files:
lib/Target/RISCV/RISCVISelLowering.cpp
test/CodeGen/RISCV/tail-calls.ll
Index: test/CodeGen/RISCV/tail-calls.ll
===================================================================
--- test/CodeGen/RISCV/tail-calls.ll
+++ test/CodeGen/RISCV/tail-calls.ll
@@ -47,17 +47,6 @@
ret void
}
-; Do not tail call optimize functions with varargs.
-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)
- ret void
-}
-
; Do not tail call optimize if stack is used to pass parameters.
declare i32 @callee_args(i32 %a, i32 %b, i32 %c, i32 %dd, i32 %e, i32 %ff, i32 %g, i32 %h, i32 %i, i32 %j, i32 %k, i32 %l, i32 %m, i32 %n)
define i32 @caller_args(i32 %a, i32 %b, i32 %c, i32 %dd, i32 %e, i32 %ff, i32 %g, i32 %h, i32 %i, i32 %j, i32 %k, i32 %l, i32 %m, i32 %n) nounwind {
Index: lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- lib/Target/RISCV/RISCVISelLowering.cpp
+++ 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.215337.patch
Type: text/x-patch
Size: 1656 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190815/4c156ce7/attachment.bin>
More information about the llvm-commits
mailing list