summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Lin <tclin914@gmail.com>2019-09-04 02:03:36 +0000
committerJim Lin <tclin914@gmail.com>2019-09-04 02:03:36 +0000
commitb77aa1d2486f3a0506dea642b6b75c8bdbde71ec (patch)
treeba32d2d80b8caec51ffd93291f5e4b50aad7301f
parent594f0e0927f4e5e782d4a7b0ed8153925d35dd5d (diff)
downloadbcm5719-llvm-b77aa1d2486f3a0506dea642b6b75c8bdbde71ec.tar.gz
bcm5719-llvm-b77aa1d2486f3a0506dea642b6b75c8bdbde71ec.zip
[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 llvm-svn: 370835
-rw-r--r--llvm/lib/Target/RISCV/RISCVISelLowering.cpp5
-rw-r--r--llvm/test/CodeGen/RISCV/tail-calls.ll4
2 files changed, 2 insertions, 7 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 6f5978fb3cb..86add6ecccf 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -1946,7 +1946,6 @@ bool RISCVTargetLowering::isEligibleForTailCallOptimization(
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::isEligibleForTailCallOptimization(
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;
diff --git a/llvm/test/CodeGen/RISCV/tail-calls.ll b/llvm/test/CodeGen/RISCV/tail-calls.ll
index dea1521b05c..970f9ee31b3 100644
--- a/llvm/test/CodeGen/RISCV/tail-calls.ll
+++ b/llvm/test/CodeGen/RISCV/tail-calls.ll
@@ -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
}
OpenPOWER on IntegriCloud