re PR ipa/44563 (GCC uses a lot of RAM when compiling a large numbers of functions)
authorRichard Biener <rguenther@suse.de>
Tue, 10 Mar 2015 08:25:31 +0000 (08:25 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 10 Mar 2015 08:25:31 +0000 (08:25 +0000)
2015-03-10  Richard Biener  <rguenther@suse.de>

PR middle-end/44563
* cgraph.h (struct cgraph_edge_hasher): Add hash overload
for compare_type.
* cgraph.c (cgraph_edge_hasher::hash): Inline htab_hash_pointer.
(cgraph_update_edge_in_call_site_hash): Use cgraph_edge_hasher::hash.
(cgraph_add_edge_to_call_site_hash): Likewise.
(cgraph_node::get_edge): Likewise.
(cgraph_edge::set_call_stmt): Likewise.
(cgraph_edge::remove_caller): Likewise.

From-SVN: r221308

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraph.h

index f878488e91ab0ee3eff320a9161dc86823697b5c..84170fb5ceb839c5f21c6f1d6d39d73a898d9ead 100644 (file)
@@ -1,3 +1,15 @@
+2015-03-10  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/44563
+       * cgraph.h (struct cgraph_edge_hasher): Add hash overload
+       for compare_type.
+       * cgraph.c (cgraph_edge_hasher::hash): Inline htab_hash_pointer.
+       (cgraph_update_edge_in_call_site_hash): Use cgraph_edge_hasher::hash.
+       (cgraph_add_edge_to_call_site_hash): Likewise.
+       (cgraph_node::get_edge): Likewise.
+       (cgraph_edge::set_call_stmt): Likewise.
+       (cgraph_edge::remove_caller): Likewise.
+
 2015-03-10  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * config/nds32/nds32.h (callee_saved_regs_size): Rename to ...
index e4d5505d697a57b5862c8172be5eafcc9626eeb8..5ca19015a3dc2693304390be87c6d3cf442d180e 100644 (file)
@@ -663,7 +663,19 @@ cgraph_node::get_for_asmname (tree asmname)
 hashval_t
 cgraph_edge_hasher::hash (cgraph_edge *e)
 {
-  return htab_hash_pointer (e->call_stmt);
+  /* This is a really poor hash function, but it is what htab_hash_pointer
+     uses.  */
+  return (hashval_t) ((intptr_t)e->call_stmt >> 3);
+}
+
+/* Returns a hash value for X (which really is a cgraph_edge).  */
+
+hashval_t
+cgraph_edge_hasher::hash (gimple call_stmt)
+{
+  /* This is a really poor hash function, but it is what htab_hash_pointer
+     uses.  */
+  return (hashval_t) ((intptr_t)call_stmt >> 3);
 }
 
 /* Return nonzero if the call_stmt of of cgraph_edge X is stmt *Y.  */
@@ -680,9 +692,8 @@ static inline void
 cgraph_update_edge_in_call_site_hash (cgraph_edge *e)
 {
   gimple call = e->call_stmt;
-  *e->caller->call_site_hash->find_slot_with_hash (call,
-                                                  htab_hash_pointer (call),
-                                                  INSERT) = e;
+  *e->caller->call_site_hash->find_slot_with_hash
+      (call, cgraph_edge_hasher::hash (call), INSERT) = e;
 }
 
 /* Add call graph edge E to call site hash of its caller.  */
@@ -695,8 +706,7 @@ cgraph_add_edge_to_call_site_hash (cgraph_edge *e)
   if (e->speculative && e->indirect_unknown_callee)
     return;
   cgraph_edge **slot = e->caller->call_site_hash->find_slot_with_hash
-                                  (e->call_stmt,
-                                   htab_hash_pointer (e->call_stmt), INSERT);
+      (e->call_stmt, cgraph_edge_hasher::hash (e->call_stmt), INSERT);
   if (*slot)
     {
       gcc_assert (((cgraph_edge *)*slot)->speculative);
@@ -718,8 +728,8 @@ cgraph_node::get_edge (gimple call_stmt)
   int n = 0;
 
   if (call_site_hash)
-    return call_site_hash->find_with_hash (call_stmt,
-                                          htab_hash_pointer (call_stmt));
+    return call_site_hash->find_with_hash
+       (call_stmt, cgraph_edge_hasher::hash (call_stmt));
 
   /* This loop may turn out to be performance problem.  In such case adding
      hashtables into call nodes with very many edges is probably best
@@ -782,7 +792,7 @@ cgraph_edge::set_call_stmt (gcall *new_stmt, bool update_speculative)
       && (!speculative || !indirect_unknown_callee))
     {
       caller->call_site_hash->remove_elt_with_hash
-       (call_stmt, htab_hash_pointer (call_stmt));
+       (call_stmt, cgraph_edge_hasher::hash (call_stmt));
     }
 
   cgraph_edge *e = this;
@@ -987,8 +997,8 @@ cgraph_edge::remove_caller (void)
        caller->callees = next_callee;
     }
   if (caller->call_site_hash)
-    caller->call_site_hash->remove_elt_with_hash (call_stmt,
-                                                 htab_hash_pointer (call_stmt));
+    caller->call_site_hash->remove_elt_with_hash
+       (call_stmt, cgraph_edge_hasher::hash (call_stmt));
 }
 
 /* Put the edge onto the free list.  */
index 2b96b6bcd06c94e5c9fbc4b153e84c61871cdc3a..99af026d2d715d85984a5b55ccce91dcf8f0c698 100644 (file)
@@ -788,6 +788,7 @@ struct cgraph_edge_hasher : ggc_hasher<cgraph_edge *>
   typedef gimple compare_type;
 
   static hashval_t hash (cgraph_edge *);
+  static hashval_t hash (gimple);
   static bool equal (cgraph_edge *, gimple);
 };