tree-into-ssa.c (rewrite_stmt): Remove clobbers for variables we rewrite into SSA form.

2012-08-07  Richard Guenther  <rguenther@suse.de>

	* tree-into-ssa.c (rewrite_stmt): Remove clobbers for variables
	we rewrite into SSA form.
	(rewrite_enter_block): Adjust.
	* gimple-iterator.c (gsi_replace): Also allow replacement with
	a stmt without a lhs.
	* tree-ssa-live.c (remove_unused_locals): Remove code handling
	clobbers of SSA names.
	* tree-nested.c (convert_local_reference_stmt): Remove clobbers
	for variables we access through the local chain.
	* tree-cfg.c (verify_gimple_assign_single): Verify clobbers
	clobber full decls only.

From-SVN: r190200
This commit is contained in:
Richard Guenther 2012-08-07 12:11:43 +00:00 committed by Richard Biener
parent dcc748dd77
commit 5f33a4fc3e
6 changed files with 57 additions and 9 deletions

View File

@ -1,3 +1,17 @@
2012-08-07 Richard Guenther <rguenther@suse.de>
* tree-into-ssa.c (rewrite_stmt): Remove clobbers for variables
we rewrite into SSA form.
(rewrite_enter_block): Adjust.
* gimple-iterator.c (gsi_replace): Also allow replacement with
a stmt without a lhs.
* tree-ssa-live.c (remove_unused_locals): Remove code handling
clobbers of SSA names.
* tree-nested.c (convert_local_reference_stmt): Remove clobbers
for variables we access through the local chain.
* tree-cfg.c (verify_gimple_assign_single): Verify clobbers
clobber full decls only.
2012-08-07 Richard Guenther <rguenther@suse.de>
* gimple.h (gimple_phi_set_result): Adjust SSA_NAME_DEF_STMT.

View File

@ -427,7 +427,7 @@ gsi_replace (gimple_stmt_iterator *gsi, gimple stmt, bool update_eh_info)
if (stmt == orig_stmt)
return;
gcc_assert (!gimple_has_lhs (orig_stmt)
gcc_assert (!gimple_has_lhs (orig_stmt) || !gimple_has_lhs (stmt)
|| gimple_get_lhs (orig_stmt) == gimple_get_lhs (stmt));
gimple_set_location (stmt, gimple_location (orig_stmt));

View File

@ -3930,6 +3930,14 @@ verify_gimple_assign_single (gimple stmt)
return true;
}
if (gimple_clobber_p (stmt)
&& !DECL_P (lhs))
{
error ("non-decl LHS in clobber statement");
debug_generic_expr (lhs);
return true;
}
if (handled_component_p (lhs))
res |= verify_types_in_gimple_reference (lhs, true);

View File

@ -1323,12 +1323,12 @@ rewrite_debug_stmt_uses (gimple stmt)
definition of a variable when a new real or virtual definition is found. */
static void
rewrite_stmt (gimple_stmt_iterator si)
rewrite_stmt (gimple_stmt_iterator *si)
{
use_operand_p use_p;
def_operand_p def_p;
ssa_op_iter iter;
gimple stmt = gsi_stmt (si);
gimple stmt = gsi_stmt (*si);
/* If mark_def_sites decided that we don't need to rewrite this
statement, ignore it. */
@ -1362,9 +1362,24 @@ rewrite_stmt (gimple_stmt_iterator si)
FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_ALL_DEFS)
{
tree var = DEF_FROM_PTR (def_p);
tree name = make_ssa_name (var, stmt);
tree name;
tree tracked_var;
gcc_assert (DECL_P (var));
if (gimple_clobber_p (stmt)
&& is_gimple_reg (var))
{
/* If we rewrite a DECL into SSA form then drop its
clobber stmts and replace uses with a new default def. */
gcc_assert (TREE_CODE (var) == VAR_DECL
&& !gimple_vdef (stmt));
gsi_replace (si, gimple_build_nop (), true);
register_new_def (get_or_create_ssa_default_def (cfun, var), var);
break;
}
name = make_ssa_name (var, stmt);
SET_DEF (def_p, name);
register_new_def (DEF_FROM_PTR (def_p), var);
@ -1372,7 +1387,7 @@ rewrite_stmt (gimple_stmt_iterator si)
if (tracked_var)
{
gimple note = gimple_build_debug_bind (tracked_var, name, stmt);
gsi_insert_after (&si, note, GSI_SAME_STMT);
gsi_insert_after (si, note, GSI_SAME_STMT);
}
}
}
@ -1439,7 +1454,7 @@ rewrite_enter_block (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
of a variable when a new real or virtual definition is found. */
if (TEST_BIT (interesting_blocks, bb->index))
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
rewrite_stmt (gsi);
rewrite_stmt (&gsi);
/* Step 3. Visit all the successor blocks of BB looking for PHI nodes.
For every PHI node found, add a new argument containing the current

View File

@ -1727,6 +1727,20 @@ convert_local_reference_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
*handled_ops_p = false;
return NULL_TREE;
case GIMPLE_ASSIGN:
if (gimple_clobber_p (stmt))
{
tree lhs = gimple_assign_lhs (stmt);
if (!use_pointer_in_frame (lhs)
&& lookup_field_for_decl (info, lhs, NO_INSERT))
{
gsi_replace (gsi, gimple_build_nop (), true);
break;
}
}
*handled_ops_p = false;
return NULL_TREE;
default:
/* For every other statement that we are not interested in
handling here, let the walker traverse the operands. */

View File

@ -773,9 +773,6 @@ remove_unused_locals (void)
if (gimple_clobber_p (stmt))
{
tree lhs = gimple_assign_lhs (stmt);
lhs = get_base_address (lhs);
if (TREE_CODE (lhs) == SSA_NAME)
lhs = SSA_NAME_VAR (lhs);
if (TREE_CODE (lhs) == VAR_DECL && !is_used_p (lhs))
{
unlink_stmt_vdef (stmt);