arm64: Save func results before struct args

In gfunc_call(), structure members are loaded into registers during
argument handling.
This operation may overwrite previous function call results stored in
registers (e.g., s0). To prevent this, we must save function call
results to the stack before processing structure arguments.
This commit is contained in:
kbkpbot
2025-07-11 22:13:30 +08:00
parent 32b597746c
commit 0c12363fd3
3 changed files with 28 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#include <stdio.h>
// arm64-gen.c: gfunc_call() Second pass when struct args may overwrite previous func call result
struct vec {
float x;
float y;
};
void bug(float x, float y) {
printf("x=%f\ny=%f\n", x, y);
}
float dot(struct vec v) {
return 999.5;
}
void main(void) {
struct vec a;
a.x = 33.0f;
a.y = 77.0f;
bug(dot(a), dot(a));
}

View File

@@ -0,0 +1,2 @@
x=999.500000
y=999.500000