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

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

https://gcc.gnu.org/g:3159da6c46568a7c600f78fb3a3b76e2ea4bf4cc

commit r12-6418-g3159da6c46568a7c600f78fb3a3b76e2ea4bf4cc
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Jan 10 17:43:23 2022 +0100

    x86_64: Ignore zero width bitfields in ABI and issue -Wpsabi warning about
C zero width bitfield ABI changes [PR102024]

    For zero-width bitfields current GCC classify_argument does:
                      if (DECL_BIT_FIELD (field))
                        {
                          for (i = (int_bit_position (field)
                                    + (bit_offset % 64)) / 8 / 8;
                               i < ((int_bit_position (field) + (bit_offset %
64))
                                    + tree_to_shwi (DECL_SIZE (field))
                                    + 63) / 8 / 8; i++)
                            classes[i]
                              = merge_classes (X86_64_INTEGER_CLASS,
classes[i]);
                        }
    which I think means that if the zero-width bitfields are at bit-positions
    (in the toplevel aggregate) which are multiples of 64 bits doesn't do
    anything, (int_bit_position (field) + (bit_offset % 64)) / 64 and
    (int_bit_position (field) + (bit_offset % 64) + 63) / 64 should be equal.
    But for zero-width bitfields at other bit positions it will call
    merge_classes once.  Now, the typical case is that the zero width bitfield
    is surrounded by some bitfields and in that case, it doesn't change
    anything, but it can be sandwitched in between floats too as the testcases
    show.
    In C we had this behavior, in C++ previously the FE was removing the
    zero-width bitfields and therefore they were ignored.
    LLVM and ICC seems to ignore those bitfields both in C and C++ (== passing
    struct S in SSE register rather than in GPR).

    The x86-64 psABI has been recently clarified by
   
https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/1aa4398d26c250b252a0c4a0f777216c9a6789ec
    that zero width bitfield should be always ignored.

    This patch implements that and emits a warning for C for cases where the
ABI
    changed from GCC 11.

    2022-01-10  Jakub Jelinek  <ja...@redhat.com>

            PR target/102024
            * config/i386/i386.c (classify_argument): Add zero_width_bitfields
            argument, when seeing DECL_FIELD_CXX_ZERO_WIDTH_BIT_FIELD
bitfields,
            always ignore them, when seeing other zero sized bitfields, either
            set zero_width_bitfields to 1 and ignore it or if equal to 2
process
            it.  Pass it to recursive calls.  Add wrapper
            with old arguments and diagnose ABI differences for C structures
            with zero width bitfields.  Formatting fixes.

            * gcc.target/i386/pr102024.c: New test.
            * g++.target/i386/pr102024.C: New test.

Reply via email to