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]

[vta] fix PCH testsuite regression with DW_AT_MIPS_linkage_name


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.

Fixed as follows.  This is kind of a kludge; I can't convince myself
it makes sense to investigate why PCH makes it different.  I'm
installing this in the branch.

for  gcc/ChangeLog.vta
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	2008-11-20 20:48:22.000000000 -0200
+++ gcc/dwarf2out.c	2008-11-21 05:28:36.000000000 -0200
@@ -16529,6 +16529,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.  */
 
@@ -16612,8 +16644,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           http://www.lsd.ic.unicamp.br/~oliva/
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]