mirror of
https://github.com/TinyCC/tinycc.git
synced 2025-11-16 12:34:45 +00:00
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:
23
tests/tests2/137_funcall_struct_args.c
Normal file
23
tests/tests2/137_funcall_struct_args.c
Normal 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));
|
||||
}
|
||||
|
||||
2
tests/tests2/137_funcall_struct_args.expect
Normal file
2
tests/tests2/137_funcall_struct_args.expect
Normal file
@@ -0,0 +1,2 @@
|
||||
x=999.500000
|
||||
y=999.500000
|
||||
Reference in New Issue
Block a user