Commit ac0e4fde by Martin Liska Committed by Martin Liska

Manual changes to GCC coding style in tree-ssa-uninit.c

	* tree-ssa-uninit.c: Apply manual changes
	to the GNU coding style.
	(prune_uninit_phi_opnds): Rename from
	prune_uninit_phi_opnds_in_unrealizable_paths.

From-SVN: r235961
parent d8997c44
2016-05-06 Martin Liska <mliska@suse.cz>
* tree-ssa-uninit.c: Apply manual changes
to the GNU coding style.
(prune_uninit_phi_opnds): Rename from
prune_uninit_phi_opnds_in_unrealizable_paths.
2016-05-06 Oleg Endo <olegendo@gcc.gnu.org> 2016-05-06 Oleg Endo <olegendo@gcc.gnu.org>
* config/sh/sh.opt (madjust-unroll, minvalid-symbols, msoft-atomic, * config/sh/sh.opt (madjust-unroll, minvalid-symbols, msoft-atomic,
......
...@@ -44,7 +44,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -44,7 +44,6 @@ along with GCC; see the file COPYING3. If not see
default definitions or by checking if the predicate set that guards the default definitions or by checking if the predicate set that guards the
defining paths is a superset of the use predicate. */ defining paths is a superset of the use predicate. */
/* Pointer set of potentially undefined ssa names, i.e., /* Pointer set of potentially undefined ssa names, i.e.,
ssa names that are defined by phi with operands that ssa names that are defined by phi with operands that
are not defined or potentially undefined. */ are not defined or potentially undefined. */
...@@ -80,13 +79,12 @@ has_undefined_value_p (tree t) ...@@ -80,13 +79,12 @@ has_undefined_value_p (tree t)
&& possibly_undefined_names->contains (t))); && possibly_undefined_names->contains (t)));
} }
/* Like has_undefined_value_p, but don't return true if TREE_NO_WARNING /* Like has_undefined_value_p, but don't return true if TREE_NO_WARNING
is set on SSA_NAME_VAR. */ is set on SSA_NAME_VAR. */
static inline bool static inline bool
uninit_undefined_value_p (tree t) { uninit_undefined_value_p (tree t)
{
if (!has_undefined_value_p (t)) if (!has_undefined_value_p (t))
return false; return false;
if (SSA_NAME_VAR (t) && TREE_NO_WARNING (SSA_NAME_VAR (t))) if (SSA_NAME_VAR (t) && TREE_NO_WARNING (SSA_NAME_VAR (t)))
...@@ -149,8 +147,7 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var, ...@@ -149,8 +147,7 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var,
else else
location = DECL_SOURCE_LOCATION (var); location = DECL_SOURCE_LOCATION (var);
location = linemap_resolve_location (line_table, location, location = linemap_resolve_location (line_table, location,
LRK_SPELLING_LOCATION, LRK_SPELLING_LOCATION, NULL);
NULL);
cfun_loc = DECL_SOURCE_LOCATION (cfun->decl); cfun_loc = DECL_SOURCE_LOCATION (cfun->decl);
xloc = expand_location (location); xloc = expand_location (location);
floc = expand_location (cfun_loc); floc = expand_location (cfun_loc);
...@@ -161,10 +158,8 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var, ...@@ -161,10 +158,8 @@ warn_uninit (enum opt_code wc, tree t, tree expr, tree var,
if (location == DECL_SOURCE_LOCATION (var)) if (location == DECL_SOURCE_LOCATION (var))
return; return;
if (xloc.file != floc.file if (xloc.file != floc.file
|| linemap_location_before_p (line_table, || linemap_location_before_p (line_table, location, cfun_loc)
location, cfun_loc) || linemap_location_before_p (line_table, cfun->function_end_locus,
|| linemap_location_before_p (line_table,
cfun->function_end_locus,
location)) location))
inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var); inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var);
} }
...@@ -178,8 +173,8 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized) ...@@ -178,8 +173,8 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized)
FOR_EACH_BB_FN (bb, cfun) FOR_EACH_BB_FN (bb, cfun)
{ {
bool always_executed = dominated_by_p (CDI_POST_DOMINATORS, basic_block succ = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun));
single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)), bb); bool always_executed = dominated_by_p (CDI_POST_DOMINATORS, succ, bb);
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{ {
gimple *stmt = gsi_stmt (gsi); gimple *stmt = gsi_stmt (gsi);
...@@ -196,13 +191,13 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized) ...@@ -196,13 +191,13 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized)
{ {
use = USE_FROM_PTR (use_p); use = USE_FROM_PTR (use_p);
if (always_executed) if (always_executed)
warn_uninit (OPT_Wuninitialized, use, warn_uninit (OPT_Wuninitialized, use, SSA_NAME_VAR (use),
SSA_NAME_VAR (use), SSA_NAME_VAR (use), SSA_NAME_VAR (use),
"%qD is used uninitialized in this function", "%qD is used uninitialized in this function", stmt,
stmt, UNKNOWN_LOCATION); UNKNOWN_LOCATION);
else if (warn_possibly_uninitialized) else if (warn_possibly_uninitialized)
warn_uninit (OPT_Wmaybe_uninitialized, use, warn_uninit (OPT_Wmaybe_uninitialized, use, SSA_NAME_VAR (use),
SSA_NAME_VAR (use), SSA_NAME_VAR (use), SSA_NAME_VAR (use),
"%qD may be used uninitialized in this function", "%qD may be used uninitialized in this function",
stmt, UNKNOWN_LOCATION); stmt, UNKNOWN_LOCATION);
} }
...@@ -232,9 +227,8 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized) ...@@ -232,9 +227,8 @@ warn_uninitialized_vars (bool warn_possibly_uninitialized)
continue; continue;
if (always_executed) if (always_executed)
warn_uninit (OPT_Wuninitialized, use, warn_uninit (OPT_Wuninitialized, use, gimple_assign_rhs1 (stmt),
gimple_assign_rhs1 (stmt), base, base, "%qE is used uninitialized in this function",
"%qE is used uninitialized in this function",
stmt, UNKNOWN_LOCATION); stmt, UNKNOWN_LOCATION);
else if (warn_possibly_uninitialized) else if (warn_possibly_uninitialized)
warn_uninit (OPT_Wmaybe_uninitialized, use, warn_uninit (OPT_Wmaybe_uninitialized, use,
...@@ -322,16 +316,14 @@ find_pdom (basic_block block) ...@@ -322,16 +316,14 @@ find_pdom (basic_block block)
return EXIT_BLOCK_PTR_FOR_FN (cfun); return EXIT_BLOCK_PTR_FOR_FN (cfun);
else else
{ {
basic_block bb basic_block bb = get_immediate_dominator (CDI_POST_DOMINATORS, block);
= get_immediate_dominator (CDI_POST_DOMINATORS, block); if (!bb)
if (! bb)
return EXIT_BLOCK_PTR_FOR_FN (cfun); return EXIT_BLOCK_PTR_FOR_FN (cfun);
return bb; return bb;
} }
} }
/* Find the immediate DOM of the specified /* Find the immediate DOM of the specified basic block BLOCK. */
basic block BLOCK. */
static inline basic_block static inline basic_block
find_dom (basic_block block) find_dom (basic_block block)
...@@ -341,7 +333,7 @@ find_dom (basic_block block) ...@@ -341,7 +333,7 @@ find_dom (basic_block block)
else else
{ {
basic_block bb = get_immediate_dominator (CDI_DOMINATORS, block); basic_block bb = get_immediate_dominator (CDI_DOMINATORS, block);
if (! bb) if (!bb)
return ENTRY_BLOCK_PTR_FOR_FN (cfun); return ENTRY_BLOCK_PTR_FOR_FN (cfun);
return bb; return bb;
} }
...@@ -454,8 +446,8 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb, ...@@ -454,8 +446,8 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb,
} }
/* Now check if DEP_BB is indirectly control dependent on BB. */ /* Now check if DEP_BB is indirectly control dependent on BB. */
if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains, if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains, num_chains,
num_chains, cur_cd_chain, num_calls)) cur_cd_chain, num_calls))
{ {
found_cd_chain = true; found_cd_chain = true;
break; break;
...@@ -463,8 +455,8 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb, ...@@ -463,8 +455,8 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb,
cd_bb = find_pdom (cd_bb); cd_bb = find_pdom (cd_bb);
post_dom_check++; post_dom_check++;
if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun) || post_dom_check > if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
MAX_POSTDOM_CHECK) || post_dom_check > MAX_POSTDOM_CHECK)
break; break;
} }
cur_cd_chain->pop (); cur_cd_chain->pop ();
...@@ -475,7 +467,7 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb, ...@@ -475,7 +467,7 @@ compute_control_dep_chain (basic_block bb, basic_block dep_bb,
return found_cd_chain; return found_cd_chain;
} }
/* The type to represent a simple predicate */ /* The type to represent a simple predicate. */
struct pred_info struct pred_info
{ {
...@@ -543,13 +535,9 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains, ...@@ -543,13 +535,9 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
break; break;
} }
cond_stmt = gsi_stmt (gsi); cond_stmt = gsi_stmt (gsi);
if (is_gimple_call (cond_stmt) if (is_gimple_call (cond_stmt) && EDGE_COUNT (e->src->succs) >= 2)
&& EDGE_COUNT (e->src->succs) >= 2) /* Ignore EH edge. Can add assertion on the other edge's flag. */
{
/* Ignore EH edge. Can add assertion
on the other edge's flag. */
continue; continue;
}
/* Skip if there is essentially one succesor. */ /* Skip if there is essentially one succesor. */
if (EDGE_COUNT (e->src->succs) == 2) if (EDGE_COUNT (e->src->succs) == 2)
{ {
...@@ -577,7 +565,7 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains, ...@@ -577,7 +565,7 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
t_chain.safe_push (one_pred); t_chain.safe_push (one_pred);
has_valid_pred = true; has_valid_pred = true;
} }
else if (gswitch *gs = dyn_cast <gswitch *> (cond_stmt)) else if (gswitch *gs = dyn_cast<gswitch *> (cond_stmt))
{ {
/* Avoid quadratic behavior. */ /* Avoid quadratic behavior. */
if (gimple_switch_num_labels (gs) > MAX_SWITCH_CASES) if (gimple_switch_num_labels (gs) > MAX_SWITCH_CASES)
...@@ -607,8 +595,8 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains, ...@@ -607,8 +595,8 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
fail. */ fail. */
if (!l if (!l
|| !CASE_LOW (l) || !CASE_LOW (l)
|| (CASE_HIGH (l) && !operand_equal_p (CASE_LOW (l), || (CASE_HIGH (l)
CASE_HIGH (l), 0))) && !operand_equal_p (CASE_LOW (l), CASE_HIGH (l), 0)))
{ {
has_valid_pred = false; has_valid_pred = false;
break; break;
...@@ -702,7 +690,7 @@ collect_phi_def_edges (gphi *phi, basic_block cd_root, ...@@ -702,7 +690,7 @@ collect_phi_def_edges (gphi *phi, basic_block cd_root,
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i); fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int) i);
print_gimple_stmt (dump_file, phi, 0, 0); print_gimple_stmt (dump_file, phi, 0, 0);
} }
edges->safe_push (opnd_edge); edges->safe_push (opnd_edge);
...@@ -712,15 +700,15 @@ collect_phi_def_edges (gphi *phi, basic_block cd_root, ...@@ -712,15 +700,15 @@ collect_phi_def_edges (gphi *phi, basic_block cd_root,
gimple *def = SSA_NAME_DEF_STMT (opnd); gimple *def = SSA_NAME_DEF_STMT (opnd);
if (gimple_code (def) == GIMPLE_PHI if (gimple_code (def) == GIMPLE_PHI
&& dominated_by_p (CDI_DOMINATORS, && dominated_by_p (CDI_DOMINATORS, gimple_bb (def), cd_root))
gimple_bb (def), cd_root)) collect_phi_def_edges (as_a<gphi *> (def), cd_root, edges,
collect_phi_def_edges (as_a <gphi *> (def), cd_root, edges,
visited_phis); visited_phis);
else if (!uninit_undefined_value_p (opnd)) else if (!uninit_undefined_value_p (opnd))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i); fprintf (dump_file, "\n[CHECK] Found def edge %d in ",
(int) i);
print_gimple_stmt (dump_file, phi, 0, 0); print_gimple_stmt (dump_file, phi, 0, 0);
} }
edges->safe_push (opnd_edge); edges->safe_push (opnd_edge);
...@@ -745,7 +733,7 @@ find_def_preds (pred_chain_union *preds, gphi *phi) ...@@ -745,7 +733,7 @@ find_def_preds (pred_chain_union *preds, gphi *phi)
phi_bb = gimple_bb (phi); phi_bb = gimple_bb (phi);
/* First find the closest dominating bb to be /* First find the closest dominating bb to be
the control dependence root */ the control dependence root. */
cd_root = find_dom (phi_bb); cd_root = find_dom (phi_bb);
if (!cd_root) if (!cd_root)
return false; return false;
...@@ -789,8 +777,7 @@ find_def_preds (pred_chain_union *preds, gphi *phi) ...@@ -789,8 +777,7 @@ find_def_preds (pred_chain_union *preds, gphi *phi)
/* Dumps the predicates (PREDS) for USESTMT. */ /* Dumps the predicates (PREDS) for USESTMT. */
static void static void
dump_predicates (gimple *usestmt, pred_chain_union preds, dump_predicates (gimple *usestmt, pred_chain_union preds, const char *msg)
const char* msg)
{ {
size_t i, j; size_t i, j;
pred_chain one_pred_chain = vNULL; pred_chain one_pred_chain = vNULL;
...@@ -839,13 +826,11 @@ destroy_predicate_vecs (pred_chain_union *preds) ...@@ -839,13 +826,11 @@ destroy_predicate_vecs (pred_chain_union *preds)
preds->release (); preds->release ();
} }
/* Computes the 'normalized' conditional code with operand /* Computes the 'normalized' conditional code with operand
swapping and condition inversion. */ swapping and condition inversion. */
static enum tree_code static enum tree_code
get_cmp_code (enum tree_code orig_cmp_code, get_cmp_code (enum tree_code orig_cmp_code, bool swap_cond, bool invert)
bool swap_cond, bool invert)
{ {
enum tree_code tc = orig_cmp_code; enum tree_code tc = orig_cmp_code;
...@@ -880,14 +865,12 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc) ...@@ -880,14 +865,12 @@ is_value_included_in (tree val, tree boundary, enum tree_code cmpc)
bool result; bool result;
/* Only handle integer constant here. */ /* Only handle integer constant here. */
if (TREE_CODE (val) != INTEGER_CST if (TREE_CODE (val) != INTEGER_CST || TREE_CODE (boundary) != INTEGER_CST)
|| TREE_CODE (boundary) != INTEGER_CST)
return true; return true;
is_unsigned = TYPE_UNSIGNED (TREE_TYPE (val)); is_unsigned = TYPE_UNSIGNED (TREE_TYPE (val));
if (cmpc == GE_EXPR || cmpc == GT_EXPR if (cmpc == GE_EXPR || cmpc == GT_EXPR || cmpc == NE_EXPR)
|| cmpc == NE_EXPR)
{ {
cmpc = invert_tree_comparison (cmpc, false); cmpc = invert_tree_comparison (cmpc, false);
inverted = true; inverted = true;
...@@ -969,8 +952,7 @@ find_matching_predicate_in_rest_chains (pred_info pred, ...@@ -969,8 +952,7 @@ find_matching_predicate_in_rest_chains (pred_info pred,
} }
/* Forward declaration. */ /* Forward declaration. */
static bool static bool is_use_properly_guarded (gimple *use_stmt,
is_use_properly_guarded (gimple *use_stmt,
basic_block use_bb, basic_block use_bb,
gphi *phi, gphi *phi,
unsigned uninit_opnds, unsigned uninit_opnds,
...@@ -1005,18 +987,14 @@ is_use_properly_guarded (gimple *use_stmt, ...@@ -1005,18 +987,14 @@ is_use_properly_guarded (gimple *use_stmt,
Because some flag arg in (1) is not constant, if we do not look into the Because some flag arg in (1) is not constant, if we do not look into the
flag phis recursively, it is conservatively treated as unknown and var_1 flag phis recursively, it is conservatively treated as unknown and var_1
is thought to be flowed into use at (3). Since var_1 is potentially uninitialized is thought to be flowed into use at (3). Since var_1 is potentially
a false warning will be emitted. Checking recursively into (1), the compiler can uninitialized a false warning will be emitted.
find out that only some_val (which is defined) can flow into (3) which is OK. Checking recursively into (1), the compiler can find out that only some_val
(which is defined) can flow into (3) which is OK. */
*/
static bool static bool
prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, prune_uninit_phi_opnds (gphi *phi, unsigned uninit_opnds, gphi *flag_def,
unsigned uninit_opnds, tree boundary_cst, enum tree_code cmp_code,
gphi *flag_def,
tree boundary_cst,
enum tree_code cmp_code,
hash_set<gphi *> *visited_phis, hash_set<gphi *> *visited_phis,
bitmap *visited_flag_phis) bitmap *visited_flag_phis)
{ {
...@@ -1038,7 +1016,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1038,7 +1016,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
if (TREE_CODE (flag_arg) != SSA_NAME) if (TREE_CODE (flag_arg) != SSA_NAME)
return false; return false;
flag_arg_def = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (flag_arg)); flag_arg_def = dyn_cast<gphi *> (SSA_NAME_DEF_STMT (flag_arg));
if (!flag_arg_def) if (!flag_arg_def)
return false; return false;
...@@ -1046,7 +1024,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1046,7 +1024,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
if (TREE_CODE (phi_arg) != SSA_NAME) if (TREE_CODE (phi_arg) != SSA_NAME)
return false; return false;
phi_arg_def = dyn_cast <gphi *> (SSA_NAME_DEF_STMT (phi_arg)); phi_arg_def = dyn_cast<gphi *> (SSA_NAME_DEF_STMT (phi_arg));
if (!phi_arg_def) if (!phi_arg_def)
return false; return false;
...@@ -1056,8 +1034,8 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1056,8 +1034,8 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
if (!*visited_flag_phis) if (!*visited_flag_phis)
*visited_flag_phis = BITMAP_ALLOC (NULL); *visited_flag_phis = BITMAP_ALLOC (NULL);
if (bitmap_bit_p (*visited_flag_phis, tree phi_result = gimple_phi_result (flag_arg_def);
SSA_NAME_VERSION (gimple_phi_result (flag_arg_def)))) if (bitmap_bit_p (*visited_flag_phis, SSA_NAME_VERSION (phi_result)))
return false; return false;
bitmap_set_bit (*visited_flag_phis, bitmap_set_bit (*visited_flag_phis,
...@@ -1065,13 +1043,13 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1065,13 +1043,13 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
/* Now recursively prune the uninitialized phi args. */ /* Now recursively prune the uninitialized phi args. */
uninit_opnds_arg_phi = compute_uninit_opnds_pos (phi_arg_def); uninit_opnds_arg_phi = compute_uninit_opnds_pos (phi_arg_def);
if (!prune_uninit_phi_opnds_in_unrealizable_paths if (!prune_uninit_phi_opnds
(phi_arg_def, uninit_opnds_arg_phi, flag_arg_def, (phi_arg_def, uninit_opnds_arg_phi, flag_arg_def, boundary_cst,
boundary_cst, cmp_code, visited_phis, visited_flag_phis)) cmp_code, visited_phis, visited_flag_phis))
return false; return false;
bitmap_clear_bit (*visited_flag_phis, phi_result = gimple_phi_result (flag_arg_def);
SSA_NAME_VERSION (gimple_phi_result (flag_arg_def))); bitmap_clear_bit (*visited_flag_phis, SSA_NAME_VERSION (phi_result));
continue; continue;
} }
...@@ -1091,8 +1069,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1091,8 +1069,7 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
if (gphi *opnd_def_phi = dyn_cast <gphi *> (opnd_def)) if (gphi *opnd_def_phi = dyn_cast <gphi *> (opnd_def))
{ {
edge opnd_edge; edge opnd_edge;
unsigned uninit_opnds2 unsigned uninit_opnds2 = compute_uninit_opnds_pos (opnd_def_phi);
= compute_uninit_opnds_pos (opnd_def_phi);
if (!MASK_EMPTY (uninit_opnds2)) if (!MASK_EMPTY (uninit_opnds2))
{ {
pred_chain_union def_preds = vNULL; pred_chain_union def_preds = vNULL;
...@@ -1143,11 +1120,11 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1143,11 +1120,11 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
return true; return true;
} }
void foo(..) void foo (..)
{ {
int x; int x;
if (!init_func(&x)) if (!init_func (&x))
return; return;
.. some_code ... .. some_code ...
...@@ -1190,7 +1167,6 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi, ...@@ -1190,7 +1167,6 @@ prune_uninit_phi_opnds_in_unrealizable_paths (gphi *phi,
uninit operand positions. VISITED_PHIS is the pointer set of phi uninit operand positions. VISITED_PHIS is the pointer set of phi
stmts being checked. */ stmts being checked. */
static bool static bool
use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds, use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
gphi *phi, unsigned uninit_opnds, gphi *phi, unsigned uninit_opnds,
...@@ -1265,13 +1241,9 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds, ...@@ -1265,13 +1241,9 @@ use_pred_not_overlap_with_undef_path_pred (pred_chain_union preds,
if (cmp_code == ERROR_MARK) if (cmp_code == ERROR_MARK)
return false; return false;
all_pruned = prune_uninit_phi_opnds_in_unrealizable_paths (phi, all_pruned = prune_uninit_phi_opnds
uninit_opnds, (phi, uninit_opnds, as_a<gphi *> (flag_def), boundary_cst, cmp_code,
as_a <gphi *> (flag_def), visited_phis, &visited_flag_phis);
boundary_cst,
cmp_code,
visited_phis,
&visited_flag_phis);
if (visited_flag_phis) if (visited_flag_phis)
BITMAP_FREE (visited_flag_phis); BITMAP_FREE (visited_flag_phis);
...@@ -1307,8 +1279,8 @@ static inline bool ...@@ -1307,8 +1279,8 @@ static inline bool
is_neq_relop_p (pred_info pred) is_neq_relop_p (pred_info pred)
{ {
return (pred.cond_code == NE_EXPR && !pred.invert) return ((pred.cond_code == NE_EXPR && !pred.invert)
|| (pred.cond_code == EQ_EXPR && pred.invert); || (pred.cond_code == EQ_EXPR && pred.invert));
} }
/* Returns true if pred is of the form X != 0. */ /* Returns true if pred is of the form X != 0. */
...@@ -1360,8 +1332,7 @@ is_pred_expr_subset_of (pred_info expr1, pred_info expr2) ...@@ -1360,8 +1332,7 @@ is_pred_expr_subset_of (pred_info expr1, pred_info expr2)
if (expr2.invert) if (expr2.invert)
code2 = invert_tree_comparison (code2, false); code2 = invert_tree_comparison (code2, false);
if ((code1 == EQ_EXPR || code1 == BIT_AND_EXPR) if ((code1 == EQ_EXPR || code1 == BIT_AND_EXPR) && code2 == BIT_AND_EXPR)
&& code2 == BIT_AND_EXPR)
return wi::eq_p (expr1.pred_rhs, return wi::eq_p (expr1.pred_rhs,
wi::bit_and (expr1.pred_rhs, expr2.pred_rhs)); wi::bit_and (expr1.pred_rhs, expr2.pred_rhs));
...@@ -1378,8 +1349,7 @@ is_pred_expr_subset_of (pred_info expr1, pred_info expr2) ...@@ -1378,8 +1349,7 @@ is_pred_expr_subset_of (pred_info expr1, pred_info expr2)
of that of PRED2. Returns false if it can not be proved so. */ of that of PRED2. Returns false if it can not be proved so. */
static bool static bool
is_pred_chain_subset_of (pred_chain pred1, is_pred_chain_subset_of (pred_chain pred1, pred_chain pred2)
pred_chain pred2)
{ {
size_t np1, np2, i1, i2; size_t np1, np2, i1, i2;
...@@ -1746,8 +1716,7 @@ simplify_preds_4 (pred_chain_union *preds) ...@@ -1746,8 +1716,7 @@ simplify_preds_4 (pred_chain_union *preds)
x2 = (*b_chain)[0]; x2 = (*b_chain)[0];
y2 = (*b_chain)[1]; y2 = (*b_chain)[1];
if (!is_neq_zero_form_p (x2) if (!is_neq_zero_form_p (x2) || !is_neq_zero_form_p (y2))
|| !is_neq_zero_form_p (y2))
continue; continue;
if ((pred_expr_equal_p (x2, gimple_assign_rhs1 (def_stmt)) if ((pred_expr_equal_p (x2, gimple_assign_rhs1 (def_stmt))
...@@ -1780,7 +1749,6 @@ simplify_preds_4 (pred_chain_union *preds) ...@@ -1780,7 +1749,6 @@ simplify_preds_4 (pred_chain_union *preds)
return simplified; return simplified;
} }
/* This function simplifies predicates in PREDS. */ /* This function simplifies predicates in PREDS. */
static void static void
...@@ -1815,8 +1783,8 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use) ...@@ -1815,8 +1783,8 @@ simplify_preds (pred_chain_union *preds, gimple *use_or_def, bool is_use)
if (simplify_preds_4 (preds)) if (simplify_preds_4 (preds))
changed = true; changed = true;
}
} while (changed); while (changed);
return; return;
} }
...@@ -1915,8 +1883,7 @@ is_degenerated_phi (gimple *phi, pred_info *pred_p) ...@@ -1915,8 +1883,7 @@ is_degenerated_phi (gimple *phi, pred_info *pred_p)
def0 = SSA_NAME_DEF_STMT (op0); def0 = SSA_NAME_DEF_STMT (op0);
if (gimple_code (def0) != GIMPLE_ASSIGN) if (gimple_code (def0) != GIMPLE_ASSIGN)
return false; return false;
if (TREE_CODE_CLASS (gimple_assign_rhs_code (def0)) if (TREE_CODE_CLASS (gimple_assign_rhs_code (def0)) != tcc_comparison)
!= tcc_comparison)
return false; return false;
pred0 = get_pred_info_from_cmp (def0); pred0 = get_pred_info_from_cmp (def0);
...@@ -1932,8 +1899,7 @@ is_degenerated_phi (gimple *phi, pred_info *pred_p) ...@@ -1932,8 +1899,7 @@ is_degenerated_phi (gimple *phi, pred_info *pred_p)
def = SSA_NAME_DEF_STMT (op); def = SSA_NAME_DEF_STMT (op);
if (gimple_code (def) != GIMPLE_ASSIGN) if (gimple_code (def) != GIMPLE_ASSIGN)
return false; return false;
if (TREE_CODE_CLASS (gimple_assign_rhs_code (def)) if (TREE_CODE_CLASS (gimple_assign_rhs_code (def)) != tcc_comparison)
!= tcc_comparison)
return false; return false;
pred = get_pred_info_from_cmp (def); pred = get_pred_info_from_cmp (def);
if (!pred_equal_p (pred, pred0)) if (!pred_equal_p (pred, pred0))
...@@ -1971,8 +1937,7 @@ normalize_one_pred_1 (pred_chain_union *norm_preds, ...@@ -1971,8 +1937,7 @@ normalize_one_pred_1 (pred_chain_union *norm_preds,
if (gimple_code (def_stmt) == GIMPLE_PHI if (gimple_code (def_stmt) == GIMPLE_PHI
&& is_degenerated_phi (def_stmt, &pred)) && is_degenerated_phi (def_stmt, &pred))
work_list->safe_push (pred); work_list->safe_push (pred);
else if (gimple_code (def_stmt) == GIMPLE_PHI else if (gimple_code (def_stmt) == GIMPLE_PHI && and_or_code == BIT_IOR_EXPR)
&& and_or_code == BIT_IOR_EXPR)
{ {
int i, n; int i, n;
n = gimple_phi_num_args (def_stmt); n = gimple_phi_num_args (def_stmt);
...@@ -2048,8 +2013,7 @@ normalize_one_pred_1 (pred_chain_union *norm_preds, ...@@ -2048,8 +2013,7 @@ normalize_one_pred_1 (pred_chain_union *norm_preds,
/* Normalize PRED and store the normalized predicates into NORM_PREDS. */ /* Normalize PRED and store the normalized predicates into NORM_PREDS. */
static void static void
normalize_one_pred (pred_chain_union *norm_preds, normalize_one_pred (pred_chain_union *norm_preds, pred_info pred)
pred_info pred)
{ {
vec<pred_info, va_heap, vl_ptr> work_list = vNULL; vec<pred_info, va_heap, vl_ptr> work_list = vNULL;
enum tree_code and_or_code = ERROR_MARK; enum tree_code and_or_code = ERROR_MARK;
...@@ -2064,11 +2028,9 @@ normalize_one_pred (pred_chain_union *norm_preds, ...@@ -2064,11 +2028,9 @@ normalize_one_pred (pred_chain_union *norm_preds,
gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs); gimple *def_stmt = SSA_NAME_DEF_STMT (pred.pred_lhs);
if (gimple_code (def_stmt) == GIMPLE_ASSIGN) if (gimple_code (def_stmt) == GIMPLE_ASSIGN)
and_or_code = gimple_assign_rhs_code (def_stmt); and_or_code = gimple_assign_rhs_code (def_stmt);
if (and_or_code != BIT_IOR_EXPR if (and_or_code != BIT_IOR_EXPR && and_or_code != BIT_AND_EXPR)
&& and_or_code != BIT_AND_EXPR)
{ {
if (TREE_CODE_CLASS (and_or_code) if (TREE_CODE_CLASS (and_or_code) == tcc_comparison)
== tcc_comparison)
{ {
pred_info n_pred = get_pred_info_from_cmp (def_stmt); pred_info n_pred = get_pred_info_from_cmp (def_stmt);
push_pred (norm_preds, n_pred); push_pred (norm_preds, n_pred);
...@@ -2084,8 +2046,8 @@ normalize_one_pred (pred_chain_union *norm_preds, ...@@ -2084,8 +2046,8 @@ normalize_one_pred (pred_chain_union *norm_preds,
while (!work_list.is_empty ()) while (!work_list.is_empty ())
{ {
pred_info a_pred = work_list.pop (); pred_info a_pred = work_list.pop ();
normalize_one_pred_1 (norm_preds, &norm_chain, a_pred, normalize_one_pred_1 (norm_preds, &norm_chain, a_pred, and_or_code,
and_or_code, &work_list, &mark_set); &work_list, &mark_set);
} }
if (and_or_code == BIT_AND_EXPR) if (and_or_code == BIT_AND_EXPR)
norm_preds->safe_push (norm_chain); norm_preds->safe_push (norm_chain);
...@@ -2094,8 +2056,7 @@ normalize_one_pred (pred_chain_union *norm_preds, ...@@ -2094,8 +2056,7 @@ normalize_one_pred (pred_chain_union *norm_preds,
} }
static void static void
normalize_one_pred_chain (pred_chain_union *norm_preds, normalize_one_pred_chain (pred_chain_union *norm_preds, pred_chain one_chain)
pred_chain one_chain)
{ {
vec<pred_info, va_heap, vl_ptr> work_list = vNULL; vec<pred_info, va_heap, vl_ptr> work_list = vNULL;
hash_set<tree> mark_set; hash_set<tree> mark_set;
...@@ -2111,8 +2072,8 @@ normalize_one_pred_chain (pred_chain_union *norm_preds, ...@@ -2111,8 +2072,8 @@ normalize_one_pred_chain (pred_chain_union *norm_preds,
while (!work_list.is_empty ()) while (!work_list.is_empty ())
{ {
pred_info a_pred = work_list.pop (); pred_info a_pred = work_list.pop ();
normalize_one_pred_1 (0, &norm_chain, a_pred, normalize_one_pred_1 (0, &norm_chain, a_pred, BIT_AND_EXPR, &work_list,
BIT_AND_EXPR, &work_list, &mark_set); &mark_set);
} }
norm_preds->safe_push (norm_chain); norm_preds->safe_push (norm_chain);
...@@ -2148,14 +2109,14 @@ normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use) ...@@ -2148,14 +2109,14 @@ normalize_preds (pred_chain_union preds, gimple *use_or_def, bool is_use)
if (dump_file) if (dump_file)
{ {
fprintf (dump_file, "[AFTER NORMALIZATION -- "); fprintf (dump_file, "[AFTER NORMALIZATION -- ");
dump_predicates (use_or_def, norm_preds, is_use ? "[USE]:\n" : "[DEF]:\n"); dump_predicates (use_or_def, norm_preds,
is_use ? "[USE]:\n" : "[DEF]:\n");
} }
destroy_predicate_vecs (&preds); destroy_predicate_vecs (&preds);
return norm_preds; return norm_preds;
} }
/* Computes the predicates that guard the use and checks /* Computes the predicates that guard the use and checks
if the incoming paths that have empty (or possibly if the incoming paths that have empty (or possibly
empty) definition can be pruned/filtered. The function returns empty) definition can be pruned/filtered. The function returns
...@@ -2271,7 +2232,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds, ...@@ -2271,7 +2232,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds,
if (is_gimple_debug (use_stmt)) if (is_gimple_debug (use_stmt))
continue; continue;
if (gphi *use_phi = dyn_cast <gphi *> (use_stmt)) if (gphi *use_phi = dyn_cast<gphi *> (use_stmt))
use_bb = gimple_phi_arg_edge (use_phi, use_bb = gimple_phi_arg_edge (use_phi,
PHI_ARG_INDEX_FROM_USE (use_p))->src; PHI_ARG_INDEX_FROM_USE (use_p))->src;
else else
...@@ -2296,7 +2257,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds, ...@@ -2296,7 +2257,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds,
/* Found a phi use that is not guarded, /* Found a phi use that is not guarded,
add the phi to the worklist. */ add the phi to the worklist. */
if (!added_to_worklist->add (as_a <gphi *> (use_stmt))) if (!added_to_worklist->add (as_a<gphi *> (use_stmt)))
{ {
if (dump_file && (dump_flags & TDF_DETAILS)) if (dump_file && (dump_flags & TDF_DETAILS))
{ {
...@@ -2304,7 +2265,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds, ...@@ -2304,7 +2265,7 @@ find_uninit_use (gphi *phi, unsigned uninit_opnds,
print_gimple_stmt (dump_file, use_stmt, 0, 0); print_gimple_stmt (dump_file, use_stmt, 0, 0);
} }
worklist->safe_push (as_a <gphi *> (use_stmt)); worklist->safe_push (as_a<gphi *> (use_stmt));
possibly_undefined_names->add (phi_result); possibly_undefined_names->add (phi_result);
} }
} }
...@@ -2366,7 +2327,6 @@ warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist, ...@@ -2366,7 +2327,6 @@ warn_uninitialized_phi (gphi *phi, vec<gphi *> *worklist,
SSA_NAME_VAR (uninit_op), SSA_NAME_VAR (uninit_op),
"%qD may be used uninitialized in this function", "%qD may be used uninitialized in this function",
uninit_use_stmt, loc); uninit_use_stmt, loc);
} }
static bool static bool
...@@ -2398,7 +2358,7 @@ public: ...@@ -2398,7 +2358,7 @@ public:
{} {}
/* opt_pass methods: */ /* opt_pass methods: */
opt_pass * clone () { return new pass_late_warn_uninitialized (m_ctxt); } opt_pass *clone () { return new pass_late_warn_uninitialized (m_ctxt); }
virtual bool gate (function *) { return gate_warn_uninitialized (); } virtual bool gate (function *) { return gate_warn_uninitialized (); }
virtual unsigned int execute (function *); virtual unsigned int execute (function *);
...@@ -2439,8 +2399,7 @@ pass_late_warn_uninitialized::execute (function *fun) ...@@ -2439,8 +2399,7 @@ pass_late_warn_uninitialized::execute (function *fun)
for (i = 0; i < n; ++i) for (i = 0; i < n; ++i)
{ {
tree op = gimple_phi_arg_def (phi, i); tree op = gimple_phi_arg_def (phi, i);
if (TREE_CODE (op) == SSA_NAME if (TREE_CODE (op) == SSA_NAME && uninit_undefined_value_p (op))
&& uninit_undefined_value_p (op))
{ {
worklist.safe_push (phi); worklist.safe_push (phi);
added_to_worklist.add (phi); added_to_worklist.add (phi);
...@@ -2477,7 +2436,6 @@ make_pass_late_warn_uninitialized (gcc::context *ctxt) ...@@ -2477,7 +2436,6 @@ make_pass_late_warn_uninitialized (gcc::context *ctxt)
return new pass_late_warn_uninitialized (ctxt); return new pass_late_warn_uninitialized (ctxt);
} }
static unsigned int static unsigned int
execute_early_warn_uninitialized (void) execute_early_warn_uninitialized (void)
{ {
...@@ -2497,7 +2455,6 @@ execute_early_warn_uninitialized (void) ...@@ -2497,7 +2455,6 @@ execute_early_warn_uninitialized (void)
return 0; return 0;
} }
namespace { namespace {
const pass_data pass_data_early_warn_uninitialized = const pass_data pass_data_early_warn_uninitialized =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment