fix x86_64/i386 gfunc_call, when arg is VT_STRUCT, need fetch cpu flag before generating any code
This commit is contained in:
parent
34b7b2cef5
commit
af1cfd9e82
4 changed files with 31 additions and 1 deletions
|
@ -409,6 +409,9 @@ ST_FUNC void gfunc_call(int nb_args)
|
|||
args_size = 0;
|
||||
for(i = 0;i < nb_args; i++) {
|
||||
if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
|
||||
/* fetch cpu flag before generating any code */
|
||||
if ((vtop->r & VT_VALMASK) == VT_CMP)
|
||||
gv(RC_INT);
|
||||
size = type_size(&vtop->type, &align);
|
||||
/* align to stack align size */
|
||||
size = (size + 3) & ~3;
|
||||
|
|
23
tests/tests2/135_func_arg_struct_compare.c
Normal file
23
tests/tests2/135_func_arg_struct_compare.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
// https://lists.nongnu.org/archive/html/tinycc-devel/2024-12/msg00019.html
|
||||
// x86_64/i386 void gfunc_call(int nb_args), when push struct args, need fetch cpu flag before generating any code
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct string {
|
||||
char *str;
|
||||
int len;
|
||||
};
|
||||
|
||||
void dummy(struct string fpath, int dump_arg) {
|
||||
}
|
||||
|
||||
int main() {
|
||||
int a = 1;
|
||||
struct string x;
|
||||
x.str = "gg.v";
|
||||
x.len = 4;
|
||||
dummy(x, a == 0);
|
||||
printf("done\n");
|
||||
return 0;
|
||||
}
|
||||
|
1
tests/tests2/135_func_arg_struct_compare.expect
Normal file
1
tests/tests2/135_func_arg_struct_compare.expect
Normal file
|
@ -0,0 +1 @@
|
|||
done
|
|
@ -828,6 +828,9 @@ void gfunc_call(int nb_args)
|
|||
continue; /* arguments smaller than 8 bytes passed in registers or on stack */
|
||||
|
||||
if (bt == VT_STRUCT) {
|
||||
/* fetch cpu flag before generating any code */
|
||||
if ((vtop->r & VT_VALMASK) == VT_CMP)
|
||||
gv(RC_INT);
|
||||
/* align to stack align size */
|
||||
size = (size + 15) & ~15;
|
||||
/* generate structure store */
|
||||
|
|
Loading…
Reference in a new issue