diff options
Diffstat (limited to 'gcc/tree-into-ssa.c')
-rw-r--r-- | gcc/tree-into-ssa.c | 140 |
1 files changed, 66 insertions, 74 deletions
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c index c5789663f8a..2a389895d3d 100644 --- a/gcc/tree-into-ssa.c +++ b/gcc/tree-into-ssa.c @@ -39,7 +39,6 @@ along with GCC; see the file COPYING3. If not see #include "cfgloop.h" #include "domwalk.h" #include "params.h" -#include "vecprim.h" #include "diagnostic-core.h" @@ -84,7 +83,7 @@ typedef struct def_blocks_d *def_blocks_p; - A NULL node at the top entry is used to mark the last slot associated with the current block. */ -static VEC(tree,heap) *block_defs_stack; +static vec<tree> block_defs_stack; /* Set of existing SSA names being replaced by update_ssa. */ @@ -102,10 +101,10 @@ sbitmap interesting_blocks; released after we finish updating the SSA web. */ static bitmap names_to_release; -/* VEC of VECs of PHIs to rewrite in a basic block. Element I corresponds +/* vec of vec of PHIs to rewrite in a basic block. Element I corresponds the to basic block with index I. Allocated once per compilation, *not* released between different functions. */ -static VEC(gimple_vec, heap) *phis_to_rewrite; +static vec<gimple_vec> phis_to_rewrite; /* The bitmap of non-NULL elements of PHIS_TO_REWRITE. */ static bitmap blocks_with_phis_to_rewrite; @@ -161,8 +160,6 @@ struct var_info_d /* The information associated with decls. */ typedef struct var_info_d *var_info_p; -DEF_VEC_P(var_info_p); -DEF_VEC_ALLOC_P(var_info_p,heap); /* Each entry in VAR_INFOS contains an element of type STRUCT VAR_INFO_D. */ @@ -186,10 +183,8 @@ struct ssa_name_info /* The information associated with names. */ typedef struct ssa_name_info *ssa_name_info_p; -DEF_VEC_P (ssa_name_info_p); -DEF_VEC_ALLOC_P (ssa_name_info_p, heap); -static VEC(ssa_name_info_p, heap) *info_for_ssa_name; +static vec<ssa_name_info_p> info_for_ssa_name; static unsigned current_info_for_ssa_name_age; static bitmap_obstack update_ssa_obstack; @@ -235,7 +230,7 @@ extern void debug_currdefs (void); /* The set of symbols we ought to re-write into SSA form in update_ssa. */ static bitmap symbols_to_rename_set; -static VEC(tree,heap) *symbols_to_rename; +static vec<tree> symbols_to_rename; /* Mark SYM for renaming. */ @@ -245,7 +240,7 @@ mark_for_renaming (tree sym) if (!symbols_to_rename_set) symbols_to_rename_set = BITMAP_ALLOC (NULL); if (bitmap_set_bit (symbols_to_rename_set, DECL_UID (sym))) - VEC_safe_push (tree, heap, symbols_to_rename, sym); + symbols_to_rename.safe_push (sym); } /* Return true if SYM is marked for renaming. */ @@ -309,22 +304,21 @@ static inline ssa_name_info_p get_ssa_name_ann (tree name) { unsigned ver = SSA_NAME_VERSION (name); - unsigned len = VEC_length (ssa_name_info_p, info_for_ssa_name); + unsigned len = info_for_ssa_name.length (); struct ssa_name_info *info; /* Re-allocate the vector at most once per update/into-SSA. */ if (ver >= len) - VEC_safe_grow_cleared (ssa_name_info_p, heap, - info_for_ssa_name, num_ssa_names); + info_for_ssa_name.safe_grow_cleared (num_ssa_names); /* But allocate infos lazily. */ - info = VEC_index (ssa_name_info_p, info_for_ssa_name, ver); + info = info_for_ssa_name[ver]; if (!info) { info = XCNEW (struct ssa_name_info); info->age = current_info_for_ssa_name_age; info->info.need_phi_state = NEED_PHI_STATE_UNKNOWN; - VEC_replace (ssa_name_info_p, info_for_ssa_name, ver, info); + info_for_ssa_name[ver] = info; } if (info->age < current_info_for_ssa_name_age) @@ -734,7 +728,7 @@ find_dfsnum_interval (struct dom_dfsnum *defs, unsigned n, unsigned s) static void prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses) { - VEC(int, heap) *worklist; + vec<int> worklist; bitmap_iterator bi; unsigned i, b, p, u, top; bitmap live_phis; @@ -806,8 +800,8 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses) dfs_out numbers, increase the dfs number by one (so that it corresponds to the start of the following interval, not to the end of the current one). We use WORKLIST as a stack. */ - worklist = VEC_alloc (int, heap, n_defs + 1); - VEC_quick_push (int, worklist, 1); + worklist.create (n_defs + 1); + worklist.quick_push (1); top = 1; n_defs = 1; for (i = 1; i < adef; i++) @@ -817,8 +811,8 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses) { /* This is a closing element. Interval corresponding to the top of the stack after removing it follows. */ - VEC_pop (int, worklist); - top = VEC_index (int, worklist, VEC_length (int, worklist) - 1); + worklist.pop (); + top = worklist[worklist.length () - 1]; defs[n_defs].bb_index = top; defs[n_defs].dfs_num = defs[i].dfs_num + 1; } @@ -828,7 +822,7 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses) it to the correct position. */ defs[n_defs].bb_index = defs[i].bb_index; defs[n_defs].dfs_num = defs[i].dfs_num; - VEC_quick_push (int, worklist, b); + worklist.quick_push (b); top = b; } @@ -839,19 +833,19 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses) else n_defs++; } - VEC_pop (int, worklist); - gcc_assert (VEC_empty (int, worklist)); + worklist.pop (); + gcc_assert (worklist.is_empty ()); /* Now process the uses. */ live_phis = BITMAP_ALLOC (NULL); EXECUTE_IF_SET_IN_BITMAP (uses, 0, i, bi) { - VEC_safe_push (int, heap, worklist, i); + worklist.safe_push (i); } - while (!VEC_empty (int, worklist)) + while (!worklist.is_empty ()) { - b = VEC_pop (int, worklist); + b = worklist.pop (); if (b == ENTRY_BLOCK) continue; @@ -889,11 +883,11 @@ prune_unused_phi_nodes (bitmap phis, bitmap kills, bitmap uses) continue; bitmap_set_bit (uses, u); - VEC_safe_push (int, heap, worklist, u); + worklist.safe_push (u); } } - VEC_free (int, heap, worklist); + worklist.release (); bitmap_copy (phis, live_phis); BITMAP_FREE (live_phis); free (defs); @@ -932,15 +926,14 @@ mark_phi_for_rewrite (basic_block bb, gimple phi) bitmap_set_bit (blocks_with_phis_to_rewrite, idx); n = (unsigned) last_basic_block + 1; - if (VEC_length (gimple_vec, phis_to_rewrite) < n) - VEC_safe_grow_cleared (gimple_vec, heap, phis_to_rewrite, n); + if (phis_to_rewrite.length () < n) + phis_to_rewrite.safe_grow_cleared (n); - phis = VEC_index (gimple_vec, phis_to_rewrite, idx); - if (!phis) - phis = VEC_alloc (gimple, heap, 10); + phis = phis_to_rewrite[idx]; + phis.reserve (10); - VEC_safe_push (gimple, heap, phis, phi); - VEC_replace (gimple_vec, phis_to_rewrite, idx, phis); + phis.safe_push (phi); + phis_to_rewrite[idx] = phis; } /* Insert PHI nodes for variable VAR using the iterated dominance @@ -1049,27 +1042,27 @@ insert_phi_nodes (bitmap_head *dfs) htab_iterator hi; unsigned i; var_info_p info; - VEC(var_info_p,heap) *vars; + vec<var_info_p> vars; timevar_push (TV_TREE_INSERT_PHI_NODES); - vars = VEC_alloc (var_info_p, heap, htab_elements (var_infos)); + vars.create (htab_elements (var_infos)); FOR_EACH_HTAB_ELEMENT (var_infos, info, var_info_p, hi) if (info->info.need_phi_state != NEED_PHI_STATE_NO) - VEC_quick_push (var_info_p, vars, info); + vars.quick_push (info); /* Do two stages to avoid code generation differences for UID differences but no UID ordering differences. */ - VEC_qsort (var_info_p, vars, insert_phi_nodes_compare_var_infos); + vars.qsort (insert_phi_nodes_compare_var_infos); - FOR_EACH_VEC_ELT (var_info_p, vars, i, info) + FOR_EACH_VEC_ELT (vars, i, info) { bitmap idf = compute_idf (info->info.def_blocks.def_blocks, dfs); insert_phi_nodes_for (info->var, idf, false); BITMAP_FREE (idf); } - VEC_free(var_info_p, heap, vars); + vars.release (); timevar_pop (TV_TREE_INSERT_PHI_NODES); } @@ -1105,7 +1098,7 @@ register_new_def (tree def, tree sym) in the stack so that we know which symbol is being defined by this SSA name when we unwind the stack. */ if (currdef && !is_gimple_reg (sym)) - VEC_safe_push (tree, heap, block_defs_stack, sym); + block_defs_stack.safe_push (sym); /* Push the current reaching definition into BLOCK_DEFS_STACK. This stack is later used by the dominator tree callbacks to restore @@ -1113,7 +1106,7 @@ register_new_def (tree def, tree sym) block after a recursive visit to all its immediately dominated blocks. If there is no current reaching definition, then just record the underlying _DECL node. */ - VEC_safe_push (tree, heap, block_defs_stack, currdef ? currdef : sym); + block_defs_stack.safe_push (currdef ? currdef : sym); /* Set the current reaching definition for SYM to be DEF. */ info->current_def = def; @@ -1388,7 +1381,7 @@ rewrite_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index); /* Mark the unwind point for this block. */ - VEC_safe_push (tree, heap, block_defs_stack, NULL_TREE); + block_defs_stack.safe_push (NULL_TREE); /* Step 1. Register new definitions for every PHI node in the block. Conceptually, all the PHI nodes are executed in parallel and each PHI @@ -1423,9 +1416,9 @@ rewrite_leave_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, basic_block bb ATTRIBUTE_UNUSED) { /* Restore CURRDEFS to its original state. */ - while (VEC_length (tree, block_defs_stack) > 0) + while (block_defs_stack.length () > 0) { - tree tmp = VEC_pop (tree, block_defs_stack); + tree tmp = block_defs_stack.pop (); tree saved_def, var; if (tmp == NULL_TREE) @@ -1443,7 +1436,7 @@ rewrite_leave_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, saved_def = tmp; var = SSA_NAME_VAR (saved_def); if (!is_gimple_reg (var)) - var = VEC_pop (tree, block_defs_stack); + var = block_defs_stack.pop (); } else { @@ -1511,11 +1504,11 @@ dump_defs_stack (FILE *file, int n) i = 1; fprintf (file, "Level %d (current level)\n", i); - for (j = (int) VEC_length (tree, block_defs_stack) - 1; j >= 0; j--) + for (j = (int) block_defs_stack.length () - 1; j >= 0; j--) { tree name, var; - name = VEC_index (tree, block_defs_stack, j); + name = block_defs_stack[j]; if (name == NULL_TREE) { i++; @@ -1536,7 +1529,7 @@ dump_defs_stack (FILE *file, int n) if (!is_gimple_reg (var)) { j--; - var = VEC_index (tree, block_defs_stack, j); + var = block_defs_stack[j]; } } @@ -1572,11 +1565,11 @@ dump_currdefs (FILE *file) unsigned i; tree var; - if (VEC_empty (tree, symbols_to_rename)) + if (symbols_to_rename.is_empty ()) return; fprintf (file, "\n\nCurrent reaching definitions\n\n"); - FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, var) + FOR_EACH_VEC_ELT (symbols_to_rename, i, var) { common_info_p info = get_common_info (var); fprintf (file, "CURRDEF ("); @@ -1732,9 +1725,9 @@ register_new_update_single (tree new_name, tree old_name) restore the reaching definitions for all the variables defined in the block after a recursive visit to all its immediately dominated blocks. */ - VEC_reserve (tree, heap, block_defs_stack, 2); - VEC_quick_push (tree, block_defs_stack, currdef); - VEC_quick_push (tree, block_defs_stack, old_name); + block_defs_stack.reserve (2); + block_defs_stack.quick_push (currdef); + block_defs_stack.quick_push (old_name); /* Set the current reaching definition for OLD_NAME to be NEW_NAME. */ @@ -1988,8 +1981,8 @@ rewrite_update_phi_arguments (basic_block bb) if (!bitmap_bit_p (blocks_with_phis_to_rewrite, e->dest->index)) continue; - phis = VEC_index (gimple_vec, phis_to_rewrite, e->dest->index); - FOR_EACH_VEC_ELT (gimple, phis, i, phi) + phis = phis_to_rewrite[e->dest->index]; + FOR_EACH_VEC_ELT (phis, i, phi) { tree arg, lhs_sym, reaching_def = NULL; use_operand_p arg_p; @@ -2068,7 +2061,7 @@ rewrite_update_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, bb->index); /* Mark the unwind point for this block. */ - VEC_safe_push (tree, heap, block_defs_stack, NULL_TREE); + block_defs_stack.safe_push (NULL_TREE); if (!bitmap_bit_p (blocks_to_update, bb->index)) return; @@ -2135,9 +2128,9 @@ static void rewrite_update_leave_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, basic_block bb ATTRIBUTE_UNUSED) { - while (VEC_length (tree, block_defs_stack) > 0) + while (block_defs_stack.length () > 0) { - tree var = VEC_pop (tree, block_defs_stack); + tree var = block_defs_stack.pop (); tree saved_def; /* NULL indicates the unwind stop point for this block (see @@ -2145,7 +2138,7 @@ rewrite_update_leave_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED, if (var == NULL) return; - saved_def = VEC_pop (tree, block_defs_stack); + saved_def = block_defs_stack.pop (); get_common_info (var)->current_def = saved_def; } } @@ -2191,7 +2184,7 @@ rewrite_blocks (basic_block entry, enum rewrite_mode what) else gcc_unreachable (); - block_defs_stack = VEC_alloc (tree, heap, 10); + block_defs_stack.create (10); /* Initialize the dominator walker. */ init_walk_dominator_tree (&walk_data); @@ -2211,7 +2204,7 @@ rewrite_blocks (basic_block entry, enum rewrite_mode what) dump_tree_ssa_stats (dump_file); } - VEC_free (tree, heap, block_defs_stack); + block_defs_stack.release (); timevar_pop (TV_TREE_SSA_REWRITE_BLOCKS); } @@ -2288,7 +2281,7 @@ init_ssa_renamer (void) /* Allocate memory for the DEF_BLOCKS hash table. */ gcc_assert (var_infos == NULL); - var_infos = htab_create (VEC_length (tree, cfun->local_decls), + var_infos = htab_create (vec_safe_length (cfun->local_decls), var_info_hash, var_info_eq, free); bitmap_obstack_initialize (&update_ssa_obstack); @@ -2808,7 +2801,7 @@ delete_update_ssa (void) BITMAP_FREE (symbols_to_rename_set); symbols_to_rename_set = NULL; - VEC_free (tree, heap, symbols_to_rename); + symbols_to_rename.release (); if (names_to_release) { @@ -2824,10 +2817,9 @@ delete_update_ssa (void) if (blocks_with_phis_to_rewrite) EXECUTE_IF_SET_IN_BITMAP (blocks_with_phis_to_rewrite, 0, i, bi) { - gimple_vec phis = VEC_index (gimple_vec, phis_to_rewrite, i); - - VEC_free (gimple, heap, phis); - VEC_replace (gimple_vec, phis_to_rewrite, i, NULL); + gimple_vec phis = phis_to_rewrite[i]; + phis.release (); + phis_to_rewrite[i].create (0); } BITMAP_FREE (blocks_with_phis_to_rewrite); @@ -3141,8 +3133,8 @@ update_ssa (unsigned update_flags) gcc_assert (update_ssa_initialized_fn == cfun); blocks_with_phis_to_rewrite = BITMAP_ALLOC (NULL); - if (!phis_to_rewrite) - phis_to_rewrite = VEC_alloc (gimple_vec, heap, last_basic_block + 1); + if (!phis_to_rewrite.exists ()) + phis_to_rewrite.create (last_basic_block + 1); blocks_to_update = BITMAP_ALLOC (NULL); /* Ensure that the dominance information is up-to-date. */ @@ -3248,7 +3240,7 @@ update_ssa (unsigned update_flags) sbitmap_free (tmp); } - FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, sym) + FOR_EACH_VEC_ELT (symbols_to_rename, i, sym) insert_updated_phi_nodes_for (sym, dfs, blocks_to_update, update_flags); @@ -3269,7 +3261,7 @@ update_ssa (unsigned update_flags) EXECUTE_IF_SET_IN_BITMAP (old_ssa_names, 0, i, sbi) get_ssa_name_ann (ssa_name (i))->info.current_def = NULL_TREE; - FOR_EACH_VEC_ELT (tree, symbols_to_rename, i, sym) + FOR_EACH_VEC_ELT (symbols_to_rename, i, sym) get_var_info (sym)->info.current_def = NULL_TREE; /* Now start the renaming process at START_BB. */ |