https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120840
--- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by H.J. Lu <h...@gcc.gnu.org>: https://gcc.gnu.org/g:9a602ce3f4c95648c0c48d3f26fc52f69d012505 commit r16-1771-g9a602ce3f4c95648c0c48d3f26fc52f69d012505 Author: H.J. Lu <hjl.to...@gmail.com> Date: Sat Jun 28 09:39:41 2025 +0800 x86: Preserve frame pointer for no_callee_saved_registers attribute Update functions with no_callee_saved_registers/preserve_none attribute to preserve frame pointer since caller may use it to save the current stack: pushq %rbp movq %rsp, %rbp ... call function ... leave ret If callee changes frame pointer without restoring it, caller will fail to restore its stack after callee returns as LEAVE does mov %rbp, %rsp pop %rbp The corrupted frame pointer will corrupt stack pointer in caller. There are no regressions on Linux/x86-64. Also tested with https://github.com/python/cpython configured with "./configure --with-tail-call-interp". gcc/ PR target/120840 * config/i386/i386-expand.cc (ix86_expand_call): Don't mark hard frame pointer as clobber. * config/i386/i386-options.cc (ix86_set_func_type): Use TYPE_NO_CALLEE_SAVED_REGISTERS instead of TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP. * config/i386/i386.cc (ix86_function_ok_for_sibcall): Remove the TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP check. (ix86_save_reg): Merge TYPE_NO_CALLEE_SAVED_REGISTERS and TYPE_PRESERVE_NONE with TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP. * config/i386/i386.h (call_saved_registers_type): Remove TYPE_NO_CALLEE_SAVED_REGISTERS_EXCEPT_BP. * doc/extend.texi: Update no_callee_saved_registers documentation. gcc/testsuite/ PR target/120840 * gcc.target/i386/no-callee-saved-1.c: Updated. * gcc.target/i386/no-callee-saved-2.c: Likewise. * gcc.target/i386/no-callee-saved-7.c: Likewise. * gcc.target/i386/no-callee-saved-8.c: Likewise. * gcc.target/i386/no-callee-saved-9.c: Likewise. * gcc.target/i386/no-callee-saved-10.c: Likewise. * gcc.target/i386/no-callee-saved-18.c: Likewise. * gcc.target/i386/no-callee-saved-19a.c: Likewise. * gcc.target/i386/no-callee-saved-19c.c: Likewise. * gcc.target/i386/no-callee-saved-19d.c: Likewise. * gcc.target/i386/pr119784a.c: Likewise. * gcc.target/i386/preserve-none-6.c: Likewise. * gcc.target/i386/preserve-none-7.c: Likewise. * gcc.target/i386/preserve-none-12.c: Likewise. * gcc.target/i386/preserve-none-13.c: Likewise. * gcc.target/i386/preserve-none-14.c: Likewise. * gcc.target/i386/preserve-none-15.c: Likewise. * gcc.target/i386/preserve-none-23.c: Likewise. * gcc.target/i386/pr120840-1a.c: New test. * gcc.target/i386/pr120840-1b.c: Likewise. * gcc.target/i386/pr120840-1c.c: Likewise. * gcc.target/i386/pr120840-1d.c: Likewise. Signed-off-by: H.J. Lu <hjl.to...@gmail.com>