diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-09-30 16:20:52 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-09-30 16:20:52 +0000 |
commit | 6c47622219d6386807b26890dcdc84f192499d33 (patch) | |
tree | 9ea524a6474c5ed4540c9d867042bd4df6f45c85 /gcc/function-abi.cc | |
parent | 7450506b5d48642a71459cfc24efcea6ca58e97e (diff) | |
download | gcc-6c47622219d6386807b26890dcdc84f192499d33.zip gcc-6c47622219d6386807b26890dcdc84f192499d33.tar.gz gcc-6c47622219d6386807b26890dcdc84f192499d33.tar.bz2 |
Remove global call sets: IRA
For -fipa-ra, IRA already keeps track of which specific registers
are call-clobbered in a region, rather than using global information.
The patch generalises this so that it tracks which ABIs are used
by calls in the region.
We can then use the new ABI descriptors to handle partially-clobbered
registers in the same way as fully-clobbered registers, without having
special code for targetm.hard_regno_call_part_clobbered. This in turn
makes -fipa-ra work for partially-clobbered registers too.
A side-effect of allowing multiple ABIs is that we no longer have
an obvious set of conflicting registers for the self-described
"fragile hack" in ira-constraints.c. This code kicks in for
user-defined registers that aren't live across a call at -O0,
and it tries to avoid allocating a call-clobbered register to them.
Here I've used the set of call-clobbered registers in the current
function's ABI, applying on top of any registers that are clobbered by
called functions. This is enough to keep gcc.dg/debug/dwarf2/pr5948.c
happy.
The handling of GENERIC_STACK_CHECK in do_reload seemed to have
a reversed condition:
for (int i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (df_regs_ever_live_p (i)
&& !fixed_regs[i]
&& call_used_or_fixed_reg_p (i))
size += UNITS_PER_WORD;
The final part of the condition counts registers that don't need to be
saved in the prologue, but I think the opposite was intended.
2019-09-30 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* function-abi.h (call_clobbers_in_region): Declare.
(call_clobbered_in_region_p): New function.
* function-abi.cc (call_clobbers_in_region): Likewise.
* ira-int.h: Include function-abi.h.
(ira_allocno::crossed_calls_abis): New field.
(ALLOCNO_CROSSED_CALLS_ABIS): New macro.
(ira_need_caller_save_regs): New function.
(ira_need_caller_save_p): Likewise.
* ira.c (setup_reg_renumber): Use ira_need_caller_save_p instead
of call_used_or_fixed_regs.
(do_reload): Use crtl->abi to test whether the current function
needs to save a register in the prologue. Count registers that
need to be saved rather than registers that don't.
* ira-build.c (create_cap_allocno): Copy ALLOCNO_CROSSED_CALLS_ABIS.
Remove unnecessary | from ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS.
(propagate_allocno_info): Merge ALLOCNO_CROSSED_CALLS_ABIS too.
(propagate_some_info_from_allocno): Likewise.
(copy_info_to_removed_store_destinations): Likewise.
(ira_flattening): Say that ALLOCNO_CROSSED_CALLS_ABIS and
ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS are handled conservatively.
(ira_build): Use ira_need_caller_save_regs instead of
call_used_or_fixed_regs.
* ira-color.c (calculate_saved_nregs): Use crtl->abi to test
whether the current function would need to save a register
before using it.
(calculate_spill_cost): Likewise.
(allocno_reload_assign): Use ira_need_caller_save_regs and
ira_need_caller_save_p instead of call_used_or_fixed_regs.
* ira-conflicts.c (ira_build_conflicts): Use
ira_need_caller_save_regs rather than call_used_or_fixed_regs
as the set of call-clobbered registers. Remove the
call_used_or_fixed_regs mask from the calculation of
temp_hard_reg_set and mask its use instead. Remove special
handling of partially-clobbered registers.
* ira-costs.c (ira_tune_allocno_costs): Use ira_need_caller_save_p.
* ira-lives.c (process_bb_node_lives): Use mode_clobbers to
calculate the set of conflicting registers for calls that
can throw. Record the ABIs of calls in ALLOCNO_CROSSED_CALLS_ABIS.
Use full_and_partial_reg_clobbers rather than full_reg_clobbers
for the calculation of ALLOCNO_CROSSED_CALLS_CLOBBERED_REGS.
Use eh_edge_abi to calculate the set of registers that could
be clobbered by an EH edge. Include partially-clobbered as
well as fully-clobbered registers.
From-SVN: r276325
Diffstat (limited to 'gcc/function-abi.cc')
-rw-r--r-- | gcc/function-abi.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/function-abi.cc b/gcc/function-abi.cc index 1d1ac9a..4bace9e 100644 --- a/gcc/function-abi.cc +++ b/gcc/function-abi.cc @@ -126,6 +126,31 @@ predefined_function_abi::add_full_reg_clobber (unsigned int regno) SET_HARD_REG_BIT (m_mode_clobbers[i], regno); } +/* Return the set of registers that cannot be used to hold a value of + mode MODE across the calls in a region described by ABIS and MASK, where: + + * Bit ID of ABIS is set if the region contains a call with + function_abi identifier ID. + + * MASK contains all the registers that are fully or partially + clobbered by calls in the region. + + This is not quite as accurate as testing each individual call, + but it's a close and conservatively-correct approximation. + It's much better for some targets than just using MASK. */ + +HARD_REG_SET +call_clobbers_in_region (unsigned int abis, const_hard_reg_set mask, + machine_mode mode) +{ + HARD_REG_SET result; + CLEAR_HARD_REG_SET (result); + for (unsigned int id = 0; abis; abis >>= 1, ++id) + if (abis & 1) + result |= function_abis[id].mode_clobbers (mode); + return result & mask; +} + /* Return the predefined ABI used by functions with type TYPE. */ const predefined_function_abi & |