]> git.ipfire.org Git - thirdparty/gcc.git/commit
aarch64: Fix CFA offsets in non-initial stack probes [PR119610]
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 8 May 2025 11:06:41 +0000 (12:06 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 8 May 2025 11:06:41 +0000 (12:06 +0100)
commita9d390ab17d9395ce20e899ef0180052ed79d332
tree14c955fe5def0959850a4e2cd36f14313db8678e
parentcdf689a1f12e887c22c9989e6728ffac981f71ce
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]