[SPARC] Zero-sized struct arguments consume a stack argument slot in clang, but not in GCC
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
On sparc64 GCC does not store zero-sized arguments on the stack, Clang uses a 64-bit slot for them.
https://godbolt.org/z/a6WqKjYfY
```c
struct E {};
void f(struct E a0, struct E a1, struct E a2, struct E a3,
struct E a4, struct E a5, struct E a6, unsigned char u);
void caller1(void) {
struct E e;
f(e, e, e, e, e, e, e, 0x5A);
}
void g(struct E a0, struct E a1, struct E a2, struct E a3,
struct E a4, struct E a5, struct E a6, struct E a7, unsigned char u);
void caller2(void) {
struct E e;
g(e, e, e, e, e, e, e, e, 0x5A);
}
```
On GCC the `unsigned char` is stored at the same stack offset
```assembly
caller1:
save %sp, -192, %sp
mov 90, %g1
call f, 0
stx %g1, [%sp+2223]
return %i7+8
nop
caller2:
save %sp, -192, %sp
mov 90, %g1
call g, 0
stx %g1, [%sp+2223]
return %i7+8
nop
```
But with clang the stack offset is different (by 8 bytes):
```assembly
caller1:
save %sp, -192, %sp
mov 90, %i0
call f
stx %i0, [%sp+2231]
ret
restore
caller2:
save %sp, -208, %sp
mov 90, %i0
call g
stx %i0, [%sp+2239]
ret
restore
```
Because zero-sized structs are a GNU extension, sparc64 really should follow GCC here. It's even more efficient too.
Contributor guide
Assessment
This issue has not been assessed yet.