diff mbox

[debug-early] emit early dwarf for locally scoped functions

Message ID 5511A626.8070708@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez March 24, 2015, 6 p.m. UTC
Hi Jason.

I found that for locally scoped functions we were not emitting early 
dwarf.  I've removed the restriction that only emitted non 
function-context functions to handle the case below.  BTW, this 
shouldn't be a (bloat) problem, as we are going to clean up unused DIEs 
later (well, next week :)).

void foobar ()
{
   class Object {
   public:
     char Object_method ()
     {
       return 5;
     }
   };

   Object local;
   local.Object_method();
}

There was also a GDB regression with the above test (distilled from 
gdb.cp/local.cc) where Object_method's type was being generated as

	char Object_method (const Object *)

(or something like it).  The problem was that gen_formal_types_die was 
creating nameless DIEs for the formal parameters when generating an 
object's members, but mainline was removing these nameless DIEs and I 
had mistakenly removed that bit.  I'm putting the code back in, but 
guarding it with early_dwarf_dumping, since by the time we get to late 
debug, we should have the correct named parameters which should then be 
augmented with location information.

This patch fixes the gdb.cp/local.cc regressions, while generating early 
dwarf for Object_method and associates.

I'm committing to the branch.  Let me know if you have a problem with this.

Tested with the guality.exp suite as well as the GDB testsuite.

Aldy
commit 8673cbf8204fcd7099507293a859b173343a0f9a
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Mar 24 10:47:30 2015 -0700

    Emit early dwarf for locally scoped functions.
    
    Only remove cached DW_TAG_formal_parameter's when early dwarf dumping.

Comments

Jason Merrill March 25, 2015, 7:37 p.m. UTC | #1
On 03/24/2015 02:00 PM, Aldy Hernandez wrote:
> I found that for locally scoped functions we were not emitting early
> dwarf.

Why weren't they being emitted as part of their enclosing function? 
They should be.

Jason
diff mbox

Patch

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index e60acd5..4a7b14d 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2444,8 +2444,7 @@  symbol_table::finalize_compilation_unit (void)
      locally scoped symbols.  */
   struct cgraph_node *cnode;
   FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode)
-    if (!decl_function_context (cnode->decl))
-      (*debug_hooks->early_global_decl) (cnode->decl);
+    (*debug_hooks->early_global_decl) (cnode->decl);
 
   /* Clean up anything that needs cleaning up after initial debug
      generation.  */
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 48e2eed..bcc1111 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -18792,6 +18792,18 @@  gen_subprogram_die (tree decl, dw_die_ref context_die)
 	     parameters so they can be augmented with location
 	     information later.  */
 	  remove_AT (subr_die, DW_AT_declaration);
+
+	  /* gen_formal_types_die could have created nameless DIEs for
+	     the formal parameters when generating an object's
+	     members.  Remove if early dumping; they will be shortly
+	     recreated correctly.  If we're not early dumping, we
+	     should've already removed them and should have actual
+	     named parameters.  */
+	  if (early_dwarf_dumping)
+	    {
+	      remove_AT (subr_die, DW_AT_object_pointer);
+	      remove_child_TAG (subr_die, DW_TAG_formal_parameter);
+	    }
 	}
       /* Make a specification pointing to the previously built
 	 declaration.  */