diff options
author | Jakub Jelinek <jakub@redhat.com> | 2013-04-02 20:25:36 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2013-04-02 20:25:36 +0200 |
commit | 5d751b0c970f54e3a99a177d4b2d77db81116e09 (patch) | |
tree | 4ee3c2b7dfdc5ebe044adb7a6e509a7d8ffa2e13 /gcc/tree-ssa-live.c | |
parent | e594716a6a02ffcc0a33862ff6ea8325ac2263e8 (diff) | |
download | gcc-5d751b0c970f54e3a99a177d4b2d77db81116e09.zip gcc-5d751b0c970f54e3a99a177d4b2d77db81116e09.tar.gz gcc-5d751b0c970f54e3a99a177d4b2d77db81116e09.tar.bz2 |
re PR c++/34949 (Dead code in empty destructors.)
PR c++/34949
* tree-cfg.c (verify_gimple_assign_single): Allow lhs
of gimple_clobber_p to be MEM_REF.
* gimplify.c (gimplify_modify_expr): Gimplify *to_p of
an assignment from TREE_CLOBBER_P. Allow it to be MEM_REF
after gimplification.
* asan.c (get_mem_ref_of_assignment): Don't instrument
gimple_clobber_p stmts.
* tree-ssa-dse.c (dse_optimize_stmt): Allow DSE of
gimple_clobber_p stmt if they have MEM_REF lhs and
are dead because of another gimple_clobber_p stmt.
* tree-ssa-live.c (clear_unused_block_pointer): Treat
gimple_clobber_p stmts like debug stmts.
(remove_unused_locals): Remove clobbers with MEM_REF lhs
that refer to unused VAR_DECLs or uninitialized values.
* tree-sra.c (sra_ipa_reset_debug_stmts): Also remove
gimple_clobber_p stmts if they refer to removed parameters.
(get_repl_default_def_ssa_name, sra_ipa_modify_expr): Fix up
formatting.
From-SVN: r197369
Diffstat (limited to 'gcc/tree-ssa-live.c')
-rw-r--r-- | gcc/tree-ssa-live.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index 756fa37..c8b9ce8 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -623,8 +623,8 @@ clear_unused_block_pointer_1 (tree *tp, int *, void *) return NULL_TREE; } -/* Set all block pointer in debug stmt to NULL if the block is unused, - so that they will not be streamed out. */ +/* Set all block pointer in debug or clobber stmt to NULL if the block + is unused, so that they will not be streamed out. */ static void clear_unused_block_pointer (void) @@ -639,7 +639,7 @@ clear_unused_block_pointer (void) tree b; gimple stmt = gsi_stmt (gsi); - if (!is_gimple_debug (stmt)) + if (!is_gimple_debug (stmt) && !gimple_clobber_p (stmt)) continue; b = gimple_block (stmt); if (b && !TREE_USED (b)) @@ -827,7 +827,15 @@ remove_unused_locals (void) if (gimple_clobber_p (stmt)) { tree lhs = gimple_assign_lhs (stmt); - if (TREE_CODE (lhs) == VAR_DECL && !is_used_p (lhs)) + tree base = get_base_address (lhs); + /* Remove clobbers referencing unused vars, or clobbers + with MEM_REF lhs referencing uninitialized pointers. */ + if ((TREE_CODE (base) == VAR_DECL && !is_used_p (base)) + || (TREE_CODE (lhs) == MEM_REF + && TREE_CODE (TREE_OPERAND (lhs, 0)) == SSA_NAME + && SSA_NAME_IS_DEFAULT_DEF (TREE_OPERAND (lhs, 0)) + && (TREE_CODE (SSA_NAME_VAR (TREE_OPERAND (lhs, 0))) + != PARM_DECL))) { unlink_stmt_vdef (stmt); gsi_remove (&gsi, true); |