* ggc.h (ggc_grow): New function.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 May 2014 02:58:54 +0000 (02:58 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 May 2014 02:58:54 +0000 (02:58 +0000)
* ggc-none.c (ggc_grow): New function.
* ggc-page.c (ggc_grow): Likewise.
* lto.c (read_cgraph_and_symbols): Grow ggc memory after streaming.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210908 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ggc-none.c
gcc/ggc-page.c
gcc/ggc.h
gcc/lto/ChangeLog
gcc/lto/lto.c

index 05f5e3e..46aa41c 100644 (file)
@@ -1,5 +1,11 @@
 2014-05-23  Jan Hubicka  <hubicka@ucw.cz>
 
+       * ggc.h (ggc_grow): New function.
+       * ggc-none.c (ggc_grow): New function.
+       * ggc-page.c (ggc_grow): Likewise.
+
+2014-05-23  Jan Hubicka  <hubicka@ucw.cz>
+
        * ipa.c (cgraph_non_local_node_p_1, cgraph_local_node_p, address_taken_from_non_vtable_p,
        comdat_can_be_unshared_p_1, comdat_can_be_unshared_p, cgraph_externally_visible_p,
        varpool_externally_visible_p, can_replace_by_local_alias,
index 97d3566..29a7b2f 100644 (file)
@@ -67,3 +67,8 @@ ggc_free (void *p)
 {
   free (p);
 }
+
+void
+ggc_grow (void)
+{
+}
index a8d8d0e..e37ddc2 100644 (file)
@@ -2185,6 +2185,23 @@ ggc_collect (void)
     fprintf (G.debug_file, "END COLLECTING\n");
 }
 
+/* Assume that all GGC memory is reachable and grow the limits for next collection.
+   With checking, trigger GGC so -Q compilation outputs how much of memory really is
+   reachable.  */
+
+void
+ggc_grow (void)
+{
+#ifndef ENABLE_CHECKING
+  G.allocated_last_gc = MAX (G.allocated_last_gc,
+                            G.allocated);
+#else
+  ggc_collect ();
+#endif
+  if (!quiet_flag)
+    fprintf (stderr, " {GC start %luk} ", (unsigned long) G.allocated / 1024);
+}
+
 /* Print allocation statistics.  */
 #define SCALE(x) ((unsigned long) ((x) < 1024*10 \
                  ? (x) \
index 1279aee..1c0fd3d 100644 (file)
--- a/gcc/ggc.h
+++ b/gcc/ggc.h
@@ -282,6 +282,9 @@ extern const char *ggc_alloc_string (const char *contents, int length
    function is called, not during allocations.  */
 extern void ggc_collect        (void);
 
+/* Assume that all GGC memory is reachable and grow the limits for next collection. */
+extern void ggc_grow (void);
+
 /* Register an additional root table.  This can be useful for some
    plugins.  Does nothing if the passed pointer is NULL. */
 extern void ggc_register_root_tab (const struct ggc_root_tab *);
index f4a226b..8fd483e 100644 (file)
@@ -1,5 +1,9 @@
 2014-05-23  Jan Hubicka  <hubicka@ucw.cz>
 
+       * lto.c (read_cgraph_and_symbols): Grow ggc memory after streaming.
+
+2014-05-23  Jan Hubicka  <hubicka@ucw.cz>
+
        * lto-symtab.c (lto_symtab_merge_symbols): Update code setting
        symtab pointer.
        * lto.c (compare_tree_sccs_1): Do not compare comdat groups.
index e5cdfc1..41d63f6 100644 (file)
@@ -3001,6 +3001,10 @@ read_cgraph_and_symbols (unsigned nfiles, const char **fnames)
   gimple_canonical_types = NULL;
   delete canonical_type_hash_cache;
   canonical_type_hash_cache = NULL;
+
+  /* At this stage we know that majority of GGC memory is reachable.  
+     Growing the limits prevents unnecesary invocation of GGC.  */
+  ggc_grow ();
   ggc_collect ();
 
   /* Set the hooks so that all of the ipa passes can read in their data.  */