Add dump file for WPA streaming

Message ID 20180712134228.GF94468@kam.mff.cuni.cz
State New
Headers show
Series
  • Add dump file for WPA streaming
Related show

Commit Message

Jan Hubicka July 12, 2018, 1:42 p.m.
Hi,
this patch adds dump file for WPA streaming process. It uses the new
dump file code for parittions.

Bootstrapped/regtsted x86_64-linux, will commit it shortly.

Honza

	* lto.c (do_stream_out): Add PART parameter; open dump file.
	(stream_out): Add PART parameter; pass it to do_stream_out.
	(lto_wpa_write_files): Update call of stream_out.

	* lto-streamer-out.c (copy_function_or_variable): Dump info about
	copying section.

Patch

Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 262591)
+++ lto/lto.c	(working copy)
@@ -2326,13 +2326,15 @@  static lto_file *current_lto_file;
 /* Actually stream out ENCODER into TEMP_FILENAME.  */
 
 static void
-do_stream_out (char *temp_filename, lto_symtab_encoder_t encoder)
+do_stream_out (char *temp_filename, lto_symtab_encoder_t encoder, int part)
 {
   lto_file *file = lto_obj_file_open (temp_filename, true);
   if (!file)
     fatal_error (input_location, "lto_obj_file_open() failed");
   lto_set_current_out_file (file);
 
+  gcc_assert (!dump_file);
+  streamer_dump_file = dump_begin (TDI_lto_stream_out, NULL, part);
   ipa_write_optimization_summaries (encoder);
 
   free (CONST_CAST (char *, file->filename));
@@ -2340,6 +2342,11 @@  do_stream_out (char *temp_filename, lto_
   lto_set_current_out_file (NULL);
   lto_obj_file_close (file);
   free (file);
+  if (streamer_dump_file)
+    {
+      dump_end (TDI_lto_stream_out, streamer_dump_file);
+      streamer_dump_file = NULL;
+    }
 }
 
 /* Wait for forked process and signal errors.  */
@@ -2372,14 +2379,14 @@  wait_for_child ()
 
 static void
 stream_out (char *temp_filename, lto_symtab_encoder_t encoder,
-	    bool ARG_UNUSED (last))
+	    bool ARG_UNUSED (last), int part)
 {
 #ifdef HAVE_WORKING_FORK
   static int nruns;
 
   if (lto_parallelism <= 1)
     {
-      do_stream_out (temp_filename, encoder);
+      do_stream_out (temp_filename, encoder, part);
       return;
     }
 
@@ -2399,12 +2406,12 @@  stream_out (char *temp_filename, lto_sym
       if (!cpid)
 	{
 	  setproctitle ("lto1-wpa-streaming");
-	  do_stream_out (temp_filename, encoder);
+	  do_stream_out (temp_filename, encoder, part);
 	  exit (0);
 	}
       /* Fork failed; lets do the job ourseleves.  */
       else if (cpid == -1)
-        do_stream_out (temp_filename, encoder);
+        do_stream_out (temp_filename, encoder, part);
       else
 	nruns++;
     }
@@ -2412,13 +2419,13 @@  stream_out (char *temp_filename, lto_sym
   else
     {
       int i;
-      do_stream_out (temp_filename, encoder);
+      do_stream_out (temp_filename, encoder, part);
       for (i = 0; i < nruns; i++)
 	wait_for_child ();
     }
   asm_nodes_output = true;
 #else
-  do_stream_out (temp_filename, encoder);
+  do_stream_out (temp_filename, encoder, part);
 #endif
 }
 
@@ -2508,7 +2515,7 @@  lto_wpa_write_files (void)
 	}
       gcc_checking_assert (lto_symtab_encoder_size (part->encoder) || !i);
 
-      stream_out (temp_filename, part->encoder, i == n_sets - 1);
+      stream_out (temp_filename, part->encoder, i == n_sets - 1, i);
 
       part->encoder = NULL;
 
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c	(revision 262591)
+++ lto-streamer-out.c	(working copy)
@@ -2293,6 +2304,8 @@  copy_function_or_variable (struct symtab
   struct lto_in_decl_state *in_state;
   struct lto_out_decl_state *out_state = lto_get_out_decl_state ();
 
+  if (streamer_dump_file)
+    fprintf (streamer_dump_file, "Copying section for %s\n", name);
   lto_begin_section (section_name, false);
   free (section_name);