+2017-05-13 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.
+
2017-05-13 Trevor Saunders <tbsaunde+gcc@tbsaunde.org>
* cfganal.c (mark_dfs_back_edges): Replace manual stack with
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)
delete_insn (other_def->insn);
}
- BITMAP_FREE (combined_live_range);
}
}
}
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;
}
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
if (dump_file)
fprintf (dump_file, "failed to move\n");
}
- BITMAP_FREE (live_range);
+
return !give_up;
}
{
basic_block *blocks;
basic_block bb;
- bitmap visited;
unsigned int i = 1;
unsigned int vc = 0;
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)
}
}
- BITMAP_FREE (visited);
return blocks;
}
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);
}
free (stack);
- BITMAP_FREE (visited);
return post_order_num;
}
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
}
free (stack);
- BITMAP_FREE (visited);
return post_order_num;
}
#include "vec.h"
#include "hash-table.h"
#include "basic-block.h"
+#include "bitmap.h"
/* Return true if the compiler should produce HSAIL. */
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);
/* 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 ();
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;
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. */
initialize_uninitialized_regs (void)
{
basic_block bb;
- bitmap already_genned = BITMAP_ALLOC (NULL);
+ auto_bitmap already_genned;
if (optimize == 1)
{
df_dump (dump_file);
df_remove_problem (df_live);
}
-
- BITMAP_FREE (already_genned);
}
namespace {
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 ();
updated_nodes, NULL);
update_callee_keys (edge_heap, where,
updated_nodes);
- BITMAP_FREE (updated_nodes);
}
}
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;
"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);
}
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);
ltrans_statics_bitcount);
}
}
- BITMAP_FREE (ltrans_statics);
lto_destroy_simple_output_block (ob);
splay_tree_delete (reference_vars_to_consider);
}
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++)
df_insn_rescan (insn);
}
}
-
- BITMAP_FREE (cleared_regs);
}
/* A pass over indirect jumps, converting simple cases to direct jumps.
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
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))
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);
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);
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);
}
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
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
tree type;
tree val;
enum tree_code cmp;
- bitmap visited;
edge_iterator ei;
enum br_predictor predictor;
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)
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. */
}
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);
edge e;
basic_block *bbs;
unsigned i;
- bitmap tovisit = BITMAP_ALLOC (NULL);
+ auto_bitmap tovisit;
estimate_loops_at_level (loop->inner);
bitmap_set_bit (tovisit, bbs[i]->index);
free (bbs);
propagate_freq (loop->header, tovisit);
- BITMAP_FREE (tovisit);
}
}
static void
estimate_loops (void)
{
- bitmap tovisit = BITMAP_ALLOC (NULL);
+ auto_bitmap tovisit;
basic_block bb;
/* Start by estimating the frequencies in the loops. */
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
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;
{
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);
pro = last_ok;
- BITMAP_FREE (bb_tmp);
free_dominance_info (CDI_POST_DOMINATORS);
}
if (pro == entry)
{
- BITMAP_FREE (bb_with);
free_dominance_info (CDI_DOMINATORS);
return;
}
*entry_edge = make_single_succ_edge (new_bb, pro, EDGE_FALLTHRU);
force_nonfallthru (*entry_edge);
- BITMAP_FREE (bb_with);
free_dominance_info (CDI_DOMINATORS);
}
\f
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));
}
sbitmap_free (old);
- BITMAP_FREE (seen);
}
/* If we cannot handle placing some component's prologues or epilogues where
{
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;
}
}
- 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);
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 ();
}
vec<gimple *> starting_stmts,
vec<partition *> *partitions)
{
- bitmap processed = BITMAP_ALLOC (NULL);
+ auto_bitmap processed;
int i;
gimple *stmt;
/* 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. */
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);
/* 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);
end: ;
release_chains (chains);
free_data_refs (datarefs);
- BITMAP_FREE (tmp_vars);
BITMAP_FREE (looparound_phis);
free_affine_expand_cache (&name_expansions);
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;
else
compute_samebase_partition_bases (map);
- BITMAP_FREE (used_in_copies);
-
if (num_var_partitions (map) < 1)
{
delete_coalesce_list (cl);
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.
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;
/* 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;
}
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));
}
if (to_clear != -1U)
bitmap_clear_bit (inserted_exprs, to_clear);
- BITMAP_FREE (worklist);
}
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;
/* 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;
}
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;
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;
{
unsigned int i;
bitmap_iterator bi;
- bitmap tmp = BITMAP_ALLOC (NULL);
+ auto_bitmap tmp;
basic_block bb;
edge e;
edge_iterator ei;
}
}
}
-
- BITMAP_FREE (tmp);
}
bool retval = false;
unsigned int i;
bitmap_iterator bi;
- bitmap threaded_blocks;
struct loop *loop;
+ auto_bitmap threaded_blocks;
if (!paths.exists ())
{
goto out;
}
- threaded_blocks = BITMAP_ALLOC (NULL);
memset (&thread_stats, 0, sizeof (thread_stats));
/* Remove any paths that referenced removed edges. */
free_original_copy_tables ();
- BITMAP_FREE (threaded_blocks);
- threaded_blocks = NULL;
paths.release ();
if (retval)
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));
else
set_dom_info_availability (CDI_DOMINATORS, orig_dom_state);
- BITMAP_FREE (names_defined_in_bb);
timevar_pop (TV_TREE_SSA_VERIFY);
return;
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;
update_ssa (TODO_update_ssa);
}
- BITMAP_FREE (not_reg_needs);
- BITMAP_FREE (addresses_taken);
- BITMAP_FREE (suitable_for_renaming);
timevar_pop (TV_ADDRESS_TAKEN);
}
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;
/* 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++)
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);
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.