* Remove global REG_SETs
@ 2019-09-09 16:37 Richard Sandiford
2019-09-09 17:48 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2019-09-09 16:37 UTC (permalink / raw)
To: gcc-patches
[Follows on from https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00571.html]
We currently maintain global REG_SET versions of fixed_reg_set
and regs_invalidated_by_call. With bitmap_view, we can instead
operate directly on the underlying HARD_REG_SETs, avoiding the
need to keep the two pieces of data in sync.
I have a series of patches that removes the assumption that there's
a single global ABI for all functions in the translation unit,
which includes not relying on having a global regs_invalidated_by_call.
Removing the REG_SET equivalent is one step to doing that.
Note that the affected DF code is used for EH edges or dumping only,
so shouldn't be performance critical.
Tested on aarch64-linux-gnu and x86_64-linux-gnu. Also tested on an
sh-linux-gnu cross and comparing the assembly output for gcc.c-torture,
gcc.dg and g++.dg. OK to install?
Richard
2019-09-09 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* regset.h (regs_invalidated_by_call_regset): Delete.
(fixed_reg_set_regset): Likewise.
* reginfo.c (regs_invalidated_by_call_regset): Likewise.
(fixed_reg_set_regset, persistent_obstack): Likewise.
(init_reg_sets_1, globalize_reg): Update accordingly.
* df.h (df_print_regset, df_print_word_regset): Take a const_bitmap
instead of a bitmap.
* df-core.c (df_print_regset, df_print_word_regset): Likewise.
* df-problems.c (df_rd_local_compute): Use regs_invalidated_by_call
instead of regs_invalidated_by_call_regset.
(df_lr_confluence_n, df_md_confluence_n): Likewise.
* df-scan.c (df_scan_start_dump): Likewise.
* dse.c (copy_fixed_regs): Likewise.
* config/sh/sh.c (sh_find_equiv_gbr_addr): Likewise.
Index: gcc/regset.h
===================================================================
--- gcc/regset.h 2019-09-09 17:23:00.740796731 +0100
+++ gcc/regset.h 2019-09-09 17:34:18.064026324 +0100
@@ -111,14 +111,6 @@ #define EXECUTE_IF_AND_COMPL_IN_REG_SET(
#define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI) \
-/* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used
- in dataflow more conveniently. */
-
-extern regset regs_invalidated_by_call_regset;
-
-/* Same information as FIXED_REG_SET but in regset form. */
-extern regset fixed_reg_set_regset;
-
/* An obstack for regsets. */
extern bitmap_obstack reg_obstack;
Index: gcc/reginfo.c
===================================================================
--- gcc/reginfo.c 2019-09-09 17:02:41.477377259 +0100
+++ gcc/reginfo.c 2019-09-09 17:34:18.064026324 +0100
@@ -92,17 +92,6 @@ #define CALL_REALLY_USED_REGNO_P(X) cal
/* Declaration for the global register. */
tree global_regs_decl[FIRST_PSEUDO_REGISTER];
-/* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used
- in dataflow more conveniently. */
-regset regs_invalidated_by_call_regset;
-
-/* Same information as FIXED_REG_SET but in regset form. */
-regset fixed_reg_set_regset;
-
-/* The bitmap_obstack is used to hold some static variables that
- should not be reset after each function is compiled. */
-static bitmap_obstack persistent_obstack;
-
/* Used to initialize reg_alloc_order. */
#ifdef REG_ALLOC_ORDER
static int initial_reg_alloc_order[FIRST_PSEUDO_REGISTER] = REG_ALLOC_ORDER;
@@ -364,17 +353,6 @@ init_reg_sets_1 (void)
CLEAR_HARD_REG_SET (call_used_reg_set);
CLEAR_HARD_REG_SET (call_fixed_reg_set);
CLEAR_HARD_REG_SET (regs_invalidated_by_call);
- if (!regs_invalidated_by_call_regset)
- {
- bitmap_obstack_initialize (&persistent_obstack);
- regs_invalidated_by_call_regset = ALLOC_REG_SET (&persistent_obstack);
- }
- else
- CLEAR_REG_SET (regs_invalidated_by_call_regset);
- if (!fixed_reg_set_regset)
- fixed_reg_set_regset = ALLOC_REG_SET (&persistent_obstack);
- else
- CLEAR_REG_SET (fixed_reg_set_regset);
operand_reg_set &= accessible_reg_set;
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
@@ -405,10 +383,7 @@ init_reg_sets_1 (void)
#endif
if (fixed_regs[i])
- {
- SET_HARD_REG_BIT (fixed_reg_set, i);
- SET_REGNO_REG_SET (fixed_reg_set_regset, i);
- }
+ SET_HARD_REG_BIT (fixed_reg_set, i);
if (call_used_regs[i])
SET_HARD_REG_BIT (call_used_reg_set, i);
@@ -426,10 +401,7 @@ init_reg_sets_1 (void)
if (i == STACK_POINTER_REGNUM)
;
else if (global_regs[i])
- {
- SET_HARD_REG_BIT (regs_invalidated_by_call, i);
- SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i);
- }
+ SET_HARD_REG_BIT (regs_invalidated_by_call, i);
else if (i == FRAME_POINTER_REGNUM)
;
else if (!HARD_FRAME_POINTER_IS_FRAME_POINTER
@@ -442,10 +414,7 @@ init_reg_sets_1 (void)
&& i == (unsigned) PIC_OFFSET_TABLE_REGNUM && fixed_regs[i])
;
else if (CALL_REALLY_USED_REGNO_P (i))
- {
- SET_HARD_REG_BIT (regs_invalidated_by_call, i);
- SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i);
- }
+ SET_HARD_REG_BIT (regs_invalidated_by_call, i);
}
call_fixed_reg_set = fixed_reg_set;
@@ -800,10 +769,7 @@ globalize_reg (tree decl, int i)
appropriate regs_invalidated_by_call bit, even if it's already
set in fixed_regs. */
if (i != STACK_POINTER_REGNUM)
- {
- SET_HARD_REG_BIT (regs_invalidated_by_call, i);
- SET_REGNO_REG_SET (regs_invalidated_by_call_regset, i);
- }
+ SET_HARD_REG_BIT (regs_invalidated_by_call, i);
/* If already fixed, nothing else to do. */
if (fixed_regs[i])
Index: gcc/df.h
===================================================================
--- gcc/df.h 2019-07-10 19:41:26.363898284 +0100
+++ gcc/df.h 2019-09-09 17:34:18.064026324 +0100
@@ -991,8 +991,8 @@ extern bool df_reg_defined (rtx_insn *,
extern df_ref df_find_use (rtx_insn *, rtx);
extern bool df_reg_used (rtx_insn *, rtx);
extern void df_worklist_dataflow (struct dataflow *,bitmap, int *, int);
-extern void df_print_regset (FILE *file, bitmap r);
-extern void df_print_word_regset (FILE *file, bitmap r);
+extern void df_print_regset (FILE *file, const_bitmap r);
+extern void df_print_word_regset (FILE *file, const_bitmap r);
extern void df_dump (FILE *);
extern void df_dump_region (FILE *);
extern void df_dump_start (FILE *);
Index: gcc/df-core.c
===================================================================
--- gcc/df-core.c 2019-07-12 11:33:27.712037291 +0100
+++ gcc/df-core.c 2019-09-09 17:34:18.060026352 +0100
@@ -2052,7 +2052,7 @@ debug_regset (regset r)
This is part of making a debugging dump. */
void
-df_print_regset (FILE *file, bitmap r)
+df_print_regset (FILE *file, const_bitmap r)
{
unsigned int i;
bitmap_iterator bi;
@@ -2077,7 +2077,7 @@ df_print_regset (FILE *file, bitmap r)
debugging dump. */
void
-df_print_word_regset (FILE *file, bitmap r)
+df_print_word_regset (FILE *file, const_bitmap r)
{
unsigned int max_reg = max_reg_num ();
Index: gcc/df-problems.c
===================================================================
--- gcc/df-problems.c 2019-09-09 16:53:26.701274338 +0100
+++ gcc/df-problems.c 2019-09-09 17:34:18.064026324 +0100
@@ -389,7 +389,6 @@ df_rd_local_compute (bitmap all_blocks)
{
unsigned int bb_index;
bitmap_iterator bi;
- unsigned int regno;
class df_rd_problem_data *problem_data
= (class df_rd_problem_data *) df_rd->problem_data;
bitmap sparse_invalidated = &problem_data->sparse_invalidated_by_call;
@@ -406,10 +405,9 @@ df_rd_local_compute (bitmap all_blocks)
}
/* Set up the knockout bit vectors to be applied across EH_EDGES. */
- EXECUTE_IF_SET_IN_BITMAP (regs_invalidated_by_call_regset, 0, regno, bi)
- {
- if (! HARD_REGISTER_NUM_P (regno)
- || !(df->changeable_flags & DF_NO_HARD_REGS))
+ if (!(df->changeable_flags & DF_NO_HARD_REGS))
+ for (unsigned int regno = 0; regno < FIRST_PSEUDO_REGISTER; ++regno)
+ if (TEST_HARD_REG_BIT (regs_invalidated_by_call, regno))
{
if (DF_DEFS_COUNT (regno) > DF_SPARSE_THRESHOLD)
bitmap_set_bit (sparse_invalidated, regno);
@@ -418,7 +416,6 @@ df_rd_local_compute (bitmap all_blocks)
DF_DEFS_BEGIN (regno),
DF_DEFS_COUNT (regno));
}
- }
bitmap_release (&seen_in_block);
bitmap_release (&seen_in_insn);
@@ -983,7 +980,10 @@ df_lr_confluence_n (edge e)
/* ??? Abnormal call edges ignored for the moment, as this gets
confused by sibling call edges, which crashes reg-stack. */
if (e->flags & EDGE_EH)
- changed = bitmap_ior_and_compl_into (op1, op2, regs_invalidated_by_call_regset);
+ {
+ bitmap_view<HARD_REG_SET> eh_kills (regs_invalidated_by_call);
+ changed = bitmap_ior_and_compl_into (op1, op2, eh_kills);
+ }
else
changed = bitmap_ior_into (op1, op2);
@@ -4635,8 +4635,10 @@ df_md_confluence_n (edge e)
return false;
if (e->flags & EDGE_EH)
- return bitmap_ior_and_compl_into (op1, op2,
- regs_invalidated_by_call_regset);
+ {
+ bitmap_view<HARD_REG_SET> eh_kills (regs_invalidated_by_call);
+ return bitmap_ior_and_compl_into (op1, op2, eh_kills);
+ }
else
return bitmap_ior_into (op1, op2);
}
Index: gcc/df-scan.c
===================================================================
--- gcc/df-scan.c 2019-07-10 19:41:21.635936149 +0100
+++ gcc/df-scan.c 2019-09-09 17:34:18.064026324 +0100
@@ -313,7 +313,7 @@ df_scan_start_dump (FILE *file ATTRIBUTE
rtx_insn *insn;
fprintf (file, ";; invalidated by call \t");
- df_print_regset (file, regs_invalidated_by_call_regset);
+ df_print_regset (file, bitmap_view<HARD_REG_SET> (regs_invalidated_by_call));
fprintf (file, ";; hardware regs used \t");
df_print_regset (file, &df->hardware_regs_used);
fprintf (file, ";; regular block artificial uses \t");
Index: gcc/dse.c
===================================================================
--- gcc/dse.c 2019-09-09 16:53:26.701274338 +0100
+++ gcc/dse.c 2019-09-09 17:34:18.064026324 +0100
@@ -2392,7 +2392,7 @@ copy_fixed_regs (const_bitmap in)
bitmap ret;
ret = ALLOC_REG_SET (NULL);
- bitmap_and (ret, in, fixed_reg_set_regset);
+ bitmap_and (ret, in, bitmap_view<HARD_REG_SET> (fixed_reg_set));
return ret;
}
Index: gcc/config/sh/sh.c
===================================================================
--- gcc/config/sh/sh.c 2019-09-09 17:02:41.549376753 +0100
+++ gcc/config/sh/sh.c 2019-09-09 17:34:18.060026352 +0100
@@ -11695,7 +11695,7 @@ sh_find_equiv_gbr_addr (rtx_insn* insn,
{
if (CALL_P (DF_REF_INSN (d)))
{
- if (REGNO_REG_SET_P (regs_invalidated_by_call_regset, GBR_REG))
+ if (TEST_HARD_REG_BIT (regs_invalidated_by_call, GBR_REG))
return NULL_RTX;
else
continue;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Remove global REG_SETs
2019-09-09 16:37 Remove global REG_SETs Richard Sandiford
@ 2019-09-09 17:48 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2019-09-09 17:48 UTC (permalink / raw)
To: gcc-patches, richard.sandiford
On 9/9/19 10:37 AM, Richard Sandiford wrote:
> [Follows on from https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00571.html]
>
> We currently maintain global REG_SET versions of fixed_reg_set
> and regs_invalidated_by_call. With bitmap_view, we can instead
> operate directly on the underlying HARD_REG_SETs, avoiding the
> need to keep the two pieces of data in sync.
>
> I have a series of patches that removes the assumption that there's
> a single global ABI for all functions in the translation unit,
> which includes not relying on having a global regs_invalidated_by_call.
> Removing the REG_SET equivalent is one step to doing that.
>
> Note that the affected DF code is used for EH edges or dumping only,
> so shouldn't be performance critical.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu. Also tested on an
> sh-linux-gnu cross and comparing the assembly output for gcc.c-torture,
> gcc.dg and g++.dg. OK to install?
>
> Richard
>
>
> 2019-09-09 Richard Sandiford <richard.sandiford@arm.com>
>
> gcc/
> * regset.h (regs_invalidated_by_call_regset): Delete.
> (fixed_reg_set_regset): Likewise.
> * reginfo.c (regs_invalidated_by_call_regset): Likewise.
> (fixed_reg_set_regset, persistent_obstack): Likewise.
> (init_reg_sets_1, globalize_reg): Update accordingly.
> * df.h (df_print_regset, df_print_word_regset): Take a const_bitmap
> instead of a bitmap.
> * df-core.c (df_print_regset, df_print_word_regset): Likewise.
> * df-problems.c (df_rd_local_compute): Use regs_invalidated_by_call
> instead of regs_invalidated_by_call_regset.
> (df_lr_confluence_n, df_md_confluence_n): Likewise.
> * df-scan.c (df_scan_start_dump): Likewise.
> * dse.c (copy_fixed_regs): Likewise.
> * config/sh/sh.c (sh_find_equiv_gbr_addr): Likewise.
>
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-09 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-09 16:37 Remove global REG_SETs Richard Sandiford
2019-09-09 17:48 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).