https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119784
Bug ID: 119784 Summary: -mapxf saves registers beyond red zone Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com CC: liuhongt at gcc dot gnu.org Target Milestone: --- Target: x86-64 [hjl@gnu-tgl-3 pr119628]$ cat x1.c #define DONT_SAVE_REGS __attribute__((no_callee_saved_registers)) #define SAVE_REGS __attribute__((no_caller_saved_registers)) typedef DONT_SAVE_REGS void (*op_t)(void *next); extern op_t code[]; SAVE_REGS void start() { void *next = code; code[0](code + 1); } [hjl@gnu-tgl-3 pr119628]$ /usr/gcc-14.2.1-x32/bin/gcc -O2 -mtune-ctrl=prologue_using_move,epilogue_using_move -S x1.c -mapxf -mgeneral-regs-only [hjl@gnu-tgl-3 pr119628]$ cat x1.s .file "x1.c" .text .p2align 4 .globl start .type start, @function start: .LFB0: .cfi_startproc movq %rax, -248(%rsp) <<< Red zone is only 128 bytes. movq %rcx, -232(%rsp) movq %rbx, -224(%rsp) movq %rsi, -216(%rsp) movq %rdi, -208(%rsp) .cfi_offset 0, -256 .cfi_offset 1, -248 .cfi_offset 2, -240 .cfi_offset 3, -232 .cfi_offset 4, -224 .cfi_offset 5, -216 movl $code+8, %edi movq %rbp, -200(%rsp) movq %r8, -192(%rsp) movq %r9, -184(%rsp) movq %r10, -176(%rsp) movq %r11, -168(%rsp) movq %r12, -160(%rsp) movq %r13, -152(%rsp) movq %r14, -144(%rsp) movq %r15, -136(%rsp) movq %r16, -128(%rsp) movq %r17, -120(%rsp) movq %r18, -112(%rsp) movq %r19, -104(%rsp) movq %r20, -96(%rsp) movq %r21, -88(%rsp) movq %r22, -80(%rsp) movq %r23, -72(%rsp) movq %r24, -64(%rsp) movq %r25, -56(%rsp) movq %r26, -48(%rsp) movq %r27, -40(%rsp) movq %r28, -32(%rsp) movq %r29, -24(%rsp) movq %r30, -16(%rsp) movq %r31, -8(%rsp) subq $248, %rsp .cfi_def_cfa_offset 256 .cfi_offset 6, -208 .cfi_offset 8, -200 .cfi_offset 9, -192 .cfi_offset 10, -184 .cfi_offset 11, -176 .cfi_offset 12, -168 .cfi_offset 13, -160 .cfi_offset 14, -152 .cfi_offset 15, -144 .cfi_offset 130, -136 .cfi_offset 131, -128 .cfi_offset 132, -120 .cfi_offset 133, -112 .cfi_offset 134, -104 .cfi_offset 135, -96 .cfi_offset 136, -88 .cfi_offset 137, -80 .cfi_offset 138, -72 .cfi_offset 139, -64 .cfi_offset 140, -56 .cfi_offset 141, -48 .cfi_offset 142, -40 .cfi_offset 143, -32 .cfi_offset 144, -24 .cfi_offset 145, -16 call *code(%rip) movq (%rsp), %rax movq 8(%rsp), %rdx movq 16(%rsp), %rcx movq 24(%rsp), %rbx movq 32(%rsp), %rsi movq 40(%rsp), %rdi movq 48(%rsp), %rbp movq 56(%rsp), %r8 movq 64(%rsp), %r9 movq 72(%rsp), %r10 movq 80(%rsp), %r11 movq 88(%rsp), %r12 movq 96(%rsp), %r13 movq 104(%rsp), %r14 movq 112(%rsp), %r15 movq 120(%rsp), %r16 movq 128(%rsp), %r17 movq 136(%rsp), %r18 movq 144(%rsp), %r19 movq 152(%rsp), %r20 movq 160(%rsp), %r21 movq 168(%rsp), %r22 movq 176(%rsp), %r23 movq 184(%rsp), %r24 movq 192(%rsp), %r25 movq 200(%rsp), %r26 movq 208(%rsp), %r27 movq 216(%rsp), %r28 movq 224(%rsp), %r29 movq 232(%rsp), %r30 movq 240(%rsp), %r31 addq $248, %rsp .cfi_restore 15 .cfi_restore 14 .cfi_restore 13 .cfi_restore 12 .cfi_restore 11 .cfi_restore 10 .cfi_restore 9 .cfi_restore 8 .cfi_restore 6 .cfi_restore 5 .cfi_restore 4 .cfi_restore 3 .cfi_restore 2 .cfi_restore 1 .cfi_restore 0 .cfi_def_cfa_offset 8 ret .cfi_endproc .LFE0: .size start, .-start .ident "GCC: (GNU) 14.2.1 20240906 [releases/gcc-14 r14-10649-gaedf6f810ee]" .section .note.GNU-stack,"",@progbits [hjl@gnu-tgl-3 pr119628]$