Commit db5f8b93 by Richard Henderson Committed by Richard Henderson

re PR debug/23190 (debug info omitted for uninitialized variables (stabs))

        PR debug/23190
        * toplev.c (wrapup_global_declaration_1): Split out ...
        (wrapup_global_declaration_2): ... from ...
        (wrapup_global_declarations): ... here.  Return bool.
        (check_global_declaration_1): Split out ...
        (check_global_declarations): from here.
        (emit_debug_global_declarations): New.
        * toplev.h (wrapup_global_declaration_1, wrapup_global_declaration_2,
        check_global_declaration_1, emit_debug_global_declarations): Declare.
        * c-decl.c (c_write_global_declarations_1): Don't create a vector
        of decls.  Call wrapup_global_declaration_1,
        wrapup_global_declaration_2, check_global_declaration_1 directly.
        (c_write_global_declarations_2): New.
        (ext_block): New.
        (c_write_global_declarations): Call c_write_global_declarations_2.
        * langhooks.c (write_global_declarations): Call
        emit_debug_global_declarations.
        * cgraphunit.c (cgraph_varpool_remove_unreferenced_decls): Don't
        remove decls that have DECL_RTL_SET_P.
        * passes.c (rest_of_decl_compilation): Invoke
        cgraph_varpool_finalize_decl for all but functions.
cp/
        * decl.c (wrapup_globals_for_namespace): Call
        emit_debug_global_declarations.
        * decl2.c (cp_finish_file): Likewise.

