diff options
Diffstat (limited to 'gcc/tree-ssa-uninit.c')
-rw-r--r-- | gcc/tree-ssa-uninit.c | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/gcc/tree-ssa-uninit.c b/gcc/tree-ssa-uninit.c index 64259fbcc5f..f2578b7e8f8 100644 --- a/gcc/tree-ssa-uninit.c +++ b/gcc/tree-ssa-uninit.c @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3. If not see #include "function.h" #include "gimple-pretty-print.h" #include "bitmap.h" +#include "hash-set.h" #include "pointer-set.h" #include "tree-ssa-alias.h" #include "internal-fn.h" @@ -60,7 +61,7 @@ along with GCC; see the file COPYING3. If not see /* Pointer set of potentially undefined ssa names, i.e., ssa names that are defined by phi with operands that are not defined or potentially undefined. */ -static pointer_set_t *possibly_undefined_names = 0; +static hash_set<tree> *possibly_undefined_names = 0; /* Bit mask handling macros. */ #define MASK_SET_BIT(mask, pos) mask |= (1 << pos) @@ -89,7 +90,7 @@ has_undefined_value_p (tree t) { return (ssa_undefined_value_p (t) || (possibly_undefined_names - && pointer_set_contains (possibly_undefined_names, t))); + && possibly_undefined_names->contains (t))); } @@ -648,13 +649,13 @@ find_predicates (pred_chain_union *preds, static void collect_phi_def_edges (gimple phi, basic_block cd_root, vec<edge> *edges, - pointer_set_t *visited_phis) + hash_set<gimple> *visited_phis) { size_t i, n; edge opnd_edge; tree opnd; - if (pointer_set_insert (visited_phis, phi)) + if (visited_phis->add (phi)) return; n = gimple_phi_num_args (phi); @@ -707,7 +708,6 @@ find_def_preds (pred_chain_union *preds, gimple phi) vec<edge> def_edges = vNULL; bool has_valid_pred = false; basic_block phi_bb, cd_root = 0; - pointer_set_t *visited_phis; phi_bb = gimple_bb (phi); /* First find the closest dominating bb to be @@ -716,9 +716,8 @@ find_def_preds (pred_chain_union *preds, gimple phi) if (!cd_root) return false; - visited_phis = pointer_set_create (); - collect_phi_def_edges (phi, cd_root, &def_edges, visited_phis); - pointer_set_destroy (visited_phis); + hash_set<gimple> visited_phis; + collect_phi_def_edges (phi, cd_root, &def_edges, &visited_phis); n = def_edges.length (); if (n == 0) @@ -941,7 +940,7 @@ is_use_properly_guarded (gimple use_stmt, basic_block use_bb, gimple phi, unsigned uninit_opnds, - pointer_set_t *visited_phis); + hash_set<gimple> *visited_phis); /* Returns true if all uninitialized opnds are pruned. Returns false otherwise. PHI is the phi node with uninitialized operands, @@ -983,7 +982,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi, gimple flag_def, tree boundary_cst, enum tree_code cmp_code, - pointer_set_t *visited_phis, + hash_set<gimple> *visited_phis, bitmap *visited_flag_phis) { unsigned i; @@ -1153,7 +1152,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gimple phi, static bool use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds, gimple phi, unsigned uninit_opnds, - pointer_set_t *visited_phis) + hash_set<gimple> *visited_phis) { unsigned int i, n; gimple flag_def = 0; @@ -1818,11 +1817,11 @@ push_pred (pred_chain_union *norm_preds, pred_info pred) inline static void push_to_worklist (tree op, vec<pred_info, va_heap, vl_ptr> *work_list, - pointer_set_t *mark_set) + hash_set<tree> *mark_set) { - if (pointer_set_contains (mark_set, op)) + if (mark_set->contains (op)) return; - pointer_set_insert (mark_set, op); + mark_set->add (op); pred_info arg_pred; arg_pred.pred_lhs = op; @@ -1907,7 +1906,7 @@ normalize_one_pred_1 (pred_chain_union *norm_preds, pred_info pred, enum tree_code and_or_code, vec<pred_info, va_heap, vl_ptr> *work_list, - pointer_set_t *mark_set) + hash_set<tree> *mark_set) { if (!is_neq_zero_form_p (pred)) { @@ -1987,7 +1986,6 @@ normalize_one_pred (pred_chain_union *norm_preds, pred_info pred) { vec<pred_info, va_heap, vl_ptr> work_list = vNULL; - pointer_set_t *mark_set = NULL; enum tree_code and_or_code = ERROR_MARK; pred_chain norm_chain = vNULL; @@ -2015,19 +2013,18 @@ normalize_one_pred (pred_chain_union *norm_preds, } work_list.safe_push (pred); - mark_set = pointer_set_create (); + hash_set<tree> mark_set; while (!work_list.is_empty ()) { pred_info a_pred = work_list.pop (); normalize_one_pred_1 (norm_preds, &norm_chain, a_pred, - and_or_code, &work_list, mark_set); + and_or_code, &work_list, &mark_set); } if (and_or_code == BIT_AND_EXPR) norm_preds->safe_push (norm_chain); work_list.release (); - pointer_set_destroy (mark_set); } static void @@ -2035,26 +2032,25 @@ normalize_one_pred_chain (pred_chain_union *norm_preds, pred_chain one_chain) { vec<pred_info, va_heap, vl_ptr> work_list = vNULL; - pointer_set_t *mark_set = pointer_set_create (); + hash_set<tree> mark_set; pred_chain norm_chain = vNULL; size_t i; for (i = 0; i < one_chain.length (); i++) { work_list.safe_push (one_chain[i]); - pointer_set_insert (mark_set, one_chain[i].pred_lhs); + mark_set.add (one_chain[i].pred_lhs); } while (!work_list.is_empty ()) { pred_info a_pred = work_list.pop (); normalize_one_pred_1 (0, &norm_chain, a_pred, - BIT_AND_EXPR, &work_list, mark_set); + BIT_AND_EXPR, &work_list, &mark_set); } norm_preds->safe_push (norm_chain); work_list.release (); - pointer_set_destroy (mark_set); } /* Normalize predicate chains PREDS and returns the normalized one. */ @@ -2112,7 +2108,7 @@ is_use_properly_guarded (gimple use_stmt, basic_block use_bb, gimple phi, unsigned uninit_opnds, - pointer_set_t *visited_phis) + hash_set<gimple> *visited_phis) { basic_block phi_bb; pred_chain_union preds = vNULL; @@ -2120,7 +2116,7 @@ is_use_properly_guarded (gimple use_stmt, bool has_valid_preds = false; bool is_properly_guarded = false; - if (pointer_set_insert (visited_phis, phi)) + if (visited_phis->add (phi)) return false; phi_bb = gimple_bb (phi); @@ -2181,7 +2177,7 @@ is_use_properly_guarded (gimple use_stmt, static gimple find_uninit_use (gimple phi, unsigned uninit_opnds, vec<gimple> *worklist, - pointer_set_t *added_to_worklist) + hash_set<gimple> *added_to_worklist) { tree phi_result; use_operand_p use_p; @@ -2192,28 +2188,22 @@ find_uninit_use (gimple phi, unsigned uninit_opnds, FOR_EACH_IMM_USE_FAST (use_p, iter, phi_result) { - pointer_set_t *visited_phis; basic_block use_bb; use_stmt = USE_STMT (use_p); if (is_gimple_debug (use_stmt)) continue; - visited_phis = pointer_set_create (); - if (gimple_code (use_stmt) == GIMPLE_PHI) use_bb = gimple_phi_arg_edge (use_stmt, PHI_ARG_INDEX_FROM_USE (use_p))->src; else use_bb = gimple_bb (use_stmt); + hash_set<gimple> visited_phis; if (is_use_properly_guarded (use_stmt, use_bb, phi, uninit_opnds, - visited_phis)) - { - pointer_set_destroy (visited_phis); - continue; - } - pointer_set_destroy (visited_phis); + &visited_phis)) + continue; if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -2226,7 +2216,7 @@ find_uninit_use (gimple phi, unsigned uninit_opnds, /* Found a phi use that is not guarded, add the phi to the worklist. */ - if (!pointer_set_insert (added_to_worklist, use_stmt)) + if (!added_to_worklist->add (use_stmt)) { if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -2235,7 +2225,7 @@ find_uninit_use (gimple phi, unsigned uninit_opnds, } worklist->safe_push (use_stmt); - pointer_set_insert (possibly_undefined_names, phi_result); + possibly_undefined_names->add (phi_result); } } @@ -2252,7 +2242,7 @@ find_uninit_use (gimple phi, unsigned uninit_opnds, static void warn_uninitialized_phi (gimple phi, vec<gimple> *worklist, - pointer_set_t *added_to_worklist) + hash_set<gimple> *added_to_worklist) { unsigned uninit_opnds; gimple uninit_use_stmt = 0; @@ -2339,7 +2329,6 @@ pass_late_warn_uninitialized::execute (function *fun) basic_block bb; gimple_stmt_iterator gsi; vec<gimple> worklist = vNULL; - pointer_set_t *added_to_worklist; calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_POST_DOMINATORS); @@ -2350,8 +2339,8 @@ pass_late_warn_uninitialized::execute (function *fun) timevar_push (TV_TREE_UNINIT); - possibly_undefined_names = pointer_set_create (); - added_to_worklist = pointer_set_create (); + possibly_undefined_names = new hash_set<tree>; + hash_set<gimple> added_to_worklist; /* Initialize worklist */ FOR_EACH_BB_FN (bb, fun) @@ -2373,7 +2362,7 @@ pass_late_warn_uninitialized::execute (function *fun) && uninit_undefined_value_p (op)) { worklist.safe_push (phi); - pointer_set_insert (added_to_worklist, phi); + added_to_worklist.add (phi); if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, "[WORKLIST]: add to initial list: "); @@ -2388,12 +2377,11 @@ pass_late_warn_uninitialized::execute (function *fun) { gimple cur_phi = 0; cur_phi = worklist.pop (); - warn_uninitialized_phi (cur_phi, &worklist, added_to_worklist); + warn_uninitialized_phi (cur_phi, &worklist, &added_to_worklist); } worklist.release (); - pointer_set_destroy (added_to_worklist); - pointer_set_destroy (possibly_undefined_names); + delete possibly_undefined_names; possibly_undefined_names = NULL; free_dominance_info (CDI_POST_DOMINATORS); timevar_pop (TV_TREE_UNINIT); |