Fix function call on arm64 and riscv

arm64-gen.c/riscv64-gen.c
- Copy code from x86_64-gen.c (fetch cpu flag before generating any code)

tests/tcctest.c:
- Add test code
This commit is contained in:
herman ten brugge 2021-06-22 07:38:39 +02:00
parent 0378168c13
commit b5d4b908c4
3 changed files with 23 additions and 0 deletions

View File

@ -1010,6 +1010,10 @@ ST_FUNC void gfunc_call(int nb_args)
stack = (stack + 15) >> 4 << 4;
/* fetch cpu flag before generating any code */
if ((vtop->r & VT_VALMASK) == VT_CMP)
gv(RC_INT);
if (stack >= 0x1000000) // 16Mb
tcc_error("stack size too big %lu", stack);
if (stack & 0xfff)

View File

@ -621,6 +621,11 @@ ST_FUNC void gfunc_call(int nb_args)
stack_adj = (stack_adj + 15) & -16;
tempspace = (tempspace + 15) & -16;
stack_add = stack_adj + tempspace;
/* fetch cpu flag before generating any code */
if ((vtop->r & VT_VALMASK) == VT_CMP)
gv(RC_INT);
if (stack_add) {
if (stack_add >= 0x1000) {
o(0x37 | (5 << 7) | (-stack_add & 0xfffff000)); //lui t0, upper(v)

View File

@ -4161,6 +4161,19 @@ void bounds_check1_test (void)
pv(y);
}
/* This failed on arm64/riscv64 */
void map_add(int a, int b, int c, int d, int e, int f, int g, int h, int i)
{
printf ("%d %d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h, i);
}
void func_arg_test(void)
{
int a = 0;
int b = 1;
map_add(0, 1, 2, 3, 4, 5, 6, 7, a && b);
}
/* gcc 2.95.3 does not handle correctly CR in strings or after strays */
#define CORRECT_CR_HANDLING
@ -4276,6 +4289,7 @@ int main(int argc, char **argv)
RUN(volatile_test);
RUN(attrib_test);
RUN(bounds_check1_test);
RUN(func_arg_test);
return 0;
}