From-SVN: r104065
parent 41306174
2005-09-08 Richard Henderson <rth@redhat.com>
PR debug/23190
* toplev.c (wrapup_global_declaration_1): Split out ...
(wrapup_global_declaration_2): ... from ...
(wrapup_global_declarations): ... here. Return bool.
(check_global_declaration_1): Split out ...
(check_global_declarations): from here.
(emit_debug_global_declarations): New.
* toplev.h (wrapup_global_declaration_1, wrapup_global_declaration_2,
check_global_declaration_1, emit_debug_global_declarations): Declare.
* c-decl.c (c_write_global_declarations_1): Don't create a vector
of decls. Call wrapup_global_declaration_1,
wrapup_global_declaration_2, check_global_declaration_1 directly.
(c_write_global_declarations_2): New.
(ext_block): New.
(c_write_global_declarations): Call c_write_global_declarations_2.
* langhooks.c (write_global_declarations): Call
emit_debug_global_declarations.
* cgraphunit.c (cgraph_varpool_remove_unreferenced_decls): Don't
remove decls that have DECL_RTL_SET_P.
* passes.c (rest_of_decl_compilation): Invoke
cgraph_varpool_finalize_decl for all but functions.
2005-09-08 Eric Botcazou <ebotcazou@libertysurf.fr>
* tree-vrp.c (extract_range_from_unary_expr): Do not set the range for
......
......@@ -7540,20 +7540,18 @@ build_cdtor (int method_type, tree cdtors)
cgraph_build_static_cdtor (method_type, body, DEFAULT_INIT_PRIORITY);
}
/* Perform final processing on one file scope's declarations (or the
external scope's declarations), GLOBALS. */
/* A subroutine of c_write_global_declarations. Perform final processing
on one file scope's declarations (or the external scope's declarations),
GLOBALS. */
static void
c_write_global_declarations_1 (tree globals)
{
size_t len = list_length (globals);
tree *vec = XNEWVEC (tree, len);
size_t i;
tree decl;
/* Process the decls in the order they were written. */
for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
for (decl = globals; decl; decl = TREE_CHAIN (decl))
{
vec[i] = decl;
/* Check for used but undefined static functions using the C
standard's definition of "used", and set TREE_NO_WARNING so
that check_global_declarations doesn't repeat the check. */
......@@ -7566,18 +7564,32 @@ c_write_global_declarations_1 (tree globals)
pedwarn ("%q+F used but never defined", decl);
TREE_NO_WARNING (decl) = 1;
}
wrapup_global_declaration_1 (decl);
wrapup_global_declaration_2 (decl);
check_global_declaration_1 (decl);
}
}
wrapup_global_declarations (vec, len);
check_global_declarations (vec, len);
/* A subroutine of c_write_global_declarations Emit debug information for each
of the declarations in GLOBALS. */
free (vec);
static void
c_write_global_declarations_2 (tree globals)
{
tree decl;
for (decl = globals; decl ; decl = TREE_CHAIN (decl))
debug_hooks->global_decl (decl);
}
/* Preserve the external declarations scope across a garbage collect. */
static GTY(()) tree ext_block;
void
c_write_global_declarations (void)
{
tree ext_block, t;
tree t;
/* We don't want to do this if generating a PCH. */
if (pch_file)
......@@ -7593,10 +7605,6 @@ c_write_global_declarations (void)
external_scope = 0;
gcc_assert (!current_scope);
/* Process all file scopes in this compilation, and the external_scope,
through wrapup_global_declarations and check_global_declarations. */
for (t = all_translation_units; t; t = TREE_CHAIN (t))
c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
if (ext_block)
{
tree tmp = BLOCK_VARS (ext_block);
......@@ -7608,6 +7616,11 @@ c_write_global_declarations (void)
dump_end (TDI_tu, stream);
}
}
/* Process all file scopes in this compilation, and the external_scope,
through wrapup_global_declarations and check_global_declarations. */
for (t = all_translation_units; t; t = TREE_CHAIN (t))
c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t)));
c_write_global_declarations_1 (BLOCK_VARS (ext_block));
/* Generate functions to call static constructors and destructors
......@@ -7619,6 +7632,19 @@ c_write_global_declarations (void)
/* We're done parsing; proceed to optimize and emit assembly.
FIXME: shouldn't be the front end's responsibility to call this. */
cgraph_optimize ();
/* After cgraph has had a chance to emit everything that's going to
be emitted, output debug information for globals. */
if (errorcount == 0 && sorrycount == 0)
{
timevar_push (TV_SYMOUT);
for (t = all_translation_units; t; t = TREE_CHAIN (t))
c_write_global_declarations_2 (BLOCK_VARS (DECL_INITIAL (t)));
c_write_global_declarations_2 (BLOCK_VARS (ext_block));
timevar_pop (TV_SYMOUT);
}
ext_block = NULL;
}
#include "gt-c-decl.h"
......@@ -311,7 +311,13 @@ cgraph_varpool_remove_unreferenced_decls (void)
&& ((DECL_ASSEMBLER_NAME_SET_P (decl)
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
|| node->force_output
|| decide_is_variable_needed (node, decl)))
|| decide_is_variable_needed (node, decl)
/* ??? Cgraph does not yet rule the world with an iron hand,
and does not control the emission of debug information.
After a variable has its DECL_RTL set, we must assume that
it may be referenced by the debug information, and we can
no longer elide it. */
|| DECL_RTL_SET_P (decl)))
cgraph_varpool_mark_needed_node (node);
node = next;
......
2005-09-08 Richard Henderson <rth@redhat.com>
PR debug/23190
* decl.c (wrapup_globals_for_namespace): Call
emit_debug_global_declarations.
* decl2.c (cp_finish_file): Likewise.
2005-09-08 Mark Mitchell <mark@codesourcery.com>
PR c++/23691
......
......@@ -789,6 +789,7 @@ wrapup_globals_for_namespace (tree namespace, void* data)
if (last_time)
{
check_global_declarations (vec, len);
emit_debug_global_declarations (vec, len);
return 0;
}
......
......@@ -3106,8 +3106,12 @@ cp_finish_file (void)
etc., and emit debugging information. */
walk_namespaces (wrapup_globals_for_namespace, /*data=*/&reconsider);
if (VEC_length (tree, pending_statics) != 0)
check_global_declarations (VEC_address (tree, pending_statics),
VEC_length (tree, pending_statics));
{
check_global_declarations (VEC_address (tree, pending_statics),
VEC_length (tree, pending_statics));
emit_debug_global_declarations (VEC_address (tree, pending_statics),
VEC_length (tree, pending_statics));
}
/* Generate hidden aliases for Java. */
build_java_method_aliases ();
......
......@@ -478,10 +478,10 @@ write_global_declarations (void)
vec[len - i - 1] = decl;
wrapup_global_declarations (vec, len);
check_global_declarations (vec, len);
emit_debug_global_declarations (vec, len);
/* Clean up. */
/* Clean up. */
free (vec);
}
......
......@@ -158,8 +158,7 @@ rest_of_decl_compilation (tree decl,
|| DECL_INITIAL (decl))
&& !DECL_EXTERNAL (decl))
{
if (flag_unit_at_a_time && !cgraph_global_info_ready
&& TREE_CODE (decl) != FUNCTION_DECL)
if (TREE_CODE (decl) != FUNCTION_DECL)
cgraph_varpool_finalize_decl (decl);
else
assemble_variable (decl, top_level, at_end, 0);
......
/* PR 23190 */
/* Well, collateral damage from a proposed patch fixing 23190. We'd emit
debug info for multilib_exclusions_raw without emitting the variable
itself, leading to link errors. This reduced form is filed as PR 23777,
for not eliminating things soon enough. */
/* { dg-do link } */
static const char *const multilib_exclusions_raw[] = { 0 };
void __attribute__((noinline)) f(char *const *p)
{
__asm__ ("" : : "g"(p) : "memory");
}
void g (char **o)
{
const char *const *q = multilib_exclusions_raw;
f (o);
while (*q++)
f (o);
}
int main() { return 0; }
/* PR 23190 */
/* { dg-do compile }
/* { dg-options "-gdwarf-2 -dA" } */
/* { dg-final { scan-assembler "xyzzy\[^\\n\\r\]+DW_AT_name" } } */
void f(void)
{
static int xyzzy;
xyzzy += 3;
}
/* PR 23190 */
/* { dg-do compile }
/* { dg-options "-O2 -gdwarf-2 -dA" } */
/* { dg-final { scan-assembler "DW_OP_addr\[\\n\\r\]+\[^\\n\\r\]+foo" } } */
/* { dg-final { scan-assembler "DW_OP_addr\[\\n\\r\]+\[^\\n\\r\]+bar" } } */
static int foo;
int bar;
int main(void)
{
foo += 3;
bar *= 5;
return 0;
}
......@@ -92,8 +92,12 @@ extern void fnotice (FILE *, const char *, ...)
ATTRIBUTE_PRINTF_2;
#endif
extern int wrapup_global_declarations (tree *, int);
extern void wrapup_global_declaration_1 (tree);
extern bool wrapup_global_declaration_2 (tree);
extern bool wrapup_global_declarations (tree *, int);
extern void check_global_declaration_1 (tree);
extern void check_global_declarations (tree *, int);
extern void emit_debug_global_declarations (tree *, int);
extern void write_global_declarations (void);
/* A unique local time stamp, might be zero if none is available. */
......
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