]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Don't trust TYPE_ALIGN for pointers [PR108910]
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 17 Apr 2023 13:41:00 +0000 (14:41 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Mon, 17 Apr 2023 13:41:00 +0000 (14:41 +0100)
commit66700dde0dfb2c2b07d771f90df1fe16d1d61ce9
treee27fc14022ff54518c3c691902cb096089b7028d
parent3d2210dafd872e8470e2a6ae5eea74d2669bc055
aarch64: Don't trust TYPE_ALIGN for pointers [PR108910]

The aarch64 PCS rules ignore user alignment for scalars and
vectors and use the "natural" alignment of the type.  GCC tried
to calculate that natural alignment using:

  TYPE_ALIGN (TYPE_MAIN_VARIANT (type))

But as discussed in the PR, it's possible that the main variant
of a pointer type is an overaligned type (although that's usually
accidental).

This isn't known to be a problem for other types, so this patch
changes the bare minimum.  It might be that we need to ignore
TYPE_ALIGN in other cases too.

gcc/
PR target/108910
* config/aarch64/aarch64.cc (aarch64_function_arg_alignment): Do
not trust TYPE_ALIGN for pointer types; use POINTER_SIZE instead.

gcc/testsuite/
PR target/108910
* gcc.dg/torture/pr108910.c: New test.

(cherry picked from commit 66946624b96b762985de56444d726a0ebd4e0df5)
gcc/config/aarch64/aarch64.cc
gcc/testsuite/gcc.dg/torture/pr108910.c [new file with mode: 0644]