Message ID | mpt5xv7a66s.fsf@arm.com |
---|---|
State | New |
Headers | show |
Series | Cache the set of EH_RETURN_DATA_REGNOs | expand |
On Tue, May 21, 2024 at 11:03 AM Richard Sandiford <richard.sandiford@arm.com> wrote: > > While reviewing Andrew's fix for PR114843, it seemed like it would > be convenient to have a HARD_REG_SET of EH_RETURN_DATA_REGNOs. > This patch adds one and uses it to simplify a couple of use sites. > > Tested on aarch64-linux-gnu & x86_64-linux-gnu. OK to install? OK > Richard > > > gcc/ > * hard-reg-set.h (target_hard_regs::x_eh_return_data_regs): New field. > (eh_return_data_regs): New macro. > * reginfo.cc (init_reg_sets_1): Initialize x_eh_return_data_regs. > * df-scan.cc (df_get_exit_block_use_set): Use it. > * ira-lives.cc (process_out_of_region_eh_regs): Likewise. > --- > gcc/df-scan.cc | 8 +------- > gcc/hard-reg-set.h | 5 +++++ > gcc/ira-lives.cc | 10 ++-------- > gcc/reginfo.cc | 10 ++++++++++ > 4 files changed, 18 insertions(+), 15 deletions(-) > > diff --git a/gcc/df-scan.cc b/gcc/df-scan.cc > index 1bade2cd71e..c8ab3c09cee 100644 > --- a/gcc/df-scan.cc > +++ b/gcc/df-scan.cc > @@ -3702,13 +3702,7 @@ df_get_exit_block_use_set (bitmap exit_block_uses) > > /* Mark the registers that will contain data for the handler. */ > if (reload_completed && crtl->calls_eh_return) > - for (i = 0; ; ++i) > - { > - unsigned regno = EH_RETURN_DATA_REGNO (i); > - if (regno == INVALID_REGNUM) > - break; > - bitmap_set_bit (exit_block_uses, regno); > - } > + IOR_REG_SET_HRS (exit_block_uses, eh_return_data_regs); > > #ifdef EH_RETURN_STACKADJ_RTX > if ((!targetm.have_epilogue () || ! epilogue_completed) > diff --git a/gcc/hard-reg-set.h b/gcc/hard-reg-set.h > index 8c1d1512ca2..340eb425c10 100644 > --- a/gcc/hard-reg-set.h > +++ b/gcc/hard-reg-set.h > @@ -421,6 +421,9 @@ struct target_hard_regs { > with the local stack frame are safe, but scant others. */ > HARD_REG_SET x_regs_invalidated_by_call; > > + /* The set of registers that are used by EH_RETURN_DATA_REGNO. */ > + HARD_REG_SET x_eh_return_data_regs; > + > /* Table of register numbers in the order in which to try to use them. */ > int x_reg_alloc_order[FIRST_PSEUDO_REGISTER]; > > @@ -485,6 +488,8 @@ extern struct target_hard_regs *this_target_hard_regs; > #define call_used_or_fixed_regs \ > (regs_invalidated_by_call | fixed_reg_set) > #endif > +#define eh_return_data_regs \ > + (this_target_hard_regs->x_eh_return_data_regs) > #define reg_alloc_order \ > (this_target_hard_regs->x_reg_alloc_order) > #define inv_reg_alloc_order \ > diff --git a/gcc/ira-lives.cc b/gcc/ira-lives.cc > index e07d3dc3e89..958eabb9708 100644 > --- a/gcc/ira-lives.cc > +++ b/gcc/ira-lives.cc > @@ -1260,14 +1260,8 @@ process_out_of_region_eh_regs (basic_block bb) > for (int n = ALLOCNO_NUM_OBJECTS (a) - 1; n >= 0; n--) > { > ira_object_t obj = ALLOCNO_OBJECT (a, n); > - for (int k = 0; ; k++) > - { > - unsigned int regno = EH_RETURN_DATA_REGNO (k); > - if (regno == INVALID_REGNUM) > - break; > - SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno); > - SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), regno); > - } > + OBJECT_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs; > + OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs; > } > } > } > diff --git a/gcc/reginfo.cc b/gcc/reginfo.cc > index a0baeb90e12..73121365c47 100644 > --- a/gcc/reginfo.cc > +++ b/gcc/reginfo.cc > @@ -420,6 +420,16 @@ init_reg_sets_1 (void) > } > } > > + /* Recalculate eh_return_data_regs. */ > + CLEAR_HARD_REG_SET (eh_return_data_regs); > + for (i = 0; ; ++i) > + { > + unsigned int regno = EH_RETURN_DATA_REGNO (i); > + if (regno == INVALID_REGNUM) > + break; > + SET_HARD_REG_BIT (eh_return_data_regs, regno); > + } > + > memset (have_regs_of_mode, 0, sizeof (have_regs_of_mode)); > memset (contains_reg_of_mode, 0, sizeof (contains_reg_of_mode)); > for (m = 0; m < (unsigned int) MAX_MACHINE_MODE; m++) > -- > 2.25.1 >
diff --git a/gcc/df-scan.cc b/gcc/df-scan.cc index 1bade2cd71e..c8ab3c09cee 100644 --- a/gcc/df-scan.cc +++ b/gcc/df-scan.cc @@ -3702,13 +3702,7 @@ df_get_exit_block_use_set (bitmap exit_block_uses) /* Mark the registers that will contain data for the handler. */ if (reload_completed && crtl->calls_eh_return) - for (i = 0; ; ++i) - { - unsigned regno = EH_RETURN_DATA_REGNO (i); - if (regno == INVALID_REGNUM) - break; - bitmap_set_bit (exit_block_uses, regno); - } + IOR_REG_SET_HRS (exit_block_uses, eh_return_data_regs); #ifdef EH_RETURN_STACKADJ_RTX if ((!targetm.have_epilogue () || ! epilogue_completed) diff --git a/gcc/hard-reg-set.h b/gcc/hard-reg-set.h index 8c1d1512ca2..340eb425c10 100644 --- a/gcc/hard-reg-set.h +++ b/gcc/hard-reg-set.h @@ -421,6 +421,9 @@ struct target_hard_regs { with the local stack frame are safe, but scant others. */ HARD_REG_SET x_regs_invalidated_by_call; + /* The set of registers that are used by EH_RETURN_DATA_REGNO. */ + HARD_REG_SET x_eh_return_data_regs; + /* Table of register numbers in the order in which to try to use them. */ int x_reg_alloc_order[FIRST_PSEUDO_REGISTER]; @@ -485,6 +488,8 @@ extern struct target_hard_regs *this_target_hard_regs; #define call_used_or_fixed_regs \ (regs_invalidated_by_call | fixed_reg_set) #endif +#define eh_return_data_regs \ + (this_target_hard_regs->x_eh_return_data_regs) #define reg_alloc_order \ (this_target_hard_regs->x_reg_alloc_order) #define inv_reg_alloc_order \ diff --git a/gcc/ira-lives.cc b/gcc/ira-lives.cc index e07d3dc3e89..958eabb9708 100644 --- a/gcc/ira-lives.cc +++ b/gcc/ira-lives.cc @@ -1260,14 +1260,8 @@ process_out_of_region_eh_regs (basic_block bb) for (int n = ALLOCNO_NUM_OBJECTS (a) - 1; n >= 0; n--) { ira_object_t obj = ALLOCNO_OBJECT (a, n); - for (int k = 0; ; k++) - { - unsigned int regno = EH_RETURN_DATA_REGNO (k); - if (regno == INVALID_REGNUM) - break; - SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno); - SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), regno); - } + OBJECT_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs; + OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) |= eh_return_data_regs; } } } diff --git a/gcc/reginfo.cc b/gcc/reginfo.cc index a0baeb90e12..73121365c47 100644 --- a/gcc/reginfo.cc +++ b/gcc/reginfo.cc @@ -420,6 +420,16 @@ init_reg_sets_1 (void) } } + /* Recalculate eh_return_data_regs. */ + CLEAR_HARD_REG_SET (eh_return_data_regs); + for (i = 0; ; ++i) + { + unsigned int regno = EH_RETURN_DATA_REGNO (i); + if (regno == INVALID_REGNUM) + break; + SET_HARD_REG_BIT (eh_return_data_regs, regno); + } + memset (have_regs_of_mode, 0, sizeof (have_regs_of_mode)); memset (contains_reg_of_mode, 0, sizeof (contains_reg_of_mode)); for (m = 0; m < (unsigned int) MAX_MACHINE_MODE; m++)