diff mbox

[LTO] Move canonical type stuff out-of-GC land

Message ID alpine.LNX.2.00.1310141628500.5598@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Oct. 14, 2013, 2:29 p.m. UTC
This replaces the tree -> int hashtable caching hash values by
a pointer_map <hashval_t> and moves it out-of-GC.  Likewise
it moves the actual type hashtable out-of-GC.

LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2013-10-14  Richard Biener  <rguenther@suse.de>

	lto/
	* lto.c (gimple_canonical_types): Move out-of GC space.
	(canonical_type_hash_cache): Make a pointer-map.
	(num_canonical_type_hash_entries, num_canonical_type_hash_queries):
	New counters.
	(iterative_hash_canonical_type): Adjust.
	(read_cgraph_and_symbols): Likewise.
	(print_lto_report_1): Likewise.

Comments

Tobias Burnus Oct. 14, 2013, 6 p.m. UTC | #1
Richard Biener wrote:
> This replaces the tree -> int hashtable caching hash values by
> a pointer_map <hashval_t> and moves it out-of-GC.  Likewise
> it moves the actual type hashtable out-of-GC.
>
> LTO bootstrapped and tested on x86_64-unknown-linux-gnu, applied.


I think it's due to this patch that bootstrapping into an empty 
directory fails during Stage 1 for me with the following message.

Tobias

g++ -c  -DIN_GCC_FRONTEND -g -DIN_GCC   -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long 
-Wno-variadic-macros -Wno-overlength-strings -fno-common 
-DHAVE_CONFIG_H -I. -Ilto -I../../gcc -I../../gcc/lto 
-I../../gcc/../include -I../../gcc/../libcpp/include 
-I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid 
-I../libdecnumber -I../../gcc/../libbacktrace -DCLOOG_INT_GMP    -o 
lto/lto.o -MT lto/lto.o -MMD -MP -MF lto/.deps/lto.TPo ../../gcc/lto/lto.c
In file included from ../../gcc/lto/lto.c:3258:0:
./gt-lto-lto.h:153:6: error: 'type_hash_cache' was not declared in this 
scope
      &type_hash_cache,
       ^
./gt-lto-lto.h:155:13: error: 'type_hash_cache' was not declared in this 
scope
      sizeof (type_hash_cache),
              ^
./gt-lto-lto.h:161:6: error: 'gimple_types' was not declared in this scope
      &gimple_types,
       ^
./gt-lto-lto.h:163:13: error: 'gimple_types' was not declared in this scope
      sizeof (gimple_types),
              ^
./gt-lto-lto.h:173:6: error: 'type_hash_cache' was not declared in this 
scope
      &type_hash_cache,
       ^
./gt-lto-lto.h:175:13: error: 'type_hash_cache' was not declared in this 
scope
      sizeof (type_hash_cache),
              ^
./gt-lto-lto.h:180:6: error: 'gimple_types' was not declared in this scope
      &gimple_types,
       ^
./gt-lto-lto.h:182:13: error: 'gimple_types' was not declared in this scope
      sizeof (gimple_types),
              ^
make[3]: *** [lto/lto.o] Error 1


> 2013-10-14  Richard Biener  <rguenther@suse.de>
>
> 	lto/
> 	* lto.c (gimple_canonical_types): Move out-of GC space.
> 	(canonical_type_hash_cache): Make a pointer-map.
> 	(num_canonical_type_hash_entries, num_canonical_type_hash_queries):
> 	New counters.
> 	(iterative_hash_canonical_type): Adjust.
> 	(read_cgraph_and_symbols): Likewise.
> 	(print_lto_report_1): Likewise.
Tobias Burnus Oct. 14, 2013, 6:06 p.m. UTC | #2
Pilot error:
   rm -rf &
doesn't delete the build directory. With a really empty directory works.

Sorry for the noise!

