aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-live.c
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2012-08-17 09:42:06 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2012-08-17 09:42:06 +0000
commit3f9b14ffa3cefe2c35111fa9f067dab4e92dcdc8 (patch)
tree0ebbe8deabfc8b9cc126c002c0f1e91f0ac0ea98 /gcc/tree-ssa-live.c
parenta69b2a7d8260addd968fdff64bb3b706560cecd7 (diff)
downloadgcc-3f9b14ffa3cefe2c35111fa9f067dab4e92dcdc8.zip
gcc-3f9b14ffa3cefe2c35111fa9f067dab4e92dcdc8.tar.gz
gcc-3f9b14ffa3cefe2c35111fa9f067dab4e92dcdc8.tar.bz2
re PR middle-end/54146 (Very slow compile with attribute((flatten)))
PR middle-end/54146 * tree-ssa-loop-im.c (lim_bitmap_obstack): New bitmap_obstack. (memref_free): Don't free the bitmaps individually here. (mem_ref_alloc): Allocate the bitmaps on the new bitmap obstack. (analyze_memory_references): Likewise. (tree_ssa_lim_initialize): Initialize the new bitmap obstack. (tree_ssa_lim_finalize): Release it. * dse.c (dse_bitmap_obstack): New bitmap obstack. (dse_obstack): New obstack. (get_group_info): Allocate the bitmaps on the new bitmap obstack. (dse_step0): Allocate the scratch bitmap on reg_obstack. Initialize the new bitmap obstack and normal obstack. Use XNEWVEC for bb_table. (record_store): Allocate regs_set on reg_obstack. (dse_step1): Allocate regs_live on reg_obstack. (dse_step2_init): Allocate offset_map_n and offset_map_p on the new obstack. (dse_step3_scan): Allocate bitmaps on the new bitmap obstack. (dse_step3): Likewise. (dse_confluence_0): Likewise. (dse_confluence_n): Likewise. (dse_transfer_function): Likewise. (dse_step7): Destroy the new obstacks, and everything allocated on them, in one big sweep. (rest_of_handle_dse): Update. * cfgexpand.c (stack_var_bitmap_obstack): New bitmap obstack. (add_stack_var_conflict): Allocate bitmaps on it. (add_scope_conflicts_1): Likewise. (add_scope_conflicts): Likewise. (update_alias_info_with_stack_vars): Likewise. (init_vars_expansion): Move TREE_USED fiddling expand_used_vars. Initialize the new bitmap obstack. (fini_vars_expansion): Release it. (estimated_stack_frame_size): Use init_vars_expansion to set things up and always clean up at the end. (expand_used_vars): Do the TREE_USED trickery here. Always call fini_vars_expansion. * tree-ssa-live.h (struct tree_live_info_d): Make livein and liveout arrays of bitmap_head to avoid one indirection per bitmap access. (live_on_entry, live_on_exit, live_var_map, live_merge_and_clear, make_live_on_entry): Update. * tree-ssa-live.c (partition_view_bitmap): Don't double-free 'used'. (liveness_bitmap_obstack): New bitmap obstack. (remove_unused_locals): Use it to allocate all bitmaps on. Update for livein/liveout changes in tree-ssa-live.h. (delete_tree_live_info): Release the bitmap obstack. (loe_visit_block, live_worklist, set_var_live_on_entry, calculate_live_on_exit, dump_live_info): Update. (calculate_live_ranges): Initialize the bitmap. * tree-ssa-ter.c (ter_bitmap_obstack): New bitmap obstack. (new_temp_expr_table): Allocate bitmap on it. (make_dependent_on_partition, add_to_partition_kill_list, add_dependence, process_replaceable): Likewise. (find_replaceable_exprs): Initialize and release the new obstack here. * df-problems.c (df_lr_add_problem): Allocate persistent bitmap for out_of_date_transfer_functions on df_bitmap_obstack. (df_live_add_problem): Likewise. (df_chain_add_problem): Likewise. (df_word_lr_add_problem): Likewise. From-SVN: r190475
Diffstat (limited to 'gcc/tree-ssa-live.c')
-rw-r--r--gcc/tree-ssa-live.c59
1 files changed, 28 insertions, 31 deletions
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index bd6ac9a..f4ecaf3 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -293,7 +293,7 @@ partition_view_fini (var_map map, bitmap selected)
/* Create a partition view which includes all the used partitions in MAP. If
WANT_BASES is true, create the base variable map as well. */
-extern void
+void
partition_view_normal (var_map map, bool want_bases)
{
bitmap used;
@@ -312,7 +312,7 @@ partition_view_normal (var_map map, bool want_bases)
the bitmap ONLY. If WANT_BASES is true, create the base variable map
as well. */
-extern void
+void
partition_view_bitmap (var_map map, bitmap only, bool want_bases)
{
bitmap used;
@@ -329,7 +329,6 @@ partition_view_bitmap (var_map map, bitmap only, bool want_bases)
}
partition_view_fini (map, new_partitions);
- BITMAP_FREE (used);
if (want_bases)
var_map_base_init (map);
else
@@ -849,6 +848,12 @@ remove_unused_locals (void)
timevar_pop (TV_REMOVE_UNUSED);
}
+/* Obstack for globale liveness info bitmaps. We don't want to put these
+ on the default obstack because these bitmaps can grow quite large and
+ we'll hold on to all that memory until the end of the compiler run.
+ As a bonus, delete_tree_live_info can destroy all the bitmaps by just
+ releasing the whole obstack. */
+static bitmap_obstack liveness_bitmap_obstack;
/* Allocate and return a new live range information object base on MAP. */
@@ -856,24 +861,24 @@ static tree_live_info_p
new_tree_live_info (var_map map)
{
tree_live_info_p live;
- unsigned x;
+ basic_block bb;
- live = (tree_live_info_p) xmalloc (sizeof (struct tree_live_info_d));
+ live = XNEW (struct tree_live_info_d);
live->map = map;
live->num_blocks = last_basic_block;
- live->livein = (bitmap *)xmalloc (last_basic_block * sizeof (bitmap));
- for (x = 0; x < (unsigned)last_basic_block; x++)
- live->livein[x] = BITMAP_ALLOC (NULL);
+ live->livein = XNEWVEC (bitmap_head, last_basic_block);
+ FOR_EACH_BB (bb)
+ bitmap_initialize (&live->livein[bb->index], &liveness_bitmap_obstack);
- live->liveout = (bitmap *)xmalloc (last_basic_block * sizeof (bitmap));
- for (x = 0; x < (unsigned)last_basic_block; x++)
- live->liveout[x] = BITMAP_ALLOC (NULL);
+ live->liveout = XNEWVEC (bitmap_head, last_basic_block);
+ FOR_EACH_BB (bb)
+ bitmap_initialize (&live->liveout[bb->index], &liveness_bitmap_obstack);
live->work_stack = XNEWVEC (int, last_basic_block);
live->stack_top = live->work_stack;
- live->global = BITMAP_ALLOC (NULL);
+ live->global = BITMAP_ALLOC (&liveness_bitmap_obstack);
return live;
}
@@ -883,19 +888,10 @@ new_tree_live_info (var_map map)
void
delete_tree_live_info (tree_live_info_p live)
{
- int x;
-
- BITMAP_FREE (live->global);
+ bitmap_obstack_release (&liveness_bitmap_obstack);
free (live->work_stack);
-
- for (x = live->num_blocks - 1; x >= 0; x--)
- BITMAP_FREE (live->liveout[x]);
free (live->liveout);
-
- for (x = live->num_blocks - 1; x >= 0; x--)
- BITMAP_FREE (live->livein[x]);
free (live->livein);
-
free (live);
}
@@ -928,7 +924,7 @@ loe_visit_block (tree_live_info_p live, basic_block bb, sbitmap visited,
predecessor block. This should be the live on entry vars to pred.
Note that liveout is the DEFs in a block while live on entry is
being calculated. */
- bitmap_and_compl (tmp, loe, live->liveout[pred_bb->index]);
+ bitmap_and_compl (tmp, loe, &live->liveout[pred_bb->index]);
/* Add these bits to live-on-entry for the pred. if there are any
changes, and pred_bb has been visited already, add it to the
@@ -952,7 +948,7 @@ live_worklist (tree_live_info_p live)
unsigned b;
basic_block bb;
sbitmap visited = sbitmap_alloc (last_basic_block + 1);
- bitmap tmp = BITMAP_ALLOC (NULL);
+ bitmap tmp = BITMAP_ALLOC (&liveness_bitmap_obstack);
sbitmap_zero (visited);
@@ -997,7 +993,7 @@ set_var_live_on_entry (tree ssa_name, tree_live_info_p live)
def_bb = gimple_bb (stmt);
/* Mark defs in liveout bitmap temporarily. */
if (def_bb)
- bitmap_set_bit (live->liveout[def_bb->index], p);
+ bitmap_set_bit (&live->liveout[def_bb->index], p);
}
else
def_bb = ENTRY_BLOCK_PTR;
@@ -1036,7 +1032,7 @@ set_var_live_on_entry (tree ssa_name, tree_live_info_p live)
if (add_block)
{
global = true;
- bitmap_set_bit (live->livein[add_block->index], p);
+ bitmap_set_bit (&live->livein[add_block->index], p);
}
}
@@ -1058,7 +1054,7 @@ calculate_live_on_exit (tree_live_info_p liveinfo)
/* live on entry calculations used liveout vectors for defs, clear them. */
FOR_EACH_BB (bb)
- bitmap_clear (liveinfo->liveout[bb->index]);
+ bitmap_clear (&liveinfo->liveout[bb->index]);
/* Set all the live-on-exit bits for uses in PHIs. */
FOR_EACH_BB (bb)
@@ -1083,14 +1079,14 @@ calculate_live_on_exit (tree_live_info_p liveinfo)
continue;
e = gimple_phi_arg_edge (phi, i);
if (e->src != ENTRY_BLOCK_PTR)
- bitmap_set_bit (liveinfo->liveout[e->src->index], p);
+ bitmap_set_bit (&liveinfo->liveout[e->src->index], p);
}
}
/* Add each successors live on entry to this bock live on exit. */
FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest != EXIT_BLOCK_PTR)
- bitmap_ior_into (liveinfo->liveout[bb->index],
+ bitmap_ior_into (&liveinfo->liveout[bb->index],
live_on_entry (liveinfo, e->dest));
}
}
@@ -1106,6 +1102,7 @@ calculate_live_ranges (var_map map)
unsigned i;
tree_live_info_p live;
+ bitmap_obstack_initialize (&liveness_bitmap_obstack);
live = new_tree_live_info (map);
for (i = 0; i < num_var_partitions (map); i++)
{
@@ -1185,7 +1182,7 @@ dump_live_info (FILE *f, tree_live_info_p live, int flag)
FOR_EACH_BB (bb)
{
fprintf (f, "\nLive on entry to BB%d : ", bb->index);
- EXECUTE_IF_SET_IN_BITMAP (live->livein[bb->index], 0, i, bi)
+ EXECUTE_IF_SET_IN_BITMAP (&live->livein[bb->index], 0, i, bi)
{
print_generic_expr (f, partition_to_var (map, i), TDF_SLIM);
fprintf (f, " ");
@@ -1199,7 +1196,7 @@ dump_live_info (FILE *f, tree_live_info_p live, int flag)
FOR_EACH_BB (bb)
{
fprintf (f, "\nLive on exit from BB%d : ", bb->index);
- EXECUTE_IF_SET_IN_BITMAP (live->liveout[bb->index], 0, i, bi)
+ EXECUTE_IF_SET_IN_BITMAP (&live->liveout[bb->index], 0, i, bi)
{
print_generic_expr (f, partition_to_var (map, i), TDF_SLIM);
fprintf (f, " ");