This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[trunk<-vta] Re: [vta] fix PCH testsuite regression with DW_AT_MIPS_linkage_name


On Nov 25, 2008, Alexandre Oliva <aoliva@redhat.com> wrote:

> Turns out compilations with PCH get DECL_ASSEMBLER_NAME set earlier
> than without it, so the code I added to defer the computation of D_A_N
> in dwarf2out behaved differently, adding the DW_AT_M_l_n attribute in
> a different order.  Not just that: it also attached the attribute to
> the wrong die.  Oops.

Ok for trunk?  (This depends on and fixes an error in
vta-cp-defer-decl-asm-name.patch, just pinged under subject âdefer
computation of DECL_ASSEMBLER_NAME in dwarf2outâ)

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* dwarf2out.c (move_linkage_attr): New.
	(dwarf2out_finish): Add MIPS_linkage_name attribute to the correct
	die, at the right place.

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c.orig	2009-05-29 04:16:40.000000000 -0300
+++ gcc/dwarf2out.c	2009-05-31 02:00:56.000000000 -0300
@@ -16469,6 +16469,38 @@ file_table_relative_p (void ** slot, voi
   return 1;
 }
 
+/* Move a DW_AT_MIPS_linkage_name attribute just added to dw_die_ref
+   to the location it would have been added, should we know its
+   DECL_ASSEMBLER_NAME when we added other attributes.  This will
+   probably improve compactness of debug info, removing equivalent
+   abbrevs, and hide any differences caused by deferring the
+   computation of the assembler name, triggered by e.g. PCH.  */
+
+static inline void
+move_linkage_attr (dw_die_ref die)
+{
+  unsigned ix = VEC_length (dw_attr_node, die->die_attr);
+  dw_attr_node linkage = *VEC_last (dw_attr_node, die->die_attr);
+  dw_attr_ref prev;
+
+  gcc_assert (linkage.dw_attr == DW_AT_MIPS_linkage_name);
+
+  while (--ix)
+    {
+      prev = VEC_index (dw_attr_node, die->die_attr, ix - 1);
+
+      if (prev->dw_attr == DW_AT_decl_line || prev->dw_attr == DW_AT_name)
+	{
+	  VEC_replace (dw_attr_node, die->die_attr, ix, &linkage);
+	  return;
+	}
+      else
+	VEC_replace (dw_attr_node, die->die_attr, ix, prev);
+    }
+
+  gcc_unreachable ();
+}
+
 /* Output stuff that dwarf requires at the end of every file,
    and generate the DWARF-2 debugging info.  */
 
@@ -16561,8 +16593,11 @@ dwarf2out_finish (const char *filename)
     {
       tree decl = node->created_for;
       if (DECL_ASSEMBLER_NAME (decl) != DECL_NAME (decl))
-	add_AT_string (die, DW_AT_MIPS_linkage_name,
-		       IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+	{
+	  add_AT_string (node->die, DW_AT_MIPS_linkage_name,
+			 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+	  move_linkage_attr (node->die);
+	}
     }
 
   deferred_asm_name = NULL;
-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]