[llvm] [AVR] Support stack realignment (PR #187129)
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 19 06:57:55 PDT 2026
benshi001 wrote:
I think current implementation is much better than the previous one, except two issues:
1. the above two failures in `make check-llvm-codegen -j`.
2. some wrong assembly is generated, for example
```c++
// clang a.c -O2 -Wall -S --target=avr -mmcu=atmega328
oid g(void *, void *);
void f() {
int a = 22;
_Alignas(8) int d = 55;
g(&a, &d);
}
```
The following assembly is generated
```
push r28
push r29
in r28, 61
in r29, 62
sbiw r28, 11
in r0, 63
cli
out 62, r29
out 63, r0
out 61, r28
movw r24, r28
adiw r24, 10
andi r24, 248
ldi r18, 22
ldi r19, 0
std Y+2, r19
std Y+1, r18
ldi r18, 55
ldi r19, 0
movw r22, r24
movw r30, r22
std Z+1, r19
st Z, r18
movw r24, r28
adiw r24, 1
call g
adiw r28, 11
in r0, 63
cli
out 62, r29
out 63, r0
out 61, r28
pop r29
pop r28
ret
```
`22` is stored to (Y+2):(Y+1) and `55` is stored to an location aligned to 8-byte. It seems the order is reverse.
https://github.com/llvm/llvm-project/pull/187129
More information about the llvm-commits
mailing list