]> gcc.gnu.org Git - gcc.git/commit
aarch64: Fix bit-field alignment in param passing [PR105549]
authorChristophe Lyon <christophe.lyon@arm.com>
Fri, 25 Nov 2022 13:35:11 +0000 (13:35 +0000)
committerChristophe Lyon <christophe.lyon@arm.com>
Thu, 12 Jan 2023 13:43:41 +0000 (14:43 +0100)
commit6610daa1cfb75b72500c22ae97988ec2a48b85c6
tree01635beb7f50e6b5a0b5401c3c6d82bea7deb865
parent3df1a115be22caeab3ffe7afb12e71adb54ff132
aarch64: Fix bit-field alignment in param passing [PR105549]

While working on enabling DFP for AArch64, I noticed new failures in
gcc.dg/compat/struct-layout-1.exp (t028) which were not actually
caused by DFP types handling. These tests are generated during 'make
check' and enabling DFP made generation different (not sure if new
non-DFP tests are generated, or if existing ones are generated
differently, the tests in question are huge and difficult to compare).

Anyway, I reduced the problem to what I attach at the end of the new
gcc.target/aarch64/aapcs64/va_arg-17.c test and rewrote it in the same
scheme as other va_arg* AArch64 tests.  Richard Sandiford further
reduced this to a non-vararg function, added as a second testcase.

This is a tough case mixing bit-fields and alignment, where
aarch64_function_arg_alignment did not follow what its descriptive
comment says: we want to use the natural alignment of the bit-field
type only if the user didn't reduce the alignment for the bit-field
itself.

The patch also adds a comment and assert that would help someone who
has to look at this area again.

The fix would be very small, except that this introduces a new ABI
break, and we have to warn about that.  Since this actually fixes a
problem introduced in GCC 9.1, we keep the old computation to detect
when we now behave differently.

This patch adds two new tests (va_arg-17.c and
pr105549.c). va_arg-17.c contains the reduced offending testcase from
struct-layout-1.exp for reference.  We update some tests introduced by
the previous patch, where parameters with bit-fields and packed
attribute now emit a different warning.

2022-11-28  Christophe Lyon  <christophe.lyon@arm.com>
    Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR target/105549
* config/aarch64/aarch64.cc (aarch64_function_arg_alignment):
Check DECL_PACKED for bitfield.
(aarch64_layout_arg): Warn when parameter passing ABI changes.
(aarch64_function_arg_boundary): Do not warn here.
(aarch64_gimplify_va_arg_expr): Warn when parameter passing ABI
changes.

gcc/testsuite/
PR target/105549
* gcc.target/aarch64/bitfield-abi-warning-align16-O2.c: Update.
* gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c: Update.
* gcc.target/aarch64/bitfield-abi-warning-align32-O2.c: Update.
* gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c: Update.
* gcc.target/aarch64/aapcs64/va_arg-17.c: New test.
* gcc.target/aarch64/pr105549.c: New test.
* g++.target/aarch64/bitfield-abi-warning-align16-O2.C: Update.
* g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C: Update.
* g++.target/aarch64/bitfield-abi-warning-align32-O2.C: Update.
* g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C: Update.
gcc/config/aarch64/aarch64.cc
gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C
gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2.C
gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C
gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2.C
gcc/testsuite/gcc.target/aarch64/aapcs64/va_arg-17.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c
gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2.c
gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c
gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2.c
gcc/testsuite/gcc.target/aarch64/pr105549.c [new file with mode: 0644]
This page took 0.065256 seconds and 5 git commands to generate.