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; 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 {