From 65c7f19debb61f5b554c64a04ece92b951881282 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sun, 24 Jun 2018 20:12:51 +0200 Subject: [PATCH] Fix stored type of arguments on x86-64 the lvalue Syms for arguments didn't correctly reflect their own types in all cases (a side-effect of the type being stored in type->t and the ->r members (as VT_LVAL_xxx), so the below used an int load (not a byte load) in the conditional. extern void bar (void); void foo (signed char c) { signed char x = c; if (c) bar(); } --- x86_64-gen.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x86_64-gen.c b/x86_64-gen.c index c41bc934..2672e138 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -988,7 +988,8 @@ void gfunc_prolog(CType *func_type) if (reg_param_index < REGN) { gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr); } - sym_push(sym->v & ~SYM_FIELD, type, VT_LLOCAL | VT_LVAL, addr); + sym_push(sym->v & ~SYM_FIELD, type, + VT_LLOCAL | lvalue_type(type->t), addr); } else { if (reg_param_index < REGN) { /* save arguments passed by register */ @@ -1001,7 +1002,8 @@ void gfunc_prolog(CType *func_type) gen_modrm64(0x89, arg_regs[reg_param_index], VT_LOCAL, NULL, addr); } } - sym_push(sym->v & ~SYM_FIELD, type, VT_LOCAL | VT_LVAL, addr); + sym_push(sym->v & ~SYM_FIELD, type, + VT_LOCAL | lvalue_type(type->t), addr); } addr += 8; reg_param_index++; @@ -1567,7 +1569,7 @@ void gfunc_prolog(CType *func_type) default: break; /* nothing to be done for x86_64_mode_none */ } sym_push(sym->v & ~SYM_FIELD, type, - VT_LOCAL | VT_LVAL, param_addr); + VT_LOCAL | lvalue_type(type->t), param_addr); } #ifdef CONFIG_TCC_BCHECK