From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D396C384BC17; Wed, 26 Aug 2020 16:03:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D396C384BC17 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598457805; bh=DDFyqX7lo4v9KDXXGF32QC7a2StmTeUhRqfMPrK5iog=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZJPZbcEh0uGR8Gpl0pVaJE5bkE/7Sp4+n6hci9UrkQ37A5YS9owKpEECHYEXGeG2E sEBh2i3gOe/REf/PST7Hnsq6uE3ti4qlVmSZS/5d4Y/KGDd8XKQ//TsJgZuY86vTys q9q2f93bUUXqdrnyG5X9z4q3UTkScwaOPL1wRE2g= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/65146] alignment of _Atomic structure member is not correct Date: Wed, 26 Aug 2020 16:03:25 +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: 4.9.2 X-Bugzilla-Keywords: ABI X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2020 16:03:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D65146 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org, | |uros at gcc dot gnu.org --- Comment #21 from Jakub Jelinek --- So, are we talking about something like (no -Wpsabi here) --- gcc/config/i386/i386.c.jj 2020-08-24 10:00:01.321258451 +0200 +++ gcc/config/i386/i386.c 2020-08-26 17:54:39.089468108 +0200 @@ -16487,7 +16487,11 @@ iamcu_alignment (tree type, int align) /* Intel MCU psABI specifies scalar types > 4 bytes aligned to 4 bytes. */ - mode =3D TYPE_MODE (strip_array_types (type)); + type =3D strip_array_types (type); + if (TYPE_ATOMIC (type)) + return align; + + mode =3D TYPE_MODE (type); switch (GET_MODE_CLASS (mode)) { case MODE_INT: @@ -16757,7 +16761,7 @@ ix86_minimum_alignment (tree exp, machin /* Don't do dynamic stack realignment for long long objects with -mpreferred-stack-boundary=3D2. */ if ((mode =3D=3D DImode || (type && TYPE_MODE (type) =3D=3D DImode)) - && (!type || !TYPE_USER_ALIGN (type)) + && (!type || (!TYPE_USER_ALIGN (type) && !TYPE_ATOMIC (type))) && (!decl || !DECL_USER_ALIGN (decl))) { gcc_checking_assert (!TARGET_STV); @@ -20293,7 +20297,10 @@ x86_field_alignment (tree type, int comp return computed; if (TARGET_IAMCU) return iamcu_alignment (type, computed); - mode =3D TYPE_MODE (strip_array_types (type)); + type =3D strip_array_types (type); + if (TYPE_ATOMIC (type)) + return computed; + mode =3D TYPE_MODE (type); if (mode =3D=3D DFmode || mode =3D=3D DCmode || GET_MODE_CLASS (mode) =3D=3D MODE_INT || GET_MODE_CLASS (mode) =3D=3D MODE_COMPLEX_INT) No idea whether we need the ix86_minimum_alignment change and about IAMCU I= 'll defer to H.J., but the last hunk fixes something like #c1 or struct A { char a; _Atomic long long b; }; struct B { char a; _Atomic double b; }; int a =3D __builtin_offsetof (struct A, b); int b =3D __builtin_offsetof (struct B, b); with -m32 for me.=