dwarf2out.c (cu_die_list): New global.
authorRichard Biener <rguenther@suse.de>
Wed, 28 Sep 2016 14:31:04 +0000 (14:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 28 Sep 2016 14:31:04 +0000 (14:31 +0000)
2016-09-27  Richard Biener  <rguenther@suse.de>

* dwarf2out.c (cu_die_list): New global.
(dwarf2out_finish): Walk cu_die_list instead of limbo DIEs.  Add
main_comp_unit_die to cu_die_list if we created it.
Move break_out_includes ...
(dwarf2out_early_finish): ... here.  Push created CU DIEs onto
the cu_die_list.

From-SVN: r240579

gcc/ChangeLog
gcc/dwarf2out.c

index c03ac53..3c70860 100644 (file)
@@ -1,3 +1,12 @@
+2016-09-27  Richard Biener  <rguenther@suse.de>
+
+       * dwarf2out.c (cu_die_list): New global.
+       (dwarf2out_finish): Walk cu_die_list instead of limbo DIEs.  Add
+       main_comp_unit_die to cu_die_list if we created it.
+       Move break_out_includes ...
+       (dwarf2out_early_finish): ... here.  Push created CU DIEs onto
+       the cu_die_list.
+
 2016-09-28  Richard Biener  <rguenther@suse.de>
 
        * dwarf2out.c (struct die_struct): Add removed flag.
index b6d6ace..972da16 100644 (file)
@@ -2866,6 +2866,9 @@ static GTY(()) dw_die_ref single_comp_unit_die;
 /* A list of type DIEs that have been separated into comdat sections.  */
 static GTY(()) comdat_type_node *comdat_type_list;
 
+/* A list of CU DIEs that have been separated.  */
+static GTY(()) limbo_die_node *cu_die_list;
+
 /* A list of DIEs with a NULL parent waiting to be relocated.  */
 static GTY(()) limbo_die_node *limbo_die_list;
 
@@ -27855,11 +27858,6 @@ dwarf2out_finish (const char *)
   resolve_addr (comp_unit_die ());
   move_marked_base_types ();
 
-  /* Generate separate CUs for each of the include files we've seen.
-     They will go into limbo_die_list.  */
-  if (flag_eliminate_dwarf2_dups)
-    break_out_includes (comp_unit_die ());
-
   /* Initialize sections and labels used for actual assembler output.  */
   init_sections_and_labels ();
 
@@ -27867,7 +27865,7 @@ dwarf2out_finish (const char *)
      have children.  */
   add_sibling_attributes (comp_unit_die ());
   limbo_die_node *node;
-  for (node = limbo_die_list; node; node = node->next)
+  for (node = cu_die_list; node; node = node->next)
     add_sibling_attributes (node->die);
   for (ctnode = comdat_type_list; ctnode != NULL; ctnode = ctnode->next)
     add_sibling_attributes (ctnode->root_die);
@@ -27876,7 +27874,15 @@ dwarf2out_finish (const char *)
      skeleton compile_unit DIE that remains in the .o, while
      most attributes go in the DWO compile_unit_die.  */
   if (dwarf_split_debug_info)
-    main_comp_unit_die = gen_compile_unit_die (NULL);
+    {
+      limbo_die_node *cu;
+      main_comp_unit_die = gen_compile_unit_die (NULL);
+      cu = limbo_die_list;
+      gcc_assert (cu->die == main_comp_unit_die);
+      limbo_die_list = limbo_die_list->next;
+      cu->next = cu_die_list;
+      cu_die_list = cu;
+    }
   else
     main_comp_unit_die = comp_unit_die ();
 
@@ -27988,7 +27994,7 @@ dwarf2out_finish (const char *)
 
   /* Output all of the compilation units.  We put the main one last so that
      the offsets are available to output_pubnames.  */
-  for (node = limbo_die_list; node; node = node->next)
+  for (node = cu_die_list; node; node = node->next)
     output_comp_unit (node->die, 0);
 
   hash_table<comdat_type_hasher> comdat_type_table (100);
@@ -28217,6 +28223,21 @@ dwarf2out_early_finish (const char *filename)
       prune_unused_types ();
     }
 
+  /* Generate separate CUs for each of the include files we've seen.
+     They will go into limbo_die_list and from there to cu_die_list.  */
+  if (flag_eliminate_dwarf2_dups)
+    {
+      gcc_assert (limbo_die_list == NULL);
+      break_out_includes (comp_unit_die ());
+      limbo_die_node *cu;
+      while ((cu = limbo_die_list))
+       {
+         limbo_die_list = cu->next;
+         cu->next = cu_die_list;
+         cu_die_list = cu;
+       }
+    }
+
   /* The early debug phase is now finished.  */
   early_dwarf_finished = true;
 }