move several bitmaps from gc memory to the default obstack and use auto_bitmap

These places where probably trying to use the default bitmap obstack,
but passing 0 to bitmap_initialize actually uses gc allocation.  In any
case they are all cleaned up before going out of scope so using
auto_bitmap should be fine.

gcc/ChangeLog:

2017-05-13  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* haifa-sched.c (estimate_shadow_tick): Replace manual bitmap
	management with auto_bitmap.
	(fix_inter_tick): Likewise.
	(fix_recovery_deps): Likewise.
	* ira.c (add_store_equivs): Likewise.
	(find_moveable_pseudos): Likewise.
	(split_live_ranges_for_shrink_wrap): Likewise.
	* print-rtl.c (rtx_reuse_manager::rtx_reuse_manager): Likewise.
	(rtx_reuse_manager::seen_def_p): Likewise.
	(rtx_reuse_manager::set_seen_def): Likewise.
	* print-rtl.h (class rtx_reuse_manager): Likewise.

From-SVN: r248022
This commit is contained in:
Trevor Saunders 2017-05-14 00:38:53 +00:00 committed by Trevor Saunders
parent 0e3de1d41e
commit 8f9b31f7f1
5 changed files with 52 additions and 76 deletions

View file

@ -1,3 +1,17 @@
2017-05-13 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* haifa-sched.c (estimate_shadow_tick): Replace manual bitmap
management with auto_bitmap.
(fix_inter_tick): Likewise.
(fix_recovery_deps): Likewise.
* ira.c (add_store_equivs): Likewise.
(find_moveable_pseudos): Likewise.
(split_live_ranges_for_shrink_wrap): Likewise.
* print-rtl.c (rtx_reuse_manager::rtx_reuse_manager): Likewise.
(rtx_reuse_manager::seen_def_p): Likewise.
(rtx_reuse_manager::set_seen_def): Likewise.
* print-rtl.h (class rtx_reuse_manager): Likewise.
2017-05-13 Trevor Saunders <tbsaunde+gcc@tbsaunde.org> 2017-05-13 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* bt-load.c (combine_btr_defs): Use auto_bitmap to manage bitmap * bt-load.c (combine_btr_defs): Use auto_bitmap to manage bitmap

View file

