public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/102024] New: zero width bitfields and ABIs
@ 2021-08-23 14:36 jakub at gcc dot gnu.org
  2021-08-23 14:38 ` [Bug target/102024] [12 Regression] " jakub at gcc dot gnu.org
                   ` (39 more replies)
  0 siblings, 40 replies; 41+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-08-23 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102024
           Summary: zero width bitfields and ABIs
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

My r12-2975-g32c3a75390623a0470df52af13f78baddd562981 change removed removal of
zero width unnamed bitfields from the C++ FE, the C FE has never been removing
those (the removal was certainly premature, as the newly added traits need to
see the zero width unnamed bitfields).
This unfortunately can affect ABI on several targets.
>From quick grep I think this can't affect
alpha, arc, avr, bfin, bpf, c6x, cr16, cris, csky, epiphany, fr30, frv, ft32,
gcn, h8300, lm32, m32c, m32r, m68k, mcore, microblaze, mmix, mn10300, moxie,
msp430, nds32, nios2, nvptx, or1k, pa, pdp11, pru, rl78, rx, stormy16, tilegx,
tilepro, v850, vax, visium, xtensa
are all safe, they either don't mention TYPE_FIELDS in their backends or use it
either in va_list or in structure layout code only (structure layout happens
before the zero width bitfields are removed by the FE).
TYPE_MODE should be ok too, it is just passing of arguments by value and
returning by value that could be problematic on
aarch64, arm, i386, ia64, iq2000, mips, riscv, rs6000, s390, sh and sparc
I think sh is ok, it ignores integer_zerop (DECL_SIZE (field)).

riscv apparently has old (< GCC 10) and new (>= GCC 10) ABI and the old one
didn't ignore them and made C and C++ ABI incompatible, while the new one does
ignore them.  So, my patch probably broke the 
"ABI for flattened struct with zero-length bit-fields changed in GCC 10"
warning (why isn't it guarded with -Wpsabi?), perhaps we should mark the C++
zero width bitfields with some attribute or flag so that backends could emit
correct -Wpsabi warnings?

x86_64 seems to be affected:
struct S { float a; int : 0; float b; };

__attribute__((noipa)) struct S
foo (struct S x)
{
  return x;
}

void
bar (void)
{
  struct S s = { 0.0f, 0.0f };
  foo (s);
}

With GCC 10 and C we emit:
        xorl    %edi, %edi
        jmp     foo
With C++ we emit:
        pxor    %xmm0, %xmm0
        jmp     _Z3foo1S
with current trunk
        xorl    %edi, %edi
        jmp     _Z3foo1S

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2022-04-27  7:23 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 14:36 [Bug target/102024] New: zero width bitfields and ABIs 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
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

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).