This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 08/13] move several bitmaps from gc memory to the default obstack and use auto_bitmap
On Tue, May 9, 2017 at 10:52 PM, <tbsaunde+gcc@tbsaunde.org> wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> 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.
Ok.
Richard.
> gcc/ChangeLog:
>
> 2017-05-09 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.
> ---
> gcc/haifa-sched.c | 23 +++++----------
> gcc/ira.c | 84 +++++++++++++++++++------------------------------------
> gcc/print-rtl.c | 5 ++--
> gcc/print-rtl.h | 2 +-
> 4 files changed, 38 insertions(+), 76 deletions(-)
>
> diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
> index 0ebf110471c..1fcc01d04ae 100644
> --- a/gcc/haifa-sched.c
> +++ b/gcc/haifa-sched.c
> @@ -4843,14 +4843,12 @@ estimate_insn_tick (bitmap processed, rtx_insn *insn, int budget)
> static int
> estimate_shadow_tick (struct delay_pair *p)
> {
> - bitmap_head processed;
> + auto_bitmap processed;
> int t;
> 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));
> - bitmap_clear (&processed);
> if (cutoff)
> return max_insn_queue_index;
> 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)
> {
> /* 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
> basic block boundaries. Basically insns that are unconditionally ready
> on the start of the block are more preferable then those which have
> a one cycle dependency over insn from the previous block. */
> int next_clock = clock_var + 1;
>
> - bitmap_initialize (&processed, 0);
> -
> /* Iterates over scheduled instructions and fix their INSN_TICKs and
> INSN_TICKs of dependent instructions, so that INSN_TICKs are consistent
> across different blocks. */
> @@ -7539,7 +7535,7 @@ fix_inter_tick (rtx_insn *head, rtx_insn *tail)
> gcc_assert (tick >= MIN_TICK);
>
> /* 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;
>
> @@ -7563,7 +7559,7 @@ fix_inter_tick (rtx_insn *head, rtx_insn *tail)
> /* If NEXT has its INSN_TICK calculated, fix it.
> If not - it will be properly calculated from
> scratch later in fix_tick_ready. */
> - && bitmap_set_bit (&processed, INSN_LUID (next)))
> + && bitmap_set_bit (processed, INSN_LUID (next)))
> {
> 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.
> @@ -8617,9 +8612,7 @@ fix_recovery_deps (basic_block rec)
> {
> rtx_insn *note, *insn, *jump;
> auto_vec<rtx_insn *, 10> ready_list;
> - bitmap_head in_ready;
> -
> - bitmap_initialize (&in_ready, 0);
> + auto_bitmap in_ready;
>
> /* NOTE - a basic block note. */
> note = NEXT_INSN (BB_HEAD (rec));
> @@ -8642,7 +8635,7 @@ fix_recovery_deps (basic_block rec)
> {
> 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);
> }
> else
> @@ -8657,8 +8650,6 @@ fix_recovery_deps (basic_block rec)
> }
> while (insn != note);
>
> - bitmap_clear (&in_ready);
> -
> /* Try to add instructions to the ready or queue list. */
> unsigned int i;
> rtx_insn *temp;
> diff --git a/gcc/ira.c b/gcc/ira.c
> index c9751ce81ba..36a779bd37f 100644
> --- a/gcc/ira.c
> +++ b/gcc/ira.c
> @@ -3635,16 +3635,15 @@ update_equiv_regs (void)
> static 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))
> {
> rtx set, src, dest;
> unsigned regno;
> rtx_insn *init_insn;
>
> - bitmap_set_bit (&seen_insns, INSN_UID (insn));
> + bitmap_set_bit (seen_insns, INSN_UID (insn));
>
> if (! INSN_P (insn))
> continue;
> @@ -3665,7 +3664,7 @@ add_store_equivs (void)
> && ! reg_equiv[regno].pdx_subregs
> && reg_equiv[regno].init_insns != NULL
> && (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)
> && validate_equiv_mem (init_insn, src, dest) == valid_reload
> && ! memref_used_between_p (dest, init_insn, insn)
> @@ -3685,7 +3684,6 @@ add_store_equivs (void)
> INSN_UID (insn));
> }
> }
> - bitmap_clear (&seen_insns);
> }
>
> /* 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. */
> bitmap_head *bb_moveable_reg_sets = XNEWVEC (bitmap_head,
> 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_initialize (&interesting, 0);
>
> first_moveable_pseudo = max_regs;
> pseudo_replaced_reg.release ();
> @@ -4497,10 +4494,6 @@ find_moveable_pseudos (void)
> calculate_dominance_info (CDI_DOMINATORS);
>
> 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)
> {
> rtx_insn *insn;
> @@ -4511,13 +4504,13 @@ find_moveable_pseudos (void)
> bitmap_initialize (local, 0);
> bitmap_initialize (transp, 0);
> bitmap_initialize (moveable, 0);
> - bitmap_copy (&live, df_get_live_out (bb));
> - bitmap_and_into (&live, df_get_live_in (bb));
> - bitmap_copy (transp, &live);
> + bitmap_copy (live, df_get_live_out (bb));
> + bitmap_and_into (live, df_get_live_in (bb));
> + bitmap_copy (transp, live);
> bitmap_clear (moveable);
> - bitmap_clear (&live);
> - bitmap_clear (&used);
> - bitmap_clear (&set);
> + bitmap_clear (live);
> + bitmap_clear (used);
> + bitmap_clear (set);
> FOR_BB_INSNS (bb, insn)
> if (NONDEBUG_INSN_P (insn))
> {
> @@ -4531,20 +4524,20 @@ find_moveable_pseudos (void)
> if (use
> && 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))
> {
> unsigned regno = DF_REF_REGNO (use);
> bitmap_set_bit (moveable, regno);
> - bitmap_set_bit (&set, regno);
> - bitmap_set_bit (&used, regno);
> + bitmap_set_bit (set, regno);
> + bitmap_set_bit (used, regno);
> bitmap_clear_bit (transp, regno);
> continue;
> }
> FOR_EACH_INSN_INFO_USE (use, insn_info)
> {
> unsigned regno = DF_REF_REGNO (use);
> - bitmap_set_bit (&used, regno);
> + bitmap_set_bit (used, regno);
> if (bitmap_clear_bit (moveable, regno))
> bitmap_clear_bit (transp, regno);
> }
> @@ -4552,17 +4545,13 @@ find_moveable_pseudos (void)
> FOR_EACH_INSN_INFO_DEF (def, insn_info)
> {
> unsigned regno = DF_REF_REGNO (def);
> - bitmap_set_bit (&set, regno);
> + bitmap_set_bit (set, regno);
> bitmap_clear_bit (transp, regno);
> bitmap_clear_bit (moveable, regno);
> }
> }
> }
>
> - bitmap_clear (&live);
> - bitmap_clear (&used);
> - bitmap_clear (&set);
> -
> FOR_EACH_BB_FN (bb, cfun)
> {
> bitmap local = bb_local + bb->index;
> @@ -4605,7 +4594,7 @@ find_moveable_pseudos (void)
> if (dump_file)
> fprintf (dump_file, "Ignoring reg %d, has equiv memory\n",
> regno);
> - bitmap_set_bit (&unusable_as_input, regno);
> + bitmap_set_bit (unusable_as_input, regno);
> continue;
> }
>
> @@ -4665,7 +4654,7 @@ find_moveable_pseudos (void)
> continue;
> }
>
> - bitmap_set_bit (&interesting, regno);
> + bitmap_set_bit (interesting, regno);
> /* If we get here, we know closest_use is a non-NULL insn
> (as opposed to const_0_rtx). */
> 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);
> rtx_insn *def_insn = DF_REF_INSN (def);
> @@ -4728,7 +4717,7 @@ find_moveable_pseudos (void)
> FOR_EACH_INSN_USE (use, def_insn)
> {
> 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;
> if (dump_file)
> @@ -4794,8 +4783,6 @@ find_moveable_pseudos (void)
> bitmap_clear (bb_transp_live + bb->index);
> bitmap_clear (bb_moveable_reg_sets + bb->index);
> }
> - bitmap_clear (&interesting);
> - bitmap_clear (&unusable_as_input);
> free (uid_luid);
> free (closest_uses);
> free (bb_local);
> @@ -4875,14 +4862,12 @@ split_live_ranges_for_shrink_wrap (void)
> basic_block bb, call_dom = NULL;
> basic_block first = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun));
> rtx_insn *insn, *last_interesting_insn = NULL;
> - bitmap_head need_new, reachable;
> + auto_bitmap need_new, reachable;
> vec<basic_block> queue;
>
> if (!SHRINK_WRAPPING_ENABLED)
> return false;
>
> - bitmap_initialize (&need_new, 0);
> - bitmap_initialize (&reachable, 0);
> queue.create (n_basic_blocks_for_fn (cfun));
>
> FOR_EACH_BB_FN (bb, cfun)
> @@ -4891,22 +4876,18 @@ split_live_ranges_for_shrink_wrap (void)
> {
> if (bb == first)
> {
> - bitmap_clear (&need_new);
> - bitmap_clear (&reachable);
> queue.release ();
> return false;
> }
>
> - bitmap_set_bit (&need_new, bb->index);
> - bitmap_set_bit (&reachable, bb->index);
> + bitmap_set_bit (need_new, bb->index);
> + bitmap_set_bit (reachable, bb->index);
> queue.quick_push (bb);
> break;
> }
>
> if (queue.is_empty ())
> {
> - bitmap_clear (&need_new);
> - bitmap_clear (&reachable);
> queue.release ();
> return false;
> }
> @@ -4919,7 +4900,7 @@ split_live_ranges_for_shrink_wrap (void)
> bb = queue.pop ();
> FOR_EACH_EDGE (e, ei, bb->succs)
> 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.release ();
> @@ -4931,32 +4912,23 @@ split_live_ranges_for_shrink_wrap (void)
> continue;
>
> if (DF_REG_DEF_COUNT (REGNO (dest)) > 1)
> - {
> - bitmap_clear (&need_new);
> - bitmap_clear (&reachable);
> - return false;
> - }
> + return false;
>
> for (df_ref use = DF_REG_USE_CHAIN (REGNO(dest));
> use;
> use = DF_REF_NEXT_REG (use))
> {
> int ubbi = DF_REF_BB (use)->index;
> - if (bitmap_bit_p (&reachable, ubbi))
> - bitmap_set_bit (&need_new, ubbi);
> + if (bitmap_bit_p (reachable, ubbi))
> + bitmap_set_bit (need_new, ubbi);
> }
> last_interesting_insn = insn;
> }
>
> - bitmap_clear (&reachable);
> if (!last_interesting_insn)
> - {
> - bitmap_clear (&need_new);
> - return false;
> - }
> + return false;
>
> - call_dom = nearest_common_dominator_for_set (CDI_DOMINATORS, &need_new);
> - bitmap_clear (&need_new);
> + call_dom = nearest_common_dominator_for_set (CDI_DOMINATORS, need_new);
> if (call_dom == first)
> return false;
>
> diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> index 30fd7597450..20bdafdb580 100644
> --- a/gcc/print-rtl.c
> +++ b/gcc/print-rtl.c
> @@ -90,7 +90,6 @@ rtx_writer::rtx_writer (FILE *outf, int ind, bool simple, bool compact,
> rtx_reuse_manager::rtx_reuse_manager ()
> : m_next_id (0)
> {
> - bitmap_initialize (&m_defs_seen, NULL);
> }
>
> /* 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
> 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. */
> @@ -166,7 +165,7 @@ rtx_reuse_manager::seen_def_p (int reuse_id)
> void
> 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 */
> diff --git a/gcc/print-rtl.h b/gcc/print-rtl.h
> index 81dfcba62cf..eee949a1792 100644
> --- a/gcc/print-rtl.h
> +++ b/gcc/print-rtl.h
> @@ -153,7 +153,7 @@ class rtx_reuse_manager
> private:
> hash_map<const_rtx, int> m_rtx_occurrence_count;
> hash_map<const_rtx, int> m_rtx_reuse_ids;
> - bitmap_head m_defs_seen;
> + auto_bitmap m_defs_seen;
> int m_next_id;
> };
>
> --
> 2.11.0
>