This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 06/18] move reg_equivs out of gc memory
- From: tbsaunde+gcc at tbsaunde dot org
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 20 Apr 2016 02:22:10 -0400
- Subject: [PATCH 06/18] move reg_equivs out of gc memory
- Authentication-results: sourceware.org; auth=none
- References: <1461133342-10794-1-git-send-email-tbsaunde+gcc at tbsaunde dot org>
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
It used the gc vector type, but isn't marked as a gc route, and appears
to be manually managed, so it should be safe to use the normal heap
vector.
gcc/ChangeLog:
2016-04-19 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* ira-emit.c (emit_move_list): Adjust.
* ira.c (fix_reg_equiv_init): Likewise.
(update_equiv_regs): Likewise.
(ira): Likewise.
(do_reload): Likewise.
* reload.c (subst_reloads): Likewise.
* reload.h (reg_equivs): Move to the normal heap.
* reload1.c (grow_reg_equivs): Adjust.
(reload): Likewise.
(eliminate_regs_1): Likewise.
(elimination_effects): Likewise.
(init_eliminable_invariants): Likewise.
(free_reg_equiv): Likewise.
---
gcc/ira-emit.c | 4 ++--
gcc/ira.c | 11 +++++------
gcc/reload.c | 4 ++--
gcc/reload.h | 19 ++++++++-----------
gcc/reload1.c | 36 +++++++++---------------------------
5 files changed, 26 insertions(+), 48 deletions(-)
diff --git a/gcc/ira-emit.c b/gcc/ira-emit.c
index 691bd1d..3fc29f1 100644
--- a/gcc/ira-emit.c
+++ b/gcc/ira-emit.c
@@ -914,7 +914,7 @@ emit_move_list (move_t list, int freq)
machine_mode mode;
enum reg_class aclass;
- grow_reg_equivs ();
+ reg_equivs.safe_grow_cleared (max_reg_num ());
start_sequence ();
for (; list != NULL; list = list->next)
{
@@ -948,7 +948,7 @@ emit_move_list (move_t list, int freq)
|| (ira_reg_equiv[regno].invariant == NULL_RTX
&& ira_reg_equiv[regno].constant == NULL_RTX))
continue; /* regno has no equivalence. */
- ira_assert ((int) reg_equivs->length () > regno);
+ ira_assert ((int) reg_equivs.length () > regno);
reg_equiv_init (regno)
= gen_rtx_INSN_LIST (VOIDmode, insn, reg_equiv_init (regno));
}
diff --git a/gcc/ira.c b/gcc/ira.c
index 8ac153b..e3e4969 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -2685,8 +2685,8 @@ fix_reg_equiv_init (void)
if (max_regno_before_ira < max_regno)
{
- max = vec_safe_length (reg_equivs);
- grow_reg_equivs ();
+ max = reg_equivs.length ();
+ reg_equivs.safe_grow_cleared (max_reg_num ());
for (i = FIRST_PSEUDO_REGISTER; i < max; i++)
for (prev = NULL, x = reg_equiv_init (i);
x != NULL_RTX;
@@ -3350,7 +3350,7 @@ update_equiv_regs (void)
pdx_subregs = XCNEWVEC (bool, max_regno);
reg_equiv = XCNEWVEC (struct equivalence, max_regno);
- grow_reg_equivs ();
+ reg_equivs.safe_grow_cleared (max_reg_num ());
init_alias_analysis ();
@@ -5358,7 +5358,7 @@ ira (FILE *f)
overall_cost_before = ira_overall_cost;
if (! ira_conflicts_p)
- grow_reg_equivs ();
+ reg_equivs.safe_grow_cleared (max_reg_num ());
else
{
fix_reg_equiv_init ();
@@ -5425,8 +5425,7 @@ do_reload (void)
lra (ira_dump_file);
/* ???!!! Move it before lra () when we use ira_reg_equiv in
LRA. */
- vec_free (reg_equivs);
- reg_equivs = NULL;
+ reg_equivs.release ();
need_dce = false;
}
else
diff --git a/gcc/reload.c b/gcc/reload.c
index 06426d9..91d0b4d 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -6267,9 +6267,9 @@ subst_reloads (rtx_insn *insn)
for (check_regno = 0; check_regno < max_regno; check_regno++)
{
#define CHECK_MODF(ARRAY) \
- gcc_assert (!(*reg_equivs)[check_regno].ARRAY \
+ gcc_assert (!reg_equivs[check_regno].ARRAY \
|| !loc_mentioned_in_p (r->where, \
- (*reg_equivs)[check_regno].ARRAY))
+ reg_equivs[check_regno].ARRAY))
CHECK_MODF (constant);
CHECK_MODF (memory_loc);
diff --git a/gcc/reload.h b/gcc/reload.h
index 98b75e3..7bf9e6d 100644
--- a/gcc/reload.h
+++ b/gcc/reload.h
@@ -243,21 +243,21 @@ struct reg_equivs_t
};
#define reg_equiv_constant(ELT) \
- (*reg_equivs)[(ELT)].constant
+ reg_equivs[(ELT)].constant
#define reg_equiv_invariant(ELT) \
- (*reg_equivs)[(ELT)].invariant
+ reg_equivs[(ELT)].invariant
#define reg_equiv_memory_loc(ELT) \
- (*reg_equivs)[(ELT)].memory_loc
+ reg_equivs[(ELT)].memory_loc
#define reg_equiv_address(ELT) \
- (*reg_equivs)[(ELT)].address
+ reg_equivs[(ELT)].address
#define reg_equiv_mem(ELT) \
- (*reg_equivs)[(ELT)].mem
+ reg_equivs[(ELT)].mem
#define reg_equiv_alt_mem_list(ELT) \
- (*reg_equivs)[(ELT)].alt_mem_list
+ reg_equivs[(ELT)].alt_mem_list
#define reg_equiv_init(ELT) \
- (*reg_equivs)[(ELT)].init
+ reg_equivs[(ELT)].init
-extern vec<reg_equivs_t, va_gc> *reg_equivs;
+extern vec<reg_equivs_t> reg_equivs;
/* All the "earlyclobber" operands of the current insn
are recorded here. */
@@ -458,7 +458,4 @@ extern void debug_reload (void);
reloading to/from a register that is wider than a word. */
extern rtx reload_adjust_reg_for_mode (rtx, machine_mode);
-/* Allocate or grow the reg_equiv tables, initializing new entries to 0. */
-extern void grow_reg_equivs (void);
-
#endif /* GCC_RELOAD_H */
diff --git a/gcc/reload1.c b/gcc/reload1.c
index c2800f8..d0084ac 100644
--- a/gcc/reload1.c
+++ b/gcc/reload1.c
@@ -322,7 +322,7 @@ static int first_label_num;
static char *offsets_known_at;
static HOST_WIDE_INT (*offsets_at)[NUM_ELIMINABLE_REGS];
-vec<reg_equivs_t, va_gc> *reg_equivs;
+vec<reg_equivs_t> reg_equivs;
/* Stack of addresses where an rtx has been changed. We can undo the
changes by popping items off the stack and restoring the original
@@ -643,24 +643,6 @@ has_nonexceptional_receiver (void)
return false;
}
-/* Grow (or allocate) the REG_EQUIVS array from its current size (which may be
- zero elements) to MAX_REG_NUM elements.
-
- Initialize all new fields to NULL and update REG_EQUIVS_SIZE. */
-void
-grow_reg_equivs (void)
-{
- int old_size = vec_safe_length (reg_equivs);
- int max_regno = max_reg_num ();
- int i;
- reg_equivs_t ze;
-
- memset (&ze, 0, sizeof (reg_equivs_t));
- vec_safe_reserve (reg_equivs, max_regno);
- for (i = old_size; i < max_regno; i++)
- reg_equivs->quick_insert (i, ze);
-}
-
/* Global variables used by reload and its subroutines. */
@@ -818,7 +800,7 @@ reload (rtx_insn *first, int global)
Record memory equivalents in reg_mem_equiv so they can
be substituted eventually by altering the REG-rtx's. */
- grow_reg_equivs ();
+ reg_equivs.safe_grow_cleared (max_reg_num ());
reg_old_renumber = XCNEWVEC (short, max_regno);
memcpy (reg_old_renumber, reg_renumber, max_regno * sizeof (short));
pseudo_forbidden_regs = XNEWVEC (HARD_REG_SET, max_regno);
@@ -2559,7 +2541,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn,
}
else if (reg_renumber && reg_renumber[regno] < 0
- && reg_equivs
+ && !reg_equivs.is_empty ()
&& reg_equiv_invariant (regno))
{
if (may_use_invariant || (insn && DEBUG_INSN_P (insn)))
@@ -2644,7 +2626,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn,
if (GET_CODE (new0) == PLUS && REG_P (new1)
&& REGNO (new1) >= FIRST_PSEUDO_REGISTER
&& reg_renumber[REGNO (new1)] < 0
- && reg_equivs
+ && !reg_equivs.is_empty ()
&& reg_equiv_constant (REGNO (new1)) != 0)
new1 = reg_equiv_constant (REGNO (new1));
else if (GET_CODE (new1) == PLUS && REG_P (new0)
@@ -2814,7 +2796,7 @@ eliminate_regs_1 (rtx x, machine_mode mem_mode, rtx insn,
may do the replacement in certain circumstances. */
if (REG_P (SUBREG_REG (x))
&& !paradoxical_subreg_p (x)
- && reg_equivs
+ && !reg_equivs.is_empty ()
&& reg_equiv_memory_loc (REGNO (SUBREG_REG (x))) != 0)
{
new_rtx = SUBREG_REG (x);
@@ -2983,7 +2965,7 @@ elimination_effects (rtx x, machine_mode mem_mode)
}
else if (reg_renumber[regno] < 0
- && reg_equivs
+ && !reg_equivs.is_empty ()
&& reg_equiv_constant (regno)
&& ! function_invariant_p (reg_equiv_constant (regno)))
elimination_effects (reg_equiv_constant (regno), mem_mode);
@@ -3054,7 +3036,7 @@ elimination_effects (rtx x, machine_mode mem_mode)
if (REG_P (SUBREG_REG (x))
&& (GET_MODE_SIZE (GET_MODE (x))
<= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))))
- && reg_equivs
+ && !reg_equivs.is_empty ()
&& reg_equiv_memory_loc (REGNO (SUBREG_REG (x))) != 0)
return;
@@ -4117,7 +4099,7 @@ init_eliminable_invariants (rtx_insn *first, bool do_subregs)
int i;
rtx_insn *insn;
- grow_reg_equivs ();
+ reg_equivs.safe_grow_cleared (max_reg_num ());
if (do_subregs)
reg_max_ref_width = XCNEWVEC (unsigned int, max_regno);
else
@@ -4244,7 +4226,7 @@ free_reg_equiv (void)
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (reg_equiv_alt_mem_list (i))
free_EXPR_LIST_list (®_equiv_alt_mem_list (i));
- vec_free (reg_equivs);
+ reg_equivs.release ();
}
/* Kick all pseudos out of hard register REGNO.
--
2.7.4