Commit 70235ab9 by Jakub Jelinek Committed by Jakub Jelinek

re PR debug/43329 (Early inlining causes suboptimal debug info)

	PR debug/43329
	* tree-inline.c (remap_decls): Put old_var rather than origin_var
	into *nonlocalized_list vector.
	* dwarf2out.c (gen_formal_parameter_die): Call decl_ultimate_origin
	even if origin is non-NULL.
	(gen_variable_die): Likewise.
	(process_scope_var): Don't change origin.
	(gen_decl_die): Likewise.
	* tree-cfgcleanup.c (remove_forwarder_block): Check single_pred_p
	before adding new edges instead of after it, fix moving over
	debug stmts.

	* gcc.dg/guality/pr43329-1.c: New test.

From-SVN: r157402
parent d76f631a
2010-03-12 Jakub Jelinek <jakub@redhat.com>
PR debug/43329
* tree-inline.c (remap_decls): Put old_var rather than origin_var
into *nonlocalized_list vector.
* dwarf2out.c (gen_formal_parameter_die): Call decl_ultimate_origin
even if origin is non-NULL.
(gen_variable_die): Likewise.
(process_scope_var): Don't change origin.
(gen_decl_die): Likewise.
* tree-cfgcleanup.c (remove_forwarder_block): Check single_pred_p
before adding new edges instead of after it, fix moving over
debug stmts.
2010-03-11 David S. Miller <davem@davemloft.net> 2010-03-11 David S. Miller <davem@davemloft.net>
* configure.ac (gcc_cv_as_cfi_advance_working): Skip a multiple of four. * configure.ac (gcc_cv_as_cfi_advance_working): Skip a multiple of four.
......
...@@ -17382,14 +17382,16 @@ gen_formal_parameter_die (tree node, tree origin, bool emit_name_p, ...@@ -17382,14 +17382,16 @@ gen_formal_parameter_die (tree node, tree origin, bool emit_name_p,
dw_die_ref context_die) dw_die_ref context_die)
{ {
tree node_or_origin = node ? node : origin; tree node_or_origin = node ? node : origin;
tree ultimate_origin;
dw_die_ref parm_die dw_die_ref parm_die
= new_die (DW_TAG_formal_parameter, context_die, node); = new_die (DW_TAG_formal_parameter, context_die, node);
switch (TREE_CODE_CLASS (TREE_CODE (node_or_origin))) switch (TREE_CODE_CLASS (TREE_CODE (node_or_origin)))
{ {
case tcc_declaration: case tcc_declaration:
if (!origin) ultimate_origin = decl_ultimate_origin (node_or_origin);
origin = decl_ultimate_origin (node); if (node || ultimate_origin)
origin = ultimate_origin;
if (origin != NULL) if (origin != NULL)
add_abstract_origin_attribute (parm_die, origin); add_abstract_origin_attribute (parm_die, origin);
else else
...@@ -18106,15 +18108,16 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die) ...@@ -18106,15 +18108,16 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
HOST_WIDE_INT off; HOST_WIDE_INT off;
tree com_decl; tree com_decl;
tree decl_or_origin = decl ? decl : origin; tree decl_or_origin = decl ? decl : origin;
tree ultimate_origin;
dw_die_ref var_die; dw_die_ref var_die;
dw_die_ref old_die = decl ? lookup_decl_die (decl) : NULL; dw_die_ref old_die = decl ? lookup_decl_die (decl) : NULL;
dw_die_ref origin_die; dw_die_ref origin_die;
int declaration = (DECL_EXTERNAL (decl_or_origin) int declaration = (DECL_EXTERNAL (decl_or_origin)
|| class_or_namespace_scope_p (context_die)); || class_or_namespace_scope_p (context_die));
if (!origin) ultimate_origin = decl_ultimate_origin (decl_or_origin);
origin = decl_ultimate_origin (decl); if (decl || ultimate_origin)
origin = ultimate_origin;
com_decl = fortran_common (decl_or_origin, &off); com_decl = fortran_common (decl_or_origin, &off);
/* Symbol in common gets emitted as a child of the common block, in the form /* Symbol in common gets emitted as a child of the common block, in the form
...@@ -19160,10 +19163,6 @@ process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die) ...@@ -19160,10 +19163,6 @@ process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die)
{ {
dw_die_ref die; dw_die_ref die;
tree decl_or_origin = decl ? decl : origin; tree decl_or_origin = decl ? decl : origin;
tree ultimate_origin = origin ? decl_ultimate_origin (origin) : NULL;
if (ultimate_origin)
origin = ultimate_origin;
if (TREE_CODE (decl_or_origin) == FUNCTION_DECL) if (TREE_CODE (decl_or_origin) == FUNCTION_DECL)
die = lookup_decl_die (decl_or_origin); die = lookup_decl_die (decl_or_origin);
...@@ -19435,7 +19434,7 @@ static void ...@@ -19435,7 +19434,7 @@ static void
gen_decl_die (tree decl, tree origin, dw_die_ref context_die) gen_decl_die (tree decl, tree origin, dw_die_ref context_die)
{ {
tree decl_or_origin = decl ? decl : origin; tree decl_or_origin = decl ? decl : origin;
tree class_origin = NULL; tree class_origin = NULL, ultimate_origin;
if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin)) if (DECL_P (decl_or_origin) && DECL_IGNORED_P (decl_or_origin))
return; return;
...@@ -19481,7 +19480,9 @@ gen_decl_die (tree decl, tree origin, dw_die_ref context_die) ...@@ -19481,7 +19480,9 @@ gen_decl_die (tree decl, tree origin, dw_die_ref context_die)
/* If we're emitting a clone, emit info for the abstract instance. */ /* If we're emitting a clone, emit info for the abstract instance. */
if (origin || DECL_ORIGIN (decl) != decl) if (origin || DECL_ORIGIN (decl) != decl)
dwarf2out_abstract_function (origin ? origin : DECL_ABSTRACT_ORIGIN (decl)); dwarf2out_abstract_function (origin
? DECL_ORIGIN (origin)
: DECL_ABSTRACT_ORIGIN (decl));
/* If we're emitting an out-of-line copy of an inline function, /* If we're emitting an out-of-line copy of an inline function,
emit info for the abstract instance and set up to refer to it. */ emit info for the abstract instance and set up to refer to it. */
...@@ -19580,9 +19581,9 @@ gen_decl_die (tree decl, tree origin, dw_die_ref context_die) ...@@ -19580,9 +19581,9 @@ gen_decl_die (tree decl, tree origin, dw_die_ref context_die)
complicated because of the possibility that the VAR_DECL really complicated because of the possibility that the VAR_DECL really
represents an inlined instance of a formal parameter for an inline represents an inlined instance of a formal parameter for an inline
function. */ function. */
if (!origin) ultimate_origin = decl_ultimate_origin (decl_or_origin);
origin = decl_ultimate_origin (decl); if (ultimate_origin != NULL_TREE
if (origin != NULL_TREE && TREE_CODE (origin) == PARM_DECL) && TREE_CODE (ultimate_origin) == PARM_DECL)
gen_formal_parameter_die (decl, origin, gen_formal_parameter_die (decl, origin,
true /* Emit name attribute. */, true /* Emit name attribute. */,
context_die); context_die);
......
2010-03-12 Jakub Jelinek <jakub@redhat.com>
PR debug/43329
* gcc.dg/guality/pr43329-1.c: New test.
2010-03-11 Martin Jambor <mjambor@suse.cz> 2010-03-11 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/43257 PR tree-optimization/43257
......
/* PR debug/43329 */
/* { dg-do run } */
/* { dg-options "-g" } */
static inline void
foo (int argx)
{
int varx = argx;
__asm__ volatile ("nop"); /* { dg-final { gdb-test 10 "argx" "25" } } */
__asm__ volatile ("nop" : : "g" (varx)); /* { dg-final { gdb-test 10 "varx" "25" } } */
}
int i;
__attribute__((noinline))
void baz (int x)
{
asm volatile ("" : : "r" (x) : "memory");
}
static inline void
bar (void)
{
foo (25);
i = i + 2;
i = i * 2;
i = i - 4;
baz (i);
i = i * 2;
i = i >> 1;
i = i << 6;
baz (i);
i = i + 2;
i = i * 2;
i = i - 4;
baz (i);
i = i * 2;
i = i >> 6;
i = i << 1;
baz (i);
}
int
main (void)
{
__asm__ volatile ("" : "=r" (i) : "0" (0));
bar ();
bar ();
return i;
}
...@@ -376,6 +376,7 @@ remove_forwarder_block (basic_block bb) ...@@ -376,6 +376,7 @@ remove_forwarder_block (basic_block bb)
gimple label; gimple label;
edge_iterator ei; edge_iterator ei;
gimple_stmt_iterator gsi, gsi_to; gimple_stmt_iterator gsi, gsi_to;
bool can_move_debug_stmts;
/* We check for infinite loops already in tree_forwarder_block_p. /* We check for infinite loops already in tree_forwarder_block_p.
However it may happen that the infinite loop is created However it may happen that the infinite loop is created
...@@ -424,6 +425,8 @@ remove_forwarder_block (basic_block bb) ...@@ -424,6 +425,8 @@ remove_forwarder_block (basic_block bb)
} }
} }
can_move_debug_stmts = single_pred_p (dest);
/* Redirect the edges. */ /* Redirect the edges. */
for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei)); ) for (ei = ei_start (bb->preds); (e = ei_safe_edge (ei)); )
{ {
...@@ -480,15 +483,16 @@ remove_forwarder_block (basic_block bb) ...@@ -480,15 +483,16 @@ remove_forwarder_block (basic_block bb)
/* Move debug statements if the destination has just a single /* Move debug statements if the destination has just a single
predecessor. */ predecessor. */
if (single_pred_p (dest)) if (can_move_debug_stmts)
{ {
gsi_to = gsi_after_labels (dest); gsi_to = gsi_after_labels (dest);
for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); ) for (gsi = gsi_after_labels (bb); !gsi_end_p (gsi); )
{ {
if (!is_gimple_debug (gsi_stmt (gsi))) gimple debug = gsi_stmt (gsi);
if (!is_gimple_debug (debug))
break; break;
gsi_remove (&gsi, false); gsi_remove (&gsi, false);
gsi_insert_before (&gsi_to, label, GSI_SAME_STMT); gsi_insert_before (&gsi_to, debug, GSI_SAME_STMT);
} }
} }
......
...@@ -533,7 +533,6 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) ...@@ -533,7 +533,6 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id)
for (old_var = decls; old_var; old_var = TREE_CHAIN (old_var)) for (old_var = decls; old_var; old_var = TREE_CHAIN (old_var))
{ {
tree new_var; tree new_var;
tree origin_var = DECL_ORIGIN (old_var);
if (can_be_nonlocal (old_var, id)) if (can_be_nonlocal (old_var, id))
{ {
...@@ -545,7 +544,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) ...@@ -545,7 +544,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id)
if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE) if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE)
&& !DECL_IGNORED_P (old_var) && !DECL_IGNORED_P (old_var)
&& nonlocalized_list) && nonlocalized_list)
VEC_safe_push (tree, gc, *nonlocalized_list, origin_var); VEC_safe_push (tree, gc, *nonlocalized_list, old_var);
continue; continue;
} }
...@@ -563,7 +562,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id) ...@@ -563,7 +562,7 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id)
if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE) if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE)
&& !DECL_IGNORED_P (old_var) && !DECL_IGNORED_P (old_var)
&& nonlocalized_list) && nonlocalized_list)
VEC_safe_push (tree, gc, *nonlocalized_list, origin_var); VEC_safe_push (tree, gc, *nonlocalized_list, old_var);
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment