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();
}
This commit is contained in:
Michael Matz 2018-06-24 20:12:51 +02:00
parent 91bdb5a4a3
commit 65c7f19deb
1 changed files with 5 additions and 3 deletions

View File

@ -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