[debug-early] emitting early debug for external variables
Aldy Hernandez
aldyh@redhat.com
Thu Mar 19 18:03:00 GMT 2015
On 03/19/2015 02:08 AM, Richard Biener wrote:
> On Wed, Mar 18, 2015 at 10:28 PM, Jason Merrill <jason@redhat.com> wrote:
>> If you move the call to rest_of_decl_compilation we could go through and
>> prune the debug info for unused decls at dwarf2out_finish time, the way we
>> do with unused types.
>
> True. Note that the varpool nodes eventually get created once the
> first use is seen.
> So I wonder how much garbage we create by unconditionally creating the node
> in rest_of_decl_compilation (yeah, header files, of course - probably
> a similar issue
> for unused function declarations?).
>
> I'd prefer to do early_global_decl from rest_of_decl_compilation (and shun the
> symtab/varpool walk - but that would require the FEs would hand off each global
> that possibly needs debug info through rest_of_decl_compilation).
>
> To prune globals during early(!) dwarf2out_finish you should be able to use the
> symbol table (not sure if we prune all unused symbols, but surely the list
> of references should be empty).
>
> Richard.
Thank you both.
I have moved the debug early generation for _symbols_ to
rest_of_decl_compilation. I'm not so so brave as to move
FUNCTION_DECL's and such. Besides, things are working fine. Let me get
through the rest of my gdb regressions. :).
I am now running gdb tests for every patch, in an effort to fix the
plethora of regressions I have caused over the past few months. The
current patch exposes no regressions for guality.exp, or for the gdb
testsuite. For that matter, it fixes 4-5 gdb regressions.
I will prune the unused DIEs in a subsequent patch; actually much later,
when I'm done regression hunting.
Let me know if you have any problems with this. I am committing to the
branch.
Aldy
-------------- next part --------------
commit b1457fad19257267facddb6ce88c6041a24a5154
Author: Aldy Hernandez <aldyh@redhat.com>
Date: Thu Mar 19 10:21:02 2015 -0700
Unconditionally send all global symbols (whether used or not) to
early_global_decl.
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 1650c6c..e60acd5 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2430,16 +2430,6 @@ symbol_table::finalize_compilation_unit (void)
if (flag_dump_passes)
dump_passes ();
- /* Generate early debug for global symbols. Any local symbols will
- be handled by either handling reachable functions further down
- (and by consequence, locally scoped symbols), or by generating
- DIEs for types. */
- symtab_node *snode;
- FOR_EACH_SYMBOL (snode)
- if (TREE_CODE (snode->decl) != FUNCTION_DECL
- && !decl_function_context (snode->decl))
- (*debug_hooks->early_global_decl) (snode->decl);
-
/* Gimplify and lower all functions, compute reachability and
remove unreachable nodes. */
analyze_functions ();
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 92f4903..76fd70b 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -21868,17 +21868,6 @@ dwarf2out_decl (tree decl)
break;
case VAR_DECL:
- /* Ignore this VAR_DECL if it refers to a file-scope extern data object
- declaration and if the declaration was never even referenced from
- within this entire compilation unit. We suppress these DIEs in
- order to save space in the .debug section (by eliminating entries
- which are probably useless). Note that we must not suppress
- block-local extern declarations (whether used or not) because that
- would screw-up the debugger's name lookup mechanism and cause it to
- miss things which really ought to be in scope at a given point. */
- if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
- return NULL;
-
/* For local statics lookup proper context die. */
if (local_function_static (decl))
context_die = lookup_decl_die (DECL_CONTEXT (decl));
@@ -25110,6 +25099,8 @@ dwarf2out_finish (const char *filename)
if (flag_eliminate_unused_debug_types)
prune_unused_types ();
+ /* FIXME: Prune DIEs for unused decls. */
+
/* Generate separate COMDAT sections for type DIEs. */
if (use_debug_types)
{
diff --git a/gcc/passes.c b/gcc/passes.c
index 3a16768..ce06035 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -293,11 +293,16 @@ rest_of_decl_compilation (tree decl,
&& TREE_STATIC (decl))
varpool_node::get_create (decl);
- /* ?? Theoretically, we should be able to to call
- debug_hooks->early_global_decl() here just as we do for
- rest_of_type_compilation below. This would require changing how
- we're currently calling early_global_decl() in all the
- front-ends. Something to look into later. */
+ /* Generate early debug for global symbols. Any local symbols will
+ be handled by either handling reachable functions from
+ finalize_compilation_unit (and by consequence, locally scoped
+ symbols), or by rest_of_type_compilation below. */
+ if (!flag_wpa
+ && TREE_CODE (decl) != FUNCTION_DECL
+ && !decl_function_context (decl)
+ && !current_function_decl
+ && !decl_type_context (decl))
+ (*debug_hooks->early_global_decl) (decl);
}
/* Called after finishing a record, union or enumeral type. */
More information about the Gcc-patches
mailing list