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]

Re: [lto] fix array bounds information


On 12/13/07, Nathan Froyd <froydnj@codesourcery.com> wrote:
> In some cases, subrange DIEs for arrays were being eliminated from being
> output, which caused problems when reading LTO files back in, as those
> arrays were suddenly lacking bounds information.  Such types were
> usually associated with constructors for arrays--particularly
> strings--and various bits of the compiler became upset that they didn't
> have bounds information available.  This patch fixes that by marking any
> DIEs created on LTO's behalf and their children used, so the DWARF
> writer is forced to output them.  Prior to this, the topmost DIE
> (DW_TAG_array_type) would get marked, but its children would be
> deleted...and mysteriously reappear as children of the compilation unit
> die.

I saw this too in some cases with vector types on a 4.1.1 based
compiler with the die_perennial_p support backported to it.

Here is the patch which I did:
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 2218)
+++ dwarf2out.c (revision 2219)
@@ -11503,6 +11503,18 @@ dwarf2out_abstract_function (tree decl)
   cfun = save_cfun;
 }

+static void
+premark_used_types_subdie (dw_die_ref die, int dokids)
+{
+  dw_die_ref c;
+  die->die_perennial_p = 1;
+  if (die->die_parent)
+    premark_used_types_subdie (die->die_parent, 0);
+  if (dokids)
+    for (c = die->die_child; c; c = c->die_sib)
+      premark_used_types_subdie (c, 1);
+}
+
 /* Helper function of premark_used_types() which gets called through
    htab_traverse_resize().

@@ -11517,7 +11529,7 @@ premark_used_types_helper (void **slot,
   type = *slot;
   die = lookup_type_die (type);
   if (die != NULL)
-    die->die_perennial_p = 1;
+    premark_used_types_subdie (die, 1);
   return 1;
 }


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