@ -4843,14 +4843,12 @@ estimate_insn_tick (bitmap processed, rtx_insn *insn, int budget)
static int static int
estimate_shadow_tick (struct delay_pair *p) estimate_shadow_tick (struct delay_pair *p)
{ {
bitmap_head processed; auto_bitmap processed;
int t; int t;
bool cutoff; bool cutoff;
bitmap_initialize (&processed, 0);
cutoff = !estimate_insn_tick (&processed, p->i2, cutoff = !estimate_insn_tick (processed, p->i2,
max_insn_queue_index + pair_delay (p)); max_insn_queue_index + pair_delay (p));
bitmap_clear (&processed);
if (cutoff) if (cutoff)
return max_insn_queue_index; return max_insn_queue_index;
t = INSN_TICK_ESTIMATE (p->i2) - (clock_var + pair_delay (p) + 1); t = INSN_TICK_ESTIMATE (p->i2) - (clock_var + pair_delay (p) + 1);
@ -7515,15 +7513,13 @@ static void
fix_inter_tick (rtx_insn *head, rtx_insn *tail) fix_inter_tick (rtx_insn *head, rtx_insn *tail)
{ {
/* Set of instructions with corrected INSN_TICK. */ /* Set of instructions with corrected INSN_TICK. */
bitmap_head processed; auto_bitmap processed;
/* ??? It is doubtful if we should assume that cycle advance happens on /* ??? It is doubtful if we should assume that cycle advance happens on
basic block boundaries. Basically insns that are unconditionally ready basic block boundaries. Basically insns that are unconditionally ready
on the start of the block are more preferable then those which have on the start of the block are more preferable then those which have
a one cycle dependency over insn from the previous block. */ a one cycle dependency over insn from the previous block. */
int next_clock = clock_var + 1; int next_clock = clock_var + 1;
bitmap_initialize (&processed, 0);
/* Iterates over scheduled instructions and fix their INSN_TICKs and /* Iterates over scheduled instructions and fix their INSN_TICKs and
INSN_TICKs of dependent instructions, so that INSN_TICKs are consistent INSN_TICKs of dependent instructions, so that INSN_TICKs are consistent
across different blocks. */ across different blocks. */
@ -7539,7 +7535,7 @@ fix_inter_tick (rtx_insn *head, rtx_insn *tail)
gcc_assert (tick >= MIN_TICK); gcc_assert (tick >= MIN_TICK);
/* Fix INSN_TICK of instruction from just scheduled block. */ /* Fix INSN_TICK of instruction from just scheduled block. */
if (bitmap_set_bit (&processed, INSN_LUID (head))) if (bitmap_set_bit (processed, INSN_LUID (head)))
{ {
tick -= next_clock; tick -= next_clock;
@ -7563,7 +7559,7 @@ fix_inter_tick (rtx_insn *head, rtx_insn *tail)
/* If NEXT has its INSN_TICK calculated, fix it. /* If NEXT has its INSN_TICK calculated, fix it.
If not - it will be properly calculated from If not - it will be properly calculated from
scratch later in fix_tick_ready. */ scratch later in fix_tick_ready. */
&& bitmap_set_bit (&processed, INSN_LUID (next))) && bitmap_set_bit (processed, INSN_LUID (next)))
{ {
tick -= next_clock; tick -= next_clock;
@ -7580,7 +7576,6 @@ fix_inter_tick (rtx_insn *head, rtx_insn *tail)
} }
} }
} }
bitmap_clear (&processed);
} }
/* Check if NEXT is ready to be added to the ready or queue list. /* Check if NEXT is ready to be added to the ready or queue list.
@ -8617,9 +8612,7 @@ fix_recovery_deps (basic_block rec)
{ {
rtx_insn *note, *insn, *jump; rtx_insn *note, *insn, *jump;
auto_vec<rtx_insn *, 10> ready_list; auto_vec<rtx_insn *, 10> ready_list;
bitmap_head in_ready; auto_bitmap in_ready;
bitmap_initialize (&in_ready, 0);
/* NOTE - a basic block note. */ /* NOTE - a basic block note. */
note = NEXT_INSN (BB_HEAD (rec)); note = NEXT_INSN (BB_HEAD (rec));
@ -8642,7 +8635,7 @@ fix_recovery_deps (basic_block rec)
{ {
sd_delete_dep (sd_it); sd_delete_dep (sd_it);
if (bitmap_set_bit (&in_ready, INSN_LUID (consumer))) if (bitmap_set_bit (in_ready, INSN_LUID (consumer)))
ready_list.safe_push (consumer); ready_list.safe_push (consumer);
} }
else else
@ -8657,8 +8650,6 @@ fix_recovery_deps (basic_block rec)
} }
while (insn != note); while (insn != note);
bitmap_clear (&in_ready);
/* Try to add instructions to the ready or queue list. */ /* Try to add instructions to the ready or queue list. */
unsigned int i; unsigned int i;
rtx_insn *temp; rtx_insn *temp;

View file

