public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3383] Fix PR debug/101947
@ 2021-09-07 13:43 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2021-09-07 13:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:81e9178fe7f8bae4609619b1195765b14eef35b7

commit r12-3383-g81e9178fe7f8bae4609619b1195765b14eef35b7
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue Sep 7 15:41:49 2021 +0200

    Fix PR debug/101947
    
    This is the recent LTO bootstrap failure with Ada enabled.  The compiler now
    generates DW_OP_deref_type for a unit of the Ada front-end, which means that
    the offset of base types in the CU must be computed during early DWARF too.
    
    gcc/
            PR debug/101947
            * dwarf2out.c (mark_base_types): New overloaded function.
            (dwarf2out_early_finish): Invoke it on the COMDAT type list as well
            as the compilation unit, and call move_marked_base_types afterward.

Diff:
---
 gcc/dwarf2out.c | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 44 insertions(+), 8 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 4f100606618..fbad269b566 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -30295,6 +30295,40 @@ mark_base_types (dw_loc_descr_ref loc)
     }
 }
 
+/* Stripped-down variant of resolve_addr, mark DW_TAG_base_type nodes
+   referenced from typed stack ops and count how often they are used.  */
+
+static void
+mark_base_types (dw_die_ref die)
+{
+  dw_die_ref c;
+  dw_attr_node *a;
+  dw_loc_list_ref *curr;
+  unsigned ix;
+
+  FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)
+    switch (AT_class (a))
+      {
+      case dw_val_class_loc_list:
+	curr = AT_loc_list_ptr (a);
+	while (*curr)
+	  {
+	    mark_base_types ((*curr)->expr);
+	    curr = &(*curr)->dw_loc_next;
+	  }
+	break;
+
+      case dw_val_class_loc:
+	mark_base_types (AT_loc (a));
+	break;
+
+      default:
+	break;
+      }
+
+  FOR_EACH_CHILD (die, c, mark_base_types (c));
+}
+
 /* Comparison function for sorting marked base types.  */
 
 static int
@@ -32697,6 +32731,7 @@ ctf_debug_do_cu (dw_die_ref die)
 static void
 dwarf2out_early_finish (const char *filename)
 {
+  comdat_type_node *ctnode;
   set_early_dwarf s;
   char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -32776,8 +32811,7 @@ dwarf2out_early_finish (const char *filename)
       /* For each new comdat type unit, copy declarations for incomplete
          types to make the new unit self-contained (i.e., no direct
          references to the main compile unit).  */
-      for (comdat_type_node *ctnode = comdat_type_list;
-	   ctnode != NULL; ctnode = ctnode->next)
+      for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
         copy_decls_for_unworthy_types (ctnode->root_die);
       copy_decls_for_unworthy_types (comp_unit_die ());
 
@@ -32792,8 +32826,7 @@ dwarf2out_early_finish (const char *filename)
   note_variable_value (comp_unit_die ());
   for (limbo_die_node *node = cu_die_list; node; node = node->next)
     note_variable_value (node->die);
-  for (comdat_type_node *ctnode = comdat_type_list; ctnode != NULL;
-       ctnode = ctnode->next)
+  for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
     note_variable_value (ctnode->root_die);
   for (limbo_die_node *node = limbo_die_list; node; node = node->next)
     note_variable_value (node->die);
@@ -32845,13 +32878,17 @@ dwarf2out_early_finish (const char *filename)
      location related output removed and some LTO specific changes.
      Some refactoring might make both smaller and easier to match up.  */
 
+  for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
+    mark_base_types (ctnode->root_die);
+  mark_base_types (comp_unit_die ());
+  move_marked_base_types ();
+
   /* Traverse the DIE's and add sibling attributes to those DIE's
      that have children.  */
   add_sibling_attributes (comp_unit_die ());
   for (limbo_die_node *node = limbo_die_list; node; node = node->next)
     add_sibling_attributes (node->die);
-  for (comdat_type_node *ctnode = comdat_type_list;
-       ctnode != NULL; ctnode = ctnode->next)
+  for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
     add_sibling_attributes (ctnode->root_die);
 
   /* AIX Assembler inserts the length, so adjust the reference to match the
@@ -32881,8 +32918,7 @@ dwarf2out_early_finish (const char *filename)
     output_comp_unit (node->die, 0, NULL);
 
   hash_table<comdat_type_hasher> comdat_type_table (100);
-  for (comdat_type_node *ctnode = comdat_type_list;
-       ctnode != NULL; ctnode = ctnode->next)
+  for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
     {
       comdat_type_node **slot = comdat_type_table.find_slot (ctnode, INSERT);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-07 13:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 13:43 [gcc r12-3383] Fix PR debug/101947 Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).