public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [debug-early] emitting early debug for external variables
       [not found]   ` <CAFiYyc1Qjxk+gMqp99ruhoEXCw6pV6_6XD=pLB67ZLLioGNVDQ@mail.gmail.com>
@ 2015-03-19 18:03     ` Aldy Hernandez
  2015-03-19 19:44       ` Jason Merrill
  0 siblings, 1 reply; 3+ messages in thread
From: Aldy Hernandez @ 2015-03-19 18:03 UTC (permalink / raw)
  To: Richard Biener, Jason Merrill; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1759 bytes --]

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

[-- Attachment #2: curr --]
[-- Type: text/plain, Size: 3373 bytes --]

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.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [debug-early] emitting early debug for external variables
  2015-03-19 18:03     ` [debug-early] emitting early debug for external variables Aldy Hernandez
@ 2015-03-19 19:44       ` Jason Merrill
  2015-03-19 20:09         ` Aldy Hernandez
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2015-03-19 19:44 UTC (permalink / raw)
  To: Aldy Hernandez, Richard Biener; +Cc: gcc-patches

On 03/19/2015 02:03 PM, Aldy Hernandez wrote:
>
> I have moved the debug early generation for _symbols_ to
> rest_of_decl_compilation

I think you mean "variables".  Functions are also symbols.  :)

Other than that, makes sense to me.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [debug-early] emitting early debug for external variables
  2015-03-19 19:44       ` Jason Merrill
@ 2015-03-19 20:09         ` Aldy Hernandez
  0 siblings, 0 replies; 3+ messages in thread
From: Aldy Hernandez @ 2015-03-19 20:09 UTC (permalink / raw)
  To: Jason Merrill, Richard Biener; +Cc: gcc-patches

On 03/19/2015 12:43 PM, Jason Merrill wrote:
> On 03/19/2015 02:03 PM, Aldy Hernandez wrote:
>>
>> I have moved the debug early generation for _symbols_ to
>> rest_of_decl_compilation
>
> I think you mean "variables".  Functions are also symbols.  :)

Oops, yes I did :).

I will adjust the comments in my patch.

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-19 20:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5509E183.6000908@redhat.com>
     [not found] ` <5509EDF1.3040908@redhat.com>
     [not found]   ` <CAFiYyc1Qjxk+gMqp99ruhoEXCw6pV6_6XD=pLB67ZLLioGNVDQ@mail.gmail.com>
2015-03-19 18:03     ` [debug-early] emitting early debug for external variables Aldy Hernandez
2015-03-19 19:44       ` Jason Merrill
2015-03-19 20:09         ` Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).