This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[vta,vta4.3] copy block and location info into new debug stmts
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 10 Sep 2008 04:33:33 -0300
- Subject: [vta,vta4.3] copy block and location info into new debug stmts
This patch arranges for debug stmts to get block and location info set
up from the phi node (trunk only) or gimple stmt that causes the debug
stmt to be created in the first place. It doesn't make any difference
to executable code, as expected, but it introduces additional line
number markers that might make for a slightly better debug experience.
Patches for vta and vta4.3, respectively.
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* gimple.c (gimple_build_debug_bind_stat): Copy block and location
information from new stmt argument.
* gimple.h (gimple_build_debug_bind_stat): Adjust declaration.
(gimple_build_debug_bind): Adjust.
* tree-inline.c (remap_gimple_stmt, setup_one_parameter): Adjust.
* tree-into-ssa.c (insert_phi_nodes_for, rewrite_stmt): Adjust.
Index: gcc/gimple.c
===================================================================
--- gcc/gimple.c.orig 2008-09-05 03:09:36.000000000 -0300
+++ gcc/gimple.c 2008-09-05 03:11:05.000000000 -0300
@@ -834,13 +834,18 @@ gimple_build_switch_vec (tree index, tre
VAR is bound to VALUE. */
gimple
-gimple_build_debug_bind_stat (tree var, tree value MEM_STAT_DECL)
+gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL)
{
gimple p = gimple_build_with_ops_stat (GIMPLE_DEBUG, VAR_DEBUG_VALUE, 2
PASS_MEM_STAT);
gimple_debug_bind_set_var (p, var);
gimple_debug_bind_set_value (p, value);
+ if (stmt)
+ {
+ gimple_set_block (p, gimple_block (stmt));
+ gimple_set_location (p, gimple_location (stmt));
+ }
return p;
}
Index: gcc/gimple.h
===================================================================
--- gcc/gimple.h.orig 2008-09-05 03:09:36.000000000 -0300
+++ gcc/gimple.h 2008-09-05 03:09:53.000000000 -0300
@@ -776,9 +776,9 @@ gimple gimple_build_assign_with_ops_stat
#define gimple_build_assign_with_ops(c,o1,o2,o3) \
gimple_build_assign_with_ops_stat (c, o1, o2, o3 MEM_STAT_INFO)
-gimple gimple_build_debug_bind_stat (tree, tree MEM_STAT_DECL);
-#define gimple_build_debug_bind(var,val) \
- gimple_build_debug_bind_stat ((var), (val) MEM_STAT_INFO)
+gimple gimple_build_debug_bind_stat (tree, tree, gimple MEM_STAT_DECL);
+#define gimple_build_debug_bind(var,val,stmt) \
+ gimple_build_debug_bind_stat ((var), (val), (stmt) MEM_STAT_INFO)
gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
gimple gimple_build_call (tree, unsigned, ...);
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c.orig 2008-09-05 03:09:36.000000000 -0300
+++ gcc/tree-inline.c 2008-09-05 03:09:53.000000000 -0300
@@ -1202,7 +1202,8 @@ remap_gimple_stmt (gimple stmt, copy_bod
if (IS_DEBUG_BIND (stmt))
{
copy = gimple_build_debug_bind (VAR_DEBUG_VALUE_VAR (stmt),
- VAR_DEBUG_VALUE_VALUE (stmt));
+ VAR_DEBUG_VALUE_VALUE (stmt),
+ stmt);
VARRAY_PUSH_GENERIC_PTR (id->debug_stmts, copy);
}
else
@@ -2055,7 +2056,8 @@ setup_one_parameter (copy_body_data *id,
{
gimple note = gimple_build_debug_bind (var,
is_gimple_reg (p)
- ? def : var);
+ ? def : var,
+ init_stmt);
gsi_insert_after (&si, note, GSI_SAME_STMT);
}
Index: gcc/tree-into-ssa.c
===================================================================
--- gcc/tree-into-ssa.c.orig 2008-09-05 03:09:36.000000000 -0300
+++ gcc/tree-into-ssa.c 2008-09-05 03:09:53.000000000 -0300
@@ -1395,7 +1395,8 @@ insert_phi_nodes_for (tree var, bitmap p
phi = create_phi_node (var, bb);
if (!update_p && var_debug_value_for_decl (var))
{
- gimple note = gimple_build_debug_bind (var, PHI_RESULT (phi));
+ gimple note = gimple_build_debug_bind (var, PHI_RESULT (phi),
+ phi);
gimple_stmt_iterator si = gsi_after_labels (bb);
gsi_insert_before (&si, note, GSI_SAME_STMT);
}
@@ -1613,7 +1614,7 @@ rewrite_stmt (struct dom_walk_data *walk
SET_DEF (def_p, name = make_ssa_name (var, stmt));
if (var_debug_value_for_decl (var))
{
- gimple note = gimple_build_debug_bind (var, name);
+ gimple note = gimple_build_debug_bind (var, name, stmt);
gsi_insert_after (&si, note, GSI_SAME_STMT);
}
register_new_def (DEF_FROM_PTR (def_p), var);
for gcc/ChangeLog.vta
from Alexandre Oliva <aoliva@redhat.com>
* tree.c (build_var_debug_value_stat): Copy block and location
information from new stmt argument.
* tree.h (build_var_debug_value_stat): Adjust declaration.
(build_var_debug_value): Adjust.
* tree-inline.c (setup_one_parameter): Adjust.
* tree-into-ssa.c (insert_phi_nodes_for, rewrite_stmt): Adjust.
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c.orig 2008-08-12 03:55:41.000000000 -0300
+++ gcc/tree-inline.c 2008-09-05 03:56:41.000000000 -0300
@@ -1633,7 +1633,8 @@ setup_one_parameter (copy_body_data *id,
{
tree note = build_var_debug_value (var,
is_gimple_reg (p)
- ? def : var);
+ ? def : var,
+ bsi_stmt (bsi));
bsi_insert_after (&bsi, note, BSI_SAME_STMT);
}
Index: gcc/tree-into-ssa.c
===================================================================
--- gcc/tree-into-ssa.c.orig 2008-08-12 04:22:54.000000000 -0300
+++ gcc/tree-into-ssa.c 2008-09-05 03:57:35.000000000 -0300
@@ -1423,7 +1423,7 @@ insert_phi_nodes_for (tree var, bitmap p
phi = create_phi_node (sym, bb);
if (!update_p && var_debug_value_for_decl (sym))
{
- tree note = build_var_debug_value (sym, PHI_RESULT (phi));
+ tree note = build_var_debug_value (sym, PHI_RESULT (phi), phi);
block_stmt_iterator si = bsi_after_labels (bb);
bsi_insert_before (&si, note, BSI_SAME_STMT);
}
@@ -1637,7 +1637,7 @@ rewrite_stmt (struct dom_walk_data *walk
SET_DEF (def_p, name = make_ssa_name (var, stmt));
if (var_debug_value_for_decl (var))
{
- tree note = build_var_debug_value (var, name);
+ tree note = build_var_debug_value (var, name, stmt);
bsi_insert_after (&si, note, BSI_SAME_STMT);
}
register_new_def (DEF_FROM_PTR (def_p), var);
Index: gcc/tree.c
===================================================================
--- gcc/tree.c.orig 2008-09-05 03:55:09.000000000 -0300
+++ gcc/tree.c 2008-09-05 04:47:18.000000000 -0300
@@ -1,6 +1,6 @@
/* Language-independent node constructors for parse phase of GNU compiler.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
Free Software Foundation, Inc.
This file is part of GCC.
@@ -3166,7 +3166,7 @@ build_gimple_modify_stmt_stat (tree arg0
type, so we can't use build2 (a.k.a. build2_stat). */
tree
-build_var_debug_value_stat (tree arg0, tree arg1 MEM_STAT_DECL)
+build_var_debug_value_stat (tree arg0, tree arg1, tree stmt MEM_STAT_DECL)
{
tree t;
@@ -3174,6 +3174,12 @@ build_var_debug_value_stat (tree arg0, t
/* ?? We don't care about setting flags for tuples... */
VAR_DEBUG_VALUE_SET_VAR (t, arg0);
VAR_DEBUG_VALUE_VALUE (t) = arg1;
+ if (stmt && GIMPLE_STMT_P (stmt))
+ {
+ GIMPLE_STMT_BLOCK (t) = GIMPLE_STMT_BLOCK (stmt);
+ GIMPLE_STMT_LOCUS (t) = GIMPLE_STMT_LOCUS (stmt);
+ }
+
return t;
}
Index: gcc/tree.h
===================================================================
--- gcc/tree.h.orig 2008-09-05 03:55:09.000000000 -0300
+++ gcc/tree.h 2008-09-05 03:54:00.000000000 -0300
@@ -4020,9 +4020,9 @@ extern tree build_gimple_modify_stmt_sta
#define build_gimple_modify_stmt(t1,t2) \
build_gimple_modify_stmt_stat (t1,t2 MEM_STAT_INFO)
-extern tree build_var_debug_value_stat (tree, tree MEM_STAT_DECL);
-#define build_var_debug_value(t1,t2) \
- build_var_debug_value_stat (t1,t2 MEM_STAT_INFO)
+extern tree build_var_debug_value_stat (tree, tree, tree MEM_STAT_DECL);
+#define build_var_debug_value(t1,t2,t3) \
+ build_var_debug_value_stat (t1,t2,t3 MEM_STAT_INFO)
extern tree build_int_cst (tree, HOST_WIDE_INT);
extern tree build_int_cst_type (tree, HOST_WIDE_INT);
--
Alexandre Oliva http://www.lsd.ic.unicamp.br/~oliva/
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
FSFLA Board Member ÂSÃ Libre! => http://www.fsfla.org/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}