(Besides, the correct patch would have been 
http://gcc.gnu.org/ml/gcc-patches/2013-10/msg00939.html )

Tobias
diff mbox

Patch

Index: gcc/lto/lto.c
===================================================================
--- gcc/lto/lto.c	(revision 203533)
+++ gcc/lto/lto.c	(working copy)
@@ -255,10 +255,10 @@  lto_read_in_decl_state (struct data_in *
 
 
 /* Global canonical type table.  */
-static GTY((if_marked ("ggc_marked_p"), param_is (union tree_node)))
-  htab_t gimple_canonical_types;
-static GTY((if_marked ("tree_int_map_marked_p"), param_is (struct tree_int_map)))
-  htab_t canonical_type_hash_cache;
+static htab_t gimple_canonical_types;
+static pointer_map <hashval_t> *canonical_type_hash_cache;
+static unsigned long num_canonical_type_hash_entries;
+static unsigned long num_canonical_type_hash_queries;
 
 /* Returning a hash value for gimple type TYPE combined with VAL.
 
@@ -269,12 +269,12 @@  static hashval_t
 iterative_hash_canonical_type (tree type, hashval_t val)
 {
   hashval_t v;
-  void **slot;
-  struct tree_int_map *mp, m;
+  hashval_t *slot;
 
-  m.base.from = type;
-  if ((slot = htab_find_slot (canonical_type_hash_cache, &m, NO_INSERT)))
-    return iterative_hash_hashval_t (((struct tree_int_map *) *slot)->to, val);
+  num_canonical_type_hash_queries++;
+  slot = canonical_type_hash_cache->contains (type);
+  if (slot)
+    return iterative_hash_hashval_t (*slot, val);
 
   /* Combine a few common features of types so that types are grouped into
      smaller sets; when searching for existing matching types to merge,
@@ -374,14 +374,9 @@  iterative_hash_canonical_type (tree type
     }
 
   /* Cache the just computed hash value.  */
-  mp = ggc_alloc_cleared_tree_int_map ();
-  mp->base.from = type;
-  mp->to = v;
-  /* As we recurse the hashtable may expand between looking up the
-     cached value (and not finding one) and here, so we have to
-     re-lookup the slot.  */
-  slot = htab_find_slot (canonical_type_hash_cache, &m, INSERT);
-  *slot = (void *) mp;
+  num_canonical_type_hash_entries++;
+  slot = canonical_type_hash_cache->insert (type);
+  *slot = v;
 
   return iterative_hash_hashval_t (v, val);
 }
@@ -2749,8 +2744,7 @@  read_cgraph_and_symbols (unsigned nfiles
     }
   cgraph_state = CGRAPH_LTO_STREAMING;
 
-  canonical_type_hash_cache = htab_create_ggc (512, tree_int_map_hash,
-					       tree_int_map_eq, NULL);
+  canonical_type_hash_cache = new pointer_map <hashval_t>;
   gimple_canonical_types = htab_create_ggc (16381, gimple_canonical_type_hash,
 					    gimple_canonical_type_eq, 0);
   gcc_obstack_init (&tree_scc_hash_obstack);
@@ -2817,7 +2811,7 @@  read_cgraph_and_symbols (unsigned nfiles
   obstack_free (&tree_scc_hash_obstack, NULL);
   htab_delete (gimple_canonical_types);
   gimple_canonical_types = NULL;
-  htab_delete (canonical_type_hash_cache);
+  delete canonical_type_hash_cache;
   canonical_type_hash_cache = NULL;
   ggc_collect ();
 
@@ -3023,13 +3017,10 @@  print_lto_report_1 (void)
 	       (long) gimple_canonical_types->searches,
 	       (long) gimple_canonical_types->collisions,
 	       htab_collisions (gimple_canonical_types));
-      fprintf (stderr, "[%s] GIMPLE canonical type hash table: size %ld, "
-	       "%ld elements, %ld searches, %ld collisions (ratio: %f)\n", pfx,
-	       (long) htab_size (canonical_type_hash_cache),
-	       (long) htab_elements (canonical_type_hash_cache),
-	       (long) canonical_type_hash_cache->searches,
-	       (long) canonical_type_hash_cache->collisions,
-	       htab_collisions (canonical_type_hash_cache));
+      fprintf (stderr, "[%s] GIMPLE canonical type pointer-map: "
+	       "%lu elements, %ld searches\n", pfx,
+	       num_canonical_type_hash_entries,
+	       num_canonical_type_hash_queries);
     }
 
   print_lto_report (pfx);