Commit e74780a3 by Xinliang David Li Committed by Xinliang David Li

Fix PR44932

From-SVN: r162310
parent 8b4c365c
2010-07-19 Xinliang David Li <davidxl@google.com>
PR testsuite/44932
* tree-ssa-uninit.c (collect_phi_def_edges): Fix bug collecting def edges.
(find_uninit_use): Add dump.
(is_use_properly_guarded): Ditto.
(warn_uninitialized_phi): Ditto.
(execute_late_warn_uninitialized): Ditto.
2010-07-19 Richard Guenther <rguenther@suse.de> 2010-07-19 Richard Guenther <rguenther@suse.de>
PR middle-end/44941 PR middle-end/44941
......
...@@ -490,17 +490,33 @@ collect_phi_def_edges (gimple phi, basic_block cd_root, ...@@ -490,17 +490,33 @@ collect_phi_def_edges (gimple phi, basic_block cd_root,
opnd_edge = gimple_phi_arg_edge (phi, i); opnd_edge = gimple_phi_arg_edge (phi, i);
opnd = gimple_phi_arg_def (phi, i); opnd = gimple_phi_arg_def (phi, i);
if (TREE_CODE (opnd) != SSA_NAME if (TREE_CODE (opnd) != SSA_NAME)
|| !ssa_undefined_value_p (opnd)) {
VEC_safe_push (edge, heap, *edges, opnd_edge); if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i);
print_gimple_stmt (dump_file, phi, 0, 0);
}
VEC_safe_push (edge, heap, *edges, opnd_edge);
}
else else
{ {
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 (def, cd_root, edges, collect_phi_def_edges (def, cd_root, edges,
visited_phis); visited_phis);
else if (!ssa_undefined_value_p (opnd))
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "\n[CHECK] Found def edge %d in ", (int)i);
print_gimple_stmt (dump_file, phi, 0, 0);
}
VEC_safe_push (edge, heap, *edges, opnd_edge);
}
} }
} }
} }
...@@ -1530,7 +1546,7 @@ is_use_properly_guarded (gimple use_stmt, ...@@ -1530,7 +1546,7 @@ is_use_properly_guarded (gimple use_stmt,
if (dump_file) if (dump_file)
dump_predicates (use_stmt, num_preds, preds, dump_predicates (use_stmt, num_preds, preds,
"Use in stmt "); "\nUse in stmt ");
has_valid_preds = find_def_preds (&def_preds, has_valid_preds = find_def_preds (&def_preds,
&num_def_preds, phi); &num_def_preds, phi);
...@@ -1615,15 +1631,26 @@ find_uninit_use (gimple phi, unsigned uninit_opnds, ...@@ -1615,15 +1631,26 @@ find_uninit_use (gimple phi, unsigned uninit_opnds,
} }
pointer_set_destroy (visited_phis); pointer_set_destroy (visited_phis);
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "[CHECK]: Found unguarded use: ");
print_gimple_stmt (dump_file, use_stmt, 0, 0);
}
/* Found one real use, return. */ /* Found one real use, return. */
if (gimple_code (use_stmt) != GIMPLE_PHI) if (gimple_code (use_stmt) != GIMPLE_PHI)
return use_stmt; return use_stmt;
/* 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 (!pointer_set_insert (added_to_worklist, if (!pointer_set_insert (added_to_worklist,
use_stmt)) use_stmt))
{ {
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "[WORKLIST]: Update worklist with phi: ");
print_gimple_stmt (dump_file, use_stmt, 0, 0);
}
VEC_safe_push (gimple, heap, *worklist, use_stmt); VEC_safe_push (gimple, heap, *worklist, use_stmt);
pointer_set_insert (possibly_undefined_names, pointer_set_insert (possibly_undefined_names,
phi_result); phi_result);
...@@ -1658,6 +1685,12 @@ warn_uninitialized_phi (gimple phi, VEC(gimple, heap) **worklist, ...@@ -1658,6 +1685,12 @@ warn_uninitialized_phi (gimple phi, VEC(gimple, heap) **worklist,
if (MASK_EMPTY (uninit_opnds)) if (MASK_EMPTY (uninit_opnds))
return; return;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "[CHECK]: examining phi: ");
print_gimple_stmt (dump_file, phi, 0, 0);
}
/* Now check if we have any use of the value without proper guard. */ /* Now check if we have any use of the value without proper guard. */
uninit_use_stmt = find_uninit_use (phi, uninit_opnds, uninit_use_stmt = find_uninit_use (phi, uninit_opnds,
worklist, added_to_worklist); worklist, added_to_worklist);
...@@ -1717,6 +1750,11 @@ execute_late_warn_uninitialized (void) ...@@ -1717,6 +1750,11 @@ execute_late_warn_uninitialized (void)
{ {
VEC_safe_push (gimple, heap, worklist, phi); VEC_safe_push (gimple, heap, worklist, phi);
pointer_set_insert (added_to_worklist, phi); pointer_set_insert (added_to_worklist, phi);
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "[WORKLIST]: add to initial list: ");
print_gimple_stmt (dump_file, phi, 0, 0);
}
break; break;
} }
} }
...@@ -1728,7 +1766,7 @@ execute_late_warn_uninitialized (void) ...@@ -1728,7 +1766,7 @@ execute_late_warn_uninitialized (void)
cur_phi = VEC_pop (gimple, worklist); cur_phi = VEC_pop (gimple, worklist);
warn_uninitialized_phi (cur_phi, &worklist, added_to_worklist); warn_uninitialized_phi (cur_phi, &worklist, added_to_worklist);
} }
VEC_free (gimple, heap, worklist); VEC_free (gimple, heap, worklist);
pointer_set_destroy (added_to_worklist); pointer_set_destroy (added_to_worklist);
pointer_set_destroy (possibly_undefined_names); pointer_set_destroy (possibly_undefined_names);
......
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