From: Richard Sandiford <[email protected]>
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.
---
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 6d229be9205..f5caef29c6e 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -91,6 +91,7 @@ along with GCC; see the file COPYING3. If not see
#include "debug.h"
#include "dwarf2out.h"
#include "cfgcleanup.h"
+#include "function-abi.h"
#include "i386-builtins.h"
#include "i386-features.h"
#include "i386-expand.h"
@@ -4328,7 +4329,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 4c8b7840fc3..4cbbb42ae39 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -6883,7 +6883,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));
}
@@ -23549,13 +23550,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. */
@@ -24017,7 +24018,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;
--
2.54.0