From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BCF0F3858D33; Mon, 28 Aug 2023 18:28:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCF0F3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1693247295; bh=NJQHhBkkPZmZMbPyqhW6hZitW4k7LY7in9NBRcVW52o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OEu8UNQIcfSrO6Wjw9JxPUqhS9qxG4wuHJkGz6U78e03++BWk62COYasvWu3gW1Ax uR7/jXlpEGkwx+iGvGyQft1o5d73jSy8U5Fdc47dtzfqBnCI9FpJUI5ZscTiT4vipM LWZZWkMhNTS2xQGynOQDrg+29LnEjB3t4RVtuIHE= From: "gabrielopcode at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/111107] i686-w64-mingw32 does not realign stack when __attribute__((aligned)) or __attribute__((vector_size)) are used Date: Mon, 28 Aug 2023 18:28:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: ABI, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: gabrielopcode at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111107 Gabriel Iv=C4=83ncescu changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gabrielopcode at gmail dot= com --- Comment #7 from Gabriel Iv=C4=83ncescu = --- So to re-iterate summary of the problem: 1) The i686 Win32 ABI has a de-facto stack alignment of 4 bytes *only*. GCC= may have set it to 16 bytes on Linux because it compiled the whole userland, but that's not the case on Windows; the caller can be MSVC compiled code (very likely on Windows) and MSVC only uses 4-byte alignment. 2) SSE is *not* the only thing that requires stack realignment. Sure, it do= es require it, but that's more a side effect of requiring larger-than-4 alignm= ent in the first place. A variable (or its type) declared with __attribute__((aligned(...))) **shou= ld** also let GCC re-align the stack upon entry, if it's > 4 bytes and if it's actually used on the stack and spilled (or has its address taken). There's no reason to special-case SSE at all. It's just the alignment of the variable or spilled vector that should matter, and GCC must know that the incoming stack is aligned only to 4 bytes on this platform. i686 PE targets should simply default to -mincoming-stack-boundary=3D2 -mpreferred-stack-boundary=3D2 (the latter to minimize realignments unless necessary), as that's basically MSVC's behavior, and as such the de-facto standard on this platform.=