https://gcc.gnu.org/g:16355119ad3c7e209e1e5bdac5849355205ad3fb

commit r17-2207-g16355119ad3c7e209e1e5bdac5849355205ad3fb
Author: Richard Sandiford <[email protected]>
Date:   Thu May 14 22:43:40 2026 +0100

    i386: Avoid reading call_used_regs
    
    call_used_regs is a legacy interface that targets use to tell
    init_reg_sets_1 about the default (system) ABI.  In x86 terms,
    that means the ABI associated with ix86_abi.
    
    Targets can continue to read call_used_regs directly if they
    don't have multiple ABIs.  But now that x86 does, it's better
    to be explicit about which ABI is being queried.  This is
    currently a nop but becomes important with the upcoming
    function_abi patch.
    
    As the comment in ix86_emit_tls_call says:
    
          /* TLS_GD and TLS_LD_BASE instructions are normal functions which
             clobber caller-saved registers. [...]
    
    So that function really is querying the system ABI.
    
    Similarly, x86_order_regs_for_local_alloc is called when initialising
    a target, rather than once per function, so it too should query the
    system ABI.
    
    ix86_save_reg and x86_64_select_profile_regnum ask about the
    current function's ABI, which is crtl->abi.
    
    gcc/
            * config/i386/i386-features.cc: Include function-abi.h.
            (ix86_emit_tls_call): Use default_function_abi instead of
            call_used_regs.
            * config/i386/i386.cc (x86_order_regs_for_local_alloc): Likewise.
            (ix86_save_reg, x86_64_select_profile_regnum): Use crtl->abi
            instead of call_used_regs.

Diff:
---
 gcc/config/i386/i386-features.cc |  3 ++-
 gcc/config/i386/i386.cc          | 13 +++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index e0fc13efe86e..c6c3c906c8db 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -90,6 +90,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-vector-builder.h"
 #include "debug.h"
 #include "dwarf2out.h"
+#include "function-abi.h"
 #include "i386-builtins.h"
 #include "i386-features.h"
 #include "i386-expand.h"
@@ -4349,7 +4350,7 @@ ix86_emit_tls_call (rtx tls_set, x86_cse_kind kind, 
basic_block bb,
         instructions.  */
       if (kind != X86_CSE_TLSDESC)
        for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-         if (call_used_regs[i]
+         if (default_function_abi.clobbers_full_reg_p (i)
              && !fixed_regs[i]
              && bitmap_bit_p (in, i))
            bitmap_set_bit (live_caller_saved_regs, i);
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 2e5a225574b9..c22d059e8ca5 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -6870,7 +6870,8 @@ ix86_save_reg (unsigned int regno, bool maybe_eh_return, 
bool ignore_outlined)
     }
 
   return (df_regs_ever_live_p (regno)
-         && !call_used_or_fixed_reg_p (regno)
+         && !fixed_regs[regno]
+         && !crtl->abi->clobbers_full_reg_p (regno)
          && (regno != HARD_FRAME_POINTER_REGNUM || !frame_pointer_needed));
 }
 
@@ -23524,13 +23525,13 @@ x86_order_regs_for_local_alloc (void)
 
    /* First allocate the local general purpose registers.  */
    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-     if (GENERAL_REGNO_P (i) && call_used_or_fixed_reg_p (i))
-       reg_alloc_order [pos++] = i;
+     if (GENERAL_REGNO_P (i) && default_function_abi.clobbers_full_reg_p (i))
+       reg_alloc_order [pos++] = i;
 
    /* Global general purpose registers.  */
    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
-     if (GENERAL_REGNO_P (i) && !call_used_or_fixed_reg_p (i))
-       reg_alloc_order [pos++] = i;
+     if (GENERAL_REGNO_P (i) && !default_function_abi.clobbers_full_reg_p (i))
+       reg_alloc_order [pos++] = i;
 
    /* x87 registers come first in case we are doing FP math
       using them.  */
@@ -23992,7 +23993,7 @@ x86_64_select_profile_regnum (bool r11_ok 
ATTRIBUTE_UNUSED)
 #endif
        && TEST_HARD_REG_BIT (accessible_reg_set, i)
        && (ix86_save_reg (i, true, true)
-           || (call_used_regs[i]
+           || (crtl->abi->clobbers_full_reg_p (i)
                && !fixed_regs[i]
                && !REGNO_REG_SET_P (reg_live, i))))
       return i;

Reply via email to