public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "zfigura at codeweavers dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/111107] New: i686-w64-mingw32 does not realign stack when __attribute__((aligned)) or __attribute__((vector_size)) are used Date: Tue, 22 Aug 2023 21:27:32 +0000 [thread overview] Message-ID: <bug-111107-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111107 Bug ID: 111107 Summary: i686-w64-mingw32 does not realign stack when __attribute__((aligned)) or __attribute__((vector_size)) are used Product: gcc Version: 12.2.0 Status: UNCONFIRMED Keywords: ABI, wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: zfigura at codeweavers dot com Target Milestone: --- Target: i686-w64-mingw32 Minimal example: typedef int myint[4] __attribute__((aligned(16))); extern void g(void *); void f(void) { myint a; g(&a); } The same thing happens if __attribute__((aligned(16))) is applied to the variable instead of the typedef. This seems to also prevent __m128 from being aligned correctly (which uses the "vector_size" attribute rather than "aligned", but I would assume that "vector_size" implies "aligned"). -mincoming-stack-boundary=2 works as a workaround; so does -mstackrealign. Neither should be necessary, though. I've seen some disagreement [1] [2] as to whether the stack alignment for i686-w64-mingw32 *should* be 16 or 4, but as far as I can tell it really should be 4. It's explicitly called out in a code comment [3]; it shows up when -msse2 is used [4], and, well, it reflects the actual ABI of programs that exist in the wild. We do regularly come across programs in Wine that don't align the stack to a 16-byte boundary before calling win32 functions, and while -mstackrealign and similar functions exist, they imply that we either waste time and space unnecessarily aligning *every* function, or we manually align any function that might use an aligned type, which is in general something that's treated as the compiler's responsibility. [1] https://github.com/mingw-w64/mingw-w64/issues/30#issuecomment-1685487779 [2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273#c5 [3] https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/i386/cygming.h;h=d539f8d0699d69b014e9d3378e78d690ea289f14;hb=HEAD#l34 [4] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110273#c6
next reply other threads:[~2023-08-22 21:27 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-08-22 21:27 zfigura at codeweavers dot com [this message] 2023-08-22 21:29 ` [Bug target/111107] " pinskia at gcc dot gnu.org 2023-08-22 21:41 ` zfigura at codeweavers dot com 2023-08-22 21:41 ` pinskia at gcc dot gnu.org 2023-08-22 21:56 ` zfigura at codeweavers dot com 2023-08-23 7:55 ` rguenth at gcc dot gnu.org 2023-08-24 20:29 ` zfigura at codeweavers dot com 2023-08-28 18:28 ` gabrielopcode at gmail dot com 2023-11-25 7:34 ` alexhenrie24 at gmail dot com 2023-11-25 8:57 ` amonakov at gcc dot gnu.org 2023-11-25 17:40 ` gabrielopcode at gmail dot com 2023-11-25 18:54 ` alexhenrie24 at gmail dot com 2023-11-25 19:20 ` alexhenrie24 at gmail dot com 2023-11-25 21:45 ` alexhenrie24 at gmail dot com 2023-11-28 22:34 ` ebotcazou at gcc dot gnu.org 2023-11-28 22:58 ` ebotcazou at gcc dot gnu.org 2023-11-29 3:54 ` zfigura at codeweavers dot com 2023-11-29 7:49 ` ebotcazou at gcc dot gnu.org 2023-11-29 19:05 ` zfigura at codeweavers dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-111107-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).