@ -3635,16 +3635,15 @@ update_equiv_regs (void)
static void static void
add_store_equivs (void) add_store_equivs (void)
{ {
bitmap_head seen_insns; auto_bitmap seen_insns;
bitmap_initialize (&seen_insns, NULL);
for (rtx_insn *insn = get_insns (); insn; insn = NEXT_INSN (insn)) for (rtx_insn *insn = get_insns (); insn; insn = NEXT_INSN (insn))
{ {
rtx set, src, dest; rtx set, src, dest;
unsigned regno; unsigned regno;
rtx_insn *init_insn; rtx_insn *init_insn;
bitmap_set_bit (&seen_insns, INSN_UID (insn)); bitmap_set_bit (seen_insns, INSN_UID (insn));
if (! INSN_P (insn)) if (! INSN_P (insn))
continue; continue;
@ -3665,7 +3664,7 @@ add_store_equivs (void)
&& ! reg_equiv[regno].pdx_subregs && ! reg_equiv[regno].pdx_subregs
&& reg_equiv[regno].init_insns != NULL && reg_equiv[regno].init_insns != NULL
&& (init_insn = reg_equiv[regno].init_insns->insn ()) != 0 && (init_insn = reg_equiv[regno].init_insns->insn ()) != 0
&& bitmap_bit_p (&seen_insns, INSN_UID (init_insn)) && bitmap_bit_p (seen_insns, INSN_UID (init_insn))
&& ! find_reg_note (init_insn, REG_EQUIV, NULL_RTX) && ! find_reg_note (init_insn, REG_EQUIV, NULL_RTX)
&& validate_equiv_mem (init_insn, src, dest) == valid_reload && validate_equiv_mem (init_insn, src, dest) == valid_reload
&& ! memref_used_between_p (dest, init_insn, insn) && ! memref_used_between_p (dest, init_insn, insn)
@ -3685,7 +3684,6 @@ add_store_equivs (void)
INSN_UID (insn)); INSN_UID (insn));
} }
} }
bitmap_clear (&seen_insns);
} }
/* Scan all regs killed in an insn to see if any of them are registers /* Scan all regs killed in an insn to see if any of them are registers
@ -4485,9 +4483,8 @@ find_moveable_pseudos (void)
moved freely downwards, but are otherwise transparent to a block. */ moved freely downwards, but are otherwise transparent to a block. */
bitmap_head *bb_moveable_reg_sets = XNEWVEC (bitmap_head, bitmap_head *bb_moveable_reg_sets = XNEWVEC (bitmap_head,
last_basic_block_for_fn (cfun)); last_basic_block_for_fn (cfun));
bitmap_head live, used, set, interesting, unusable_as_input; auto_bitmap live, used, set, interesting, unusable_as_input;
bitmap_iterator bi; bitmap_iterator bi;
bitmap_initialize (&interesting, 0);
first_moveable_pseudo = max_regs; first_moveable_pseudo = max_regs;
pseudo_replaced_reg.release (); pseudo_replaced_reg.release ();
@ -4497,10 +4494,6 @@ find_moveable_pseudos (void)
calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_DOMINATORS);
i = 0; i = 0;
bitmap_initialize (&live, 0);
bitmap_initialize (&used, 0);
bitmap_initialize (&set, 0);
bitmap_initialize (&unusable_as_input, 0);
FOR_EACH_BB_FN (bb, cfun) FOR_EACH_BB_FN (bb, cfun)
{ {
rtx_insn *insn; rtx_insn *insn;
@ -4511,13 +4504,13 @@ find_moveable_pseudos (void)
bitmap_initialize (local, 0); bitmap_initialize (local, 0);
bitmap_initialize (transp, 0); bitmap_initialize (transp, 0);
bitmap_initialize (moveable, 0); bitmap_initialize (moveable, 0);
bitmap_copy (&live, df_get_live_out (bb)); bitmap_copy (live, df_get_live_out (bb));
bitmap_and_into (&live, df_get_live_in (bb)); bitmap_and_into (live, df_get_live_in (bb));
bitmap_copy (transp, &live); bitmap_copy (transp, live);
bitmap_clear (moveable); bitmap_clear (moveable);
bitmap_clear (&live); bitmap_clear (live);
bitmap_clear (&used); bitmap_clear (used);
bitmap_clear (&set); bitmap_clear (set);
FOR_BB_INSNS (bb, insn) FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn)) if (NONDEBUG_INSN_P (insn))
{ {
@ -4531,20 +4524,20 @@ find_moveable_pseudos (void)
if (use if (use
&& def && def
&& DF_REF_REGNO (use) == DF_REF_REGNO (def) && DF_REF_REGNO (use) == DF_REF_REGNO (def)
&& !bitmap_bit_p (&set, DF_REF_REGNO (use)) && !bitmap_bit_p (set, DF_REF_REGNO (use))
&& rtx_moveable_p (&PATTERN (insn), OP_IN)) && rtx_moveable_p (&PATTERN (insn), OP_IN))
{ {
unsigned regno = DF_REF_REGNO (use); unsigned regno = DF_REF_REGNO (use);
bitmap_set_bit (moveable, regno); bitmap_set_bit (moveable, regno);
bitmap_set_bit (&set, regno); bitmap_set_bit (set, regno);
bitmap_set_bit (&used, regno); bitmap_set_bit (used, regno);
bitmap_clear_bit (transp, regno); bitmap_clear_bit (transp, regno);
continue; continue;
} }
FOR_EACH_INSN_INFO_USE (use, insn_info) FOR_EACH_INSN_INFO_USE (use, insn_info)
{ {
unsigned regno = DF_REF_REGNO (use); unsigned regno = DF_REF_REGNO (use);
bitmap_set_bit (&used, regno); bitmap_set_bit (used, regno);
if (bitmap_clear_bit (moveable, regno)) if (bitmap_clear_bit (moveable, regno))
bitmap_clear_bit (transp, regno); bitmap_clear_bit (transp, regno);
} }
@ -4552,17 +4545,13 @@ find_moveable_pseudos (void)
FOR_EACH_INSN_INFO_DEF (def, insn_info) FOR_EACH_INSN_INFO_DEF (def, insn_info)
{ {
unsigned regno = DF_REF_REGNO (def); unsigned regno = DF_REF_REGNO (def);
bitmap_set_bit (&set, regno); bitmap_set_bit (set, regno);
bitmap_clear_bit (transp, regno); bitmap_clear_bit (transp, regno);
bitmap_clear_bit (moveable, regno); bitmap_clear_bit (moveable, regno);
} }
} }
} }
bitmap_clear (&live);
bitmap_clear (&used);
bitmap_clear (&set);
FOR_EACH_BB_FN (bb, cfun) FOR_EACH_BB_FN (bb, cfun)
{ {
bitmap local = bb_local + bb->index; bitmap local = bb_local + bb->index;
@ -4605,7 +4594,7 @@ find_moveable_pseudos (void)
if (dump_file) if (dump_file)
fprintf (dump_file, "Ignoring reg %d, has equiv memory\n", fprintf (dump_file, "Ignoring reg %d, has equiv memory\n",
regno); regno);
bitmap_set_bit (&unusable_as_input, regno); bitmap_set_bit (unusable_as_input, regno);
continue; continue;
} }
@ -4665,7 +4654,7 @@ find_moveable_pseudos (void)
continue; continue;
} }
bitmap_set_bit (&interesting, regno); bitmap_set_bit (interesting, regno);
/* If we get here, we know closest_use is a non-NULL insn /* If we get here, we know closest_use is a non-NULL insn
(as opposed to const_0_rtx). */ (as opposed to const_0_rtx). */
closest_uses[regno] = as_a <rtx_insn *> (closest_use); closest_uses[regno] = as_a <rtx_insn *> (closest_use);
@ -4684,7 +4673,7 @@ find_moveable_pseudos (void)
} }
} }
EXECUTE_IF_SET_IN_BITMAP (&interesting, 0, i, bi) EXECUTE_IF_SET_IN_BITMAP (interesting, 0, i, bi)
{ {
df_ref def = DF_REG_DEF_CHAIN (i); df_ref def = DF_REG_DEF_CHAIN (i);
rtx_insn *def_insn = DF_REF_INSN (def); rtx_insn *def_insn = DF_REF_INSN (def);
@ -4728,7 +4717,7 @@ find_moveable_pseudos (void)
FOR_EACH_INSN_USE (use, def_insn) FOR_EACH_INSN_USE (use, def_insn)
{ {
unsigned regno = DF_REF_REGNO (use); unsigned regno = DF_REF_REGNO (use);
if (bitmap_bit_p (&unusable_as_input, regno)) if (bitmap_bit_p (unusable_as_input, regno))
{ {
all_ok = false; all_ok = false;
if (dump_file) if (dump_file)
@ -4794,8 +4783,6 @@ find_moveable_pseudos (void)
bitmap_clear (bb_transp_live + bb->index); bitmap_clear (bb_transp_live + bb->index);
bitmap_clear (bb_moveable_reg_sets + bb->index); bitmap_clear (bb_moveable_reg_sets + bb->index);
} }
bitmap_clear (&interesting);
bitmap_clear (&unusable_as_input);
free (uid_luid); free (uid_luid);
free (closest_uses); free (closest_uses);
free (bb_local); free (bb_local);
@ -4875,14 +4862,12 @@ split_live_ranges_for_shrink_wrap (void)
basic_block bb, call_dom = NULL; basic_block bb, call_dom = NULL;
basic_block first = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)); basic_block first = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun));
rtx_insn *insn, *last_interesting_insn = NULL; rtx_insn *insn, *last_interesting_insn = NULL;
bitmap_head need_new, reachable; auto_bitmap need_new, reachable;
vec<basic_block> queue; vec<basic_block> queue;
if (!SHRINK_WRAPPING_ENABLED) if (!SHRINK_WRAPPING_ENABLED)
return false; return false;
bitmap_initialize (&need_new, 0);
bitmap_initialize (&reachable, 0);
queue.create (n_basic_blocks_for_fn (cfun)); queue.create (n_basic_blocks_for_fn (cfun));
FOR_EACH_BB_FN (bb, cfun) FOR_EACH_BB_FN (bb, cfun)
@ -4891,22 +4876,18 @@ split_live_ranges_for_shrink_wrap (void)
{ {
if (bb == first) if (bb == first)
{ {
bitmap_clear (&need_new);
bitmap_clear (&reachable);
queue.release (); queue.release ();
return false; return false;
} }
bitmap_set_bit (&need_new, bb->index); bitmap_set_bit (need_new, bb->index);
bitmap_set_bit (&reachable, bb->index); bitmap_set_bit (reachable, bb->index);
queue.quick_push (bb); queue.quick_push (bb);
break; break;
} }
if (queue.is_empty ()) if (queue.is_empty ())
{ {
bitmap_clear (&need_new);
bitmap_clear (&reachable);
queue.release (); queue.release ();
return false; return false;
} }
@ -4919,7 +4900,7 @@ split_live_ranges_for_shrink_wrap (void)
bb = queue.pop (); bb = queue.pop ();
FOR_EACH_EDGE (e, ei, bb->succs) FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun)
&& bitmap_set_bit (&reachable, e->dest->index)) && bitmap_set_bit (reachable, e->dest->index))
queue.quick_push (e->dest); queue.quick_push (e->dest);
} }
queue.release (); queue.release ();
@ -4931,32 +4912,23 @@ split_live_ranges_for_shrink_wrap (void)
continue; continue;
if (DF_REG_DEF_COUNT (REGNO (dest)) > 1) if (DF_REG_DEF_COUNT (REGNO (dest)) > 1)
{ return false;
bitmap_clear (&need_new);
bitmap_clear (&reachable);
return false;
}
for (df_ref use = DF_REG_USE_CHAIN (REGNO(dest)); for (df_ref use = DF_REG_USE_CHAIN (REGNO(dest));
use; use;
use = DF_REF_NEXT_REG (use)) use = DF_REF_NEXT_REG (use))
{ {
int ubbi = DF_REF_BB (use)->index; int ubbi = DF_REF_BB (use)->index;
if (bitmap_bit_p (&reachable, ubbi)) if (bitmap_bit_p (reachable, ubbi))
bitmap_set_bit (&need_new, ubbi); bitmap_set_bit (need_new, ubbi);
} }
last_interesting_insn = insn; last_interesting_insn = insn;
} }
bitmap_clear (&reachable);
if (!last_interesting_insn) if (!last_interesting_insn)
{ return false;
bitmap_clear (&need_new);
return false;
}
call_dom = nearest_common_dominator_for_set (CDI_DOMINATORS, &need_new); call_dom = nearest_common_dominator_for_set (CDI_DOMINATORS, need_new);
bitmap_clear (&need_new);
if (call_dom == first) if (call_dom == first)
return false; return false;

