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]

Free symtab hash after merging


Hi,
LTO symtab stores pointers to cgraph/varpool nodes.  Since varpool nodes are ggc_freed after removed,
we get an ICE when we start remove unused variables from the varpool.
This patch simply removes the symtab after we are done to convserve memory.
In longer run I we want to keep it around longer so we can read function
bodies into LTO compilation only when needed to conserve peak memory use (and
get similar memory use as WPA), but then I guess we can solve this by clearing
out the pointers to doing something similar.  For now this seems most resonable
thing to do.

Honza

	* lto-symtab.c (lto_symtab_free): New function.
	* lto-streamer.h (lto_symtab_free): Declare.

	* lto.c (read_cgraph_and_symbols): Use lto_symtab_free.
Index: lto-symtab.c
===================================================================
--- lto-symtab.c	(revision 159269)
+++ lto-symtab.c	(working copy)
@@ -65,6 +65,15 @@ static GTY ((if_marked ("lto_symtab_entr
 	     param_is (struct lto_symtab_entry_def)))
   htab_t lto_symtab_identifiers;
 
+/* Free symtab hashtable.  */
+
+void
+lto_symtab_free (void)
+{
+  htab_delete (lto_symtab_identifiers);
+  lto_symtab_identifiers = NULL;
+}
+
 /* Return the hash value of an lto_symtab_entry_t object pointed to by P.  */
 
 static hashval_t
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 159269)
+++ lto/lto.c	(working copy)
@@ -1640,6 +1644,8 @@ read_cgraph_and_symbols (unsigned nfiles
 			 node->ipa_transforms_to_apply,
 			 (ipa_opt_pass)&pass_ipa_inline);
       }
+  lto_symtab_free ();
+
   timevar_pop (TV_IPA_LTO_CGRAPH_MERGE);
 
   timevar_push (TV_IPA_LTO_DECL_INIT_IO);
Index: lto-streamer.h
===================================================================
--- lto-streamer.h	(revision 159269)
+++ lto-streamer.h	(working copy)
@@ -872,7 +874,8 @@ extern void lto_symtab_merge_decls (void
 extern void lto_symtab_merge_cgraph_nodes (void);
 extern tree lto_symtab_prevailing_decl (tree decl);
 extern enum ld_plugin_symbol_resolution lto_symtab_get_resolution (tree decl);
+extern void lto_symtab_free (void);

 
 /* In lto-opts.c.  */
 extern void lto_register_user_option (size_t, const char *, int, int);


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