Bug 21230 – Incorrect stack alignment of 16byte aligned aggregates on linux

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-09-07T16:12:02Z
Last change time
2024-12-13T19:11:24Z
Keywords
backend, wrong-code
Assigned to
No Owner
Creator
MrSmith33
Moved to GitHub: dmd#19782 →

Comments

Comment #0 by mrsmith33 — 2020-09-07T16:12:02Z
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: ``` align(16) struct s { long a; } extern(C) void foo(int, int, int, int, int, int, s, s); void bar() { // push 10 // push 7 // call foo@PLT foo(1,2,3,4,5,6, s(7),s(10)); } ``` C code: ``` struct __attribute__((aligned(16))) s { long a; }; void foo(int, int, int, int, int, int, s, s); void bar() { // push 0 // push 10 // push 0 // push 7 foo(1,2,3,4,5,6, s{7},s{10}); } ``` However alignment starts to work if you replace 16 with 32. https://godbolt.org/z/6r7GbW Issue for ldc: https://github.com/ldc-developers/ldc/issues/3557
Comment #1 by robert.schadek — 2024-12-13T19:11:24Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19782 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB