[debug-early] Cache DW_TAG_label's if appropriate
diff mbox

Message ID 5509AFFF.6070408@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez March 18, 2015, 5:03 p.m. UTC
I'm running the gdb testsuite with the debug-early branch compiler, and 
fixing regressions.

gdb.base/label.c was causing gdb to ICE because we were generating 
multiple DW_TAG_label's for the same DECL.  Consequently, I have fixed 
gen_label_die to handle multiple calls with the same DECL.

By the way Jason, is there any reason we previously called 
equate_decl_number_to_die() only for abstract instances?:

   if (DECL_ABSTRACT_P (decl))
     equate_decl_number_to_die (decl, lbl_die);
   else
     {
       insn = DECL_RTL_IF_SET (decl);

I was unable to find the original reasoning, because the original patch 
setting this was from the 1990s, and it came en-masse when dwarf2out.c 
was contributed.  I don't see anything else in dwarf2out.c doing a 
lookup_decl_die() on a LABEL_DECL, so I don't even know why the 
equate_decl_number_to_die() is even there.

Anyways, in the immortal words of Shaggy... "wasn't me", so I'm leaving 
this bit untouched.

Tested on x86-64 Linux with the gdb regression suite.

Committed to branch.
Aldy
commit 8fea2b5c37026b3121afc0a98630542bb9a733dd
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Wed Mar 18 09:55:38 2015 -0700

    Cache DW_TAG_label's if appropriate.

Comments

Jason Merrill March 18, 2015, 8:59 p.m. UTC | #1
On 03/18/2015 01:03 PM, Aldy Hernandez wrote:
> By the way Jason, is there any reason we previously called
> equate_decl_number_to_die() only for abstract instances?:

So that multiple concrete instances can find the abstract instance.

Why isn't DECL_ABSTRACT_P set the first time you get here for the label 
in question?

> I don't see anything else in dwarf2out.c doing a
> lookup_decl_die() on a LABEL_DECL, so I don't even know why the
> equate_decl_number_to_die() is even there.

add_abstract_origin_attribute uses lookup_decl_die.

Jason
Aldy Hernandez March 18, 2015, 11:44 p.m. UTC | #2
On 03/18/2015 01:59 PM, Jason Merrill wrote:
> On 03/18/2015 01:03 PM, Aldy Hernandez wrote:
>> By the way Jason, is there any reason we previously called
>> equate_decl_number_to_die() only for abstract instances?:
>
> So that multiple concrete instances can find the abstract instance.

Ah, I see.

>
> Why isn't DECL_ABSTRACT_P set the first time you get here for the label
> in question?

Oh, that part was working fine.  The testcase that prompted this whole 
thing had nothing to do with DECL_ABSTRACT_P.  I was just curious if I 
could remove the call to equate_decl_number_to_die, but I see it's needed.

>
>> I don't see anything else in dwarf2out.c doing a
>> lookup_decl_die() on a LABEL_DECL, so I don't even know why the
>> equate_decl_number_to_die() is even there.
>
> add_abstract_origin_attribute uses lookup_decl_die.

Thanks.
Aldy

Patch
diff mbox

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 30c6cc6..92f4903 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -19725,14 +19725,20 @@  static void
 gen_label_die (tree decl, dw_die_ref context_die)
 {
   tree origin = decl_ultimate_origin (decl);
-  dw_die_ref lbl_die = new_die (DW_TAG_label, context_die, decl);
+  dw_die_ref lbl_die = lookup_decl_die (decl);
   rtx insn;
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-  if (origin != NULL)
-    add_abstract_origin_attribute (lbl_die, origin);
-  else
-    add_name_and_src_coords_attributes (lbl_die, decl);
+  if (!lbl_die)
+    {
+      lbl_die = new_die (DW_TAG_label, context_die, decl);
+      equate_decl_number_to_die (decl, lbl_die);
+
+      if (origin != NULL)
+	add_abstract_origin_attribute (lbl_die, origin);
+      else
+	add_name_and_src_coords_attributes (lbl_die, decl);
+    }
 
   if (DECL_ABSTRACT_P (decl))
     equate_decl_number_to_die (decl, lbl_die);