aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfgexpand.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/cfgexpand.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/cfgexpand.c')
-rw-r--r--gcc/cfgexpand.c50
1 files changed, 30 insertions, 20 deletions
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index da383a9..91457eb 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -185,6 +185,10 @@ static size_t stack_vars_alloc;
static size_t stack_vars_num;
static struct pointer_map_t *decl_to_stack_part;
+/* Conflict bitmaps go on this obstack. This allows us to destroy
+ all of them in one big sweep. */
+static bitmap_obstack stack_var_bitmap_obstack;
+
/* An array of indices such that stack_vars[stack_vars_sorted[i]].size
is non-decreasing. */
static size_t *stack_vars_sorted;
@@ -299,9 +303,9 @@ add_stack_var_conflict (size_t x, size_t y)
struct stack_var *a = &stack_vars[x];
struct stack_var *b = &stack_vars[y];
if (!a->conflicts)
- a->conflicts = BITMAP_ALLOC (NULL);
+ a->conflicts = BITMAP_ALLOC (&stack_var_bitmap_obstack);
if (!b->conflicts)
- b->conflicts = BITMAP_ALLOC (NULL);
+ b->conflicts = BITMAP_ALLOC (&stack_var_bitmap_obstack);
bitmap_set_bit (a->conflicts, y);
bitmap_set_bit (b->conflicts, x);
}
@@ -431,7 +435,7 @@ add_scope_conflicts_1 (basic_block bb, bitmap work, bool for_conflict)
{
struct stack_var *a = &stack_vars[i];
if (!a->conflicts)
- a->conflicts = BITMAP_ALLOC (NULL);
+ a->conflicts = BITMAP_ALLOC (&stack_var_bitmap_obstack);
bitmap_ior_into (a->conflicts, work);
}
visit = visit_conflict;
@@ -464,7 +468,7 @@ add_scope_conflicts (void)
We then do a mostly classical bitmap liveness algorithm. */
FOR_ALL_BB (bb)
- bb->aux = BITMAP_ALLOC (NULL);
+ bb->aux = BITMAP_ALLOC (&stack_var_bitmap_obstack);
rpo = XNEWVEC (int, last_basic_block);
n_bbs = pre_and_rev_post_order_compute (NULL, rpo, false);
@@ -647,7 +651,7 @@ update_alias_info_with_stack_vars (void)
{
unsigned i;
struct pointer_set_t *visited = pointer_set_create ();
- bitmap temp = BITMAP_ALLOC (NULL);
+ bitmap temp = BITMAP_ALLOC (&stack_var_bitmap_obstack);
for (i = 1; i < num_ssa_names; i++)
{
@@ -1378,14 +1382,11 @@ create_stack_guard (void)
static void
init_vars_expansion (void)
{
- tree t;
- unsigned ix;
- /* Set TREE_USED on all variables in the local_decls. */
- FOR_EACH_LOCAL_DECL (cfun, ix, t)
- TREE_USED (t) = 1;
+ /* Conflict bitmaps, and a few related temporary bitmaps, go here. */
+ bitmap_obstack_initialize (&stack_var_bitmap_obstack);
- /* Clear TREE_USED on all variables associated with a block scope. */
- clear_tree_used (DECL_INITIAL (current_function_decl));
+ /* A map from decl to stack partition. */
+ decl_to_stack_part = pointer_map_create ();
/* Initialize local stack smashing state. */
has_protected_decls = false;
@@ -1396,11 +1397,11 @@ init_vars_expansion (void)
static void
fini_vars_expansion (void)
{
- size_t i, n = stack_vars_num;
- for (i = 0; i < n; i++)
- BITMAP_FREE (stack_vars[i].conflicts);
- XDELETEVEC (stack_vars);
- XDELETEVEC (stack_vars_sorted);
+ bitmap_obstack_release (&stack_var_bitmap_obstack);
+ if (stack_vars)
+ XDELETEVEC (stack_vars);
+ if (stack_vars_sorted)
+ XDELETEVEC (stack_vars_sorted);
stack_vars = NULL;
stack_vars_sorted = NULL;
stack_vars_alloc = stack_vars_num = 0;
@@ -1428,6 +1429,8 @@ estimated_stack_frame_size (struct cgraph_node *node)
current_function_decl = node->symbol.decl;
push_cfun (fn);
+ init_vars_expansion ();
+
FOR_EACH_LOCAL_DECL (fn, i, var)
if (auto_var_in_fn_p (var, fn->decl))
size += expand_one_var (var, true, false);
@@ -1439,8 +1442,9 @@ estimated_stack_frame_size (struct cgraph_node *node)
for (i = 0; i < stack_vars_num; ++i)
stack_vars_sorted[i] = i;
size += account_stack_vars ();
- fini_vars_expansion ();
}
+
+ fini_vars_expansion ();
pop_cfun ();
current_function_decl = old_cur_fun_decl;
return size;
@@ -1464,6 +1468,12 @@ expand_used_vars (void)
frame_phase = off ? align - off : 0;
}
+ /* Set TREE_USED on all variables in the local_decls. */
+ FOR_EACH_LOCAL_DECL (cfun, i, var)
+ TREE_USED (var) = 1;
+ /* Clear TREE_USED on all variables associated with a block scope. */
+ clear_tree_used (DECL_INITIAL (current_function_decl));
+
init_vars_expansion ();
ssa_name_decls = pointer_map_create ();
@@ -1613,10 +1623,10 @@ expand_used_vars (void)
}
expand_stack_vars (NULL);
-
- fini_vars_expansion ();
}
+ fini_vars_expansion ();
+
/* If there were any artificial non-ignored vars without rtl
found earlier, see if deferred stack allocation hasn't assigned
rtl to them. */