On Tue, May 12, 2026 at 2:42 AM H.J. Lu <[email protected]> wrote:
>
> DRAP register is used to restore stack pointer in epilogue for stack
> realignment.  In no-callee-saved and preserve_none functions, although
> DRAP register isn't preserved, it must be unchanged between prologue
> and epilogue so that stack pointer can be restored.  In no-callee-saved
> and preserve_none functions, mark BX_REG as fixed and use it for DRAP
> register.
>
> NB: r12-r15 aren't made available as the local general purpose registers
> since it causes:
>
> FAIL: gcc.target/i386/preserve-none-1.c scan-assembler-not movq
> FAIL: gcc.target/i386/preserve-none-30a.c check-function-bodies entry
> FAIL: gcc.target/i386/preserve-none-30b.c check-function-bodies entry
>
> which have the same cause as
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124798
>
> gcc/
>
> PR target/120870
> * config/i386/i386.cc (X86_NO_CALLEE_DRAP_REG): New.
> (ix86_conditional_register_usage): Mark X86_NO_CALLEE_DRAP_REG
> as fixed.
> (find_drap_reg): Return X86_PRESERVE_NONE_DRAP_REG for
> no-callee-saved and preserve_none functions
>
> gcc/testsuite/
>
> PR target/120870
> * gcc.target/i386/pr120870-1.c: New test.
> * gcc.target/i386/pr120870-2.c: Likewise.

+      case TYPE_NO_CALLEE_SAVED_REGISTERS:
+      case TYPE_PRESERVE_NONE:
+      /* DRAP register is used to restore stack pointer in epilogue
+         for stack realignment.  Although DRAP register isn't
+         preserved, it must be unchanged between prologue and
+         epilogue so that stack pointer can be restored.  In
+         no-callee-saved and preserve_none function, mark BX_REG
+         as fixed and use it for DRAP register.  */
+      fixed_regs[X86_NO_CALLEE_DRAP_REG] = 1;

Isn't this hammer too big? This will remove RBX even when DRAP is not
needed, which I assume is in the majority of cases.

Uros.

Reply via email to