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]

Allow target to emit LTO early debug to a separate LTO file.


Hi Tom, Richi,

This is something I was experimenting with to try and solve platform problems with early debug.

Not a “finished patch” (I’ve removed the Darwin back-end parts) but would like your comments on the central idea.

This is to switch to the alternate LTO file (this process already exists for the actual LTO output) before the early debug is started and switch back to the regular output file after.  Therefore both the LTO early debug and the LTO streamed data end up in a separate file (this can be concatenated as we do now, guaranteeing that it appears after any referenced symbols, or could be handled in “some other way” if that was a useful solution).

Now the second part of this delays the output of the .file directives until the “regular” output of the asm (it could be that this could be simplified now there there’s a start/end function pair).

The idea is that the main output text is identical with/without the early debug (and, in fact, it’s broken without this change - since the .file directives would end up in the separate LTO stream).

thoughts?
Iain


diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index ec490d75bd..1a7db6c353 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2777,11 +2777,14 @@ symbol_table::finalize_compilation_unit (void)
       FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode)
 	(*debug_hooks->early_global_decl) (cnode->decl);
 
+     targetm.asm_out.lto_start ();
       /* Clean up anything that needs cleaning up after initial debug
 	 generation.  */
       debuginfo_early_start ();
       (*debug_hooks->early_finish) (main_input_filename);
+
       debuginfo_early_stop ();
+      targetm.asm_out.lto_end ();
     }
 
   /* Finally drive the pass manager.  */


diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 74a5926524..5f166b7f42 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -3600,6 +3600,9 @@ static GTY(()) unsigned int poc_label_num;
 /* The last file entry emitted by maybe_emit_file().  */
 static GTY(()) struct dwarf_file_data * last_emitted_file;
 
+/* Don't emit the .file directives for early debug.  */
+static bool delay_emit_file = false;
+
 /* Number of internal labels generated by gen_internal_sym().  */
 static GTY(()) int label_num;
 
@@ -26939,7 +26942,7 @@ lookup_filename (const char *file_name)
 static int
 maybe_emit_file (struct dwarf_file_data * fd)
 {
-  if (! fd->emitted_number)
+  if (! fd->emitted_number && ! delay_emit_file)
     {
       if (last_emitted_file)
 	fd->emitted_number = last_emitted_file->emitted_number + 1;
@@ -31866,6 +31869,7 @@ dwarf2out_early_finish (const char *filename)
   set_early_dwarf s;
   char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];
 
+  delay_emit_file = true;
   /* PCH might result in DW_AT_producer string being restored from the
      header compilation, so always fill it with empty string initially
      and overwrite only here.  */
@@ -31917,6 +31921,7 @@ dwarf2out_early_finish (const char *filename)
 	  fprintf (dump_file, "LTO EARLY DWARF for %s\n", filename);
 	  print_die (comp_unit_die (), dump_file);
 	}
+      delay_emit_file = false;
       return;
     }
 
@@ -32006,7 +32011,11 @@ dwarf2out_early_finish (const char *filename)
 	 copy_lto_debug_sections operation of the simple object support in
 	 libiberty is not implemented for them yet.  */
       || TARGET_PECOFF || TARGET_COFF)
-    return;
+      || TARGET_PECOFF)
+    {
+      delay_emit_file = false;
+      return;
+    }
 
   /* Now as we are going to output for LTO initialize sections and labels
      to the LTO variants.  We don't need a random-seed postfix as other
@@ -32128,6 +32137,8 @@ dwarf2out_early_finish (const char *filename)
 				    output_indirect_string> (form);
     }
 
+  delay_emit_file = false;
+
   /* Switch back to the text section.  */
   switch_to_section (text_section);
 }
-- 
2.17.1




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