diff options
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 79 |
1 files changed, 35 insertions, 44 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index e034762..cfa6527 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "hash-table.h" +#include "hash-map.h" #include "tm.h" #include "tree.h" #include "trans-mem.h" @@ -92,7 +93,7 @@ static const int initial_cfg_capacity = 20; more persistent. The key is getting notification of changes to the CFG (particularly edge removal, creation and redirection). */ -static struct pointer_map_t *edge_to_cases; +static hash_map<edge, tree> *edge_to_cases; /* If we record edge_to_cases, this bitmap will hold indexes of basic blocks that end in a GIMPLE_SWITCH which we touched @@ -1048,19 +1049,17 @@ make_cond_expr_edges (basic_block bb) SWITCH_EXPRs and structure sharing rules, then free the hash table element. */ -static bool -edge_to_cases_cleanup (const void *key ATTRIBUTE_UNUSED, void **value, - void *data ATTRIBUTE_UNUSED) +bool +edge_to_cases_cleanup (edge const &, tree const &value, void *) { tree t, next; - for (t = (tree) *value; t; t = next) + for (t = value; t; t = next) { next = CASE_CHAIN (t); CASE_CHAIN (t) = NULL; } - *value = NULL; return true; } @@ -1070,7 +1069,7 @@ void start_recording_case_labels (void) { gcc_assert (edge_to_cases == NULL); - edge_to_cases = pointer_map_create (); + edge_to_cases = new hash_map<edge, tree>; touched_switch_bbs = BITMAP_ALLOC (NULL); } @@ -1089,8 +1088,8 @@ end_recording_case_labels (void) { bitmap_iterator bi; unsigned i; - pointer_map_traverse (edge_to_cases, edge_to_cases_cleanup, NULL); - pointer_map_destroy (edge_to_cases); + edge_to_cases->traverse<void *, edge_to_cases_cleanup> (NULL); + delete edge_to_cases; edge_to_cases = NULL; EXECUTE_IF_SET_IN_BITMAP (touched_switch_bbs, 0, i, bi) { @@ -1113,7 +1112,7 @@ end_recording_case_labels (void) static tree get_cases_for_edge (edge e, gimple t) { - void **slot; + tree *slot; size_t i, n; /* If we are not recording cases, then we do not have CASE_LABEL_EXPR @@ -1121,9 +1120,9 @@ get_cases_for_edge (edge e, gimple t) if (!recording_case_labels_p ()) return NULL; - slot = pointer_map_contains (edge_to_cases, e); + slot = edge_to_cases->get (e); if (slot) - return (tree) *slot; + return *slot; /* If we did not find E in the hash table, then this must be the first time we have been queried for information about E & T. Add all the @@ -1139,12 +1138,12 @@ get_cases_for_edge (edge e, gimple t) /* Add it to the chain of CASE_LABEL_EXPRs referencing E, or create a new chain. */ - slot = pointer_map_insert (edge_to_cases, this_edge); - CASE_CHAIN (elt) = (tree) *slot; - *slot = elt; + tree &s = edge_to_cases->get_or_insert (this_edge); + CASE_CHAIN (elt) = s; + s = elt; } - return (tree) *pointer_map_contains (edge_to_cases, e); + return *edge_to_cases->get (e); } /* Create the edges for a GIMPLE_SWITCH starting at block BB. */ @@ -2577,12 +2576,11 @@ last_and_only_stmt (basic_block bb) static void reinstall_phi_args (edge new_edge, edge old_edge) { - edge_var_map_vector *v; edge_var_map *vm; int i; gimple_stmt_iterator phis; - v = redirect_edge_var_map_vector (old_edge); + vec<edge_var_map> *v = redirect_edge_var_map_vector (old_edge); if (!v) return; @@ -6268,22 +6266,20 @@ gather_blocks_in_sese_region (basic_block entry, basic_block exit, The duplicates are recorded in VARS_MAP. */ static void -replace_by_duplicate_decl (tree *tp, struct pointer_map_t *vars_map, +replace_by_duplicate_decl (tree *tp, hash_map<tree, tree> *vars_map, tree to_context) { tree t = *tp, new_t; struct function *f = DECL_STRUCT_FUNCTION (to_context); - void **loc; if (DECL_CONTEXT (t) == to_context) return; - loc = pointer_map_contains (vars_map, t); + bool existed; + tree &loc = vars_map->get_or_insert (t, &existed); - if (!loc) + if (!existed) { - loc = pointer_map_insert (vars_map, t); - if (SSA_VAR_P (t)) { new_t = copy_var_decl (t, DECL_NAME (t), TREE_TYPE (t)); @@ -6296,10 +6292,10 @@ replace_by_duplicate_decl (tree *tp, struct pointer_map_t *vars_map, } DECL_CONTEXT (new_t) = to_context; - *loc = new_t; + loc = new_t; } else - new_t = (tree) *loc; + new_t = loc; *tp = new_t; } @@ -6309,15 +6305,14 @@ replace_by_duplicate_decl (tree *tp, struct pointer_map_t *vars_map, VARS_MAP maps old ssa names and var_decls to the new ones. */ static tree -replace_ssa_name (tree name, struct pointer_map_t *vars_map, +replace_ssa_name (tree name, hash_map<tree, tree> *vars_map, tree to_context) { - void **loc; tree new_name; gcc_assert (!virtual_operand_p (name)); - loc = pointer_map_contains (vars_map, name); + tree *loc = vars_map->get (name); if (!loc) { @@ -6335,11 +6330,10 @@ replace_ssa_name (tree name, struct pointer_map_t *vars_map, new_name = copy_ssa_name_fn (DECL_STRUCT_FUNCTION (to_context), name, SSA_NAME_DEF_STMT (name)); - loc = pointer_map_insert (vars_map, name); - *loc = new_name; + vars_map->put (name, new_name); } else - new_name = (tree) *loc; + new_name = *loc; return new_name; } @@ -6350,9 +6344,9 @@ struct move_stmt_d tree new_block; tree from_context; tree to_context; - struct pointer_map_t *vars_map; + hash_map<tree, tree> *vars_map; htab_t new_label_map; - struct pointer_map_t *eh_map; + hash_map<void *, void *> *eh_map; bool remap_decls_p; }; @@ -6429,11 +6423,9 @@ static int move_stmt_eh_region_nr (int old_nr, struct move_stmt_d *p) { eh_region old_r, new_r; - void **slot; old_r = get_eh_region_from_number (old_nr); - slot = pointer_map_contains (p->eh_map, old_r); - new_r = (eh_region) *slot; + new_r = static_cast<eh_region> (*p->eh_map->get (old_r)); return new_r->index; } @@ -6767,7 +6759,7 @@ new_label_mapper (tree decl, void *data) subblocks. */ static void -replace_block_vars_by_duplicates (tree block, struct pointer_map_t *vars_map, +replace_block_vars_by_duplicates (tree block, hash_map<tree, tree> *vars_map, tree to_context) { tree *tp, t; @@ -6845,7 +6837,7 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, edge e; edge_iterator ei; htab_t new_label_map; - struct pointer_map_t *vars_map, *eh_map; + hash_map<void *, void *> *eh_map; struct loop *loop = entry_bb->loop_father; struct loop *loop0 = get_loop (saved_cfun, 0); struct move_stmt_d d; @@ -6989,14 +6981,14 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, /* Move blocks from BBS into DEST_CFUN. */ gcc_assert (bbs.length () >= 2); after = dest_cfun->cfg->x_entry_block_ptr; - vars_map = pointer_map_create (); + hash_map<tree, tree> vars_map; memset (&d, 0, sizeof (d)); d.orig_block = orig_block; d.new_block = DECL_INITIAL (dest_cfun->decl); d.from_context = cfun->decl; d.to_context = dest_cfun->decl; - d.vars_map = vars_map; + d.vars_map = &vars_map; d.new_label_map = new_label_map; d.eh_map = eh_map; d.remap_decls_p = true; @@ -7051,13 +7043,12 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, } replace_block_vars_by_duplicates (DECL_INITIAL (dest_cfun->decl), - vars_map, dest_cfun->decl); + &vars_map, dest_cfun->decl); if (new_label_map) htab_delete (new_label_map); if (eh_map) - pointer_map_destroy (eh_map); - pointer_map_destroy (vars_map); + delete eh_map; /* Rewire the entry and exit blocks. The successor to the entry block turns into the successor of DEST_FN's ENTRY_BLOCK_PTR in |