Commit 6b20f353 by Dodji Seketeli Committed by Dodji Seketeli

re PR debug/27574 (MIssing debug info at -O0 for a local variable in a C++ constructor)

gcc/ChangeLog:
2008-11-12  Dodji Seketeli  <dodji@redhat.com>

	PR debug/27574
	* cgraph.h: New abstract_and_needed member to struct cgraph_node.
	* cgraphunit.c (cgraph_analyze_functions): Flag abstract functions
	- which clones are reachable - as "abstract and needed".
	* cgraph.c (cgraph_release_function_body):  If a node is "abstract and needed",
	do not release its DECL_INITIAL() content because that will be needed to emit
	debug info.

gcc/testsuite/ChangeLog:
2008-11-12  Dodji Seketeli  <dodji@redhat.com>

	PR debug/27574
	* g++.dg/debug/dwarf2/local-var-in-contructor.C: New test.

From-SVN: r141807
parent ac125082
2008-11-12 Dodji Seketeli <dodji@redhat.com>
PR debug/27574
* cgraph.h: New abstract_and_needed member to struct cgraph_node.
* cgraphunit.c (cgraph_analyze_functions): Flag abstract functions
- which clones are reachable - as "abstract and needed".
* cgraph.c (cgraph_release_function_body): If a node is "abstract and needed",
do not release its DECL_INITIAL() content because that will be needed to emit
debug info.
2008-11-12 Steve Ellcey <sje@cup.hp.com>
PR target/27880
......
......@@ -936,7 +936,11 @@ cgraph_release_function_body (struct cgraph_node *node)
DECL_STRUCT_FUNCTION (node->decl) = NULL;
}
DECL_SAVED_TREE (node->decl) = NULL;
DECL_INITIAL (node->decl) = error_mark_node;
/* If the node is abstract and needed, then do not clear DECL_INITIAL
of its associated function function declaration because it's
needed to emit debug info later. */
if (!node->abstract_and_needed)
DECL_INITIAL (node->decl) = error_mark_node;
}
/* Remove the node from cgraph. */
......
......@@ -166,6 +166,9 @@ struct cgraph_node GTY((chain_next ("%h.next"), chain_prev ("%h.previous")))
/* Set when function must be output - it is externally visible
or its address is taken. */
unsigned needed : 1;
/* Set when decl is an abstract function pointed to by the
ABSTRACT_DECL_ORIGIN of a reachable function. */
unsigned abstract_and_needed : 1;
/* Set when function is reachable by call from other function
that is either reachable or needed. */
unsigned reachable : 1;
......
......@@ -896,6 +896,15 @@ cgraph_analyze_functions (void)
if (!edge->callee->reachable)
cgraph_mark_reachable_node (edge->callee);
/* If decl is a clone of an abstract function, mark that abstract
function so that we don't release its body. The DECL_INITIAL() of that
abstract function declaration will be later needed to output debug info. */
if (DECL_ABSTRACT_ORIGIN (decl))
{
struct cgraph_node *origin_node = cgraph_node (DECL_ABSTRACT_ORIGIN (decl));
origin_node->abstract_and_needed = true;
}
/* We finalize local static variables during constructing callgraph
edges. Process their attributes too. */
process_function_and_variable_attributes (first_processed,
......
......@@ -4187,6 +4187,10 @@ rest_of_handle_final (void)
timevar_push (TV_SYMOUT);
(*debug_hooks->function_decl) (current_function_decl);
timevar_pop (TV_SYMOUT);
/* Release the blocks that are linked to DECL_INITIAL() to free the memory. */
DECL_INITIAL (current_function_decl) = error_mark_node;
if (DECL_STATIC_CONSTRUCTOR (current_function_decl)
&& targetm.have_ctors_dtors)
targetm.asm_out.constructor (XEXP (DECL_RTL (current_function_decl), 0),
......
2008-11-12 Dodji Seketeli <dodji@redhat.com>
PR debug/27574
* g++.dg/debug/dwarf2/local-var-in-contructor.C: New test.
2008-11-12 Eric Botcazou <ebotcazou@adacore.com>
* gcc.c-torture/execute/20081112-1.c: New test.
......
// Contributed by Dodji Seketeli <dodji@redhat.com>
// Origin PR27574
// { dg-do compile }
// { dg-options "-O0 -g" }
// { dg-final { scan-assembler "problem" } }
void f (int *)
{
}
class A
{
public:
A(int i);
};
A::A(int i)
{
int *problem = new int(i);
f (problem);
}
int
main (void)
{
A a (0);
return 0;
}
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