ia32: Fix alignment of _Atomic fields [PR65146]
authorJakub Jelinek <jakub@redhat.com>
Thu, 27 Aug 2020 16:44:40 +0000 (18:44 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 27 Aug 2020 16:44:40 +0000 (18:44 +0200)
commit04df5e7de2f3dd652a9cddc1c9adfbdf45947ae6
treec72fded4155fe7118553038173a04e3b507d0d66
parentabca87c57847cd04f5e05935ff9ae5121c1ecb1d
ia32: Fix alignment of _Atomic fields [PR65146]

For _Atomic fields, lowering the alignment of long long or double etc.
fields on ia32 is undesirable, because then one really can't perform atomic
operations on those using cmpxchg8b.

The following patch stops lowering the alignment in fields for _Atomic
types (the x86_field_alignment change) and for -mpreferred-stack-boundary=2
also ensures we don't misalign _Atomic long long etc. automatic variables
(the ix86_{local,minimum}_alignment changes).
Not sure about iamcu_alignment change, I know next to nothing about IA MCU,
but unless it doesn't have cmpxchg8b instruction, it would surprise me if we
don't want to do it as well.
clang apparently doesn't lower the field alignment for _Atomic.

2020-08-27  Jakub Jelinek  <jakub@redhat.com>

PR target/65146
* config/i386/i386.c (iamcu_alignment): Don't decrease alignment
for TYPE_ATOMIC types.
(ix86_local_alignment): Likewise.
(ix86_minimum_alignment): Likewise.
(x86_field_alignment): Likewise, and emit a -Wpsabi diagnostic
for it.

* gcc.target/i386/pr65146.c: New test.
gcc/config/i386/i386.c
gcc/testsuite/gcc.target/i386/pr65146.c [new file with mode: 0644]