public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/102024] [12 Regression] zero width bitfields and ABIs
Date: Fri, 03 Sep 2021 07:53:28 +0000	[thread overview]
Message-ID: <bug-102024-4-xtTlKQDJkm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102024-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102024

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:e902136b310ee17d4b49eb42d9d5e487d5dcf4a1

commit r12-3324-ge902136b310ee17d4b49eb42d9d5e487d5dcf4a1
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Sep 3 09:46:32 2021 +0200

    c++, abi: Set DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD on C++ zero width
bitfields [PR102024]

    The removal of remove_zero_width_bitfields function and its call from
    C++ FE layout_class_type (which I've done in the P0466R5
    layout-compatible helper intrinsics patch, so that the FE can actually
    determine what is and isn't layout-compatible according to the spec)
    unfortunately changed the ABI on various platforms.
    The C FE has been keeping zero-width bitfields in the types, while
    the C++ FE has been removing them after structure layout, so in various
    cases when passing such structures in registers we had different ABI
    between C and C++.

    While both the C and C++ FE had some code to remove zero width bitfields
    after structure layout, in both FEs it was buggy and didn't really remove
    any.  In the C FE that code has been removed later on, while in the C++ FE
    for GCC 4.5 in PR42217 it has been actually fixed, so the C++ FE started
    to remove those bitfields.

    The following patch doesn't change anything ABI-wise, but allows the
    targets to decide what to do, emit -Wpsabi warnings etc.
    Non-C zero width bitfields will be seen by the backends as normal
    zero width bitfields, C++ zero width bitfields that used to be previously
    removed will have DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD flag set.
    I've reused the DECL_FIELD_ABI_IGNORED flag which is only used on
non-bitfield
    FIELD_DECLs right now, but the macros now check DECL_BIT_FIELD flag.

    Each backend can then decide what it wants, whether it wants to keep
    different ABI between C and C++ as in GCC 11 and older (i.e. incompatible
    with G++ <= 4.4, compatible with G++ 4.5 .. 11), for that it would
    ignore for the aggregate passing/returning decisions all
    DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD FIELD_DECLs), whether it wants to never
    ignore zero width bitfields (no changes needed for that case, except
perhaps
    -Wpsabi warning should be added and for that
DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD
    can be tested), or whether it wants to always ignore zero width bitfields
    (I think e.g. riscv in GCC 10+ does that).

    All this patch does is set the flag which the backends can then use.

    2021-09-03  Jakub Jelinek  <jakub@redhat.com>

            PR target/102024
    gcc/
            * tree.h (DECL_FIELD_ABI_IGNORED): Changed into rvalue only macro
            that is false if DECL_BIT_FIELD.
            (SET_DECL_FIELD_ABI_IGNORED, DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD,
            SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD): Define.
            * tree-streamer-out.c (pack_ts_decl_common_value_fields): For
            DECL_BIT_FIELD stream DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD instead
            of DECL_FIELD_ABI_IGNORED.
            * tree-streamer-in.c (unpack_ts_decl_common_value_fields): Use
            SET_DECL_FIELD_ABI_IGNORED instead of writing to
            DECL_FIELD_ABI_IGNORED and for DECL_BIT_FIELD use
            SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD instead.
            * lto-streamer-out.c (hash_tree): For DECL_BIT_FIELD hash
            DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD instead of
DECL_FIELD_ABI_IGNORED.
    gcc/cp/
            * class.c (build_base_field): Use SET_DECL_FIELD_ABI_IGNORED
            instead of writing to DECL_FIELD_ABI_IGNORED.
            (layout_class_type): Likewise.  In the place where zero-width
            bitfields used to be removed, use
            SET_DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD on those fields instead.
    gcc/lto/
            * lto-common.c (compare_tree_sccs_1): Also compare
            DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD values.

  parent reply	other threads:[~2021-09-03  7:53 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 14:36 [Bug target/102024] New: " jakub at gcc dot gnu.org
2021-08-23 14:38 ` [Bug target/102024] [12 Regression] " jakub at gcc dot gnu.org
2021-08-23 14:40 ` jakub at gcc dot gnu.org
2021-08-23 15:20 ` jakub at gcc dot gnu.org
2021-08-23 15:37 ` jakub at gcc dot gnu.org
2021-08-23 16:17 ` rsandifo at gcc dot gnu.org
2021-08-23 20:42 ` segher at gcc dot gnu.org
2021-08-23 20:49 ` segher at gcc dot gnu.org
2021-08-24  7:06 ` rguenth at gcc dot gnu.org
2021-08-24 14:13 ` matz at gcc dot gnu.org
2021-08-24 21:36 ` segher at gcc dot gnu.org
2021-08-25 19:23 ` wschmidt at gcc dot gnu.org
2021-08-25 19:33 ` wschmidt at gcc dot gnu.org
2021-08-25 20:08 ` wschmidt at gcc dot gnu.org
2021-09-03  7:53 ` cvs-commit at gcc dot gnu.org [this message]
2021-09-03  8:12 ` jakub at gcc dot gnu.org
2021-09-21 16:16 ` wschmidt at gcc dot gnu.org
2021-09-23 12:40 ` cvs-commit at gcc dot gnu.org
2022-01-10 16:47 ` cvs-commit at gcc dot gnu.org
2022-03-24  9:39 ` ebotcazou at gcc dot gnu.org
2022-03-24 11:25 ` cvs-commit at gcc dot gnu.org
2022-03-29 16:44 ` cvs-commit at gcc dot gnu.org
2022-03-29 16:45 ` cvs-commit at gcc dot gnu.org
2022-03-30 10:27 ` jakub at gcc dot gnu.org
2022-03-30 10:39 ` jakub at gcc dot gnu.org
2022-03-30 12:40 ` hp at gcc dot gnu.org
2022-03-30 12:43 ` jakub at gcc dot gnu.org
2022-03-30 13:05 ` jakub at gcc dot gnu.org
2022-03-30 13:42 ` xry111 at mengyan1223 dot wang
2022-03-30 13:53 ` jakub at gcc dot gnu.org
2022-03-30 14:34 ` xry111 at mengyan1223 dot wang
2022-03-30 19:02 ` xry111 at mengyan1223 dot wang
2022-03-31 12:36 ` segher at gcc dot gnu.org
2022-03-31 12:50 ` jakub at gcc dot gnu.org
2022-03-31 15:08 ` xry111 at mengyan1223 dot wang
2022-03-31 15:14 ` xry111 at mengyan1223 dot wang
2022-04-01  9:50 ` cvs-commit at gcc dot gnu.org
2022-04-01 14:39 ` cvs-commit at gcc dot gnu.org
2022-04-01 14:39 ` cvs-commit at gcc dot gnu.org
2022-04-02  0:47 ` segher at gcc dot gnu.org
2022-04-27  7:23 ` cvs-commit at gcc dot gnu.org

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-102024-4-xtTlKQDJkm@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: link
Be 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).