This makes sure clobbers of SSA names are never retained in the IL. First by verifying that in the gimple verifier, second by removing them when we go into SSA form. Third by catching those we have to get rid of when un-nesting - this avoids stuff like
finally { D.1234 = CLOBBER; frame.i = D.1234; } and D.1234 being a candidate for a register. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-08-07 Richard Guenther <rguent...@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. Index: gcc/tree-into-ssa.c =================================================================== --- gcc/tree-into-ssa.c (revision 190199) +++ gcc/tree-into-ssa.c (working copy) @@ -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_dat 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 Index: gcc/gimple-iterator.c =================================================================== --- gcc/gimple-iterator.c (revision 190198) +++ gcc/gimple-iterator.c (working copy) @@ -427,7 +427,7 @@ gsi_replace (gimple_stmt_iterator *gsi, 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)); Index: gcc/tree-ssa-live.c =================================================================== --- gcc/tree-ssa-live.c (revision 190198) +++ gcc/tree-ssa-live.c (working copy) @@ -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); Index: gcc/tree-nested.c =================================================================== --- gcc/tree-nested.c (revision 190198) +++ gcc/tree-nested.c (working copy) @@ -1727,6 +1727,20 @@ convert_local_reference_stmt (gimple_stm *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. */ Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 190199) +++ gcc/tree-cfg.c (working copy) @@ -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);