diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index b8c2067370402e1892e8784457de6b371f577120..101fbfb7b2598defa41eb2f80039c40af360f5ba 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,11 @@
+2014-03-19  Richard Biener  <rguenther@suse.de>
+
+	* lto.c (lto_wpa_write_files): Move call to
+	lto_promote_cross_file_statics ...
+	(do_whole_program_analysis): ... here, into the partitioning
+	block.  Do not ggc_collect after lto_wpa_write_files but
+	for a last time before it.
+
 2014-03-19  Jakub Jelinek  <jakub@redhat.com>
 
 	PR lto/60571
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 9ebcdce3a45254a4ed1057690b0d23e0e3c186b8..df9f031518af0dbf4bdf5e97557dd0db29871be5 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -2568,11 +2568,6 @@ lto_wpa_write_files (void)
   FOR_EACH_VEC_ELT (ltrans_partitions, i, part)
     lto_stats.num_output_symtab_nodes += lto_symtab_encoder_size (part->encoder);
 
-  /* Find out statics that need to be promoted
-     to globals with hidden visibility because they are accessed from multiple
-     partitions.  */
-  lto_promote_cross_file_statics ();
-
   timevar_pop (TV_WHOPR_WPA);
 
   timevar_push (TV_WHOPR_WPA_IO);
@@ -3284,11 +3279,21 @@ do_whole_program_analysis (void)
     node->aux = NULL;
 
   lto_stats.num_cgraph_partitions += ltrans_partitions.length ();
+
+  /* Find out statics that need to be promoted
+     to globals with hidden visibility because they are accessed from multiple
+     partitions.  */
+  lto_promote_cross_file_statics ();
   timevar_pop (TV_WHOPR_PARTITIONING);
 
   timevar_stop (TV_PHASE_OPT_GEN);
-  timevar_start (TV_PHASE_STREAM_OUT);
 
+  /* Collect a last time - in lto_wpa_write_files we may end up forking
+     with the idea that this doesn't increase memory usage.  So we
+     absoultely do not want to collect after that.  */
+  ggc_collect ();
+
+  timevar_start (TV_PHASE_STREAM_OUT);
   if (!quiet_flag)
     {
       fprintf (stderr, "\nStreaming out");
@@ -3297,10 +3302,8 @@ do_whole_program_analysis (void)
   lto_wpa_write_files ();
   if (!quiet_flag)
     fprintf (stderr, "\n");
-
   timevar_stop (TV_PHASE_STREAM_OUT);
 
-  ggc_collect ();
   if (post_ipa_mem_report)
     {
       fprintf (stderr, "Memory consumption after IPA\n");