]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Fix CFA offsets in non-initial stack probes [PR119610]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 29 Apr 2025 15:07:37 +0000 (16:07 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 29 Apr 2025 15:07:37 +0000 (16:07 +0100)
commit68a75e3c0dcdb883cc96b626b541da20ab4df2f2
tree41f760b89269b9fd12c04ca9b8fb810b9a473f94
parent972a03737284b8611ec4e6315f6ca04d56ec05bf
aarch64: Fix CFA offsets in non-initial stack probes [PR119610]

PR119610 is about incorrect CFI output for a stack probe when that
probe is not the initial allocation.  The main aarch64 stack probe
function, aarch64_allocate_and_probe_stack_space, implicitly assumed
that the incoming stack pointer pointed to the top of the frame,
and thus held the CFA.

aarch64_save_callee_saves and aarch64_restore_callee_saves use a
parameter called bytes_below_sp to track how far the stack pointer
is above the base of the static frame.  This patch does the same
thing for aarch64_allocate_and_probe_stack_space.

Also, I noticed that the SVE path was attaching the first CFA note
to the wrong instruction: it was attaching the note to the calculation
of the stack size, rather than to the r11<-sp copy.

gcc/
PR target/119610
* config/aarch64/aarch64.cc (aarch64_allocate_and_probe_stack_space):
Add a bytes_below_sp parameter and use it to calculate the CFA
offsets.  Attach the first SVE CFA note to the move into the
associated temporary register.
(aarch64_allocate_and_probe_stack_space): Update calls accordingly.
Start out with bytes_per_sp set to the frame size and decrement
it after each allocation.

gcc/testsuite/
PR target/119610
* g++.dg/torture/pr119610.C: New test.
* g++.target/aarch64/sve/pr119610-sve.C: Likewise.

(cherry picked from commit fa61afef18a8566d1907a5ae0e7754e1eac207d9)
gcc/config/aarch64/aarch64.cc
gcc/testsuite/g++.dg/torture/pr119610.C [new file with mode: 0644]
gcc/testsuite/g++.target/aarch64/sve/pr119610-sve.C [new file with mode: 0644]