public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: tbsaunde+gcc@tbsaunde.org
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 07/13] use auto_bitmap more
Date: Wed, 10 May 2017 08:28:00 -0000	[thread overview]
Message-ID: <CAFiYyc0WsEmj2WjKDWV8ijNAL8rvmnustpZVqWaZDequYyj8VQ@mail.gmail.com> (raw)
In-Reply-To: <20170509205242.2237-8-tbsaunde+gcc@tbsaunde.org>

On Tue, May 9, 2017 at 10:52 PM,  <tbsaunde+gcc@tbsaunde.org> wrote:
> From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
>
> gcc/ChangeLog:

Ok.

Richard.

> 2017-05-09  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
>
>         * bt-load.c (combine_btr_defs): Use auto_bitmap to manage bitmap
>         lifetime.
>         (migrate_btr_def): Likewise.
>         * cfgloop.c (get_loop_body_in_bfs_order): Likewise.
>         * df-core.c (loop_post_order_compute): Likewise.
>         (loop_inverted_post_order_compute): Likewise.
>         * hsa-common.h: Likewise.
>         * hsa-gen.c (hsa_bb::~hsa_bb): Likewise.
>         * init-regs.c (initialize_uninitialized_regs): Likewise.
>         * ipa-inline.c (resolve_noninline_speculation): Likewise.
>         (inline_small_functions): Likewise.
>         * ipa-reference.c (ipa_reference_write_optimization_summary):
> Likewise.
>         * ira.c (combine_and_move_insns): Likewise.
>         (build_insn_chain): Likewise.
>         * loop-invariant.c (find_invariants): Likewise.
>         * lower-subreg.c (propagate_pseudo_copies): Likewise.
>         * predict.c (tree_predict_by_opcode): Likewise.
>         (predict_paths_leading_to): Likewise.
>         (predict_paths_leading_to_edge): Likewise.
>         (estimate_loops_at_level): Likewise.
>         (estimate_loops): Likewise.
>         * shrink-wrap.c (try_shrink_wrapping): Likewise.
>         (spread_components): Likewise.
>         * tree-cfg.c (remove_edge_and_dominated_blocks): Likewise.
>         * tree-loop-distribution.c (rdg_build_partitions): Likewise.
>         * tree-predcom.c (tree_predictive_commoning_loop): Likewise.
>         * tree-ssa-coalesce.c (coalesce_ssa_name): Likewise.
>         * tree-ssa-phionlycprop.c (pass_phi_only_cprop::execute):
> Likewise.
>         * tree-ssa-pre.c (remove_dead_inserted_code): Likewise.
>         * tree-ssa-sink.c (nearest_common_dominator_of_uses): Likewise.
>         * tree-ssa-threadupdate.c (compute_path_counts): Likewise.
>         (mark_threaded_blocks): Likewise.
>         (thread_through_all_blocks): Likewise.
>         * tree-ssa.c (verify_ssa): Likewise.
>         (execute_update_addresses_taken): Likewise.
>         * tree-ssanames.c (verify_ssaname_freelists): Likewise.
> ---
>  gcc/bt-load.c                |  8 +++-----
>  gcc/cfgloop.c                |  4 +---
>  gcc/df-core.c                |  8 ++------
>  gcc/hsa-common.h             |  4 ++--
>  gcc/hsa-gen.c                | 14 ++------------
>  gcc/init-regs.c              |  4 +---
>  gcc/ipa-inline.c             |  6 ++----
>  gcc/ipa-reference.c          |  3 +--
>  gcc/ira.c                    | 13 ++++---------
>  gcc/loop-invariant.c         | 12 ++++--------
>  gcc/lower-subreg.c           |  8 +-------
>  gcc/predict.c                | 19 +++++--------------
>  gcc/shrink-wrap.c            | 10 +++-------
>  gcc/tree-cfg.c               |  7 +------
>  gcc/tree-loop-distribution.c |  4 +---
>  gcc/tree-predcom.c           |  4 +---
>  gcc/tree-ssa-coalesce.c      |  4 +---
>  gcc/tree-ssa-phionlycprop.c  | 15 ++++-----------
>  gcc/tree-ssa-pre.c           |  4 +---
>  gcc/tree-ssa-sink.c          |  9 +++------
>  gcc/tree-ssa-threadupdate.c  | 13 +++----------
>  gcc/tree-ssa.c               | 12 ++++--------
>  gcc/tree-ssanames.c          | 10 +++-------
>  23 files changed, 53 insertions(+), 142 deletions(-)
>
> diff --git a/gcc/bt-load.c b/gcc/bt-load.c
> index 27be6a382c4..32924e2ecc5 100644
> --- a/gcc/bt-load.c
> +++ b/gcc/bt-load.c
> @@ -1058,7 +1058,7 @@ combine_btr_defs (btr_def *def, HARD_REG_SET *btrs_live_in_range)
>              target registers live over the merged range.  */
>           int btr;
>           HARD_REG_SET combined_btrs_live;
> -         bitmap combined_live_range = BITMAP_ALLOC (NULL);
> +         auto_bitmap combined_live_range;
>           btr_user *user;
>
>           if (other_def->live_range == NULL)
> @@ -1116,7 +1116,6 @@ combine_btr_defs (btr_def *def, HARD_REG_SET *btrs_live_in_range)
>               delete_insn (other_def->insn);
>
>             }
> -         BITMAP_FREE (combined_live_range);
>         }
>      }
>  }
> @@ -1255,7 +1254,6 @@ can_move_up (const_basic_block bb, const rtx_insn *insn, int n_insns)
>  static int
>  migrate_btr_def (btr_def *def, int min_cost)
>  {
> -  bitmap live_range;
>    HARD_REG_SET btrs_live_in_range;
>    int btr_used_near_def = 0;
>    int def_basic_block_freq;
> @@ -1289,7 +1287,7 @@ migrate_btr_def (btr_def *def, int min_cost)
>      }
>
>    btr_def_live_range (def, &btrs_live_in_range);
> -  live_range = BITMAP_ALLOC (NULL);
> +  auto_bitmap live_range;
>    bitmap_copy (live_range, def->live_range);
>
>  #ifdef INSN_SCHEDULING
> @@ -1373,7 +1371,7 @@ migrate_btr_def (btr_def *def, int min_cost)
>        if (dump_file)
>         fprintf (dump_file, "failed to move\n");
>      }
> -  BITMAP_FREE (live_range);
> +
>    return !give_up;
>  }
>
> diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
> index afd56bb8cf7..654d188e8b5 100644
> --- a/gcc/cfgloop.c
> +++ b/gcc/cfgloop.c
> @@ -923,7 +923,6 @@ get_loop_body_in_bfs_order (const struct loop *loop)
>  {
>    basic_block *blocks;
>    basic_block bb;
> -  bitmap visited;
>    unsigned int i = 1;
>    unsigned int vc = 0;
>
> @@ -931,7 +930,7 @@ get_loop_body_in_bfs_order (const struct loop *loop)
>    gcc_assert (loop->latch != EXIT_BLOCK_PTR_FOR_FN (cfun));
>
>    blocks = XNEWVEC (basic_block, loop->num_nodes);
> -  visited = BITMAP_ALLOC (NULL);
> +  auto_bitmap visited;
>    blocks[0] = loop->header;
>    bitmap_set_bit (visited, loop->header->index);
>    while (i < loop->num_nodes)
> @@ -952,7 +951,6 @@ get_loop_body_in_bfs_order (const struct loop *loop)
>         }
>      }
>
> -  BITMAP_FREE (visited);
>    return blocks;
>  }
>
> diff --git a/gcc/df-core.c b/gcc/df-core.c
> index 19f4d3dae8c..98787a768c6 100644
> --- a/gcc/df-core.c
> +++ b/gcc/df-core.c
> @@ -1303,14 +1303,13 @@ loop_post_order_compute (int *post_order, struct loop *loop)
>    edge_iterator *stack;
>    int sp;
>    int post_order_num = 0;
> -  bitmap visited;
>
>    /* Allocate stack for back-tracking up CFG.  */
>    stack = XNEWVEC (edge_iterator, loop->num_nodes + 1);
>    sp = 0;
>
>    /* Allocate bitmap to track nodes that have been visited.  */
> -  visited = BITMAP_ALLOC (NULL);
> +  auto_bitmap visited;
>
>    /* Push the first edge on to the stack.  */
>    stack[sp++] = ei_start (loop_preheader_edge (loop)->src->succs);
> @@ -1352,7 +1351,6 @@ loop_post_order_compute (int *post_order, struct loop *loop)
>      }
>
>    free (stack);
> -  BITMAP_FREE (visited);
>
>    return post_order_num;
>  }
> @@ -1367,14 +1365,13 @@ loop_inverted_post_order_compute (int *post_order, struct loop *loop)
>    edge_iterator *stack;
>    int sp;
>    int post_order_num = 0;
> -  bitmap visited;
>
>    /* Allocate stack for back-tracking up CFG.  */
>    stack = XNEWVEC (edge_iterator, loop->num_nodes + 1);
>    sp = 0;
>
>    /* Allocate bitmap to track nodes that have been visited.  */
> -  visited = BITMAP_ALLOC (NULL);
> +  auto_bitmap visited;
>
>    /* Put all latches into the initial work list.  In theory we'd want
>       to start from loop exits but then we'd have the special case of
> @@ -1420,7 +1417,6 @@ loop_inverted_post_order_compute (int *post_order, struct loop *loop)
>      }
>
>    free (stack);
> -  BITMAP_FREE (visited);
>    return post_order_num;
>  }
>
> diff --git a/gcc/hsa-common.h b/gcc/hsa-common.h
> index a24bf6e5ad1..810624e4e1c 100644
> --- a/gcc/hsa-common.h
> +++ b/gcc/hsa-common.h
> @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "vec.h"
>  #include "hash-table.h"
>  #include "basic-block.h"
> +#include "bitmap.h"
>
>
>  /* Return true if the compiler should produce HSAIL.  */
> @@ -1027,7 +1028,6 @@ class hsa_bb
>  public:
>    hsa_bb (basic_block cfg_bb);
>    hsa_bb (basic_block cfg_bb, int idx);
> -  ~hsa_bb ();
>
>    /* Append an instruction INSN into the basic block.  */
>    void append_insn (hsa_insn_basic *insn);
> @@ -1049,7 +1049,7 @@ public:
>    /* Just a number to construct names from.  */
>    int m_index;
>
> -  bitmap m_liveout, m_livein;
> +  auto_bitmap m_liveout, m_livein;
>  private:
>    /* Make the default constructor inaccessible.  */
>    hsa_bb ();
> diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
> index 4b85e0b2678..c5d8a6e1f44 100644
> --- a/gcc/hsa-gen.c
> +++ b/gcc/hsa-gen.c
> @@ -5716,8 +5716,7 @@ gen_hsa_phi_from_gimple_phi (gimple *phi_stmt, hsa_bb *hbb)
>
>  hsa_bb::hsa_bb (basic_block cfg_bb, int idx)
>    : m_bb (cfg_bb), m_first_insn (NULL), m_last_insn (NULL), m_first_phi (NULL),
> -    m_last_phi (NULL), m_index (idx), m_liveout (BITMAP_ALLOC (NULL)),
> -    m_livein (BITMAP_ALLOC (NULL))
> +    m_last_phi (NULL), m_index (idx)
>  {
>    gcc_assert (!cfg_bb->aux);
>    cfg_bb->aux = this;
> @@ -5728,21 +5727,12 @@ hsa_bb::hsa_bb (basic_block cfg_bb, int idx)
>
>  hsa_bb::hsa_bb (basic_block cfg_bb)
>    : m_bb (cfg_bb), m_first_insn (NULL), m_last_insn (NULL), m_first_phi (NULL),
> -    m_last_phi (NULL), m_index (hsa_cfun->m_hbb_count++),
> -    m_liveout (BITMAP_ALLOC (NULL)), m_livein (BITMAP_ALLOC (NULL))
> +    m_last_phi (NULL), m_index (hsa_cfun->m_hbb_count++)
>  {
>    gcc_assert (!cfg_bb->aux);
>    cfg_bb->aux = this;
>  }
>
> -/* Destructor of class representing HSA BB.  */
> -
> -hsa_bb::~hsa_bb ()
> -{
> -  BITMAP_FREE (m_livein);
> -  BITMAP_FREE (m_liveout);
> -}
> -
>  /* Create and initialize and return a new hsa_bb structure for a given CFG
>     basic block BB.  */
>
> diff --git a/gcc/init-regs.c b/gcc/init-regs.c
> index 2c69991c9e1..15d77467149 100644
> --- a/gcc/init-regs.c
> +++ b/gcc/init-regs.c
> @@ -48,7 +48,7 @@ static void
>  initialize_uninitialized_regs (void)
>  {
>    basic_block bb;
> -  bitmap already_genned = BITMAP_ALLOC (NULL);
> +  auto_bitmap already_genned;
>
>    if (optimize == 1)
>      {
> @@ -125,8 +125,6 @@ initialize_uninitialized_regs (void)
>         df_dump (dump_file);
>        df_remove_problem (df_live);
>      }
> -
> -  BITMAP_FREE (already_genned);
>  }
>
>  namespace {
> diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
> index ce79af5719e..7337e0a2fe5 100644
> --- a/gcc/ipa-inline.c
> +++ b/gcc/ipa-inline.c
> @@ -1674,7 +1674,7 @@ resolve_noninline_speculation (edge_heap_t *edge_heap, struct cgraph_edge *edge)
>        struct cgraph_node *node = edge->caller;
>        struct cgraph_node *where = node->global.inlined_to
>                                   ? node->global.inlined_to : node;
> -      bitmap updated_nodes = BITMAP_ALLOC (NULL);
> +      auto_bitmap updated_nodes;
>
>        spec_rem += edge->count;
>        edge->resolve_speculation ();
> @@ -1684,7 +1684,6 @@ resolve_noninline_speculation (edge_heap_t *edge_heap, struct cgraph_edge *edge)
>                           updated_nodes, NULL);
>        update_callee_keys (edge_heap, where,
>                           updated_nodes);
> -      BITMAP_FREE (updated_nodes);
>      }
>  }
>
> @@ -1726,7 +1725,7 @@ inline_small_functions (void)
>    struct cgraph_node *node;
>    struct cgraph_edge *edge;
>    edge_heap_t edge_heap (sreal::min ());
> -  bitmap updated_nodes = BITMAP_ALLOC (NULL);
> +  auto_bitmap updated_nodes;
>    int min_size, max_size;
>    auto_vec<cgraph_edge *> new_indirect_edges;
>    int initial_size = 0;
> @@ -2072,7 +2071,6 @@ inline_small_functions (void)
>              "Unit growth for small function inlining: %i->%i (%i%%)\n",
>              initial_size, overall_size,
>              initial_size ? overall_size * 100 / (initial_size) - 100: 0);
> -  BITMAP_FREE (updated_nodes);
>    symtab->remove_edge_removal_hook (edge_removal_hook_holder);
>  }
>
> diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
> index f47d0cc51e1..222253920fd 100644
> --- a/gcc/ipa-reference.c
> +++ b/gcc/ipa-reference.c
> @@ -992,7 +992,7 @@ ipa_reference_write_optimization_summary (void)
>    unsigned int count = 0;
>    int ltrans_statics_bitcount = 0;
>    lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder;
> -  bitmap ltrans_statics = BITMAP_ALLOC (NULL);
> +  auto_bitmap ltrans_statics;
>    int i;
>
>    reference_vars_to_consider = splay_tree_new (splay_tree_compare_ints, 0, 0);
> @@ -1052,7 +1052,6 @@ ipa_reference_write_optimization_summary (void)
>                                ltrans_statics_bitcount);
>           }
>        }
> -  BITMAP_FREE (ltrans_statics);
>    lto_destroy_simple_output_block (ob);
>    splay_tree_delete (reference_vars_to_consider);
>  }
> diff --git a/gcc/ira.c b/gcc/ira.c
> index bfb05080de1..c9751ce81ba 100644
> --- a/gcc/ira.c
> +++ b/gcc/ira.c
> @@ -3698,7 +3698,7 @@ add_store_equivs (void)
>  static void
>  combine_and_move_insns (void)
>  {
> -  bitmap cleared_regs = BITMAP_ALLOC (NULL);
> +  auto_bitmap cleared_regs;
>    int max = max_reg_num ();
>
>    for (int regno = FIRST_PSEUDO_REGISTER; regno < max; regno++)
> @@ -3856,8 +3856,6 @@ combine_and_move_insns (void)
>                 df_insn_rescan (insn);
>             }
>      }
> -
> -  BITMAP_FREE (cleared_regs);
>  }
>
>  /* A pass over indirect jumps, converting simple cases to direct jumps.
> @@ -4083,8 +4081,8 @@ build_insn_chain (void)
>    basic_block bb;
>    struct insn_chain *c = NULL;
>    struct insn_chain *next = NULL;
> -  bitmap live_relevant_regs = BITMAP_ALLOC (NULL);
> -  bitmap elim_regset = BITMAP_ALLOC (NULL);
> +  auto_bitmap live_relevant_regs;
> +  auto_bitmap elim_regset;
>    /* live_subregs is a vector used to keep accurate information about
>       which hardregs are live in multiword pseudos.  live_subregs and
>       live_subregs_used are indexed by pseudo number.  The live_subreg
> @@ -4093,7 +4091,7 @@ build_insn_chain (void)
>       live_subreg[allocno] is number of bytes that the pseudo can
>       occupy.  */
>    sbitmap *live_subregs = XCNEWVEC (sbitmap, max_regno);
> -  bitmap live_subregs_used = BITMAP_ALLOC (NULL);
> +  auto_bitmap live_subregs_used;
>
>    for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
>      if (TEST_HARD_REG_BIT (eliminable_regset, i))
> @@ -4336,9 +4334,6 @@ build_insn_chain (void)
>      if (live_subregs[i] != NULL)
>        sbitmap_free (live_subregs[i]);
>    free (live_subregs);
> -  BITMAP_FREE (live_subregs_used);
> -  BITMAP_FREE (live_relevant_regs);
> -  BITMAP_FREE (elim_regset);
>
>    if (dump_file)
>      print_insn_chains (dump_file);
> diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
> index 8292cea3e52..cda42efd13e 100644
> --- a/gcc/loop-invariant.c
> +++ b/gcc/loop-invariant.c
> @@ -1219,10 +1219,10 @@ find_invariants_body (struct loop *loop, basic_block *body,
>  static void
>  find_invariants (struct loop *loop)
>  {
> -  bitmap may_exit = BITMAP_ALLOC (NULL);
> -  bitmap always_reached = BITMAP_ALLOC (NULL);
> -  bitmap has_exit = BITMAP_ALLOC (NULL);
> -  bitmap always_executed = BITMAP_ALLOC (NULL);
> +  auto_bitmap may_exit;
> +  auto_bitmap always_reached;
> +  auto_bitmap has_exit;
> +  auto_bitmap always_executed;
>    basic_block *body = get_loop_body_in_dom_order (loop);
>
>    find_exits (loop, body, may_exit, has_exit);
> @@ -1233,10 +1233,6 @@ find_invariants (struct loop *loop)
>    find_invariants_body (loop, body, always_reached, always_executed);
>    merge_identical_invariants ();
>
> -  BITMAP_FREE (always_reached);
> -  BITMAP_FREE (always_executed);
> -  BITMAP_FREE (may_exit);
> -  BITMAP_FREE (has_exit);
>    free (body);
>  }
>
> diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c
> index a4dcec51bb5..1ab1c71211f 100644
> --- a/gcc/lower-subreg.c
> +++ b/gcc/lower-subreg.c
> @@ -405,10 +405,7 @@ find_pseudo_copy (rtx set)
>  static void
>  propagate_pseudo_copies (void)
>  {
> -  bitmap queue, propagate;
> -
> -  queue = BITMAP_ALLOC (NULL);
> -  propagate = BITMAP_ALLOC (NULL);
> +  auto_bitmap queue, propagate;
>
>    bitmap_copy (queue, decomposable_context);
>    do
> @@ -429,9 +426,6 @@ propagate_pseudo_copies (void)
>        bitmap_ior_into (decomposable_context, propagate);
>      }
>    while (!bitmap_empty_p (queue));
> -
> -  BITMAP_FREE (queue);
> -  BITMAP_FREE (propagate);
>  }
>
>  /* A pointer to one of these values is passed to
> diff --git a/gcc/predict.c b/gcc/predict.c
> index fa4e626fab8..0fc9fc5c466 100644
> --- a/gcc/predict.c
> +++ b/gcc/predict.c
> @@ -2396,7 +2396,6 @@ tree_predict_by_opcode (basic_block bb)
>    tree type;
>    tree val;
>    enum tree_code cmp;
> -  bitmap visited;
>    edge_iterator ei;
>    enum br_predictor predictor;
>
> @@ -2409,10 +2408,8 @@ tree_predict_by_opcode (basic_block bb)
>    op1 = gimple_cond_rhs (stmt);
>    cmp = gimple_cond_code (stmt);
>    type = TREE_TYPE (op0);
> -  visited = BITMAP_ALLOC (NULL);
> -  val = expr_expected_value_1 (boolean_type_node, op0, cmp, op1, visited,
> +  val = expr_expected_value_1 (boolean_type_node, op0, cmp, op1, auto_bitmap (),
>                                &predictor);
> -  BITMAP_FREE (visited);
>    if (val && TREE_CODE (val) == INTEGER_CST)
>      {
>        if (predictor == PRED_BUILTIN_EXPECT)
> @@ -2917,9 +2914,7 @@ static void
>  predict_paths_leading_to (basic_block bb, enum br_predictor pred,
>                           enum prediction taken, struct loop *in_loop)
>  {
> -  bitmap visited = BITMAP_ALLOC (NULL);
> -  predict_paths_for_bb (bb, bb, pred, taken, visited, in_loop);
> -  BITMAP_FREE (visited);
> +  predict_paths_for_bb (bb, bb, pred, taken, auto_bitmap (), in_loop);
>  }
>
>  /* Like predict_paths_leading_to but take edge instead of basic block.  */
> @@ -2943,9 +2938,7 @@ predict_paths_leading_to_edge (edge e, enum br_predictor pred,
>        }
>    if (!has_nonloop_edge)
>      {
> -      bitmap visited = BITMAP_ALLOC (NULL);
> -      predict_paths_for_bb (bb, bb, pred, taken, visited, in_loop);
> -      BITMAP_FREE (visited);
> +      predict_paths_for_bb (bb, bb, pred, taken, auto_bitmap (), in_loop);
>      }
>    else
>      predict_edge_def (e, pred, taken);
> @@ -3119,7 +3112,7 @@ estimate_loops_at_level (struct loop *first_loop)
>        edge e;
>        basic_block *bbs;
>        unsigned i;
> -      bitmap tovisit = BITMAP_ALLOC (NULL);
> +      auto_bitmap tovisit;
>
>        estimate_loops_at_level (loop->inner);
>
> @@ -3132,7 +3125,6 @@ estimate_loops_at_level (struct loop *first_loop)
>         bitmap_set_bit (tovisit, bbs[i]->index);
>        free (bbs);
>        propagate_freq (loop->header, tovisit);
> -      BITMAP_FREE (tovisit);
>      }
>  }
>
> @@ -3141,7 +3133,7 @@ estimate_loops_at_level (struct loop *first_loop)
>  static void
>  estimate_loops (void)
>  {
> -  bitmap tovisit = BITMAP_ALLOC (NULL);
> +  auto_bitmap tovisit;
>    basic_block bb;
>
>    /* Start by estimating the frequencies in the loops.  */
> @@ -3154,7 +3146,6 @@ estimate_loops (void)
>        bitmap_set_bit (tovisit, bb->index);
>      }
>    propagate_freq (ENTRY_BLOCK_PTR_FOR_FN (cfun), tovisit);
> -  BITMAP_FREE (tovisit);
>  }
>
>  /* Drop the profile for NODE to guessed, and update its frequency based on
> diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
> index 35eb85ba63c..492376d949b 100644
> --- a/gcc/shrink-wrap.c
> +++ b/gcc/shrink-wrap.c
> @@ -758,7 +758,7 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq)
>       reachable from PRO that we already found, and in VEC a stack of
>       those we still need to consider (to find successors).  */
>
> -  bitmap bb_with = BITMAP_ALLOC (NULL);
> +  auto_bitmap bb_with;
>    bitmap_set_bit (bb_with, pro->index);
>
>    vec<basic_block> vec;
> @@ -822,7 +822,7 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq)
>      {
>        calculate_dominance_info (CDI_POST_DOMINATORS);
>
> -      bitmap bb_tmp = BITMAP_ALLOC (NULL);
> +      auto_bitmap bb_tmp;
>        bitmap_copy (bb_tmp, bb_with);
>        basic_block last_ok = pro;
>        vec.truncate (0);
> @@ -859,7 +859,6 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq)
>
>        pro = last_ok;
>
> -      BITMAP_FREE (bb_tmp);
>        free_dominance_info (CDI_POST_DOMINATORS);
>      }
>
> @@ -871,7 +870,6 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq)
>
>    if (pro == entry)
>      {
> -      BITMAP_FREE (bb_with);
>        free_dominance_info (CDI_DOMINATORS);
>        return;
>      }
> @@ -1006,7 +1004,6 @@ try_shrink_wrapping (edge *entry_edge, rtx_insn *prologue_seq)
>    *entry_edge = make_single_succ_edge (new_bb, pro, EDGE_FALLTHRU);
>    force_nonfallthru (*entry_edge);
>
> -  BITMAP_FREE (bb_with);
>    free_dominance_info (CDI_DOMINATORS);
>  }
>
> @@ -1265,7 +1262,7 @@ spread_components (sbitmap components)
>       on that stack.  */
>    vec<basic_block> todo;
>    todo.create (n_basic_blocks_for_fn (cfun));
> -  bitmap seen = BITMAP_ALLOC (NULL);
> +  auto_bitmap seen;
>
>    sbitmap old = sbitmap_alloc (SBITMAP_SIZE (components));
>
> @@ -1395,7 +1392,6 @@ spread_components (sbitmap components)
>      }
>
>    sbitmap_free (old);
> -  BITMAP_FREE (seen);
>  }
>
>  /* If we cannot handle placing some component's prologues or epilogues where
> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
> index a540416cbb5..8fdfdd6f1bc 100644
> --- a/gcc/tree-cfg.c
> +++ b/gcc/tree-cfg.c
> @@ -8178,7 +8178,6 @@ remove_edge_and_dominated_blocks (edge e)
>  {
>    vec<basic_block> bbs_to_remove = vNULL;
>    vec<basic_block> bbs_to_fix_dom = vNULL;
> -  bitmap df, df_idom;
>    edge f;
>    edge_iterator ei;
>    bool none_removed = false;
> @@ -8227,9 +8226,7 @@ remove_edge_and_dominated_blocks (edge e)
>         }
>      }
>
> -  df = BITMAP_ALLOC (NULL);
> -  df_idom = BITMAP_ALLOC (NULL);
> -
> +  auto_bitmap df, df_idom;
>    if (none_removed)
>      bitmap_set_bit (df_idom,
>                     get_immediate_dominator (CDI_DOMINATORS, e->dest)->index);
> @@ -8296,8 +8293,6 @@ remove_edge_and_dominated_blocks (edge e)
>
>    iterate_fix_dominators (CDI_DOMINATORS, bbs_to_fix_dom, true);
>
> -  BITMAP_FREE (df);
> -  BITMAP_FREE (df_idom);
>    bbs_to_remove.release ();
>    bbs_to_fix_dom.release ();
>  }
> diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
> index 1b9950eca8e..a60454b5218 100644
> --- a/gcc/tree-loop-distribution.c
> +++ b/gcc/tree-loop-distribution.c
> @@ -1251,7 +1251,7 @@ rdg_build_partitions (struct graph *rdg,
>                       vec<gimple *> starting_stmts,
>                       vec<partition *> *partitions)
>  {
> -  bitmap processed = BITMAP_ALLOC (NULL);
> +  auto_bitmap processed;
>    int i;
>    gimple *stmt;
>
> @@ -1282,8 +1282,6 @@ rdg_build_partitions (struct graph *rdg,
>
>    /* All vertices should have been assigned to at least one partition now,
>       other than vertices belonging to dead code.  */
> -
> -  BITMAP_FREE (processed);
>  }
>
>  /* Dump to FILE the PARTITIONS.  */
> diff --git a/gcc/tree-predcom.c b/gcc/tree-predcom.c
> index 57d8f7d207c..23e7870dd2d 100644
> --- a/gcc/tree-predcom.c
> +++ b/gcc/tree-predcom.c
> @@ -2498,7 +2498,6 @@ tree_predictive_commoning_loop (struct loop *loop)
>    struct tree_niter_desc desc;
>    bool unroll = false;
>    edge exit;
> -  bitmap tmp_vars;
>
>    if (dump_file && (dump_flags & TDF_DETAILS))
>      fprintf (dump_file, "Processing loop %d\n",  loop->num);
> @@ -2549,7 +2548,7 @@ tree_predictive_commoning_loop (struct loop *loop)
>    /* Find the suitable components and split them into chains.  */
>    components = filter_suitable_components (loop, components);
>
> -  tmp_vars = BITMAP_ALLOC (NULL);
> +  auto_bitmap tmp_vars;
>    looparound_phis = BITMAP_ALLOC (NULL);
>    determine_roots (loop, components, &chains);
>    release_components (components);
> @@ -2617,7 +2616,6 @@ tree_predictive_commoning_loop (struct loop *loop)
>  end: ;
>    release_chains (chains);
>    free_data_refs (datarefs);
> -  BITMAP_FREE (tmp_vars);
>    BITMAP_FREE (looparound_phis);
>
>    free_affine_expand_cache (&name_expansions);
> diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c
> index 1b78d66456e..e166314ed4d 100644
> --- a/gcc/tree-ssa-coalesce.c
> +++ b/gcc/tree-ssa-coalesce.c
> @@ -1791,7 +1791,7 @@ coalesce_ssa_name (void)
>    tree_live_info_p liveinfo;
>    ssa_conflicts *graph;
>    coalesce_list *cl;
> -  bitmap used_in_copies = BITMAP_ALLOC (NULL);
> +  auto_bitmap used_in_copies;
>    var_map map;
>    unsigned int i;
>    tree a;
> @@ -1848,8 +1848,6 @@ coalesce_ssa_name (void)
>    else
>      compute_samebase_partition_bases (map);
>
> -  BITMAP_FREE (used_in_copies);
> -
>    if (num_var_partitions (map) < 1)
>      {
>        delete_coalesce_list (cl);
> diff --git a/gcc/tree-ssa-phionlycprop.c b/gcc/tree-ssa-phionlycprop.c
> index f61b269cd63..aa0f50256cd 100644
> --- a/gcc/tree-ssa-phionlycprop.c
> +++ b/gcc/tree-ssa-phionlycprop.c
> @@ -497,13 +497,11 @@ public:
>  unsigned int
>  pass_phi_only_cprop::execute (function *fun)
>  {
> -  bitmap interesting_names;
> -  bitmap interesting_names1;
>    bool cfg_altered = false;
>
>    /* Bitmap of blocks which need EH information updated.  We can not
>       update it on-the-fly as doing so invalidates the dominator tree.  */
> -  bitmap need_eh_cleanup = BITMAP_ALLOC (NULL);
> +  auto_bitmap need_eh_cleanup;
>
>    /* INTERESTING_NAMES is effectively our worklist, indexed by
>       SSA_NAME_VERSION.
> @@ -515,8 +513,8 @@ pass_phi_only_cprop::execute (function *fun)
>
>       Experiments have show we generally get better compilation
>       time behavior with bitmaps rather than sbitmaps.  */
> -  interesting_names = BITMAP_ALLOC (NULL);
> -  interesting_names1 = BITMAP_ALLOC (NULL);
> +  auto_bitmap interesting_names;
> +  auto_bitmap interesting_names1;
>
>    calculate_dominance_info (CDI_DOMINATORS);
>    cfg_altered = false;
> @@ -570,13 +568,8 @@ pass_phi_only_cprop::execute (function *fun)
>    /* Propagation of const and copies may make some EH edges dead.  Purge
>       such edges from the CFG as needed.  */
>    if (!bitmap_empty_p (need_eh_cleanup))
> -    {
> -      gimple_purge_all_dead_eh_edges (need_eh_cleanup);
> -      BITMAP_FREE (need_eh_cleanup);
> -    }
> +    gimple_purge_all_dead_eh_edges (need_eh_cleanup);
>
> -  BITMAP_FREE (interesting_names);
> -  BITMAP_FREE (interesting_names1);
>    return 0;
>  }
>
> diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
> index b4095bfdeed..8175d2599ed 100644
> --- a/gcc/tree-ssa-pre.c
> +++ b/gcc/tree-ssa-pre.c
> @@ -4903,12 +4903,11 @@ mark_operand_necessary (tree op)
>  static void
>  remove_dead_inserted_code (void)
>  {
> -  bitmap worklist;
>    unsigned i;
>    bitmap_iterator bi;
>    gimple *t;
>
> -  worklist = BITMAP_ALLOC (NULL);
> +  auto_bitmap worklist;
>    EXECUTE_IF_SET_IN_BITMAP (inserted_exprs, 0, i, bi)
>      {
>        t = SSA_NAME_DEF_STMT (ssa_name (i));
> @@ -4984,7 +4983,6 @@ remove_dead_inserted_code (void)
>             }
>         }
>      }
> -  BITMAP_FREE (worklist);
>  }
>
>
> diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c
> index eb8b36095d8..acf832d66f6 100644
> --- a/gcc/tree-ssa-sink.c
> +++ b/gcc/tree-ssa-sink.c
> @@ -128,7 +128,7 @@ static basic_block
>  nearest_common_dominator_of_uses (def_operand_p def_p, bool *debug_stmts)
>  {
>    tree var = DEF_FROM_PTR (def_p);
> -  bitmap blocks = BITMAP_ALLOC (NULL);
> +  auto_bitmap blocks;
>    basic_block commondom;
>    unsigned int j;
>    bitmap_iterator bi;
> @@ -158,17 +158,14 @@ nearest_common_dominator_of_uses (def_operand_p def_p, bool *debug_stmts)
>
>        /* Short circuit. Nothing dominates the entry block.  */
>        if (useblock == ENTRY_BLOCK_PTR_FOR_FN (cfun))
> -       {
> -         BITMAP_FREE (blocks);
> -         return NULL;
> -       }
> +       return NULL;
> +
>        bitmap_set_bit (blocks, useblock->index);
>      }
>    commondom = BASIC_BLOCK_FOR_FN (cfun, bitmap_first_set_bit (blocks));
>    EXECUTE_IF_SET_IN_BITMAP (blocks, 0, j, bi)
>      commondom = nearest_common_dominator (CDI_DOMINATORS, commondom,
>                                           BASIC_BLOCK_FOR_FN (cfun, j));
> -  BITMAP_FREE (blocks);
>    return commondom;
>  }
>
> diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
> index e30ddd821ed..319826861dc 100644
> --- a/gcc/tree-ssa-threadupdate.c
> +++ b/gcc/tree-ssa-threadupdate.c
> @@ -723,7 +723,7 @@ compute_path_counts (struct redirection_data *rd,
>       below to add up the counts of the other edges not included in this jump
>       threading path.  */
>    struct el *next, *el;
> -  bitmap in_edge_srcs = BITMAP_ALLOC (NULL);
> +  auto_bitmap in_edge_srcs;
>    for (el = rd->incoming_edges; el; el = next)
>      {
>        next = el->next;
> @@ -759,8 +759,6 @@ compute_path_counts (struct redirection_data *rd,
>    if (path_in_freq > BB_FREQ_MAX)
>      path_in_freq = BB_FREQ_MAX;
>
> -  BITMAP_FREE (in_edge_srcs);
> -
>    /* Now compute the fraction of the total count coming into the first
>       path bb that is from the current threading path.  */
>    gcov_type total_count = e->dest->count;
> @@ -1958,7 +1956,7 @@ mark_threaded_blocks (bitmap threaded_blocks)
>  {
>    unsigned int i;
>    bitmap_iterator bi;
> -  bitmap tmp = BITMAP_ALLOC (NULL);
> +  auto_bitmap tmp;
>    basic_block bb;
>    edge e;
>    edge_iterator ei;
> @@ -2169,8 +2167,6 @@ mark_threaded_blocks (bitmap threaded_blocks)
>             }
>         }
>      }
> -
> -  BITMAP_FREE (tmp);
>  }
>
>
> @@ -2436,8 +2432,8 @@ thread_through_all_blocks (bool may_peel_loop_headers)
>    bool retval = false;
>    unsigned int i;
>    bitmap_iterator bi;
> -  bitmap threaded_blocks;
>    struct loop *loop;
> +  auto_bitmap threaded_blocks;
>
>    if (!paths.exists ())
>      {
> @@ -2445,7 +2441,6 @@ thread_through_all_blocks (bool may_peel_loop_headers)
>        goto out;
>      }
>
> -  threaded_blocks = BITMAP_ALLOC (NULL);
>    memset (&thread_stats, 0, sizeof (thread_stats));
>
>    /* Remove any paths that referenced removed edges.  */
> @@ -2578,8 +2573,6 @@ thread_through_all_blocks (bool may_peel_loop_headers)
>
>    free_original_copy_tables ();
>
> -  BITMAP_FREE (threaded_blocks);
> -  threaded_blocks = NULL;
>    paths.release ();
>
>    if (retval)
> diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
> index 42e708ed673..11f5a2bac92 100644
> --- a/gcc/tree-ssa.c
> +++ b/gcc/tree-ssa.c
> @@ -1022,7 +1022,7 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
>    ssa_op_iter iter;
>    tree op;
>    enum dom_state orig_dom_state = dom_info_state (CDI_DOMINATORS);
> -  bitmap names_defined_in_bb = BITMAP_ALLOC (NULL);
> +  auto_bitmap names_defined_in_bb;
>
>    gcc_assert (!need_ssa_update_p (cfun));
>
> @@ -1176,7 +1176,6 @@ verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
>    else
>      set_dom_info_availability (CDI_DOMINATORS, orig_dom_state);
>
> -  BITMAP_FREE (names_defined_in_bb);
>    timevar_pop (TV_TREE_SSA_VERIFY);
>    return;
>
> @@ -1622,9 +1621,9 @@ void
>  execute_update_addresses_taken (void)
>  {
>    basic_block bb;
> -  bitmap addresses_taken = BITMAP_ALLOC (NULL);
> -  bitmap not_reg_needs = BITMAP_ALLOC (NULL);
> -  bitmap suitable_for_renaming = BITMAP_ALLOC (NULL);
> +  auto_bitmap addresses_taken;
> +  auto_bitmap not_reg_needs;
> +  auto_bitmap suitable_for_renaming;
>    tree var;
>    unsigned i;
>
> @@ -2005,9 +2004,6 @@ execute_update_addresses_taken (void)
>         update_ssa (TODO_update_ssa);
>      }
>
> -  BITMAP_FREE (not_reg_needs);
> -  BITMAP_FREE (addresses_taken);
> -  BITMAP_FREE (suitable_for_renaming);
>    timevar_pop (TV_ADDRESS_TAKEN);
>  }
>
> diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
> index 6487542eb8f..353c7b1906a 100644
> --- a/gcc/tree-ssanames.c
> +++ b/gcc/tree-ssanames.c
> @@ -127,7 +127,7 @@ verify_ssaname_freelists (struct function *fun)
>    if (!gimple_in_ssa_p (fun))
>      return;
>
> -  bitmap names_in_il = BITMAP_ALLOC (NULL);
> +  auto_bitmap names_in_il;
>
>    /* Walk the entire IL noting every SSA_NAME we see.  */
>    basic_block bb;
> @@ -165,7 +165,7 @@ verify_ssaname_freelists (struct function *fun)
>
>    /* Now walk the free list noting what we find there and verifying
>       there are no duplicates.  */
> -  bitmap names_in_freelists = BITMAP_ALLOC (NULL);
> +  auto_bitmap names_in_freelists;
>    if (FREE_SSANAMES (fun))
>      {
>        for (unsigned int i = 0; i < FREE_SSANAMES (fun)->length (); i++)
> @@ -221,7 +221,7 @@ verify_ssaname_freelists (struct function *fun)
>
>    unsigned int i;
>    bitmap_iterator bi;
> -  bitmap all_names = BITMAP_ALLOC (NULL);
> +  auto_bitmap all_names;
>    bitmap_set_range (all_names, UNUSED_NAME_VERSION + 1, num_ssa_names - 1);
>    bitmap_ior_into (names_in_il, names_in_freelists);
>
> @@ -230,10 +230,6 @@ verify_ssaname_freelists (struct function *fun)
>    EXECUTE_IF_AND_COMPL_IN_BITMAP(all_names, names_in_il,
>                                  UNUSED_NAME_VERSION + 1, i, bi)
>      gcc_assert (!ssa_name (i));
> -
> -  BITMAP_FREE (all_names);
> -  BITMAP_FREE (names_in_freelists);
> -  BITMAP_FREE (names_in_il);
>  }
>
>  /* Move all SSA_NAMEs from FREE_SSA_NAMES_QUEUE to FREE_SSA_NAMES.
> --
> 2.11.0
>

  reply	other threads:[~2017-05-10  8:27 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 20:53 [PATCH 00/13] misc data structure stuff tbsaunde+gcc
2017-05-09 20:53 ` [PATCH 01/13] improve safety of freeing bitmaps tbsaunde+gcc
2017-05-10  8:15   ` Richard Biener
2017-05-10 10:55     ` Trevor Saunders
2017-05-10 11:11       ` Richard Biener
2017-05-09 20:53 ` [PATCH 12/13] make depth_first_search_ds a class tbsaunde+gcc
2017-05-10  8:29   ` Richard Biener
2017-05-09 20:53 ` [PATCH 06/13] replace some manual stacks with auto_vec tbsaunde+gcc
2017-05-10  8:26   ` Richard Biener
2017-05-09 20:53 ` [PATCH 05/13] allow constructing a auto_vec with a preallocation, and a possibly larger actual allocation size tbsaunde+gcc
2017-05-10  6:58   ` Richard Sandiford
2017-05-11  7:50     ` Trevor Saunders
2017-05-11  8:18       ` Richard Biener
2017-05-11  8:23         ` Trevor Saunders
2017-05-11  9:04           ` Richard Sandiford
2017-05-09 20:53 ` [PATCH 03/13] store the bitmap_head within the auto_bitmap tbsaunde+gcc
2017-05-10  8:25   ` Richard Biener
2017-05-09 20:53 ` [PATCH 02/13] improve bitmap / sbitmap compatability of bitmap_set_bit tbsaunde+gcc
2017-05-10  6:54   ` Richard Sandiford
2017-05-11  8:01     ` Trevor Saunders
2017-05-09 20:53 ` [PATCH 10/13] make a member an auto_sbitmap tbsaunde+gcc
2017-05-10  8:26   ` Richard Biener
2017-05-09 20:53 ` [PATCH 08/13] move several bitmaps from gc memory to the default obstack and use auto_bitmap tbsaunde+gcc
2017-05-10  8:26   ` Richard Biener
2017-05-09 20:53 ` [PATCH 07/13] use auto_bitmap more tbsaunde+gcc
2017-05-10  8:28   ` Richard Biener [this message]
2017-05-09 20:53 ` [PATCH 09/13] use auto_bitmap more with alternate obstacks tbsaunde+gcc
2017-05-10  8:31   ` Richard Biener
2017-05-09 20:53 ` [PATCH 13/13] make inverted_post_order_compute() operate on a vec tbsaunde+gcc
2017-05-10  8:44   ` Richard Biener
2017-05-09 20:53 ` [PATCH 04/13] allow auto_bitmap to use other bitmap obstacks tbsaunde+gcc
2017-05-10  8:27   ` Richard Biener
2017-05-09 20:55 ` [PATCH 11/13] make more vars auto_sbitmaps tbsaunde+gcc
2017-05-10  8:27   ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc0WsEmj2WjKDWV8ijNAL8rvmnustpZVqWaZDequYyj8VQ@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tbsaunde+gcc@tbsaunde.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).