]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Fix overly restrictive sibcall check [PR107102]
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 8 Jan 2025 18:20:47 +0000 (18:20 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 8 Jan 2025 18:20:47 +0000 (18:20 +0000)
commit0de5c20b72a738782e31acce771c6f2085e1014b
tree179aaeb591cfe52921ed29bf69d8541f6aebccb4
parentf79f5b87efc690abc3b8d1b0f927f9348157348b
aarch64: Fix overly restrictive sibcall check [PR107102]

aarch64_function_ok_for_sibcall required the caller and callee
to use the same PCS variant.  However, it should be enough for the
callee to preserve at least as much register state as the caller;
preserving more state is fine.

ARM_PCS_AAPCS64, ARM_PCS_SIMD, and ARM_PCS_SVE agree on what
GPRs should be preserved.  For the others:

- ARM_PCS_AAPCS64 preserves D8-D15
- ARM_PCS_SIMD preserves Q8-Q23
- ARM_PCS_SVE preserves Z8-Z23 + P4-P15

Thus it's ok for something earlier in the list to tail call something
later in the list.

gcc/
PR target/107102
* config/aarch64/aarch64.cc (aarch64_function_ok_for_sibcall): Only
reject calls with different PCSes if the callee clobbers register
state that the caller must preserve.

gcc/testsuite/
PR target/107102
* gcc.target/aarch64/sve/sibcall_1.c: New test.
gcc/config/aarch64/aarch64.cc
gcc/testsuite/gcc.target/aarch64/sve/sibcall_1.c [new file with mode: 0644]