View file

@ -90,7 +90,6 @@ rtx_writer::rtx_writer (FILE *outf, int ind, bool simple, bool compact,
rtx_reuse_manager::rtx_reuse_manager () rtx_reuse_manager::rtx_reuse_manager ()
: m_next_id (0) : m_next_id (0)
{ {
bitmap_initialize (&m_defs_seen, NULL);
} }
/* Determine if X is of a kind suitable for dumping via reuse_rtx. */ /* Determine if X is of a kind suitable for dumping via reuse_rtx. */
@ -158,7 +157,7 @@ rtx_reuse_manager::has_reuse_id (const_rtx x, int *out)
bool bool
rtx_reuse_manager::seen_def_p (int reuse_id) rtx_reuse_manager::seen_def_p (int reuse_id)
{ {
return bitmap_bit_p (&m_defs_seen, reuse_id); return bitmap_bit_p (m_defs_seen, reuse_id);
} }
/* Record that the definition of the given reuse ID has been seen. */ /* Record that the definition of the given reuse ID has been seen. */
@ -166,7 +165,7 @@ rtx_reuse_manager::seen_def_p (int reuse_id)
void void
rtx_reuse_manager::set_seen_def (int reuse_id) rtx_reuse_manager::set_seen_def (int reuse_id)
{ {
bitmap_set_bit (&m_defs_seen, reuse_id); bitmap_set_bit (m_defs_seen, reuse_id);
} }
#endif /* #ifndef GENERATOR_FILE */ #endif /* #ifndef GENERATOR_FILE */

View file

@ -153,7 +153,7 @@ class rtx_reuse_manager
private: private:
hash_map<const_rtx, int> m_rtx_occurrence_count; hash_map<const_rtx, int> m_rtx_occurrence_count;
hash_map<const_rtx, int> m_rtx_reuse_ids; hash_map<const_rtx, int> m_rtx_reuse_ids;
bitmap_head m_defs_seen; auto_bitmap m_defs_seen;
int m_next_id; int m_next_id;
}; };