aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjakub <>2011-12-01 19:12:54 +0000
committerjakub <>2011-12-01 19:12:54 +0000
commit6126c476cb72151c4871c052db7fe10da6255aa4 (patch)
treea0a8960c1902ff04d8b319d3ba88cf5c4f64534b /gcc
parent53d86c197f0e81e9c34b463290bd8e74b49a60f0 (diff)
PR debug/50317
* tree-ssa-dce.c (remove_dead_stmt): Add a debug stmt when removing as unnecessary a store to a variable with gimple reg type. * tree-ssa-live.c (remove_unused_locals): Clear TREE_ADDRESSABLE bit on local unreferenced variables. * cfgexpand.c (expand_gimple_basic_block): Don't emit DEBUG_INSNs for !target_for_debug_bind variables.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/cfgexpand.c6
-rw-r--r--gcc/tree-ssa-dce.c20
-rw-r--r--gcc/tree-ssa-live.c12
4 files changed, 46 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1261e4befc6..0ab88fa1198 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2011-12-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/50317
+ * tree-ssa-dce.c (remove_dead_stmt): Add a debug stmt when removing
+ as unnecessary a store to a variable with gimple reg type.
+ * tree-ssa-live.c (remove_unused_locals): Clear TREE_ADDRESSABLE bit
+ on local unreferenced variables.
+ * cfgexpand.c (expand_gimple_basic_block): Don't emit DEBUG_INSNs
+ for !target_for_debug_bind variables.
+
2011-12-01 Patrick Marlier <patrick.marlier@gmail.com>
PR middle-end/51273
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 2a82b032f5d..e5a7a392eb4 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3903,6 +3903,11 @@ expand_gimple_basic_block (basic_block bb)
rtx val;
enum machine_mode mode;
+ if (TREE_CODE (var) != DEBUG_EXPR_DECL
+ && TREE_CODE (var) != LABEL_DECL
+ && !target_for_debug_bind (var))
+ goto delink_debug_stmt;
+
if (gimple_debug_bind_has_value_p (stmt))
value = gimple_debug_bind_get_value (stmt);
else
@@ -3932,6 +3937,7 @@ expand_gimple_basic_block (basic_block bb)
PAT_VAR_LOCATION_LOC (val) = (rtx)value;
}
+ delink_debug_stmt:
/* In order not to generate too many debug temporaries,
we delink all uses of debug statements we already expanded.
Therefore debug statements between definition and real
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index d6fbe622df0..a710de620df 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1215,6 +1215,26 @@ remove_dead_stmt (gimple_stmt_iterator *i, basic_block bb)
ei_next (&ei);
}
+ /* If this is a store into a variable that is being optimized away,
+ add a debug bind stmt if possible. */
+ if (MAY_HAVE_DEBUG_STMTS
+ && gimple_assign_single_p (stmt)
+ && is_gimple_val (gimple_assign_rhs1 (stmt)))
+ {
+ tree lhs = gimple_assign_lhs (stmt);
+ if ((TREE_CODE (lhs) == VAR_DECL || TREE_CODE (lhs) == PARM_DECL)
+ && !DECL_IGNORED_P (lhs)
+ && is_gimple_reg_type (TREE_TYPE (lhs))
+ && !is_global_var (lhs)
+ && !DECL_HAS_VALUE_EXPR_P (lhs))
+ {
+ tree rhs = gimple_assign_rhs1 (stmt);
+ gimple note
+ = gimple_build_debug_bind (lhs, unshare_expr (rhs), stmt);
+ gsi_insert_after (i, note, GSI_SAME_STMT);
+ }
+ }
+
unlink_stmt_vdef (stmt);
gsi_remove (i, true);
release_defs (stmt);
diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c
index b8a056ebdac..103e4f7155a 100644
--- a/gcc/tree-ssa-live.c
+++ b/gcc/tree-ssa-live.c
@@ -1,5 +1,5 @@
/* Liveness for SSA trees.
- Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Andrew MacLeod <amacleod@redhat.com>
@@ -814,7 +814,15 @@ remove_unused_locals (void)
bitmap_set_bit (global_unused_vars, DECL_UID (var));
}
else
- continue;
+ {
+ /* For unreferenced local vars drop TREE_ADDRESSABLE
+ bit in case it is referenced from debug stmts. */
+ if (DECL_CONTEXT (var) == current_function_decl
+ && TREE_ADDRESSABLE (var)
+ && is_gimple_reg_type (TREE_TYPE (var)))
+ TREE_ADDRESSABLE (var) = 0;
+ continue;
+ }
}
else if (TREE_CODE (var) == VAR_DECL
&& DECL_HARD_REGISTER (var)