https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119610

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:fa61afef18a8566d1907a5ae0e7754e1eac207d9

commit r16-112-gfa61afef18a8566d1907a5ae0e7754e1eac207d9
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Thu Apr 24 14:31:49 2025 +0100

    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.

Reply via email to