Before the referenced PR, the explicit alignment was ignored. So this is sort of a regression. At the very least, code compiled and ran without issue before the change, even if the alignment of the frame variable was wrong.
Comment #3 by bugzilla — 2023-11-15T09:06:01Z
I've boiled this down to:
ubyte[] text() {
void xxx() { }
return single!(xxx)(null);
}
ubyte[] single(alias xxx)(ubyte[] table) {
align(64) ubyte[] vector;
ubyte[] abc() { return vector; }
stage!(abc)();
return table;
}
void stage(alias abc)() {
abc();
}
which compiles to:
text:
push RBP
mov RBP,RSP
xor ESI,ESI
xor EDX,EDX
xor EDI,EDI // context pointer for xxx
call single
pop RBP
ret
xxx:
ret
single:
push RBP
mov RBP,RSP
sub RSP,0B0h
mov -020h[RBP],RDI
mov -010h[RBP],RSI
mov -8[RBP],RDX
lea RAX,-031h[RBP]
and EAX,0FFFFFFC0h
mov 0FFFFFF50h[RBP],RAX
mov RCX,0FFFFFF50h[RBP]
mov qword ptr [RCX],0
mov qword ptr 8[RCX],0
lea RDI,-020h[RBP] // context pointer for xxx, not single
call stage
mov RDX,-8[RBP]
mov RAX,-010h[RBP]
leave
ret
abc:
push RBP
mov RBP,RSP
sub RSP,010h
mov -8[RBP],RDI
mov RAX,0FFFFFF50h[RDI]
mov RDX,8[RAX]
mov RAX,[RAX]
leave
ret
stage:
push RBP
mov RBP,RSP
sub RSP,010h
mov -8[RBP],RDI
call abc
leave
ret
The error is in the LEA, which loads RDI with the context pointer for xxx(), when it should be initializing RDI with RBP, the context pointer for single().