From 98dc4c123d95f26f984fba5b4a1cf99e31e12444 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Mon, 22 Jul 2019 20:37:42 +0200 Subject: [PATCH] riscv: Fix stdarg_many_test if named params are passed on stack, the va_arg area begins after that, not at sp+0. Fixes abitest:stdarg_many_test. --- riscv64-gen.c | 6 ++++-- tccgen.c | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/riscv64-gen.c b/riscv64-gen.c index 09c011e3..fb3febd7 100644 --- a/riscv64-gen.c +++ b/riscv64-gen.c @@ -576,7 +576,7 @@ ST_FUNC void gfunc_call(int nb_args) EI(0x13, 0, 2, 2, stack_adj + tempspace); // addi sp, sp, adj } -static int func_sub_sp_offset, num_va_regs; +static int func_sub_sp_offset, num_va_regs, func_va_list_ofs; ST_FUNC void gfunc_prolog(CType *func_type) { @@ -650,6 +650,7 @@ ST_FUNC void gfunc_prolog(CType *func_type) (byref ? VT_LLOCAL : VT_LOCAL) | lvalue_type(sym->type.t), param_addr); } + func_va_list_ofs = addr; num_va_regs = 0; if (func_type->ref->f.func_type == FUNC_ELLIPSIS) { for (; aireg < 8; aireg++) { @@ -749,7 +750,8 @@ ST_FUNC void gfunc_epilog(void) ST_FUNC void gen_va_start(void) { - tcc_error("implement me: %s", __FUNCTION__); + vtop--; + vset(&char_pointer_type, VT_LOCAL, func_va_list_ofs); } ST_FUNC void gen_va_arg(CType *t) diff --git a/tccgen.c b/tccgen.c index 16f3c084..b76183b0 100644 --- a/tccgen.c +++ b/tccgen.c @@ -5180,9 +5180,7 @@ ST_FUNC void unary(void) r = VT_LOCAL; if (r != VT_LOCAL) tcc_error("__builtin_va_start expects a local variable"); - vtop->r = r; - vtop->type = char_pointer_type; - vtop->c.i = 0; + gen_va_start(); vstore(); break; #endif