https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128270
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Uros Bizjak <[email protected]>: https://gcc.gnu.org/g:b7e3114e8174f4076e6a0b136d2b65c76a301941 commit r17-5753-gb7e3114e8174f4076e6a0b136d2b65c76a301941 Author: Uros Bizjak <[email protected]> Date: Fri Oct 30 08:29:04 2026 +0100 i386: Emit REG_CFA_RESTORE in DRAP frames even in the red zone [PR128270] In a DRAP-realigned frame, the caller's frame pointer is described by a DW_CFA_expression rule relative to the frame pointer itself (Rule 18 in dwarf2out_frame_debug_expr). Registers saved by moves are described the same way, see ix86_emit_save_reg_using_mov. Once %rbp is restored by "leave" or "pop %rbp", these rules are stale and point at the wrong address. Unwinders and gdb then read garbage: the backtrace is truncated when stopping between "leave" and "ret", and the recovered values of the mov-saved registers are wrong. ix86_add_cfa_restore_note skips the note when the saved slot is within the red zone, on the assumption that unwinders can find the same value in the register and on the stack. That holds for CFA-relative DW_CFA_offset rules, but not for the frame-pointer-relative expression rules used in DRAP frames. Don't take the shortcut when stack_realign_drap. Assisted-by: Claude Sonnet 5.5 PR target/128270 gcc/ChangeLog: * config/i386/i386.cc (ix86_add_cfa_restore_note): Do not skip the note when stack_realign_drap. gcc/testsuite/ChangeLog: * gcc.target/i386/pr128270-1.c: New test. * gcc.target/i386/pr128270-2.c: Ditto. * gcc.target/i386/pr128270-3.c: Ditto. * gcc.target/i386/pr128270-4.c: Ditto.
