Patchwork Fix LTO ICE introduced by ggc_collect patch

login
register
mail settings
Submitter Jan Hubicka
Date Sept. 9, 2010, 12:05 a.m.
Message ID <20100909000520.GC21068@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/64246/
State New
Headers show

Comments

Jan Hubicka - Sept. 9, 2010, 12:05 a.m.
Hi,
we currently ICE compiling larger files because file_decl_data gets garbage collected.
Comitting as obvoius so periodic testing can continue.

Bootstrapped/regtested x86_64-linux and tested and we can build Mozilla again.

Honza

	* lto.c (real_file_count, real_file_decl_data): New static vars.
	(read_cgraph_and_symbols): Use it.
+  real_file_decl_data
+    = decl_data = ggc_alloc_cleared_vec_lto_file_decl_data_ptr (nfiles + 1);
+  real_file_count = nfiles;
 
   /* Read the resolution file.  */
   resolution = NULL;
@@ -1794,7 +2052,8 @@
 
   lto_flatten_files (decl_data, count, last_file_ix);
   lto_stats.num_input_files = count;
-  free(decl_data);
+  ggc_free(decl_data);
+  real_file_decl_data = NULL;
 
   if (resolution_file_name)
     fclose (resolution);
Andrew Pinski - Sept. 9, 2010, 12:08 a.m.
On Wed, Sep 8, 2010 at 5:05 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> -  free(decl_data);
> +  ggc_free(decl_data);
> +  real_file_decl_data = NULL;

Should you zero real_file_count also (well maybe -1).

Thanks,
Andrew Pinski
Jan Hubicka - Sept. 9, 2010, 12:16 a.m.
> On Wed, Sep 8, 2010 at 5:05 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > -  free(decl_data);
> > +  ggc_free(decl_data);
> > +  real_file_decl_data = NULL;
> 
> Should you zero real_file_count also (well maybe -1).

Well, i guess it is harmless to keep it alone since GGC code tests
pointer for non-NULL first.
Obviously some places in LTO code could use conversion to VECtors...

Honza
> 
> Thanks,
> Andrew Pinski

Patch

Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 164010)
+++ lto/lto.c	(working copy)
@@ -760,12 +760,8 @@ 
@@ -1726,6 +1977,11 @@ 
   gcc_assert (k == count);
 }
 
+/* Input file data before flattening (i.e. splitting them to subfiles to support
+   incremental linking.  */
+static int real_file_count;
+static GTY((length ("real_file_count + 1"))) struct lto_file_decl_data **real_file_decl_data;
+
 /* Read all the symbols from the input files FNAMES.  NFILES is the
    number of files requested in the command line.  Instantiate a
    global call graph by aggregating all the sub-graphs found in each
@@ -1744,7 +2000,9 @@ 
 
   timevar_push (TV_IPA_LTO_DECL_IN);
 
-  decl_data = (struct lto_file_decl_data **)xmalloc (sizeof(*decl_data) * (nfiles+1));