You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When struct is passed on the stack and alignment of struct is 16 bytes compiler does not align the struct properly. Here is a comparison between ldc, dmd and gcc. Both ldc and dmd miss the alignment.
This is... problematic. The problem is https://github.com/dlang/dmd/blob/f3a588f41c63a1655fcb733c06ef08e152da0125/src/dmd/argtypes_sysv_x64.d#L399-L404, which I've analyzed back then with such a struct being passed as the first arg (i.e., in registers), where it only occupies one register, despite its padded size of 16 bytes. If it is spilled to the stack, it's pushed as full 16-bytes struct with appropriate alignment. So the toArgTypes machinery doesn't work well in this case, as it doesn't account for such special cases, where the passed payload size depends on the parameter position.
When struct is passed on the stack and alignment of struct is 16 bytes compiler does not align the struct properly. Here is a comparison between ldc, dmd and gcc. Both ldc and dmd miss the alignment.
https://godbolt.org/z/xKc8WK
D code:
C code:
However alignment starts to work if you replace 16 with 32.
https://godbolt.org/z/6r7GbW
dmd issue: https://issues.dlang.org/show_bug.cgi?id=21230
The text was updated successfully, but these errors were encountered: