public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [01/12] Add hash_map traits that use existing hash_table-like traits
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
@ 2015-06-23 14:44 ` Richard Sandiford
  2015-06-25 16:34   ` Jeff Law
  2015-06-23 14:45 ` [02/12] Move tree operand hashers to a new header file Richard Sandiford
                   ` (10 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:44 UTC (permalink / raw)
  To: gcc-patches

This patch defines a class that converts hash_table-style traits into
hash_map traits.  It can be used as the default traits for all hash_maps
that don't specify their own traits (i.e. this patch does work on its own).

By the end of the series this class replaces default_hashmap_traits.


gcc/
	* hash-map-traits.h: Include hash-traits.h.
	(simple_hashmap_traits): New class.
	* mem-stats.h (hash_map): Change the default traits to
	simple_hashmap_traits<default_hash_traits<Key> >.

Index: gcc/hash-map-traits.h
===================================================================
--- gcc/hash-map-traits.h	2015-06-23 15:42:24.132002236 +0100
+++ gcc/hash-map-traits.h	2015-06-23 15:42:24.128002280 +0100
@@ -23,6 +23,8 @@ #define HASH_MAP_TRAITS_H
 /* Bacause mem-stats.h uses default hashmap traits, we have to
    put the class to this separate header file.  */
 
+#include "hash-traits.h"
+
 /* implement default behavior for traits when types allow it.  */
 
 struct default_hashmap_traits
@@ -101,4 +103,75 @@ struct default_hashmap_traits
     }
 };
 
+/* Implement hash_map traits for a key with hash traits H.  Empty and
+   deleted map entries are represented as empty and deleted keys.  */
+
+template <typename H>
+struct simple_hashmap_traits
+{
+  static inline hashval_t hash (const typename H::value_type &);
+  static inline bool equal_keys (const typename H::value_type &,
+				 const typename H::value_type &);
+  template <typename T> static inline void remove (T &);
+  template <typename T> static inline bool is_empty (const T &);
+  template <typename T> static inline bool is_deleted (const T &);
+  template <typename T> static inline void mark_empty (T &);
+  template <typename T> static inline void mark_deleted (T &);
+};
+
+template <typename H>
+inline hashval_t
+simple_hashmap_traits <H>::hash (const typename H::value_type &h)
+{
+  return H::hash (h);
+}
+
+template <typename H>
+inline bool
+simple_hashmap_traits <H>::equal_keys (const typename H::value_type &k1,
+				       const typename H::value_type &k2)
+{
+  return H::equal (k1, k2);
+}
+
+template <typename H>
+template <typename T>
+inline void
+simple_hashmap_traits <H>::remove (T &entry)
+{
+  H::remove (entry.m_key);
+}
+
+template <typename H>
+template <typename T>
+inline bool
+simple_hashmap_traits <H>::is_empty (const T &entry)
+{
+  return H::is_empty (entry.m_key);
+}
+
+template <typename H>
+template <typename T>
+inline bool
+simple_hashmap_traits <H>::is_deleted (const T &entry)
+{
+  return H::is_deleted (entry.m_key);
+}
+
+template <typename H>
+template <typename T>
+inline void
+simple_hashmap_traits <H>::mark_empty (T &entry)
+{
+  H::mark_empty (entry.m_key);
+}
+
+template <typename H>
+template <typename T>
+inline void
+simple_hashmap_traits <H>::mark_deleted (T &entry)
+{
+  H::mark_deleted (entry.m_key);
+}
+
 #endif // HASH_MAP_TRAITS_H
Index: gcc/mem-stats.h
===================================================================
--- gcc/mem-stats.h	2015-06-23 15:42:24.132002236 +0100
+++ gcc/mem-stats.h	2015-06-23 15:42:24.128002280 +0100
@@ -3,7 +3,7 @@ #define GCC_MEM_STATS_H
 
 /* Forward declaration.  */
 template<typename Key, typename Value,
-	 typename Traits = default_hashmap_traits>
+	 typename Traits = simple_hashmap_traits<default_hash_traits<Key> > >
 class hash_map;
 
 #define LOCATION_LINE_EXTRA_SPACE 30

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [02/12] Move tree operand hashers to a new header file
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
  2015-06-23 14:44 ` [01/12] Add hash_map traits that use existing hash_table-like traits Richard Sandiford
@ 2015-06-23 14:45 ` Richard Sandiford
  2015-06-25 16:34   ` Jeff Law
  2015-06-23 14:47 ` [03/12] Move decl hasher to " Richard Sandiford
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:45 UTC (permalink / raw)
  To: gcc-patches

There were three tree operand hashers, so move them to their own
header file.

The typedefs in this and subsequent patches are temporary and
get removed in patch 12.


gcc/
	* tree-hash-traits.h: New file.
	(tree_operand_hash): New class.
	* sanopt.c: Include tree-hash-traits.h.
	(sanopt_tree_map_traits): Use tree_operand_hash.
	* tree-if-conv.c: Include tree-hash-traits.h.
	(phi_args_hash_traits): Use tree_operand_hash.
	* tree-ssa-uncprop.c: Include tree-hash-traits.h.
	(val_ssa_equiv_hash_traits): Use tree_operand_hash.

Index: gcc/tree-hash-traits.h
===================================================================
--- /dev/null	2015-06-02 17:27:28.541944012 +0100
+++ gcc/tree-hash-traits.h	2015-06-23 15:44:07.966809173 +0100
@@ -0,0 +1,42 @@
+/* Traits for hashing trees.
+   Copyright (C) 2014-2015 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#ifndef tree_hash_traits_h
+#define tree_hash_traits_h
+
+/* Hash for trees based on operand_equal_p.  */
+struct tree_operand_hash : ggc_ptr_hash <tree_node>
+{
+  static inline hashval_t hash (const_tree);
+  static inline bool equal_keys (const_tree, const_tree);
+};
+
+inline hashval_t
+tree_operand_hash::hash (const_tree t)
+{
+  return iterative_hash_expr (t, 0);
+}
+
+inline bool
+tree_operand_hash::equal_keys (const_tree t1, const_tree t2)
+{
+  return operand_equal_p (t1, t2, 0);
+}
+
+#endif
Index: gcc/sanopt.c
===================================================================
--- gcc/sanopt.c	2015-06-23 15:44:07.970809082 +0100
+++ gcc/sanopt.c	2015-06-23 15:44:07.962809243 +0100
@@ -50,6 +50,7 @@ Software Foundation; either version 3, o
 #include "ubsan.h"
 #include "params.h"
 #include "tree-ssa-operands.h"
+#include "tree-hash-traits.h"
 
 
 /* This is used to carry information about basic blocks.  It is
@@ -98,20 +99,7 @@ maybe_get_single_definition (tree t)
   return NULL_TREE;
 }
 
-/* Traits class for tree hash maps below.  */
-
-struct sanopt_tree_map_traits : default_hashmap_traits
-{
-  static inline hashval_t hash (const_tree ref)
-  {
-    return iterative_hash_expr (ref, 0);
-  }
-
-  static inline bool equal_keys (const_tree ref1, const_tree ref2)
-  {
-    return operand_equal_p (ref1, ref2, 0);
-  }
-}; 
+typedef simple_hashmap_traits <tree_operand_hash> sanopt_tree_map_traits;
 
 /* Tree triplet for vptr_check_map.  */
 struct sanopt_tree_triplet
Index: gcc/tree-if-conv.c
===================================================================
--- gcc/tree-if-conv.c	2015-06-23 15:44:07.970809082 +0100
+++ gcc/tree-if-conv.c	2015-06-23 15:44:07.966809173 +0100
@@ -135,6 +135,7 @@ Software Foundation; either version 3, o
 #include "expr.h"
 #include "insn-codes.h"
 #include "optabs.h"
+#include "tree-hash-traits.h"
 
 /* List of basic blocks in if-conversion-suitable order.  */
 static basic_block *ifc_bbs;
@@ -1594,27 +1595,9 @@ convert_scalar_cond_reduction (gimple re
   return rhs;
 }
 
-/* Helpers for PHI arguments hashtable map.  */
+typedef simple_hashmap_traits <tree_operand_hash> phi_args_hash_traits;
 
-struct phi_args_hash_traits : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-  static inline bool equal_keys (tree, tree);
-};
-
-inline hashval_t
-phi_args_hash_traits::hash (tree value)
-{
-  return iterative_hash_expr (value, 0);
-}
-
-inline bool
-phi_args_hash_traits::equal_keys (tree value1, tree value2)
-{
-  return operand_equal_p (value1, value2, 0);
-}
-
-  /* Produce condition for all occurrences of ARG in PHI node.  */
+/* Produce condition for all occurrences of ARG in PHI node.  */
 
 static tree
 gen_phi_arg_condition (gphi *phi, vec<int> *occur,
Index: gcc/tree-ssa-uncprop.c
===================================================================
--- gcc/tree-ssa-uncprop.c	2015-06-23 15:44:07.970809082 +0100
+++ gcc/tree-ssa-uncprop.c	2015-06-23 15:44:07.966809173 +0100
@@ -50,6 +50,7 @@ the Free Software Foundation; either ver
 #include "domwalk.h"
 #include "tree-pass.h"
 #include "tree-ssa-propagate.h"
+#include "tree-hash-traits.h"
 
 /* The basic structure describing an equivalency created by traversing
    an edge.  Traversing the edge effectively means that we can assume
@@ -294,25 +295,11 @@ struct equiv_hash_elt
 
 /* Value to ssa name equivalence hashtable helpers.  */
 
-struct val_ssa_equiv_hash_traits : default_hashmap_traits
+struct val_ssa_equiv_hash_traits : simple_hashmap_traits <tree_operand_hash>
 {
-  static inline hashval_t hash (tree);
-  static inline bool equal_keys (tree, tree);
   template<typename T> static inline void remove (T &);
 };
 
-inline hashval_t
-val_ssa_equiv_hash_traits::hash (tree value)
-{
-  return iterative_hash_expr (value, 0);
-}
-
-inline bool
-val_ssa_equiv_hash_traits::equal_keys (tree value1, tree value2)
-{
-  return operand_equal_p (value1, value2, 0);
-}
-
 /* Free an instance of equiv_hash_elt.  */
 
 template<typename T>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [03/12] Move decl hasher to header file
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
  2015-06-23 14:44 ` [01/12] Add hash_map traits that use existing hash_table-like traits Richard Sandiford
  2015-06-23 14:45 ` [02/12] Move tree operand hashers to a new header file Richard Sandiford
@ 2015-06-23 14:47 ` Richard Sandiford
  2015-06-25 16:34   ` Jeff Law
  2015-06-23 14:48 ` [04/12] Move ssa_name " Richard Sandiford
                   ` (8 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:47 UTC (permalink / raw)
  To: gcc-patches

Like the previous patch, but for decl hashers.  There's only one copy
of this so far, but the idea seems general.


gcc/
	* tree-hash-traits.h (tree_decl_hash): New class.
	* tree-ssa-strlen.c: Include tree-hash-traits.h.
	(stridxlist_hash_traits): Use tree_decl_hash.

Index: gcc/tree-hash-traits.h
===================================================================
--- gcc/tree-hash-traits.h	2015-06-23 15:45:22.993947116 +0100
+++ gcc/tree-hash-traits.h	2015-06-23 15:45:22.989947161 +0100
@@ -39,4 +39,18 @@ tree_operand_hash::equal_keys (const_tre
   return operand_equal_p (t1, t2, 0);
 }
 
+/* Hasher for tree decls.  Pointer equality is enough here, but the DECL_UID
+   is a better hash than the pointer value and gives a predictable traversal
+   order.  */
+struct tree_decl_hash : ggc_ptr_hash <tree_node>
+{
+  static inline hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_decl_hash::hash (tree t)
+{
+  return DECL_UID (t);
+}
+
 #endif
Index: gcc/tree-ssa-strlen.c
===================================================================
--- gcc/tree-ssa-strlen.c	2015-06-23 15:45:22.993947116 +0100
+++ gcc/tree-ssa-strlen.c	2015-06-23 15:45:22.989947161 +0100
@@ -73,6 +73,7 @@ the Free Software Foundation; either ver
 #include "ipa-ref.h"
 #include "cgraph.h"
 #include "ipa-chkp.h"
+#include "tree-hash-traits.h"
 
 /* A vector indexed by SSA_NAME_VERSION.  0 means unknown, positive value
    is an index into strinfo vector, negative value stands for
@@ -155,20 +156,7 @@ struct decl_stridxlist_map
   struct stridxlist list;
 };
 
-/* stridxlist hashtable helpers.  */
-
-struct stridxlist_hash_traits : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-};
-
-/* Hash a from tree in a decl_stridxlist_map.  */
-
-inline hashval_t
-stridxlist_hash_traits::hash (tree item)
-{
-  return DECL_UID (item);
-}
+typedef simple_hashmap_traits <tree_decl_hash> stridxlist_hash_traits;
 
 /* Hash table for mapping decls to a chained list of offset -> idx
    mappings.  */

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [04/12] Move ssa_name hasher to header file
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (2 preceding siblings ...)
  2015-06-23 14:47 ` [03/12] Move decl hasher to " Richard Sandiford
@ 2015-06-23 14:48 ` Richard Sandiford
  2015-06-25 16:35   ` Jeff Law
  2015-06-23 14:49 ` [05/12] Move TREE_HASH " Richard Sandiford
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:48 UTC (permalink / raw)
  To: gcc-patches

Another tree hasher, this time for SSA names.  Again there's only one copy
at the moment, but the idea seems general.


gcc/
	* tree-hash-traits.h (tree_ssa_name_hasher): New class.
	* sese.c: Include tree-hash-traits.h.
	(rename_map_hasher): Use tree_ssa_name_hasher.

Index: gcc/tree-hash-traits.h
===================================================================
--- gcc/tree-hash-traits.h	2015-06-23 15:46:11.453390373 +0100
+++ gcc/tree-hash-traits.h	2015-06-23 15:46:11.449390427 +0100
@@ -53,4 +53,18 @@ tree_decl_hash::hash (tree t)
   return DECL_UID (t);
 }
 
+/* Hash for SSA_NAMEs in the same function.  Pointer equality is enough
+   here, but the SSA_NAME_VERSION is a better hash than the pointer
+   value and gives a predictable traversal order.  */
+struct tree_ssa_name_hash : ggc_ptr_hash <tree_node>
+{
+  static inline hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_ssa_name_hash::hash (tree t)
+{
+  return SSA_NAME_VERSION (t);
+}
+
 #endif
Index: gcc/sese.c
===================================================================
--- gcc/sese.c	2015-06-23 15:46:11.453390373 +0100
+++ gcc/sese.c	2015-06-23 15:46:11.449390427 +0100
@@ -63,6 +63,7 @@ the Free Software Foundation; either ver
 #include "value-prof.h"
 #include "sese.h"
 #include "tree-ssa-propagate.h"
+#include "tree-hash-traits.h"
 
 /* Helper function for debug_rename_map.  */
 
@@ -78,22 +79,7 @@ debug_rename_map_1 (tree_node *const &ol
   return true;
 }
 \f
-
-/* Hashtable helpers.  */
-
-struct rename_map_hasher : default_hashmap_traits
-{
-  static inline hashval_t hash (tree);
-};
-
-/* Computes a hash function for database element ELT.  */
-
-inline hashval_t
-rename_map_hasher::hash (tree old_name)
-{
-  return SSA_NAME_VERSION (old_name);
-}
-
+typedef simple_hashmap_traits<tree_ssa_name_hash> rename_map_hasher;
 typedef hash_map<tree, tree, rename_map_hasher> rename_map_type;
 \f
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [05/12] Move TREE_HASH hasher to header file
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (3 preceding siblings ...)
  2015-06-23 14:48 ` [04/12] Move ssa_name " Richard Sandiford
@ 2015-06-23 14:49 ` Richard Sandiford
  2015-06-25 16:36   ` Jeff Law
  2015-06-23 14:50 ` [06/12] Consolidate string hashers Richard Sandiford
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:49 UTC (permalink / raw)
  To: gcc-patches

One more tree hasher, this time based on TREE_HASH.


gcc/
	* tree-hash-traits.h (tree_hash): New class.
	* except.c: Include tree-hash-traits.h.
	(tree_hash_traits): Use tree_hash.

Index: gcc/tree-hash-traits.h
===================================================================
--- gcc/tree-hash-traits.h	2015-06-23 15:47:41.132358999 +0100
+++ gcc/tree-hash-traits.h	2015-06-23 15:47:41.128359041 +0100
@@ -67,4 +67,16 @@ tree_ssa_name_hash::hash (tree t)
   return SSA_NAME_VERSION (t);
 }
 
+/* Hasher for general trees, based on their TREE_HASH.  */
+struct tree_hash : ggc_ptr_hash <tree_node>
+{
+  static hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_hash::hash (tree t)
+{
+  return TREE_HASH (t);
+}
+
 #endif
Index: gcc/except.c
===================================================================
--- gcc/except.c	2015-06-23 15:47:41.132358999 +0100
+++ gcc/except.c	2015-06-23 15:47:41.128359041 +0100
@@ -161,14 +161,11 @@ Software Foundation; either version 3, o
 #include "tree-pass.h"
 #include "cfgloop.h"
 #include "builtins.h"
+#include "tree-hash-traits.h"
 
 static GTY(()) int call_site_base;
 
-struct tree_hash_traits : default_hashmap_traits
-{
-  static hashval_t hash (tree t) { return TREE_HASH (t); }
-};
-
+struct tree_hash_traits : simple_hashmap_traits <tree_hash> {};
 static GTY (()) hash_map<tree, tree, tree_hash_traits> *type_to_runtime_map;
 
 /* Describe the SjLj_Function_Context structure.  */

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [06/12] Consolidate string hashers
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (4 preceding siblings ...)
  2015-06-23 14:49 ` [05/12] Move TREE_HASH " Richard Sandiford
@ 2015-06-23 14:50 ` Richard Sandiford
  2015-06-24 10:13   ` Mikhail Maltsev
  2015-06-25 16:37   ` Jeff Law
  2015-06-23 14:52 ` [07/12] Use new string hasher for MIPS Richard Sandiford
                   ` (5 subsequent siblings)
  11 siblings, 2 replies; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:50 UTC (permalink / raw)
  To: gcc-patches

This patch replaces various string hashers with a single copy
in hash-traits.h.


gcc/
	* hash-traits.h (string_hash, nofree_string_hash): New classes.
	* genmatch.c (capture_id_map_hasher): Use nofree_string_hash.
	* passes.c (pass_registry_hasher): Likewise.
	* config/alpha/alpha.c (string_traits): Likewise.
	* config/i386/winnt.c (i386_find_on_wrapper_list): Likewise.
	* config/m32c/m32c.c (pragma_traits): Likewise.
	* config/mep/mep.c (pragma_traits): Likewise.

gcc/java/
	* jcf-io.c (memoized_class_lookups): Use nofree_string_hash.
	(find_class): Likewise.

Index: gcc/hash-traits.h
===================================================================
--- gcc/hash-traits.h	2015-06-23 15:48:30.751788389 +0100
+++ gcc/hash-traits.h	2015-06-23 15:48:30.743788520 +0100
@@ -121,6 +121,27 @@ pointer_hash <Type>::is_empty (Type *e)
   return e == NULL;
 }
 
+/* Hasher for "const char *" strings, using string rather than pointer
+   equality.  */
+
+struct string_hash : pointer_hash <const char>
+{
+  static inline hashval_t hash (const char *);
+  static inline bool equal (const char *, const char *);
+};
+
+inline hashval_t
+string_hash::hash (const char *id)
+{
+  return htab_hash_string (id);
+}
+
+inline bool
+string_hash::equal (const char *id1, const char *id2)
+{
+  return strcmp (id1, id2) == 0;
+}
+
 /* Remover and marker for entries in gc memory.  */
 
 template<typename T>
@@ -190,6 +211,11 @@ struct ggc_ptr_hash : pointer_hash <T>,
 template <typename T>
 struct ggc_cache_ptr_hash : pointer_hash <T>, ggc_cache_remove <T *> {};
 
+/* Traits for string elements that should not be freed when an element
+   is deleted.  */
+
+struct nofree_string_hash : string_hash, typed_noop_remove <const char *> {};
+
 template <typename T> struct default_hash_traits;
 
 template <typename T>
Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	2015-06-23 15:48:30.751788389 +0100
+++ gcc/genmatch.c	2015-06-23 15:48:30.743788520 +0100
@@ -392,26 +392,7 @@ get_operator (const char *id)
   return 0;
 }
 
-
-/* Helper for the capture-id map.  */
-
-struct capture_id_map_hasher : default_hashmap_traits
-{
-  static inline hashval_t hash (const char *);
-  static inline bool equal_keys (const char *, const char *);
-};
-
-inline hashval_t
-capture_id_map_hasher::hash (const char *id)
-{
-  return htab_hash_string (id);
-}
-
-inline bool
-capture_id_map_hasher::equal_keys (const char *id1, const char *id2)
-{
-  return strcmp (id1, id2) == 0;
-}
+typedef simple_hashmap_traits<nofree_string_hash> capture_id_map_hasher;
 
 typedef hash_map<const char *, unsigned, capture_id_map_hasher> cid_map_t;
 
Index: gcc/passes.c
===================================================================
--- gcc/passes.c	2015-06-23 15:48:30.751788389 +0100
+++ gcc/passes.c	2015-06-23 15:48:30.747788453 +0100
@@ -861,29 +861,7 @@ pass_manager::register_dump_files (opt_p
   while (pass);
 }
 
-/* Helper for pass_registry hash table.  */
-
-struct pass_registry_hasher : default_hashmap_traits
-{
-  static inline hashval_t hash (const char *);
-  static inline bool equal_keys (const char *, const char *);
-};
-
-/* Pass registry hash function.  */
-
-inline hashval_t
-pass_registry_hasher::hash (const char *name)
-{
-  return htab_hash_string (name);
-}
-
-/* Hash equal function  */
-
-inline bool
-pass_registry_hasher::equal_keys (const char *s1, const char *s2)
-{
-  return !strcmp (s1, s2);
-}
+typedef simple_hashmap_traits<nofree_string_hash> pass_registry_hasher;
 
 static hash_map<const char *, opt_pass *, pass_registry_hasher>
   *name_to_pass_map;
Index: gcc/config/alpha/alpha.c
===================================================================
--- gcc/config/alpha/alpha.c	2015-06-23 15:48:30.751788389 +0100
+++ gcc/config/alpha/alpha.c	2015-06-23 15:48:30.747788453 +0100
@@ -4808,13 +4808,7 @@ alpha_multipass_dfa_lookahead (void)
 
 struct GTY(()) alpha_links;
 
-struct string_traits : default_hashmap_traits
-{
-  static bool equal_keys (const char *const &a, const char *const &b)
-  {
-    return strcmp (a, b) == 0;
-  }
-};
+typedef simple_hashmap_traits <nofree_string_hash> string_traits;
 
 struct GTY(()) machine_function
 {
Index: gcc/config/i386/winnt.c
===================================================================
--- gcc/config/i386/winnt.c	2015-06-23 15:48:30.751788389 +0100
+++ gcc/config/i386/winnt.c	2015-06-23 15:48:30.739788568 +0100
@@ -709,29 +709,6 @@ i386_pe_record_stub (const char *name)
 
 #ifdef CXX_WRAP_SPEC_LIST
 
-/* Hashtable helpers.  */
-
-struct wrapped_symbol_hasher : nofree_ptr_hash <const char>
-{
-  static inline hashval_t hash (const char *);
-  static inline bool equal (const char *, const char *);
-  static inline void remove (const char *);
-};
-
-inline hashval_t
-wrapped_symbol_hasher::hash (const char *v)
-{
-  return htab_hash_string (v);
-}
-
-/*  Hash table equality helper function.  */
-
-inline bool
-wrapped_symbol_hasher::equal (const char *x, const char *y)
-{
-  return !strcmp (x, y);
-}
-
 /* Search for a function named TARGET in the list of library wrappers
    we are using, returning a pointer to it if found or NULL if not.
    This function might be called on quite a few symbols, and we only
@@ -743,7 +720,7 @@ wrapped_symbol_hasher::equal (const char
 i386_find_on_wrapper_list (const char *target)
 {
   static char first_time = 1;
-  static hash_table<wrapped_symbol_hasher> *wrappers;
+  static hash_table<nofree_string_hash> *wrappers;
 
   if (first_time)
     {
@@ -756,7 +733,7 @@ i386_find_on_wrapper_list (const char *t
       char *bufptr;
       /* Breaks up the char array into separated strings
          strings and enter them into the hash table.  */
-      wrappers = new hash_table<wrapped_symbol_hasher> (8);
+      wrappers = new hash_table<nofree_string_hash> (8);
       for (bufptr = wrapper_list_buffer; *bufptr; ++bufptr)
 	{
 	  char *found = NULL;
Index: gcc/config/m32c/m32c.c
===================================================================
--- gcc/config/m32c/m32c.c	2015-06-23 15:48:30.751788389 +0100
+++ gcc/config/m32c/m32c.c	2015-06-23 15:48:30.747788453 +0100
@@ -3055,16 +3055,7 @@ m32c_insert_attributes (tree node ATTRIB
     }	
 }
 
-
-struct pragma_traits : default_hashmap_traits
-{
-  static hashval_t hash (const char *str) { return htab_hash_string (str); }
-  static bool
-  equal_keys (const char *a, const char *b)
-  {
-    return !strcmp (a, b);
-  }
-};
+typedef simple_hashmap_traits<nofree_string_hash> pragma_traits;
 
 /* Hash table of pragma info.  */
 static GTY(()) hash_map<const char *, unsigned, pragma_traits> *pragma_htab;
Index: gcc/config/mep/mep.c
===================================================================
--- gcc/config/mep/mep.c	2015-06-23 15:48:30.751788389 +0100
+++ gcc/config/mep/mep.c	2015-06-23 15:48:30.743788520 +0100
@@ -4073,15 +4073,7 @@ struct GTY(()) pragma_entry {
   int flag;
 };
 
-struct pragma_traits : default_hashmap_traits
-{
-  static hashval_t hash (const char *s) { return htab_hash_string (s); }
-  static bool
-  equal_keys (const char *a, const char *b)
-  {
-    return strcmp (a, b) == 0;
-  }
-};
+typedef simple_hashmap_traits<nofree_string_hash> pragma_traits;
 
 /* Hash table of farcall-tagged sections.  */
 static GTY(()) hash_map<const char *, pragma_entry, pragma_traits> *
Index: gcc/java/jcf-io.c
===================================================================
--- gcc/java/jcf-io.c	2015-06-23 15:48:30.751788389 +0100
+++ gcc/java/jcf-io.c	2015-06-23 15:48:30.743788520 +0100
@@ -273,33 +273,11 @@ find_classfile (char *filename, JCF *jcf
   return open_class (filename, jcf, fd, dep_name);
 }
 
-
-/* Hash table helper.  */
-
-struct charstar_hash : nofree_ptr_hash <const char>
-{
-  static inline hashval_t hash (const char *candidate);
-  static inline bool equal (const char *existing, const char *candidate);
-};
-
-inline hashval_t
-charstar_hash::hash (const char *candidate)
-{
-  return htab_hash_string (candidate);
-}
-
-inline bool
-charstar_hash::equal (const char *existing, const char *candidate)
-{
-  return strcmp (existing, candidate) == 0;
-}
-
-
 /* A hash table keeping track of class names that were not found
    during class lookup.  (There is no need to cache the values
    associated with names that were found; they are saved in
    IDENTIFIER_CLASS_VALUE.)  */
-static hash_table<charstar_hash> *memoized_class_lookups;
+static hash_table<nofree_string_hash> *memoized_class_lookups;
 
 /* Returns a freshly malloc'd string with the fully qualified pathname
    of the .class file for the class CLASSNAME.  CLASSNAME must be
@@ -322,11 +300,11 @@ find_class (const char *classname, int c
 
   /* Create the hash table, if it does not already exist.  */
   if (!memoized_class_lookups)
-    memoized_class_lookups = new hash_table<charstar_hash> (37);
+    memoized_class_lookups = new hash_table<nofree_string_hash> (37);
 
   /* Loop for this class in the hashtable.  If it is present, we've
      already looked for this class and failed to find it.  */
-  hash = charstar_hash::hash (classname);
+  hash = nofree_string_hash::hash (classname);
   if (memoized_class_lookups->find_with_hash (classname, hash))
     return NULL;
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [07/12] Use new string hasher for MIPS
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (5 preceding siblings ...)
  2015-06-23 14:50 ` [06/12] Consolidate string hashers Richard Sandiford
@ 2015-06-23 14:52 ` Richard Sandiford
  2015-06-25 16:39   ` Jeff Law
  2015-06-23 14:53 ` [08/12] Add common traits for integer hash keys Richard Sandiford
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:52 UTC (permalink / raw)
  To: gcc-patches

Use the string hasher from patch 6 for MIPS.  I split this out because
local_alias_traits doesn't actually need to use SYMBOL_REF rtxes as
the map keys, since the only data used is the symbol name.


gcc/
	* config/mips/mips.c (mips16_flip_traits): Use it.
	(local_alias_traits, mips16_local_aliases): Convert from a map of
	rtxes to a map of symbol names.
	(mips16_local_alias): Update accordingly.

Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2015-06-23 15:49:32.187081876 +0100
+++ gcc/config/mips/mips.c	2015-06-23 15:49:32.183081933 +0100
@@ -1265,15 +1265,7 @@ static int mips_register_move_cost (mach
 static unsigned int mips_function_arg_boundary (machine_mode, const_tree);
 static machine_mode mips_get_reg_raw_mode (int regno);
 \f
-struct mips16_flip_traits : default_hashmap_traits
-{
-  static hashval_t hash (const char *s) { return htab_hash_string (s); }
-  static bool
-  equal_keys (const char *a, const char *b)
-  {
-    return !strcmp (a, b);
-  }
-};
+struct mips16_flip_traits : simple_hashmap_traits <nofree_string_hash> {};
 
 /* This hash table keeps track of implicit "mips16" and "nomips16" attributes
    for -mflip_mips16.  It maps decl names onto a boolean mode setting.  */
@@ -6601,30 +6593,13 @@ mips_load_call_address (enum mips_call_t
     }
 }
 \f
-struct local_alias_traits : default_hashmap_traits
-{
-  static hashval_t hash (rtx);
-  static bool equal_keys (rtx, rtx);
-};
+struct local_alias_traits : simple_hashmap_traits <nofree_string_hash> {};
 
 /* Each locally-defined hard-float MIPS16 function has a local symbol
    associated with it.  This hash table maps the function symbol (FUNC)
    to the local symbol (LOCAL). */
-static GTY (()) hash_map<rtx, rtx, local_alias_traits> *mips16_local_aliases;
-
-/* Hash table callbacks for mips16_local_aliases.  */
-
-hashval_t
-local_alias_traits::hash (rtx func)
-{
-  return htab_hash_string (XSTR (func, 0));
-}
-
-bool
-local_alias_traits::equal_keys (rtx func1, rtx func2)
-{
-  return rtx_equal_p (func1, func2);
-}
+static GTY (()) hash_map<const char *, rtx, local_alias_traits>
+  *mips16_local_aliases;
 
 /* FUNC is the symbol for a locally-defined hard-float MIPS16 function.
    Return a local alias for it, creating a new one if necessary.  */
@@ -6635,23 +6610,23 @@ mips16_local_alias (rtx func)
   /* Create the hash table if this is the first call.  */
   if (mips16_local_aliases == NULL)
     mips16_local_aliases
-      = hash_map<rtx, rtx, local_alias_traits>::create_ggc (37);
+      = hash_map<const char *, rtx, local_alias_traits>::create_ggc (37);
 
   /* Look up the function symbol, creating a new entry if need be.  */
   bool existed;
-  rtx *slot = &mips16_local_aliases->get_or_insert (func, &existed);
+  const char *func_name = XSTR (func, 0);
+  rtx *slot = &mips16_local_aliases->get_or_insert (func_name, &existed);
   gcc_assert (slot != NULL);
 
   if (!existed)
     {
-      const char *func_name, *local_name;
       rtx local;
 
       /* Create a new SYMBOL_REF for the local symbol.  The choice of
 	 __fn_local_* is based on the __fn_stub_* names that we've
 	 traditionally used for the non-MIPS16 stub.  */
       func_name = targetm.strip_name_encoding (XSTR (func, 0));
-      local_name = ACONCAT (("__fn_local_", func_name, NULL));
+      const char *local_name = ACONCAT (("__fn_local_", func_name, NULL));
       local = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (local_name));
       SYMBOL_REF_FLAGS (local) = SYMBOL_REF_FLAGS (func) | SYMBOL_FLAG_LOCAL;
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [08/12] Add common traits for integer hash keys
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (6 preceding siblings ...)
  2015-06-23 14:52 ` [07/12] Use new string hasher for MIPS Richard Sandiford
@ 2015-06-23 14:53 ` Richard Sandiford
  2015-06-25 16:40   ` Jeff Law
  2015-06-23 14:55 ` [09/12] Remove all but one use of default_hashmap_traits Richard Sandiford
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:53 UTC (permalink / raw)
  To: gcc-patches

Several places define hash traits for integers, using particular integer
values as "empty" and "deleted" markers.  This patch defines them in terms
of a single int_hash class.

I also needed to extend gengtype to accept "+" in template arguments.


gcc/
	* gengtype-parse.c (require_template_declaration): Allow '+' in
	template parameters.  Consolidate cases.
	* hash-traits.h (int_hash): New class.
	* alias.c (alias_set_hash): New structure.
	(alias_set_traits): Use it.
	* symbol-summary.h (function_summary::map_hash): New class.
	(function_summary::summary_hashmap_traits): Use it.
	* tree-inline.h (dependence_hash): New class.
	(dependence_hasher): Use it.
	* tree-ssa-reassoc.c (oecount_hasher): Use int_hash.
	* value-prof.c (profile_id_hash): New class.
	(profile_id_traits): Use it.

Index: gcc/gengtype-parse.c
===================================================================
--- gcc/gengtype-parse.c	2015-06-23 15:50:56.686110247 +0100
+++ gcc/gengtype-parse.c	2015-06-23 15:50:56.678110339 +0100
@@ -274,17 +274,13 @@ require_template_declaration (const char
 	  str = concat (str, "enum ", (char *) 0);
 	  continue;
 	}
-      if (token () == NUM)
+      if (token () == NUM
+	  || token () == ':'
+	  || token () == '+')
 	{
 	  str = concat (str, advance (), (char *) 0);
 	  continue;
 	}
-      if (token () == ':')
-	{
-	  advance ();
-	  str = concat (str, ":", (char *) 0);
-	  continue;
-	}
       if (token () == '<')
 	{
 	  advance ();
Index: gcc/hash-traits.h
===================================================================
--- gcc/hash-traits.h	2015-06-23 15:50:56.686110247 +0100
+++ gcc/hash-traits.h	2015-06-23 15:50:56.674110387 +0100
@@ -57,6 +57,68 @@ typed_noop_remove <Type>::remove (Type &
 }
 
 
+/* Hasher for integer type Type in which Empty is a spare value that can be
+   used to mark empty slots.  If Deleted != Empty then Deleted is another
+   spare value that can be used for deleted slots; if Deleted == Empty then
+   hash table entries cannot be deleted.  */
+
+template <typename Type, Type Empty, Type Deleted = Empty>
+struct int_hash : typed_noop_remove <Type>
+{
+  typedef Type value_type;
+  typedef Type compare_type;
+
+  static inline hashval_t hash (value_type);
+  static inline bool equal (value_type existing, value_type candidate);
+  static inline void mark_deleted (Type &);
+  static inline void mark_empty (Type &);
+  static inline bool is_deleted (Type);
+  static inline bool is_empty (Type);
+};
+
+template <typename Type, Type Empty, Type Deleted>
+inline hashval_t
+int_hash <Type, Empty, Deleted>::hash (value_type x)
+{
+  return x;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline bool
+int_hash <Type, Empty, Deleted>::equal (value_type x, value_type y)
+{
+  return x == y;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline void
+int_hash <Type, Empty, Deleted>::mark_deleted (Type &x)
+{
+  gcc_assert (Empty != Deleted);
+  x = Deleted;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline void
+int_hash <Type, Empty, Deleted>::mark_empty (Type &x)
+{
+  x = Empty;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline bool
+int_hash <Type, Empty, Deleted>::is_deleted (Type x)
+{
+  return Empty != Deleted && x == Deleted;
+}
+
+template <typename Type, Type Empty, Type Deleted>
+inline bool
+int_hash <Type, Empty, Deleted>::is_empty (Type x)
+{
+  return x == Empty;
+}
+
 /* Pointer hasher based on pointer equality.  Other types of pointer hash
    can inherit this and override the hash and equal functions with some
    other form of equality (such as string equality).  */
Index: gcc/alias.c
===================================================================
--- gcc/alias.c	2015-06-23 15:50:56.686110247 +0100
+++ gcc/alias.c	2015-06-23 15:50:56.678110339 +0100
@@ -143,31 +143,8 @@ Software Foundation; either version 3, o
    However, this is no actual entry for alias set zero.  It is an
    error to attempt to explicitly construct a subset of zero.  */
 
-struct alias_set_traits : default_hashmap_traits
-{
-  template<typename T>
-  static bool
-  is_empty (T &e)
-  {
-    return e.m_key == INT_MIN;
-  }
-
-  template<typename  T>
-  static bool
-  is_deleted (T &e)
-  {
-    return e.m_key == (INT_MIN + 1);
-  }
-
-  template<typename T> static void mark_empty (T &e) { e.m_key = INT_MIN; }
-
-  template<typename T>
-  static void
-  mark_deleted (T &e)
-  {
-    e.m_key = INT_MIN + 1;
-  }
-};
+struct alias_set_hash : int_hash <int, INT_MIN, INT_MIN + 1> {};
+struct alias_set_traits : simple_hashmap_traits <alias_set_hash> {};
 
 struct GTY(()) alias_set_entry_d {
   /* The alias set number, as stored in MEM_ALIAS_SET.  */
Index: gcc/symbol-summary.h
===================================================================
--- gcc/symbol-summary.h	2015-06-23 15:50:56.686110247 +0100
+++ gcc/symbol-summary.h	2015-06-23 15:50:56.678110339 +0100
@@ -200,45 +200,8 @@ class GTY((user)) function_summary <T *>
   bool m_ggc;
 
 private:
-  struct summary_hashmap_traits: default_hashmap_traits
-  {
-    static const int deleted_value = -1;
-    static const int empty_value = 0;
-
-    static hashval_t
-    hash (const int v)
-    {
-      return (hashval_t)v;
-    }
-
-    template<typename Type>
-    static bool
-    is_deleted (Type &e)
-    {
-      return e.m_key == deleted_value;
-    }
-
-    template<typename Type>
-    static bool
-    is_empty (Type &e)
-    {
-      return e.m_key == empty_value;
-    }
-
-    template<typename Type>
-    static void
-    mark_deleted (Type &e)
-    {
-      e.m_key = deleted_value;
-    }
-
-    template<typename Type>
-    static void
-    mark_empty (Type &e)
-    {
-      e.m_key = empty_value;
-    }
-  };
+  typedef int_hash <int, 0, -1> map_hash;
+  typedef simple_hashmap_traits <map_hash> summary_hashmap_traits;
 
   /* Getter for summary callgraph ID.  */
   T* get (int uid)
Index: gcc/tree-inline.h
===================================================================
--- gcc/tree-inline.h	2015-06-23 15:50:56.686110247 +0100
+++ gcc/tree-inline.h	2015-06-23 15:50:56.678110339 +0100
@@ -35,25 +35,8 @@ enum copy_body_cge_which
   CB_CGE_MOVE_CLONES
 };
 
-struct dependence_hasher : default_hashmap_traits
-{
-  template<typename T>
-  static void
-  mark_deleted (T &e)
-    { gcc_unreachable (); }
-
-  template<typename T>
-  static void
-  mark_empty (T &e)
-    { e.m_key = 0; }
-
-  template<typename T>
-  static bool
-  is_deleted (T &)
-    { return false; }
-
-  template<typename T> static bool is_empty (T &e) { return e.m_key == 0; }
-};
+typedef int_hash <unsigned short, 0> dependence_hash;
+typedef simple_hashmap_traits <dependence_hash> dependence_hasher;
 
 /* Data required for function body duplication.  */
 
Index: gcc/tree-ssa-reassoc.c
===================================================================
--- gcc/tree-ssa-reassoc.c	2015-06-23 15:50:56.686110247 +0100
+++ gcc/tree-ssa-reassoc.c	2015-06-23 15:50:56.678110339 +0100
@@ -1019,23 +1019,16 @@ typedef struct oecount_s {
 
 /* Oecount hashtable helpers.  */
 
-struct oecount_hasher
+struct oecount_hasher : int_hash <int, 0, 1>
 {
-  typedef int value_type;
-  typedef int compare_type;
-  static inline hashval_t hash (const value_type &);
-  static inline bool equal (const value_type &, const compare_type &);
-  static bool is_deleted (int &v) { return v == 1; }
-  static void mark_deleted (int &e) { e = 1; }
-  static bool is_empty (int &v) { return v == 0; }
-  static void mark_empty (int &e) { e = 0; }
-  static void remove (int &) {}
+  static inline hashval_t hash (int);
+  static inline bool equal (int, int);
 };
 
 /* Hash function for oecount.  */
 
 inline hashval_t
-oecount_hasher::hash (const value_type &p)
+oecount_hasher::hash (int p)
 {
   const oecount *c = &cvec[p - 42];
   return htab_hash_pointer (c->op) ^ (hashval_t)c->oecode;
@@ -1044,7 +1037,7 @@ oecount_hasher::hash (const value_type &
 /* Comparison function for oecount.  */
 
 inline bool
-oecount_hasher::equal (const value_type &p1, const compare_type &p2)
+oecount_hasher::equal (int p1, int p2)
 {
   const oecount *c1 = &cvec[p1 - 42];
   const oecount *c2 = &cvec[p2 - 42];
Index: gcc/value-prof.c
===================================================================
--- gcc/value-prof.c	2015-06-23 15:50:56.686110247 +0100
+++ gcc/value-prof.c	2015-06-23 15:50:56.682110292 +0100
@@ -1250,19 +1250,8 @@ gimple_mod_subtract_transform (gimple_st
   return true;
 }
 
-struct profile_id_traits : default_hashmap_traits
-{
-  template<typename T>
-  static bool
-  is_deleted (T &e)
-    {
-      return e.m_key == UINT_MAX;
-    }
-
-  template<typename T> static bool is_empty (T &e) { return e.m_key == 0; }
-  template<typename T> static void mark_deleted (T &e) { e.m_key = UINT_MAX; }
-  template<typename T> static void mark_empty (T &e) { e.m_key = 0; }
-};
+typedef int_hash <unsigned int, 0, UINT_MAX> profile_id_hash;
+typedef simple_hashmap_traits <profile_id_hash> profile_id_traits;
 
 static hash_map<unsigned int, cgraph_node *, profile_id_traits> *
 cgraph_node_map = 0;

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [09/12] Remove all but one use of default_hashmap_traits
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (7 preceding siblings ...)
  2015-06-23 14:53 ` [08/12] Add common traits for integer hash keys Richard Sandiford
@ 2015-06-23 14:55 ` Richard Sandiford
  2015-06-25 16:41   ` Jeff Law
  2015-06-23 14:56 ` [10/12] Add helper class for valued-based empty and deleted slots Richard Sandiford
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:55 UTC (permalink / raw)
  To: gcc-patches

After the previous patches in the series, there are three remaining hash
traits that use the key to represent empty and deleted entries.  This patch
makes them use simple_hashmap_traits.


gcc/
	* ipa-icf.h (symbol_compare_hash): New class.
	(symbol_compare_hashmap_traits): Use it.
	* mem-stats.h (mem_alloc_description::mem_location_hash): New class.
	(mem_alloc_description::mem_alloc_hashmap_traits): Use it.
	(mem_alloc_description::reverse_mem_map_t): Remove redundant
	default_hashmap_traits.
	* sanopt.c (sanopt_tree_triplet_hash): New class.
	(sanopt_tree_triplet_map_traits): Use it.

Index: gcc/ipa-icf.h
===================================================================
--- gcc/ipa-icf.h	2015-06-23 15:52:24.937095524 +0100
+++ gcc/ipa-icf.h	2015-06-23 15:52:24.929095617 +0100
@@ -87,10 +87,10 @@ enum sem_item_type
 
 /* Hash traits for symbol_compare_collection map.  */
 
-struct symbol_compare_hashmap_traits: default_hashmap_traits
+struct symbol_compare_hash : nofree_ptr_hash <symbol_compare_collection>
 {
   static hashval_t
-  hash (const symbol_compare_collection *v)
+  hash (value_type v)
   {
     inchash::hash hstate;
     hstate.add_int (v->m_references.length ());
@@ -107,8 +107,7 @@ struct symbol_compare_hashmap_traits: de
   }
 
   static bool
-  equal_keys (const symbol_compare_collection *a,
-	      const symbol_compare_collection *b)
+  equal (value_type a, value_type b)
   {
     if (a->m_references.length () != b->m_references.length ()
 	|| a->m_interposables.length () != b->m_interposables.length ())
@@ -126,6 +125,8 @@ struct symbol_compare_hashmap_traits: de
     return true;
   }
 };
+typedef simple_hashmap_traits <symbol_compare_hash>
+  symbol_compare_hashmap_traits;
 
 
 /* Semantic item usage pair.  */
Index: gcc/mem-stats.h
===================================================================
--- gcc/mem-stats.h	2015-06-23 15:52:24.937095524 +0100
+++ gcc/mem-stats.h	2015-06-23 15:52:24.929095617 +0100
@@ -238,10 +238,10 @@ struct mem_usage_pair
 class mem_alloc_description
 {
 public:
-  struct mem_alloc_hashmap_traits: default_hashmap_traits
+  struct mem_location_hash : nofree_ptr_hash <mem_location>
   {
     static hashval_t
-    hash (const mem_location *l)
+    hash (value_type l)
     {
 	inchash::hash hstate;
 
@@ -253,18 +253,18 @@ struct mem_usage_pair
     }
 
     static bool
-    equal_keys (const mem_location *l1, const mem_location *l2)
+    equal (value_type l1, value_type l2)
     {
       return l1->m_filename == l2->m_filename
 	&& l1->m_function == l2->m_function
 	&& l1->m_line == l2->m_line;
     }
   };
+  typedef simple_hashmap_traits<mem_location_hash> mem_alloc_hashmap_traits;
 
   /* Internal class type definitions.  */
   typedef hash_map <mem_location *, T *, mem_alloc_hashmap_traits> mem_map_t;
-  typedef hash_map <const void *, mem_usage_pair<T>, default_hashmap_traits>
-    reverse_mem_map_t;
+  typedef hash_map <const void *, mem_usage_pair<T> > reverse_mem_map_t;
   typedef hash_map <const void *, std::pair<T *, size_t> > reverse_object_map_t;
   typedef std::pair <mem_location *, T *> mem_list_t;
 
Index: gcc/sanopt.c
===================================================================
--- gcc/sanopt.c	2015-06-23 15:52:24.937095524 +0100
+++ gcc/sanopt.c	2015-06-23 15:52:24.929095617 +0100
@@ -109,8 +109,11 @@ struct sanopt_tree_triplet
 
 /* Traits class for tree triplet hash maps below.  */
 
-struct sanopt_tree_triplet_map_traits : default_hashmap_traits
+struct sanopt_tree_triplet_hash : typed_noop_remove <sanopt_tree_triplet>
 {
+  typedef sanopt_tree_triplet value_type;
+  typedef sanopt_tree_triplet compare_type;
+
   static inline hashval_t
   hash (const sanopt_tree_triplet &ref)
   {
@@ -122,41 +125,39 @@ struct sanopt_tree_triplet_map_traits :
   }
 
   static inline bool
-  equal_keys (const sanopt_tree_triplet &ref1, const sanopt_tree_triplet &ref2)
+  equal (const sanopt_tree_triplet &ref1, const sanopt_tree_triplet &ref2)
   {
     return operand_equal_p (ref1.t1, ref2.t1, 0)
 	   && operand_equal_p (ref1.t2, ref2.t2, 0)
 	   && operand_equal_p (ref1.t3, ref2.t3, 0);
   }
 
-  template<typename T>
   static inline void
-  mark_deleted (T &e)
+  mark_deleted (sanopt_tree_triplet &ref)
   {
-    e.m_key.t1 = reinterpret_cast<T *> (1);
+    ref.t1 = reinterpret_cast<tree> (1);
   }
 
-  template<typename T>
   static inline void
-  mark_empty (T &e)
+  mark_empty (sanopt_tree_triplet &ref)
   {
-    e.m_key.t1 = NULL;
+    ref.t1 = NULL;
   }
 
-  template<typename T>
   static inline bool
-  is_deleted (T &e)
+  is_deleted (const sanopt_tree_triplet &ref)
   {
-    return e.m_key.t1 == (void *) 1;
+    return ref.t1 == (void *) 1;
   }
 
-  template<typename T>
   static inline bool
-  is_empty (T &e)
+  is_empty (const sanopt_tree_triplet &ref)
   {
-    return e.m_key.t1 == NULL;
+    return ref.t1 == NULL;
   }
 };
+typedef simple_hashmap_traits <sanopt_tree_triplet_hash>
+  sanopt_tree_triplet_map_traits;
 
 /* This is used to carry various hash maps and variables used
    in sanopt_optimize_walker.  */

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [10/12] Add helper class for valued-based empty and deleted slots
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (8 preceding siblings ...)
  2015-06-23 14:55 ` [09/12] Remove all but one use of default_hashmap_traits Richard Sandiford
@ 2015-06-23 14:56 ` Richard Sandiford
  2015-06-25 16:41   ` Jeff Law
  2015-06-23 14:57 ` [11/12] Remove default_hashmap_traits Richard Sandiford
  2015-06-23 14:58 ` [12/12] Simplify uses of hash_map Richard Sandiford
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:56 UTC (permalink / raw)
  To: gcc-patches

part_traits in cfgexpand.c needs to use the value rather than the key to
represent empty and deleted slots.  What it's doing is pretty generic,
so this patch adds a helper class to hash-map-traits.h.


gcc/
	* hash-map-traits.h (unbounded_hashmap_traits): New class.
	(unbounded_int_hashmap_traits): Likewise.
	* cfgexpand.c (part_traits): Use unbounded_int_hashmap_traits.

Index: gcc/hash-map-traits.h
===================================================================
--- gcc/hash-map-traits.h	2015-06-23 15:54:04.515950631 +0100
+++ gcc/hash-map-traits.h	2015-06-23 15:54:04.511950679 +0100
@@ -174,4 +174,84 @@ simple_hashmap_traits <H>::mark_deleted
   H::mark_deleted (entry.m_key);
 }
 
+/* Implement traits for a hash_map with values of type Value for cases
+   in which the key cannot represent empty and deleted slots.  Instead
+   record empty and deleted entries in Value.  Derived classes must
+   implement the hash and equal_keys functions.  */
+
+template <typename Value>
+struct unbounded_hashmap_traits
+{
+  template <typename T> static inline void remove (T &);
+  template <typename T> static inline bool is_empty (const T &);
+  template <typename T> static inline bool is_deleted (const T &);
+  template <typename T> static inline void mark_empty (T &);
+  template <typename T> static inline void mark_deleted (T &);
+};
+
+template <typename Value>
+template <typename T>
+inline void
+unbounded_hashmap_traits <Value>::remove (T &entry)
+{
+  default_hash_traits <Value>::remove (entry.m_value);
+}
+
+template <typename Value>
+template <typename T>
+inline bool
+unbounded_hashmap_traits <Value>::is_empty (const T &entry)
+{
+  return default_hash_traits <Value>::is_empty (entry.m_value);
+}
+
+template <typename Value>
+template <typename T>
+inline bool
+unbounded_hashmap_traits <Value>::is_deleted (const T &entry)
+{
+  return default_hash_traits <Value>::is_deleted (entry.m_value);
+}
+
+template <typename Value>
+template <typename T>
+inline void
+unbounded_hashmap_traits <Value>::mark_empty (T &entry)
+{
+  default_hash_traits <Value>::mark_empty (entry.m_value);
+}
+
+template <typename Value>
+template <typename T>
+inline void
+unbounded_hashmap_traits <Value>::mark_deleted (T &entry)
+{
+  default_hash_traits <Value>::mark_deleted (entry.m_value);
+}
+
+/* Implement traits for a hash_map from integer type Key to Value in
+   cases where Key has no spare values for recording empty and deleted
+   slots.  */
+
+template <typename Key, typename Value>
+struct unbounded_int_hashmap_traits : unbounded_hashmap_traits <Value>
+{
+  static inline hashval_t hash (Key);
+  static inline bool equal_keys (Key, Key);
+};
+
+template <typename Key, typename Value>
+inline hashval_t
+unbounded_int_hashmap_traits <Key, Value>::hash (Key k)
+{
+  return k;
+}
+
+template <typename Key, typename Value>
+inline bool
+unbounded_int_hashmap_traits <Key, Value>::equal_keys (Key k1, Key k2)
+{
+  return k1 == k2;
+}
+
 #endif // HASH_MAP_TRAITS_H
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c	2015-06-23 15:54:04.515950631 +0100
+++ gcc/cfgexpand.c	2015-06-23 15:54:04.511950679 +0100
@@ -612,25 +612,7 @@ stack_var_cmp (const void *a, const void
   return 0;
 }
 
-struct part_traits : default_hashmap_traits
-{
-  template<typename T>
-    static bool
-    is_deleted (T &e)
-    { return e.m_value == reinterpret_cast<void *> (1); }
-
-  template<typename T> static bool is_empty (T &e) { return e.m_value == NULL; }
-  template<typename T>
-    static void
-    mark_deleted (T &e)
-    { e.m_value = reinterpret_cast<T> (1); }
-
-  template<typename T>
-    static void
-    mark_empty (T &e)
-      { e.m_value = NULL; }
-};
-
+struct part_traits : unbounded_int_hashmap_traits <size_t, bitmap> {};
 typedef hash_map<size_t, bitmap, part_traits> part_hashmap;
 
 /* If the points-to solution *PI points to variables that are in a partition

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [11/12] Remove default_hashmap_traits
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (9 preceding siblings ...)
  2015-06-23 14:56 ` [10/12] Add helper class for valued-based empty and deleted slots Richard Sandiford
@ 2015-06-23 14:57 ` Richard Sandiford
  2015-06-25 16:42   ` Jeff Law
  2015-06-23 14:58 ` [12/12] Simplify uses of hash_map Richard Sandiford
  11 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:57 UTC (permalink / raw)
  To: gcc-patches

The previous patches removed all uses of default_hashmap_traits,
so this patch deletes the definition.


gcc/
	* hash-map-traits.h (default_hashmap_traits): Delete.

Index: gcc/hash-map-traits.h
===================================================================
--- gcc/hash-map-traits.h	2015-06-23 15:55:43.054817986 +0100
+++ gcc/hash-map-traits.h	2015-06-23 15:55:43.050818009 +0100
@@ -25,84 +25,6 @@ #define HASH_MAP_TRAITS_H
 
 #include "hash-traits.h"
 
-/* implement default behavior for traits when types allow it.  */
-
-struct default_hashmap_traits
-{
-  /* Hashes the passed in key.  */
-
-  template<typename T>
-  static hashval_t
-  hash (T *p)
-    {
-      return uintptr_t (p) >> 3;
-    }
-
-  /* If the value converts to hashval_t just use it.  */
-
-  template<typename T> static hashval_t hash (T v) { return v; }
-
-  /* Return true if the two keys passed as arguments are equal.  */
-
-  template<typename T>
-  static bool
-  equal_keys (const T &a, const T &b)
-    {
-      return a == b;
-    }
-
-  /* Called to dispose of the key and value before marking the entry as
-     deleted.  */
-
-  template<typename T> static void remove (T &v) { v.~T (); }
-
-  /* Mark the passed in entry as being deleted.  */
-
-  template<typename T>
-  static void
-  mark_deleted (T &e)
-    {
-      mark_key_deleted (e.m_key);
-    }
-
-  /* Mark the passed in entry as being empty.  */
-
-  template<typename T>
-  static void
-  mark_empty (T &e)
-    {
-      mark_key_empty (e.m_key);
-    }
-
-  /* Return true if the passed in entry is marked as deleted.  */
-
-  template<typename T>
-  static bool
-  is_deleted (T &e)
-    {
-      return e.m_key == (void *)1;
-    }
-
-  /* Return true if the passed in entry is marked as empty.  */
-
-  template<typename T> static bool is_empty (T &e) { return e.m_key == NULL; }
-
-private:
-  template<typename T>
-  static void
-  mark_key_deleted (T *&k)
-    {
-      k = reinterpret_cast<T *> (1);
-    }
-
-  template<typename T>
-  static void
-  mark_key_empty (T *&k)
-    {
-      k = static_cast<T *> (0);
-    }
-};
-
 /* Implement hash_map traits for a key with hash traits H.  Empty and
    deleted map entries are represented as empty and deleted keys.  */
 

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [12/12] Simplify uses of hash_map
       [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
                   ` (10 preceding siblings ...)
  2015-06-23 14:57 ` [11/12] Remove default_hashmap_traits Richard Sandiford
@ 2015-06-23 14:58 ` Richard Sandiford
  2015-06-25 16:57   ` Jeff Law
  2015-06-26 14:36   ` [BUILDROBOT] could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’ (was: [12/12] Simplify uses of hash_map) Jan-Benedict Glaw
  11 siblings, 2 replies; 35+ messages in thread
From: Richard Sandiford @ 2015-06-23 14:58 UTC (permalink / raw)
  To: gcc-patches

At this point all hash_map traits know what kind of key they're
dealing with, so we can make that a traits typedef, like it is for
hash_table traits.  Then, if we make the default hash traits for
T be T, we can use hash_table-style traits as the first template
parameter to hash_map, without the need for a third.  That is, if
foo_hash hashes elements of type foo_type:

  typedef simple_hashmap_traits <foo_hash> foo_traits;
  hash_map <foo_type, value_type, foo_traits> x;

becomes just:

  hash_map <foo_hash, value_type> x;

just like a hash_table of foo_types would be:

  hash_table <foo_hash> y;

This patch makes that simplification.


gcc/
	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
	(unbounded_int_hashmap_traits::key_type): Likewise.
	* hash-map.h (hash_map): Get the key type from the traits.
	* hash-traits.h (default_hash_traits): By default, inherit from the
	template parameter.
	* alias.c (alias_set_traits): Delete.
	(alias_set_entry_d::children): Use alias_set_hash as the first
	template parameter.
	(record_alias_subset): Update accordingly.
	* except.c (tree_hash_traits): Delete.
	(type_to_runtime_map): Use tree_hash as the first template parameter.
	(init_eh): Update accordingly.
	* genmatch.c (capture_id_map_hasher): Delete.
	(cid_map_t): Use nofree_string_hash as first template parameter.
	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
	Use symbol_compare_hash as the first template parameter in
	subdivide_hash_map.
	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
	template parameter.
	* passes.c (pass_registry_hasher): Delete.
	(name_to_pass_map): Use nofree_string_hash as the first template
	parameter.
	(register_pass_name): Update accordingly.
	* sanopt.c (sanopt_tree_map_traits): Delete.
	(sanopt_tree_triplet_map_traits): Delete.
	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
	template parameter.
	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
	the first template parameter.
	* sese.c (rename_map_hasher): Delete.
	(rename_map_type): Use tree_ssa_name_hash as the first template
	parameter.
	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
	(function_summary::m_map): Use map_hash as the first template
	parameter.
	(function_summary::release): Update accordingly.
	* tree-if-conv.c (phi_args_hash_traits): Delete.
	(predicate_scalar_phi): Use tree_operand_hash as the first template
	parameter to phi_arg_map.
	* tree-inline.h (dependence_hasher): Delete.
	(copy_body_data::dependence_map): Use dependence_hash as the first
	template parameter.
	* tree-inline.c (remap_dependence_clique): Update accordingly.
	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
	parameter.
	(addr_stridxptr): Update accordingly.
	* value-prof.c (profile_id_traits): Delete.
	(cgraph_node_map): Use profile_id_hash as the first template
	parameter.
	(init_node_map): Update accordingly.
	* config/alpha/alpha.c (string_traits): Delete.
	(machine_function::links): Use nofree_string_hash as the first
	template parameter.
	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
	* config/m32c/m32c.c (pragma_traits): Delete.
	(pragma_htab): Use nofree_string_hash as the first template parameter.
	(m32c_note_pragma_address): Update accordingly.
	* config/mep/mep.c (pragma_traits): Delete.
	(pragma_htab): Use nofree_string_hash as the first template parameter.
	(mep_note_pragma_flag): Update accordingly.
	* config/mips/mips.c (mips16_flip_traits): Delete.
	(mflip_mips16_htab): Use nofree_string_hash as the first template
	parameter.
	(mflip_mips16_use_mips16_p): Update accordingly.
	(local_alias_traits): Delete.
	(mips16_local_aliases): Use nofree_string_hash as the first template
	parameter.
	(mips16_local_alias): Update accordingly.

Index: gcc/hash-map-traits.h
===================================================================
--- gcc/hash-map-traits.h	2015-06-23 15:56:38.990174759 +0100
+++ gcc/hash-map-traits.h	2015-06-23 15:56:38.986174805 +0100
@@ -31,9 +31,9 @@ #define HASH_MAP_TRAITS_H
 template <typename H>
 struct simple_hashmap_traits
 {
-  static inline hashval_t hash (const typename H::value_type &);
-  static inline bool equal_keys (const typename H::value_type &,
-				 const typename H::value_type &);
+  typedef typename H::value_type key_type;
+  static inline hashval_t hash (const key_type &);
+  static inline bool equal_keys (const key_type &, const key_type &);
   template <typename T> static inline void remove (T &);
   template <typename T> static inline bool is_empty (const T &);
   template <typename T> static inline bool is_deleted (const T &);
@@ -43,15 +43,14 @@ struct simple_hashmap_traits
 
 template <typename H>
 inline hashval_t
-simple_hashmap_traits <H>::hash (const typename H::value_type &h)
+simple_hashmap_traits <H>::hash (const key_type &h)
 {
   return H::hash (h);
 }
 
 template <typename H>
 inline bool
-simple_hashmap_traits <H>::equal_keys (const typename H::value_type &k1,
-				       const typename H::value_type &k2)
+simple_hashmap_traits <H>::equal_keys (const key_type &k1, const key_type &k2)
 {
   return H::equal (k1, k2);
 }
@@ -158,6 +157,7 @@ unbounded_hashmap_traits <Value>::mark_d
 template <typename Key, typename Value>
 struct unbounded_int_hashmap_traits : unbounded_hashmap_traits <Value>
 {
+  typedef Key key_type;
   static inline hashval_t hash (Key);
   static inline bool equal_keys (Key, Key);
 };
Index: gcc/hash-map.h
===================================================================
--- gcc/hash-map.h	2015-06-23 15:56:38.990174759 +0100
+++ gcc/hash-map.h	2015-06-23 15:56:38.986174805 +0100
@@ -21,10 +21,11 @@ Software Foundation; either version 3, o
 #ifndef hash_map_h
 #define hash_map_h
 
-template<typename Key, typename Value,
+template<typename KeyId, typename Value,
 	 typename Traits>
 class GTY((user)) hash_map
 {
+  typedef typename Traits::key_type Key;
   struct hash_entry
   {
     Key m_key;
Index: gcc/hash-traits.h
===================================================================
--- gcc/hash-traits.h	2015-06-23 15:56:38.990174759 +0100
+++ gcc/hash-traits.h	2015-06-23 15:56:38.986174805 +0100
@@ -278,7 +278,7 @@ struct ggc_cache_ptr_hash : pointer_hash
 
 struct nofree_string_hash : string_hash, typed_noop_remove <const char *> {};
 
-template <typename T> struct default_hash_traits;
+template <typename T> struct default_hash_traits : T {};
 
 template <typename T>
 struct default_hash_traits <T *> : ggc_ptr_hash <T> {};
Index: gcc/alias.c
===================================================================
--- gcc/alias.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/alias.c	2015-06-23 15:56:38.974174944 +0100
@@ -144,7 +144,6 @@ Software Foundation; either version 3, o
    error to attempt to explicitly construct a subset of zero.  */
 
 struct alias_set_hash : int_hash <int, INT_MIN, INT_MIN + 1> {};
-struct alias_set_traits : simple_hashmap_traits <alias_set_hash> {};
 
 struct GTY(()) alias_set_entry_d {
   /* The alias set number, as stored in MEM_ALIAS_SET.  */
@@ -157,7 +156,7 @@ struct GTY(()) alias_set_entry_d {
 
      continuing our example above, the children here will be all of
      `int', `double', `float', and `struct S'.  */
-  hash_map<int, int, alias_set_traits> *children;
+  hash_map<alias_set_hash, int> *children;
 
   /* Nonzero if would have a child of zero: this effectively makes this
      alias set the same as alias set zero.  */
@@ -1136,7 +1135,7 @@ record_alias_subset (alias_set_type supe
       subset_entry = get_alias_set_entry (subset);
       if (!superset_entry->children)
 	superset_entry->children
-	  = hash_map<int, int, alias_set_traits>::create_ggc (64);
+	  = hash_map<alias_set_hash, int>::create_ggc (64);
       /* If there is an entry for the subset, enter all of its children
 	 (if they are not already present) as children of the SUPERSET.  */
       if (subset_entry)
@@ -1148,7 +1147,7 @@ record_alias_subset (alias_set_type supe
 
 	  if (subset_entry->children)
 	    {
-	      hash_map<int, int, alias_set_traits>::iterator iter
+	      hash_map<alias_set_hash, int>::iterator iter
 		= subset_entry->children->begin ();
 	      for (; iter != subset_entry->children->end (); ++iter)
 		superset_entry->children->put ((*iter).first, (*iter).second);
Index: gcc/except.c
===================================================================
--- gcc/except.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/except.c	2015-06-23 15:56:38.978174900 +0100
@@ -165,8 +165,7 @@ Software Foundation; either version 3, o
 
 static GTY(()) int call_site_base;
 
-struct tree_hash_traits : simple_hashmap_traits <tree_hash> {};
-static GTY (()) hash_map<tree, tree, tree_hash_traits> *type_to_runtime_map;
+static GTY (()) hash_map<tree_hash, tree> *type_to_runtime_map;
 
 /* Describe the SjLj_Function_Context structure.  */
 static GTY(()) tree sjlj_fc_type_node;
@@ -249,8 +248,7 @@ init_eh (void)
   if (! flag_exceptions)
     return;
 
-  type_to_runtime_map
-    = hash_map<tree, tree, tree_hash_traits>::create_ggc (31);
+  type_to_runtime_map = hash_map<tree_hash, tree>::create_ggc (31);
 
   /* Create the SjLj_Function_Context structure.  This should match
      the definition in unwind-sjlj.c.  */
Index: gcc/genmatch.c
===================================================================
--- gcc/genmatch.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/genmatch.c	2015-06-23 15:56:38.974174944 +0100
@@ -392,9 +392,7 @@ get_operator (const char *id)
   return 0;
 }
 
-typedef simple_hashmap_traits<nofree_string_hash> capture_id_map_hasher;
-
-typedef hash_map<const char *, unsigned, capture_id_map_hasher> cid_map_t;
+typedef hash_map<nofree_string_hash, unsigned> cid_map_t;
 
 
 /* The AST produced by parsing of the pattern definitions.  */
Index: gcc/ipa-icf.h
===================================================================
--- gcc/ipa-icf.h	2015-06-23 15:56:38.990174759 +0100
+++ gcc/ipa-icf.h	2015-06-23 15:56:38.970174986 +0100
@@ -125,8 +125,6 @@ struct symbol_compare_hash : nofree_ptr_
     return true;
   }
 };
-typedef simple_hashmap_traits <symbol_compare_hash>
-  symbol_compare_hashmap_traits;
 
 
 /* Semantic item usage pair.  */
Index: gcc/ipa-icf.c
===================================================================
--- gcc/ipa-icf.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/ipa-icf.c	2015-06-23 15:56:38.970174986 +0100
@@ -2911,8 +2911,7 @@ sem_item_optimizer::subdivide_classes_by
 unsigned
 sem_item_optimizer::subdivide_classes_by_sensitive_refs ()
 {
-  typedef hash_map <symbol_compare_collection *, vec <sem_item *>,
-    symbol_compare_hashmap_traits> subdivide_hash_map;
+  typedef hash_map <symbol_compare_hash, vec <sem_item *> > subdivide_hash_map;
 
   unsigned newly_created_classes = 0;
 
Index: gcc/mem-stats.h
===================================================================
--- gcc/mem-stats.h	2015-06-23 15:56:38.990174759 +0100
+++ gcc/mem-stats.h	2015-06-23 15:56:38.974174944 +0100
@@ -260,10 +260,9 @@ struct mem_usage_pair
 	&& l1->m_line == l2->m_line;
     }
   };
-  typedef simple_hashmap_traits<mem_location_hash> mem_alloc_hashmap_traits;
 
   /* Internal class type definitions.  */
-  typedef hash_map <mem_location *, T *, mem_alloc_hashmap_traits> mem_map_t;
+  typedef hash_map <mem_location_hash, T *> mem_map_t;
   typedef hash_map <const void *, mem_usage_pair<T> > reverse_mem_map_t;
   typedef hash_map <const void *, std::pair<T *, size_t> > reverse_object_map_t;
   typedef std::pair <mem_location *, T *> mem_list_t;
Index: gcc/passes.c
===================================================================
--- gcc/passes.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/passes.c	2015-06-23 15:56:38.978174900 +0100
@@ -861,10 +861,7 @@ pass_manager::register_dump_files (opt_p
   while (pass);
 }
 
-typedef simple_hashmap_traits<nofree_string_hash> pass_registry_hasher;
-
-static hash_map<const char *, opt_pass *, pass_registry_hasher>
-  *name_to_pass_map;
+static hash_map<nofree_string_hash, opt_pass *> *name_to_pass_map;
 
 /* Register PASS with NAME.  */
 
@@ -872,8 +869,7 @@ typedef simple_hashmap_traits<nofree_str
 register_pass_name (opt_pass *pass, const char *name)
 {
   if (!name_to_pass_map)
-    name_to_pass_map
-      = new hash_map<const char *, opt_pass *, pass_registry_hasher> (256);
+    name_to_pass_map = new hash_map<nofree_string_hash, opt_pass *> (256);
 
   if (name_to_pass_map->get (name))
     return; /* Ignore plugin passes.  */
Index: gcc/sanopt.c
===================================================================
--- gcc/sanopt.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/sanopt.c	2015-06-23 15:56:38.974174944 +0100
@@ -99,8 +99,6 @@ maybe_get_single_definition (tree t)
   return NULL_TREE;
 }
 
-typedef simple_hashmap_traits <tree_operand_hash> sanopt_tree_map_traits;
-
 /* Tree triplet for vptr_check_map.  */
 struct sanopt_tree_triplet
 {
@@ -156,8 +154,6 @@ struct sanopt_tree_triplet_hash : typed_
     return ref.t1 == NULL;
   }
 };
-typedef simple_hashmap_traits <sanopt_tree_triplet_hash>
-  sanopt_tree_triplet_map_traits;
 
 /* This is used to carry various hash maps and variables used
    in sanopt_optimize_walker.  */
@@ -170,13 +166,12 @@ struct sanopt_ctx
 
   /* This map maps a pointer (the second argument of ASAN_CHECK) to
      a vector of ASAN_CHECK call statements that check the access.  */
-  hash_map<tree, auto_vec<gimple>, sanopt_tree_map_traits> asan_check_map;
+  hash_map<tree_operand_hash, auto_vec<gimple> > asan_check_map;
 
   /* This map maps a tree triplet (the first, second and fourth argument
      of UBSAN_VPTR) to a vector of UBSAN_VPTR call statements that check
      that virtual table pointer.  */
-  hash_map<sanopt_tree_triplet, auto_vec<gimple>,
-	   sanopt_tree_triplet_map_traits> vptr_check_map;
+  hash_map<sanopt_tree_triplet_hash, auto_vec<gimple> > vptr_check_map;
 
   /* Number of IFN_ASAN_CHECK statements.  */
   int asan_num_accesses;
Index: gcc/sese.c
===================================================================
--- gcc/sese.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/sese.c	2015-06-23 15:56:38.990174759 +0100
@@ -79,8 +79,7 @@ debug_rename_map_1 (tree_node *const &ol
   return true;
 }
 \f
-typedef simple_hashmap_traits<tree_ssa_name_hash> rename_map_hasher;
-typedef hash_map<tree, tree, rename_map_hasher> rename_map_type;
+typedef hash_map<tree_ssa_name_hash, tree> rename_map_type;
 \f
 
 /* Print to stderr all the elements of RENAME_MAP.  */
Index: gcc/symbol-summary.h
===================================================================
--- gcc/symbol-summary.h	2015-06-23 15:56:38.990174759 +0100
+++ gcc/symbol-summary.h	2015-06-23 15:56:38.970174986 +0100
@@ -83,7 +83,7 @@ class GTY((user)) function_summary <T *>
     m_symtab_duplication_hook = NULL;
 
     /* Release all summaries.  */
-    typedef typename hash_map <int, T *, summary_hashmap_traits>::iterator map_iterator;
+    typedef typename hash_map <map_hash, T *>::iterator map_iterator;
     for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
       release ((*it).second);
   }
@@ -201,7 +201,6 @@ class GTY((user)) function_summary <T *>
 
 private:
   typedef int_hash <int, 0, -1> map_hash;
-  typedef simple_hashmap_traits <map_hash> summary_hashmap_traits;
 
   /* Getter for summary callgraph ID.  */
   T* get (int uid)
@@ -215,7 +214,7 @@ class GTY((user)) function_summary <T *>
   }
 
   /* Main summary store, where summary ID is used as key.  */
-  hash_map <int, T *, summary_hashmap_traits> m_map;
+  hash_map <map_hash, T *> m_map;
   /* Internal summary insertion hook pointer.  */
   cgraph_node_hook_list *m_symtab_insertion_hook;
   /* Internal summary removal hook pointer.  */
Index: gcc/tree-if-conv.c
===================================================================
--- gcc/tree-if-conv.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/tree-if-conv.c	2015-06-23 15:56:38.970174986 +0100
@@ -1595,8 +1595,6 @@ convert_scalar_cond_reduction (gimple re
   return rhs;
 }
 
-typedef simple_hashmap_traits <tree_operand_hash> phi_args_hash_traits;
-
 /* Produce condition for all occurrences of ARG in PHI node.  */
 
 static tree
@@ -1747,7 +1745,7 @@ predicate_scalar_phi (gphi *phi, gimple_
   /* Create hashmap for PHI node which contain vector of argument indexes
      having the same value.  */
   bool swap = false;
-  hash_map<tree, auto_vec<int>, phi_args_hash_traits> phi_arg_map;
+  hash_map<tree_operand_hash, auto_vec<int> > phi_arg_map;
   unsigned int num_args = gimple_phi_num_args (phi);
   int max_ind = -1;
   /* Vector of different PHI argument values.  */
Index: gcc/tree-inline.h
===================================================================
--- gcc/tree-inline.h	2015-06-23 15:56:38.990174759 +0100
+++ gcc/tree-inline.h	2015-06-23 15:56:38.978174900 +0100
@@ -36,7 +36,6 @@ enum copy_body_cge_which
 };
 
 typedef int_hash <unsigned short, 0> dependence_hash;
-typedef simple_hashmap_traits <dependence_hash> dependence_hasher;
 
 /* Data required for function body duplication.  */
 
@@ -148,7 +147,7 @@ struct copy_body_data
 
   /* A map from the inlined functions dependence info cliques to
      equivalents in the function into which it is being inlined.  */
-  hash_map<unsigned short, unsigned short, dependence_hasher> *dependence_map;
+  hash_map<dependence_hash, unsigned short> *dependence_map;
 };
 
 /* Weights of constructions for estimate_num_insns.  */
Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/tree-inline.c	2015-06-23 15:56:38.978174900 +0100
@@ -864,8 +864,7 @@ remap_dependence_clique (copy_body_data
   if (clique == 0)
     return 0;
   if (!id->dependence_map)
-    id->dependence_map
-      = new hash_map<unsigned short, unsigned short, dependence_hasher>;
+    id->dependence_map = new hash_map<dependence_hash, unsigned short>;
   bool existed;
   unsigned short &newc = id->dependence_map->get_or_insert (clique, &existed);
   if (!existed)
Index: gcc/tree-ssa-strlen.c
===================================================================
--- gcc/tree-ssa-strlen.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/tree-ssa-strlen.c	2015-06-23 15:56:38.974174944 +0100
@@ -156,12 +156,9 @@ struct decl_stridxlist_map
   struct stridxlist list;
 };
 
-typedef simple_hashmap_traits <tree_decl_hash> stridxlist_hash_traits;
-
 /* Hash table for mapping decls to a chained list of offset -> idx
    mappings.  */
-static hash_map<tree, stridxlist, stridxlist_hash_traits>
-  *decl_to_stridxlist_htab;
+static hash_map<tree_decl_hash, stridxlist> *decl_to_stridxlist_htab;
 
 /* Obstack for struct stridxlist and struct decl_stridxlist_map.  */
 static struct obstack stridx_obstack;
@@ -327,7 +324,7 @@ addr_stridxptr (tree exp)
   if (!decl_to_stridxlist_htab)
     {
       decl_to_stridxlist_htab
-       	= new hash_map<tree, stridxlist, stridxlist_hash_traits> (64);
+       	= new hash_map<tree_decl_hash, stridxlist> (64);
       gcc_obstack_init (&stridx_obstack);
     }
 
Index: gcc/value-prof.c
===================================================================
--- gcc/value-prof.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/value-prof.c	2015-06-23 15:56:38.986174805 +0100
@@ -1251,10 +1251,8 @@ gimple_mod_subtract_transform (gimple_st
 }
 
 typedef int_hash <unsigned int, 0, UINT_MAX> profile_id_hash;
-typedef simple_hashmap_traits <profile_id_hash> profile_id_traits;
 
-static hash_map<unsigned int, cgraph_node *, profile_id_traits> *
-cgraph_node_map = 0;
+static hash_map<profile_id_hash, cgraph_node *> *cgraph_node_map = 0;
 
 /* Returns true if node graph is initialized. This
    is used to test if profile_id has been created
@@ -1274,8 +1272,7 @@ coverage_node_map_initialized_p (void)
 init_node_map (bool local)
 {
   struct cgraph_node *n;
-  cgraph_node_map
-    = new hash_map<unsigned int, cgraph_node *, profile_id_traits>;
+  cgraph_node_map = new hash_map<profile_id_hash, cgraph_node *>;
 
   FOR_EACH_DEFINED_FUNCTION (n)
     if (n->has_gimple_body_p ())
Index: gcc/config/alpha/alpha.c
===================================================================
--- gcc/config/alpha/alpha.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/config/alpha/alpha.c	2015-06-23 15:56:38.982174853 +0100
@@ -4808,8 +4808,6 @@ alpha_multipass_dfa_lookahead (void)
 
 struct GTY(()) alpha_links;
 
-typedef simple_hashmap_traits <nofree_string_hash> string_traits;
-
 struct GTY(()) machine_function
 {
   /* For flag_reorder_blocks_and_partition.  */
@@ -4819,7 +4817,7 @@ struct GTY(()) machine_function
   bool uses_condition_handler;
 
   /* Linkage entries.  */
-  hash_map<const char *, alpha_links *, string_traits> *links;
+  hash_map<nofree_string_hash, alpha_links *> *links;
 };
 
 /* How to allocate a 'struct machine_function'.  */
@@ -9546,7 +9544,7 @@ alpha_use_linkage (rtx func, bool lflag,
     }
   else
     cfun->machine->links
-      = hash_map<const char *, alpha_links *, string_traits>::create_ggc (64);
+      = hash_map<nofree_string_hash, alpha_links *>::create_ggc (64);
 
   if (al == NULL)
     {
@@ -9637,7 +9635,7 @@ alpha_write_linkage (FILE *stream, const
 
   if (cfun->machine->links)
     {
-      hash_map<const char *, alpha_links *, string_traits>::iterator iter
+      hash_map<nofree_string_hash, alpha_links *>::iterator iter
 	= cfun->machine->links->begin ();
       for (; iter != cfun->machine->links->end (); ++iter)
 	alpha_write_one_linkage ((*iter).first, (*iter).second, stream);
Index: gcc/config/m32c/m32c.c
===================================================================
--- gcc/config/m32c/m32c.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/config/m32c/m32c.c	2015-06-23 15:56:38.982174853 +0100
@@ -3055,17 +3055,14 @@ m32c_insert_attributes (tree node ATTRIB
     }	
 }
 
-typedef simple_hashmap_traits<nofree_string_hash> pragma_traits;
-
 /* Hash table of pragma info.  */
-static GTY(()) hash_map<const char *, unsigned, pragma_traits> *pragma_htab;
+static GTY(()) hash_map<nofree_string_hash, unsigned> *pragma_htab;
 
 void
 m32c_note_pragma_address (const char *varname, unsigned address)
 {
   if (!pragma_htab)
-    pragma_htab
-      = hash_map<const char *, unsigned, pragma_traits>::create_ggc (31);
+    pragma_htab = hash_map<nofree_string_hash, unsigned>::create_ggc (31);
 
   const char *name = ggc_strdup (varname);
   unsigned int *slot = &pragma_htab->get_or_insert (name);
Index: gcc/config/mep/mep.c
===================================================================
--- gcc/config/mep/mep.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/config/mep/mep.c	2015-06-23 15:56:38.986174805 +0100
@@ -4073,18 +4073,14 @@ struct GTY(()) pragma_entry {
   int flag;
 };
 
-typedef simple_hashmap_traits<nofree_string_hash> pragma_traits;
-
 /* Hash table of farcall-tagged sections.  */
-static GTY(()) hash_map<const char *, pragma_entry, pragma_traits> *
-  pragma_htab;
+static GTY(()) hash_map<nofree_string_hash, pragma_entry> *pragma_htab;
 
 static void
 mep_note_pragma_flag (const char *funcname, int flag)
 {
   if (!pragma_htab)
-    pragma_htab
-      = hash_map<const char *, pragma_entry, pragma_traits>::create_ggc (31);
+    pragma_htab = hash_map<nofree_string_hash, pragma_entry>::create_ggc (31);
 
   bool existed;
   const char *name = ggc_strdup (funcname);
Index: gcc/config/mips/mips.c
===================================================================
--- gcc/config/mips/mips.c	2015-06-23 15:56:38.990174759 +0100
+++ gcc/config/mips/mips.c	2015-06-23 15:56:38.986174805 +0100
@@ -1265,12 +1265,9 @@ static int mips_register_move_cost (mach
 static unsigned int mips_function_arg_boundary (machine_mode, const_tree);
 static machine_mode mips_get_reg_raw_mode (int regno);
 \f
-struct mips16_flip_traits : simple_hashmap_traits <nofree_string_hash> {};
-
 /* This hash table keeps track of implicit "mips16" and "nomips16" attributes
    for -mflip_mips16.  It maps decl names onto a boolean mode setting.  */
-static GTY (()) hash_map<const char *, bool, mips16_flip_traits> *
-  mflip_mips16_htab;
+static GTY (()) hash_map<nofree_string_hash, bool> *mflip_mips16_htab;
 
 /* True if -mflip-mips16 should next add an attribute for the default MIPS16
    mode, false if it should next add an attribute for the opposite mode.  */
@@ -1291,8 +1288,7 @@ mflip_mips16_use_mips16_p (tree decl)
     return !base_is_mips16;
 
   if (!mflip_mips16_htab)
-    mflip_mips16_htab
-      = hash_map<const char *, bool, mips16_flip_traits>::create_ggc (37);
+    mflip_mips16_htab = hash_map<nofree_string_hash, bool>::create_ggc (37);
 
   name = IDENTIFIER_POINTER (DECL_NAME (decl));
 
@@ -6593,13 +6589,10 @@ mips_load_call_address (enum mips_call_t
     }
 }
 \f
-struct local_alias_traits : simple_hashmap_traits <nofree_string_hash> {};
-
 /* Each locally-defined hard-float MIPS16 function has a local symbol
    associated with it.  This hash table maps the function symbol (FUNC)
    to the local symbol (LOCAL). */
-static GTY (()) hash_map<const char *, rtx, local_alias_traits>
-  *mips16_local_aliases;
+static GTY (()) hash_map<nofree_string_hash, rtx> *mips16_local_aliases;
 
 /* FUNC is the symbol for a locally-defined hard-float MIPS16 function.
    Return a local alias for it, creating a new one if necessary.  */
@@ -6609,8 +6602,7 @@ mips16_local_alias (rtx func)
 {
   /* Create the hash table if this is the first call.  */
   if (mips16_local_aliases == NULL)
-    mips16_local_aliases
-      = hash_map<const char *, rtx, local_alias_traits>::create_ggc (37);
+    mips16_local_aliases = hash_map<nofree_string_hash, rtx>::create_ggc (37);
 
   /* Look up the function symbol, creating a new entry if need be.  */
   bool existed;

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [06/12] Consolidate string hashers
  2015-06-23 14:50 ` [06/12] Consolidate string hashers Richard Sandiford
@ 2015-06-24 10:13   ` Mikhail Maltsev
  2015-06-24 11:39     ` Richard Sandiford
  2015-06-25 16:37   ` Jeff Law
  1 sibling, 1 reply; 35+ messages in thread
From: Mikhail Maltsev @ 2015-06-24 10:13 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 23.06.2015 17:49, Richard Sandiford wrote:
> This patch replaces various string hashers with a single copy
> in hash-traits.h.

(snip)

> Index: gcc/config/alpha/alpha.c
> ===================================================================
> --- gcc/config/alpha/alpha.c	2015-06-23 15:48:30.751788389 +0100
> +++ gcc/config/alpha/alpha.c	2015-06-23 15:48:30.747788453 +0100
> @@ -4808,13 +4808,7 @@ alpha_multipass_dfa_lookahead (void)
>  
>  struct GTY(()) alpha_links;
>  
> -struct string_traits : default_hashmap_traits
> -{
> -  static bool equal_keys (const char *const &a, const char *const &b)
> -  {
> -    return strcmp (a, b) == 0;
> -  }
> -};
> +typedef simple_hashmap_traits <nofree_string_hash> string_traits;
>  

I remember that when we briefly discussed unification of string traits,
a looked through GCC code and this one seemed weird to me: it does not
reimplement the hash function. I.e. the pointer value is used as hash. I
wonder, is it intentional or not? This could actually work if strings
are interned (but in that case there is no need to compare them, because
comparing pointers would be enough).

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [06/12] Consolidate string hashers
  2015-06-24 10:13   ` Mikhail Maltsev
@ 2015-06-24 11:39     ` Richard Sandiford
  0 siblings, 0 replies; 35+ messages in thread
From: Richard Sandiford @ 2015-06-24 11:39 UTC (permalink / raw)
  To: Mikhail Maltsev; +Cc: gcc-patches

Mikhail Maltsev <maltsevm@gmail.com> writes:
> On 23.06.2015 17:49, Richard Sandiford wrote:
>> Index: gcc/config/alpha/alpha.c
>> ===================================================================
>> --- gcc/config/alpha/alpha.c	2015-06-23 15:48:30.751788389 +0100
>> +++ gcc/config/alpha/alpha.c	2015-06-23 15:48:30.747788453 +0100
>> @@ -4808,13 +4808,7 @@ alpha_multipass_dfa_lookahead (void)
>>  
>>  struct GTY(()) alpha_links;
>>  
>> -struct string_traits : default_hashmap_traits
>> -{
>> -  static bool equal_keys (const char *const &a, const char *const &b)
>> -  {
>> -    return strcmp (a, b) == 0;
>> -  }
>> -};
>> +typedef simple_hashmap_traits <nofree_string_hash> string_traits;
>>  
>
> I remember that when we briefly discussed unification of string traits,
> a looked through GCC code and this one seemed weird to me: it does not
> reimplement the hash function. I.e. the pointer value is used as hash. I
> wonder, is it intentional or not? This could actually work if strings
> are interned (but in that case there is no need to compare them, because
> comparing pointers would be enough).

I think it was accidental.  The code originally used splay trees and
so didn't need to provide a hash.

SYMBOL_REF names are unique, like you say, so pointer equality should be
enough.  Even then though, htab_hash_string ought to give a better hash
than the pointer value (as well as giving a stable order, although that
isn't important here).  So IMO the patch as it stands is still an
improvement: we're keeping the existing comparison function but adding
a better hasher.

If the series goes anywhere I might look at adding a dedicated "interned
string hasher" that sits inbetween pointer_hash and string_hash.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [01/12] Add hash_map traits that use existing hash_table-like traits
  2015-06-23 14:44 ` [01/12] Add hash_map traits that use existing hash_table-like traits Richard Sandiford
@ 2015-06-25 16:34   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:34 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:42 AM, Richard Sandiford wrote:
> This patch defines a class that converts hash_table-style traits into
> hash_map traits.  It can be used as the default traits for all hash_maps
> that don't specify their own traits (i.e. this patch does work on its own).
>
> By the end of the series this class replaces default_hashmap_traits.
>
>
> gcc/
> 	* hash-map-traits.h: Include hash-traits.h.
> 	(simple_hashmap_traits): New class.
> 	* mem-stats.h (hash_map): Change the default traits to
> 	simple_hashmap_traits<default_hash_traits<Key> >.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [03/12] Move decl hasher to header file
  2015-06-23 14:47 ` [03/12] Move decl hasher to " Richard Sandiford
@ 2015-06-25 16:34   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:34 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:45 AM, Richard Sandiford wrote:
> Like the previous patch, but for decl hashers.  There's only one copy
> of this so far, but the idea seems general.
>
>
> gcc/
> 	* tree-hash-traits.h (tree_decl_hash): New class.
> 	* tree-ssa-strlen.c: Include tree-hash-traits.h.
> 	(stridxlist_hash_traits): Use tree_decl_hash.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [02/12] Move tree operand hashers to a new header file
  2015-06-23 14:45 ` [02/12] Move tree operand hashers to a new header file Richard Sandiford
@ 2015-06-25 16:34   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:34 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:44 AM, Richard Sandiford wrote:
> There were three tree operand hashers, so move them to their own
> header file.
>
> The typedefs in this and subsequent patches are temporary and
> get removed in patch 12.
>
>
> gcc/
> 	* tree-hash-traits.h: New file.
> 	(tree_operand_hash): New class.
> 	* sanopt.c: Include tree-hash-traits.h.
> 	(sanopt_tree_map_traits): Use tree_operand_hash.
> 	* tree-if-conv.c: Include tree-hash-traits.h.
> 	(phi_args_hash_traits): Use tree_operand_hash.
> 	* tree-ssa-uncprop.c: Include tree-hash-traits.h.
> 	(val_ssa_equiv_hash_traits): Use tree_operand_hash.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [04/12] Move ssa_name hasher to header file
  2015-06-23 14:48 ` [04/12] Move ssa_name " Richard Sandiford
@ 2015-06-25 16:35   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:35 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:46 AM, Richard Sandiford wrote:
> Another tree hasher, this time for SSA names.  Again there's only one copy
> at the moment, but the idea seems general.
>
>
> gcc/
> 	* tree-hash-traits.h (tree_ssa_name_hasher): New class.
> 	* sese.c: Include tree-hash-traits.h.
> 	(rename_map_hasher): Use tree_ssa_name_hasher.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [05/12] Move TREE_HASH hasher to header file
  2015-06-23 14:49 ` [05/12] Move TREE_HASH " Richard Sandiford
@ 2015-06-25 16:36   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:36 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:47 AM, Richard Sandiford wrote:
> One more tree hasher, this time based on TREE_HASH.
>
>
> gcc/
> 	* tree-hash-traits.h (tree_hash): New class.
> 	* except.c: Include tree-hash-traits.h.
> 	(tree_hash_traits): Use tree_hash.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [06/12] Consolidate string hashers
  2015-06-23 14:50 ` [06/12] Consolidate string hashers Richard Sandiford
  2015-06-24 10:13   ` Mikhail Maltsev
@ 2015-06-25 16:37   ` Jeff Law
  1 sibling, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:37 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:49 AM, Richard Sandiford wrote:
> This patch replaces various string hashers with a single copy
> in hash-traits.h.
>
>
> gcc/
> 	* hash-traits.h (string_hash, nofree_string_hash): New classes.
> 	* genmatch.c (capture_id_map_hasher): Use nofree_string_hash.
> 	* passes.c (pass_registry_hasher): Likewise.
> 	* config/alpha/alpha.c (string_traits): Likewise.
> 	* config/i386/winnt.c (i386_find_on_wrapper_list): Likewise.
> 	* config/m32c/m32c.c (pragma_traits): Likewise.
> 	* config/mep/mep.c (pragma_traits): Likewise.
>
> gcc/java/
> 	* jcf-io.c (memoized_class_lookups): Use nofree_string_hash.
> 	(find_class): Likewise.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [07/12] Use new string hasher for MIPS
  2015-06-23 14:52 ` [07/12] Use new string hasher for MIPS Richard Sandiford
@ 2015-06-25 16:39   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:39 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:50 AM, Richard Sandiford wrote:
> Use the string hasher from patch 6 for MIPS.  I split this out because
> local_alias_traits doesn't actually need to use SYMBOL_REF rtxes as
> the map keys, since the only data used is the symbol name.
>
>
> gcc/
> 	* config/mips/mips.c (mips16_flip_traits): Use it.
> 	(local_alias_traits, mips16_local_aliases): Convert from a map of
> 	rtxes to a map of symbol names.
> 	(mips16_local_alias): Update accordingly.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [08/12] Add common traits for integer hash keys
  2015-06-23 14:53 ` [08/12] Add common traits for integer hash keys Richard Sandiford
@ 2015-06-25 16:40   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:40 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:51 AM, Richard Sandiford wrote:
> Several places define hash traits for integers, using particular integer
> values as "empty" and "deleted" markers.  This patch defines them in terms
> of a single int_hash class.
>
> I also needed to extend gengtype to accept "+" in template arguments.
>
>
> gcc/
> 	* gengtype-parse.c (require_template_declaration): Allow '+' in
> 	template parameters.  Consolidate cases.
> 	* hash-traits.h (int_hash): New class.
> 	* alias.c (alias_set_hash): New structure.
> 	(alias_set_traits): Use it.
> 	* symbol-summary.h (function_summary::map_hash): New class.
> 	(function_summary::summary_hashmap_traits): Use it.
> 	* tree-inline.h (dependence_hash): New class.
> 	(dependence_hasher): Use it.
> 	* tree-ssa-reassoc.c (oecount_hasher): Use int_hash.
> 	* value-prof.c (profile_id_hash): New class.
> 	(profile_id_traits): Use it.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [10/12] Add helper class for valued-based empty and deleted slots
  2015-06-23 14:56 ` [10/12] Add helper class for valued-based empty and deleted slots Richard Sandiford
@ 2015-06-25 16:41   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:41 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:55 AM, Richard Sandiford wrote:
> part_traits in cfgexpand.c needs to use the value rather than the key to
> represent empty and deleted slots.  What it's doing is pretty generic,
> so this patch adds a helper class to hash-map-traits.h.
>
>
> gcc/
> 	* hash-map-traits.h (unbounded_hashmap_traits): New class.
> 	(unbounded_int_hashmap_traits): Likewise.
> 	* cfgexpand.c (part_traits): Use unbounded_int_hashmap_traits.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [09/12] Remove all but one use of default_hashmap_traits
  2015-06-23 14:55 ` [09/12] Remove all but one use of default_hashmap_traits Richard Sandiford
@ 2015-06-25 16:41   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:41 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:53 AM, Richard Sandiford wrote:
> After the previous patches in the series, there are three remaining hash
> traits that use the key to represent empty and deleted entries.  This patch
> makes them use simple_hashmap_traits.
>
>
> gcc/
> 	* ipa-icf.h (symbol_compare_hash): New class.
> 	(symbol_compare_hashmap_traits): Use it.
> 	* mem-stats.h (mem_alloc_description::mem_location_hash): New class.
> 	(mem_alloc_description::mem_alloc_hashmap_traits): Use it.
> 	(mem_alloc_description::reverse_mem_map_t): Remove redundant
> 	default_hashmap_traits.
> 	* sanopt.c (sanopt_tree_triplet_hash): New class.
> 	(sanopt_tree_triplet_map_traits): Use it.
OK.
jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [11/12] Remove default_hashmap_traits
  2015-06-23 14:57 ` [11/12] Remove default_hashmap_traits Richard Sandiford
@ 2015-06-25 16:42   ` Jeff Law
  0 siblings, 0 replies; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:42 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:56 AM, Richard Sandiford wrote:
> The previous patches removed all uses of default_hashmap_traits,
> so this patch deletes the definition.
>
>
> gcc/
> 	* hash-map-traits.h (default_hashmap_traits): Delete.
Ok :-)

jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-23 14:58 ` [12/12] Simplify uses of hash_map Richard Sandiford
@ 2015-06-25 16:57   ` Jeff Law
  2015-06-26 13:50     ` Rainer Orth
  2015-06-26 14:36   ` [BUILDROBOT] could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’ (was: [12/12] Simplify uses of hash_map) Jan-Benedict Glaw
  1 sibling, 1 reply; 35+ messages in thread
From: Jeff Law @ 2015-06-25 16:57 UTC (permalink / raw)
  To: gcc-patches, richard.sandiford

On 06/23/2015 08:57 AM, Richard Sandiford wrote:
> At this point all hash_map traits know what kind of key they're
> dealing with, so we can make that a traits typedef, like it is for
> hash_table traits.  Then, if we make the default hash traits for
> T be T, we can use hash_table-style traits as the first template
> parameter to hash_map, without the need for a third.  That is, if
> foo_hash hashes elements of type foo_type:
>
>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>    hash_map <foo_type, value_type, foo_traits> x;
>
> becomes just:
>
>    hash_map <foo_hash, value_type> x;
>
> just like a hash_table of foo_types would be:
>
>    hash_table <foo_hash> y;
>
> This patch makes that simplification.
>
>
> gcc/
> 	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
> 	(unbounded_int_hashmap_traits::key_type): Likewise.
> 	* hash-map.h (hash_map): Get the key type from the traits.
> 	* hash-traits.h (default_hash_traits): By default, inherit from the
> 	template parameter.
> 	* alias.c (alias_set_traits): Delete.
> 	(alias_set_entry_d::children): Use alias_set_hash as the first
> 	template parameter.
> 	(record_alias_subset): Update accordingly.
> 	* except.c (tree_hash_traits): Delete.
> 	(type_to_runtime_map): Use tree_hash as the first template parameter.
> 	(init_eh): Update accordingly.
> 	* genmatch.c (capture_id_map_hasher): Delete.
> 	(cid_map_t): Use nofree_string_hash as first template parameter.
> 	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
> 	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
> 	Use symbol_compare_hash as the first template parameter in
> 	subdivide_hash_map.
> 	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
> 	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
> 	template parameter.
> 	* passes.c (pass_registry_hasher): Delete.
> 	(name_to_pass_map): Use nofree_string_hash as the first template
> 	parameter.
> 	(register_pass_name): Update accordingly.
> 	* sanopt.c (sanopt_tree_map_traits): Delete.
> 	(sanopt_tree_triplet_map_traits): Delete.
> 	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
> 	template parameter.
> 	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
> 	the first template parameter.
> 	* sese.c (rename_map_hasher): Delete.
> 	(rename_map_type): Use tree_ssa_name_hash as the first template
> 	parameter.
> 	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
> 	(function_summary::m_map): Use map_hash as the first template
> 	parameter.
> 	(function_summary::release): Update accordingly.
> 	* tree-if-conv.c (phi_args_hash_traits): Delete.
> 	(predicate_scalar_phi): Use tree_operand_hash as the first template
> 	parameter to phi_arg_map.
> 	* tree-inline.h (dependence_hasher): Delete.
> 	(copy_body_data::dependence_map): Use dependence_hash as the first
> 	template parameter.
> 	* tree-inline.c (remap_dependence_clique): Update accordingly.
> 	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
> 	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
> 	parameter.
> 	(addr_stridxptr): Update accordingly.
> 	* value-prof.c (profile_id_traits): Delete.
> 	(cgraph_node_map): Use profile_id_hash as the first template
> 	parameter.
> 	(init_node_map): Update accordingly.
> 	* config/alpha/alpha.c (string_traits): Delete.
> 	(machine_function::links): Use nofree_string_hash as the first
> 	template parameter.
> 	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
> 	* config/m32c/m32c.c (pragma_traits): Delete.
> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
> 	(m32c_note_pragma_address): Update accordingly.
> 	* config/mep/mep.c (pragma_traits): Delete.
> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
> 	(mep_note_pragma_flag): Update accordingly.
> 	* config/mips/mips.c (mips16_flip_traits): Delete.
> 	(mflip_mips16_htab): Use nofree_string_hash as the first template
> 	parameter.
> 	(mflip_mips16_use_mips16_p): Update accordingly.
> 	(local_alias_traits): Delete.
> 	(mips16_local_aliases): Use nofree_string_hash as the first template
> 	parameter.
> 	(mips16_local_alias): Update accordingly.
Phew.  OK.

jeff

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-25 16:57   ` Jeff Law
@ 2015-06-26 13:50     ` Rainer Orth
  2015-06-26 14:38       ` Richard Sandiford
  2015-06-26 16:09       ` Mikhail Maltsev
  0 siblings, 2 replies; 35+ messages in thread
From: Rainer Orth @ 2015-06-26 13:50 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches, richard.sandiford

Jeff Law <law@redhat.com> writes:

> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>> At this point all hash_map traits know what kind of key they're
>> dealing with, so we can make that a traits typedef, like it is for
>> hash_table traits.  Then, if we make the default hash traits for
>> T be T, we can use hash_table-style traits as the first template
>> parameter to hash_map, without the need for a third.  That is, if
>> foo_hash hashes elements of type foo_type:
>>
>>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>>    hash_map <foo_type, value_type, foo_traits> x;
>>
>> becomes just:
>>
>>    hash_map <foo_hash, value_type> x;
>>
>> just like a hash_table of foo_types would be:
>>
>>    hash_table <foo_hash> y;
>>
>> This patch makes that simplification.
>>
>>
>> gcc/
>> 	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>> 	(unbounded_int_hashmap_traits::key_type): Likewise.
>> 	* hash-map.h (hash_map): Get the key type from the traits.
>> 	* hash-traits.h (default_hash_traits): By default, inherit from the
>> 	template parameter.
>> 	* alias.c (alias_set_traits): Delete.
>> 	(alias_set_entry_d::children): Use alias_set_hash as the first
>> 	template parameter.
>> 	(record_alias_subset): Update accordingly.
>> 	* except.c (tree_hash_traits): Delete.
>> 	(type_to_runtime_map): Use tree_hash as the first template parameter.
>> 	(init_eh): Update accordingly.
>> 	* genmatch.c (capture_id_map_hasher): Delete.
>> 	(cid_map_t): Use nofree_string_hash as first template parameter.
>> 	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>> 	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>> 	Use symbol_compare_hash as the first template parameter in
>> 	subdivide_hash_map.
>> 	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>> 	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>> 	template parameter.
>> 	* passes.c (pass_registry_hasher): Delete.
>> 	(name_to_pass_map): Use nofree_string_hash as the first template
>> 	parameter.
>> 	(register_pass_name): Update accordingly.
>> 	* sanopt.c (sanopt_tree_map_traits): Delete.
>> 	(sanopt_tree_triplet_map_traits): Delete.
>> 	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>> 	template parameter.
>> 	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>> 	the first template parameter.
>> 	* sese.c (rename_map_hasher): Delete.
>> 	(rename_map_type): Use tree_ssa_name_hash as the first template
>> 	parameter.
>> 	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>> 	(function_summary::m_map): Use map_hash as the first template
>> 	parameter.
>> 	(function_summary::release): Update accordingly.
>> 	* tree-if-conv.c (phi_args_hash_traits): Delete.
>> 	(predicate_scalar_phi): Use tree_operand_hash as the first template
>> 	parameter to phi_arg_map.
>> 	* tree-inline.h (dependence_hasher): Delete.
>> 	(copy_body_data::dependence_map): Use dependence_hash as the first
>> 	template parameter.
>> 	* tree-inline.c (remap_dependence_clique): Update accordingly.
>> 	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>> 	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>> 	parameter.
>> 	(addr_stridxptr): Update accordingly.
>> 	* value-prof.c (profile_id_traits): Delete.
>> 	(cgraph_node_map): Use profile_id_hash as the first template
>> 	parameter.
>> 	(init_node_map): Update accordingly.
>> 	* config/alpha/alpha.c (string_traits): Delete.
>> 	(machine_function::links): Use nofree_string_hash as the first
>> 	template parameter.
>> 	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
>> 	* config/m32c/m32c.c (pragma_traits): Delete.
>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>> 	(m32c_note_pragma_address): Update accordingly.
>> 	* config/mep/mep.c (pragma_traits): Delete.
>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>> 	(mep_note_pragma_flag): Update accordingly.
>> 	* config/mips/mips.c (mips16_flip_traits): Delete.
>> 	(mflip_mips16_htab): Use nofree_string_hash as the first template
>> 	parameter.
>> 	(mflip_mips16_use_mips16_p): Update accordingly.
>> 	(local_alias_traits): Delete.
>> 	(mips16_local_aliases): Use nofree_string_hash as the first template
>> 	parameter.
>> 	(mips16_local_alias): Update accordingly.
> Phew.  OK.

According to a reghunt, this patch broke bootstrap (at least with g++
4.7 as bootstrap compiler):

/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c: In function 'void build_wrapper_type(wrapper_data*)':
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:436:77: error: no matching function for call to 'hash_map<tree_node*, tree_node*>::traverse(auto_vec<cilk_decls>*)'
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:436:77: note: candidates are:
In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
                 from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
                 from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note:   template argument deduction/substitution failed:
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:436:77: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node* const&, auto_vec<cilk_decls>*)'
In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
                 from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
                 from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note:   template argument deduction/substitution failed:
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:436:77: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)'
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c: In function 'void cilk_outline(tree, tree_node**, void*)':
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:540:77: error: no matching function for call to 'hash_map<tree_node*, tree_node*>::traverse(auto_vec<cilk_decls>*)'
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:540:77: note: candidates are:
In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
                 from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
                 from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note:   template argument deduction/substitution failed:
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:540:77: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node* const&, auto_vec<cilk_decls>*)'
In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
                 from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
                 from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note:   template argument deduction/substitution failed:
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:540:77: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)'
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c: In function 'tree_node* create_cilk_wrapper(tree, tree_node**)':
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: error: no matching function for call to 'hash_map<tree_node*, tree_node*>::traverse(auto_vec<cilk_decls>*)'
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: note: candidates are:
In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
                 from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
                 from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note:   template argument deduction/substitution failed:
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node* const&, auto_vec<cilk_decls>*)'
In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
                 from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
                 from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note:   template argument deduction/substitution failed:
/vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)'
make: *** [c-family/cilk.o] Error 1

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [BUILDROBOT] could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’ (was: [12/12] Simplify uses of hash_map)
  2015-06-23 14:58 ` [12/12] Simplify uses of hash_map Richard Sandiford
  2015-06-25 16:57   ` Jeff Law
@ 2015-06-26 14:36   ` Jan-Benedict Glaw
  1 sibling, 0 replies; 35+ messages in thread
From: Jan-Benedict Glaw @ 2015-06-26 14:36 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 8518 bytes --]

On Tue, 2015-06-23 15:57:48 +0100, Richard Sandiford <richard.sandiford@arm.com> wrote:
> At this point all hash_map traits know what kind of key they're
> dealing with, so we can make that a traits typedef, like it is for
> hash_table traits.  Then, if we make the default hash traits for
> T be T, we can use hash_table-style traits as the first template
> parameter to hash_map, without the need for a third.  That is, if
> foo_hash hashes elements of type foo_type:
> 
>   typedef simple_hashmap_traits <foo_hash> foo_traits;
>   hash_map <foo_type, value_type, foo_traits> x;
> 
> becomes just:
> 
>   hash_map <foo_hash, value_type> x;
> 
> just like a hash_table of foo_types would be:
> 
>   hash_table <foo_hash> y;
> 
> This patch makes that simplification.

One of the patches around yours, and I guess it's specifically this one, makes
g++ (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)  (on gcc110.fsffrance.org) unhappy:

g++ -fno-PIE -c  -DIN_GCC_FRONTEND -DIN_GCC_FRONTEND -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -I. -Ic-family -I/home/jbglaw/repos/gcc/gcc -I/home/jbglaw/repos/gcc/gcc/c-family -I/home/jbglaw/repos/gcc/gcc/../include -I/home/jbglaw/repos/gcc/gcc/../libcpp/include  -I/home/jbglaw/repos/gcc/gcc/../libdecnumber -I/home/jbglaw/repos/gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I/home/jbglaw/repos/gcc/gcc/../libbacktrace   -o c-family/cilk.o -MT c-family/cilk.o -MMD -MP -MF c-family/.deps/cilk.TPo /home/jbglaw/repos/gcc/gcc/c-family/cilk.c
In file included from /home/jbglaw/repos/gcc/gcc/coretypes.h:319:0,
                 from /home/jbglaw/repos/gcc/gcc/c-family/cilk.c:25:
/home/jbglaw/repos/gcc/gcc/input.h:37:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c: In function ‘void build_wrapper_type(wrapper_data*)’:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:438:77: error: no matching function for call to ‘hash_map<tree_node*, tree_node*>::traverse(auto_vec<cilk_decls>*)’
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:438:77: note: candidates are:
In file included from /home/jbglaw/repos/gcc/gcc/hash-table.h:553:0,
                 from /home/jbglaw/repos/gcc/gcc/coretypes.h:317,
                 from /home/jbglaw/repos/gcc/gcc/c-family/cilk.c:25:
/home/jbglaw/repos/gcc/gcc/hash-map.h:173:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/home/jbglaw/repos/gcc/gcc/hash-map.h:173:8: note:   template argument deduction/substitution failed:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:438:77: error: could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node* const&, auto_vec<cilk_decls>*)’
In file included from /home/jbglaw/repos/gcc/gcc/hash-table.h:553:0,
                 from /home/jbglaw/repos/gcc/gcc/coretypes.h:317,
                 from /home/jbglaw/repos/gcc/gcc/c-family/cilk.c:25:
/home/jbglaw/repos/gcc/gcc/hash-map.h:181:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/home/jbglaw/repos/gcc/gcc/hash-map.h:181:8: note:   template argument deduction/substitution failed:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:438:77: error: could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c: In function ‘void cilk_outline(tree, tree_node**, void*)’:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:542:77: error: no matching function for call to ‘hash_map<tree_node*, tree_node*>::traverse(auto_vec<cilk_decls>*)’
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:542:77: note: candidates are:
In file included from /home/jbglaw/repos/gcc/gcc/hash-table.h:553:0,
                 from /home/jbglaw/repos/gcc/gcc/coretypes.h:317,
                 from /home/jbglaw/repos/gcc/gcc/c-family/cilk.c:25:
/home/jbglaw/repos/gcc/gcc/hash-map.h:173:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/home/jbglaw/repos/gcc/gcc/hash-map.h:173:8: note:   template argument deduction/substitution failed:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:542:77: error: could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node* const&, auto_vec<cilk_decls>*)’
In file included from /home/jbglaw/repos/gcc/gcc/hash-table.h:553:0,
                 from /home/jbglaw/repos/gcc/gcc/coretypes.h:317,
                 from /home/jbglaw/repos/gcc/gcc/c-family/cilk.c:25:
/home/jbglaw/repos/gcc/gcc/hash-map.h:181:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/home/jbglaw/repos/gcc/gcc/hash-map.h:181:8: note:   template argument deduction/substitution failed:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:542:77: error: could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c: In function ‘tree_node* create_cilk_wrapper(tree, tree_node**)’:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:749:76: error: no matching function for call to ‘hash_map<tree_node*, tree_node*>::traverse(auto_vec<cilk_decls>*)’
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:749:76: note: candidates are:
In file included from /home/jbglaw/repos/gcc/gcc/hash-table.h:553:0,
                 from /home/jbglaw/repos/gcc/gcc/coretypes.h:317,
                 from /home/jbglaw/repos/gcc/gcc/c-family/cilk.c:25:
/home/jbglaw/repos/gcc/gcc/hash-map.h:173:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/home/jbglaw/repos/gcc/gcc/hash-map.h:173:8: note:   template argument deduction/substitution failed:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:749:76: error: could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node* const&, auto_vec<cilk_decls>*)’
In file included from /home/jbglaw/repos/gcc/gcc/hash-table.h:553:0,
                 from /home/jbglaw/repos/gcc/gcc/coretypes.h:317,
                 from /home/jbglaw/repos/gcc/gcc/c-family/cilk.c:25:
/home/jbglaw/repos/gcc/gcc/hash-map.h:181:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
/home/jbglaw/repos/gcc/gcc/hash-map.h:181:8: note:   template argument deduction/substitution failed:
/home/jbglaw/repos/gcc/gcc/c-family/cilk.c:749:76: error: could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’
make[1]: *** [c-family/cilk.o] Error 1
make[1]: Leaving directory `/home/jbglaw/build/cris/build-gcc/gcc'
make: *** [all-gcc] Error 2


See eg.
http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=448826

MfG, JBG

-- 
      Jan-Benedict Glaw      jbglaw@lug-owl.de              +49-172-7608481
 Signature of:                            If it doesn't work, force it.
 the second  :                   If it breaks, it needed replacing anyway.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-26 13:50     ` Rainer Orth
@ 2015-06-26 14:38       ` Richard Sandiford
  2015-06-26 14:39         ` Jan-Benedict Glaw
  2015-06-26 15:34         ` Rainer Orth
  2015-06-26 16:09       ` Mikhail Maltsev
  1 sibling, 2 replies; 35+ messages in thread
From: Richard Sandiford @ 2015-06-26 14:38 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Jeff Law, gcc-patches

Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
> Jeff Law <law@redhat.com> writes:
>
>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>> At this point all hash_map traits know what kind of key they're
>>> dealing with, so we can make that a traits typedef, like it is for
>>> hash_table traits.  Then, if we make the default hash traits for
>>> T be T, we can use hash_table-style traits as the first template
>>> parameter to hash_map, without the need for a third.  That is, if
>>> foo_hash hashes elements of type foo_type:
>>>
>>>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>>>    hash_map <foo_type, value_type, foo_traits> x;
>>>
>>> becomes just:
>>>
>>>    hash_map <foo_hash, value_type> x;
>>>
>>> just like a hash_table of foo_types would be:
>>>
>>>    hash_table <foo_hash> y;
>>>
>>> This patch makes that simplification.
>>>
>>>
>>> gcc/
>>> 	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>> 	(unbounded_int_hashmap_traits::key_type): Likewise.
>>> 	* hash-map.h (hash_map): Get the key type from the traits.
>>> 	* hash-traits.h (default_hash_traits): By default, inherit from the
>>> 	template parameter.
>>> 	* alias.c (alias_set_traits): Delete.
>>> 	(alias_set_entry_d::children): Use alias_set_hash as the first
>>> 	template parameter.
>>> 	(record_alias_subset): Update accordingly.
>>> 	* except.c (tree_hash_traits): Delete.
>>> 	(type_to_runtime_map): Use tree_hash as the first template parameter.
>>> 	(init_eh): Update accordingly.
>>> 	* genmatch.c (capture_id_map_hasher): Delete.
>>> 	(cid_map_t): Use nofree_string_hash as first template parameter.
>>> 	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>> 	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>> 	Use symbol_compare_hash as the first template parameter in
>>> 	subdivide_hash_map.
>>> 	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>> 	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>> 	template parameter.
>>> 	* passes.c (pass_registry_hasher): Delete.
>>> 	(name_to_pass_map): Use nofree_string_hash as the first template
>>> 	parameter.
>>> 	(register_pass_name): Update accordingly.
>>> 	* sanopt.c (sanopt_tree_map_traits): Delete.
>>> 	(sanopt_tree_triplet_map_traits): Delete.
>>> 	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>> 	template parameter.
>>> 	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>> 	the first template parameter.
>>> 	* sese.c (rename_map_hasher): Delete.
>>> 	(rename_map_type): Use tree_ssa_name_hash as the first template
>>> 	parameter.
>>> 	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>> 	(function_summary::m_map): Use map_hash as the first template
>>> 	parameter.
>>> 	(function_summary::release): Update accordingly.
>>> 	* tree-if-conv.c (phi_args_hash_traits): Delete.
>>> 	(predicate_scalar_phi): Use tree_operand_hash as the first template
>>> 	parameter to phi_arg_map.
>>> 	* tree-inline.h (dependence_hasher): Delete.
>>> 	(copy_body_data::dependence_map): Use dependence_hash as the first
>>> 	template parameter.
>>> 	* tree-inline.c (remap_dependence_clique): Update accordingly.
>>> 	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>> 	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>> 	parameter.
>>> 	(addr_stridxptr): Update accordingly.
>>> 	* value-prof.c (profile_id_traits): Delete.
>>> 	(cgraph_node_map): Use profile_id_hash as the first template
>>> 	parameter.
>>> 	(init_node_map): Update accordingly.
>>> 	* config/alpha/alpha.c (string_traits): Delete.
>>> 	(machine_function::links): Use nofree_string_hash as the first
>>> 	template parameter.
>>> 	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>> 	* config/m32c/m32c.c (pragma_traits): Delete.
>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>> 	(m32c_note_pragma_address): Update accordingly.
>>> 	* config/mep/mep.c (pragma_traits): Delete.
>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>> 	(mep_note_pragma_flag): Update accordingly.
>>> 	* config/mips/mips.c (mips16_flip_traits): Delete.
>>> 	(mflip_mips16_htab): Use nofree_string_hash as the first template
>>> 	parameter.
>>> 	(mflip_mips16_use_mips16_p): Update accordingly.
>>> 	(local_alias_traits): Delete.
>>> 	(mips16_local_aliases): Use nofree_string_hash as the first template
>>> 	parameter.
>>> 	(mips16_local_alias): Update accordingly.
>> Phew.  OK.
>
> According to a reghunt, this patch broke bootstrap (at least with g++
> 4.7 as bootstrap compiler):

Which target are you using?  I just tried with a gcc 4.7 host compiler
on x86_64-linux-gnu and it seemed to work.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-26 14:38       ` Richard Sandiford
@ 2015-06-26 14:39         ` Jan-Benedict Glaw
  2015-06-26 15:34         ` Rainer Orth
  1 sibling, 0 replies; 35+ messages in thread
From: Jan-Benedict Glaw @ 2015-06-26 14:39 UTC (permalink / raw)
  To: Rainer Orth, Jeff Law, gcc-patches, richard.sandiford

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]

On Fri, 2015-06-26 15:36:01 +0100, Richard Sandiford <richard.sandiford@arm.com> wrote:
> Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
> > Jeff Law <law@redhat.com> writes:
> > > On 06/23/2015 08:57 AM, Richard Sandiford wrote:
> > > > At this point all hash_map traits know what kind of key they're
> > > > dealing with, so we can make that a traits typedef, like it is for
> > > > hash_table traits.  Then, if we make the default hash traits for
> > > > T be T, we can use hash_table-style traits as the first template
> > > > parameter to hash_map, without the need for a third.  That is, if
> > > > foo_hash hashes elements of type foo_type:
[...]
> > According to a reghunt, this patch broke bootstrap (at least with g++
> > 4.7 as bootstrap compiler):
> 
> Which target are you using?  I just tried with a gcc 4.7 host compiler
> on x86_64-linux-gnu and it seemed to work.

It's with all targets, see
http://toolchain.lug-owl.de/buildbot/timeline.php

MfG, JBG

-- 
      Jan-Benedict Glaw      jbglaw@lug-owl.de              +49-172-7608481
Signature of:  The course of history shows that as a government grows, liberty
the second  : decreases."  (Thomas Jefferson)

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-26 14:38       ` Richard Sandiford
  2015-06-26 14:39         ` Jan-Benedict Glaw
@ 2015-06-26 15:34         ` Rainer Orth
  2015-06-26 16:17           ` Richard Sandiford
  1 sibling, 1 reply; 35+ messages in thread
From: Rainer Orth @ 2015-06-26 15:34 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches, richard.sandiford

Richard Sandiford <richard.sandiford@arm.com> writes:

> Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
>> Jeff Law <law@redhat.com> writes:
>>
>>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>>> At this point all hash_map traits know what kind of key they're
>>>> dealing with, so we can make that a traits typedef, like it is for
>>>> hash_table traits.  Then, if we make the default hash traits for
>>>> T be T, we can use hash_table-style traits as the first template
>>>> parameter to hash_map, without the need for a third.  That is, if
>>>> foo_hash hashes elements of type foo_type:
>>>>
>>>>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>>>>    hash_map <foo_type, value_type, foo_traits> x;
>>>>
>>>> becomes just:
>>>>
>>>>    hash_map <foo_hash, value_type> x;
>>>>
>>>> just like a hash_table of foo_types would be:
>>>>
>>>>    hash_table <foo_hash> y;
>>>>
>>>> This patch makes that simplification.
>>>>
>>>>
>>>> gcc/
>>>> 	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>>> 	(unbounded_int_hashmap_traits::key_type): Likewise.
>>>> 	* hash-map.h (hash_map): Get the key type from the traits.
>>>> 	* hash-traits.h (default_hash_traits): By default, inherit from the
>>>> 	template parameter.
>>>> 	* alias.c (alias_set_traits): Delete.
>>>> 	(alias_set_entry_d::children): Use alias_set_hash as the first
>>>> 	template parameter.
>>>> 	(record_alias_subset): Update accordingly.
>>>> 	* except.c (tree_hash_traits): Delete.
>>>> 	(type_to_runtime_map): Use tree_hash as the first template parameter.
>>>> 	(init_eh): Update accordingly.
>>>> 	* genmatch.c (capture_id_map_hasher): Delete.
>>>> 	(cid_map_t): Use nofree_string_hash as first template parameter.
>>>> 	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>>> 	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>>> 	Use symbol_compare_hash as the first template parameter in
>>>> 	subdivide_hash_map.
>>>> 	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>>> 	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>>> 	template parameter.
>>>> 	* passes.c (pass_registry_hasher): Delete.
>>>> 	(name_to_pass_map): Use nofree_string_hash as the first template
>>>> 	parameter.
>>>> 	(register_pass_name): Update accordingly.
>>>> 	* sanopt.c (sanopt_tree_map_traits): Delete.
>>>> 	(sanopt_tree_triplet_map_traits): Delete.
>>>> 	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>>> 	template parameter.
>>>> 	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>>> 	the first template parameter.
>>>> 	* sese.c (rename_map_hasher): Delete.
>>>> 	(rename_map_type): Use tree_ssa_name_hash as the first template
>>>> 	parameter.
>>>> 	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>>> 	(function_summary::m_map): Use map_hash as the first template
>>>> 	parameter.
>>>> 	(function_summary::release): Update accordingly.
>>>> 	* tree-if-conv.c (phi_args_hash_traits): Delete.
>>>> 	(predicate_scalar_phi): Use tree_operand_hash as the first template
>>>> 	parameter to phi_arg_map.
>>>> 	* tree-inline.h (dependence_hasher): Delete.
>>>> 	(copy_body_data::dependence_map): Use dependence_hash as the first
>>>> 	template parameter.
>>>> 	* tree-inline.c (remap_dependence_clique): Update accordingly.
>>>> 	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>>> 	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>>> 	parameter.
>>>> 	(addr_stridxptr): Update accordingly.
>>>> 	* value-prof.c (profile_id_traits): Delete.
>>>> 	(cgraph_node_map): Use profile_id_hash as the first template
>>>> 	parameter.
>>>> 	(init_node_map): Update accordingly.
>>>> 	* config/alpha/alpha.c (string_traits): Delete.
>>>> 	(machine_function::links): Use nofree_string_hash as the first
>>>> 	template parameter.
>>>> 	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>>> 	* config/m32c/m32c.c (pragma_traits): Delete.
>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>> 	(m32c_note_pragma_address): Update accordingly.
>>>> 	* config/mep/mep.c (pragma_traits): Delete.
>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>> 	(mep_note_pragma_flag): Update accordingly.
>>>> 	* config/mips/mips.c (mips16_flip_traits): Delete.
>>>> 	(mflip_mips16_htab): Use nofree_string_hash as the first template
>>>> 	parameter.
>>>> 	(mflip_mips16_use_mips16_p): Update accordingly.
>>>> 	(local_alias_traits): Delete.
>>>> 	(mips16_local_aliases): Use nofree_string_hash as the first template
>>>> 	parameter.
>>>> 	(mips16_local_alias): Update accordingly.
>>> Phew.  OK.
>>
>> According to a reghunt, this patch broke bootstrap (at least with g++
>> 4.7 as bootstrap compiler):
>
> Which target are you using?  I just tried with a gcc 4.7 host compiler
> on x86_64-linux-gnu and it seemed to work.

I see it on i386-pc-solaris2.1[01] and sparc-sun-solaris2.1[01].

gcc 4.9 works there, though.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-26 13:50     ` Rainer Orth
  2015-06-26 14:38       ` Richard Sandiford
@ 2015-06-26 16:09       ` Mikhail Maltsev
  1 sibling, 0 replies; 35+ messages in thread
From: Mikhail Maltsev @ 2015-06-26 16:09 UTC (permalink / raw)
  To: Rainer Orth, Jeff Law; +Cc: gcc-patches, richard.sandiford

On 06/26/2015 04:37 PM, Rainer Orth wrote:
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node* const&, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, const Value&, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:173:8: note:   template argument deduction/substitution failed:
> /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node* const&, auto_vec<cilk_decls>*)'
> In file included from /vol/gcc/src/hg/trunk/local/gcc/hash-table.h:553:0,
>                  from /vol/gcc/src/hg/trunk/local/gcc/coretypes.h:317,
>                  from /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:25:
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note: template<class Arg, bool (* f)(tree_node*&, tree_node**, Arg)> void hash_map::traverse(Arg) const [with Arg = Arg; bool (* f)(typename Traits::key_type&, Value*, Arg) = f; KeyId = tree_node*; Value = tree_node*; Traits = simple_hashmap_traits<default_hash_traits<tree_node*> >]
> /vol/gcc/src/hg/trunk/local/gcc/hash-map.h:181:8: note:   template argument deduction/substitution failed:
> /vol/gcc/src/hg/trunk/local/gcc/c-family/cilk.c:747:76: error: could not convert template argument 'fill_decls_vec' to 'bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)'
> make: *** [c-family/cilk.o] Error 1
> 
> 	Rainer
> 

It seems that I can also reproduce this issue. The following code was
reduced from GCC r224910, genmatch.c:

$ cat ./test2.ii
template <typename Descriptor, template <typename> class> class hash_table {
  typedef typename Descriptor::value_type value_type;
  template <typename Argument, int (*)(value_type *, Argument)>
  void traverse(Argument);
};

template <typename Descriptor, template <typename> class Allocator>
template <
    typename Argument,
    int (*)(typename hash_table<Descriptor, Allocator>::value_type *,
Argument)>
void hash_table<Descriptor, Allocator>::traverse(Argument) {}

It is accepted by current GCC and Clang but rejected by EDG:

$ /opt/intel/bin/icpc -V
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on
Intel(R) 64, Version 15.0.3.187 Build 20150407
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

$ /opt/intel/bin/icpc -c ./test2.ii
./test2.ii(11): error: declaration is incompatible with function
template "void hash_table<Descriptor,
<unnamed>>::traverse<Argument,<unnamed>>(Argument)" (declared at line 4)
  void hash_table<Descriptor, Allocator>::traverse(Argument) {}
                                          ^
compilation aborted for ./test2.ii (code 2)

-- 
Regards,
    Mikhail Maltsev

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-26 15:34         ` Rainer Orth
@ 2015-06-26 16:17           ` Richard Sandiford
  2015-06-26 16:45             ` Richard Sandiford
  0 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-26 16:17 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Jeff Law, gcc-patches

Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
> Richard Sandiford <richard.sandiford@arm.com> writes:
>
>> Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
>>> Jeff Law <law@redhat.com> writes:
>>>
>>>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>>>> At this point all hash_map traits know what kind of key they're
>>>>> dealing with, so we can make that a traits typedef, like it is for
>>>>> hash_table traits.  Then, if we make the default hash traits for
>>>>> T be T, we can use hash_table-style traits as the first template
>>>>> parameter to hash_map, without the need for a third.  That is, if
>>>>> foo_hash hashes elements of type foo_type:
>>>>>
>>>>>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>>>>>    hash_map <foo_type, value_type, foo_traits> x;
>>>>>
>>>>> becomes just:
>>>>>
>>>>>    hash_map <foo_hash, value_type> x;
>>>>>
>>>>> just like a hash_table of foo_types would be:
>>>>>
>>>>>    hash_table <foo_hash> y;
>>>>>
>>>>> This patch makes that simplification.
>>>>>
>>>>>
>>>>> gcc/
>>>>> 	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>>>> 	(unbounded_int_hashmap_traits::key_type): Likewise.
>>>>> 	* hash-map.h (hash_map): Get the key type from the traits.
>>>>> 	* hash-traits.h (default_hash_traits): By default, inherit from the
>>>>> 	template parameter.
>>>>> 	* alias.c (alias_set_traits): Delete.
>>>>> 	(alias_set_entry_d::children): Use alias_set_hash as the first
>>>>> 	template parameter.
>>>>> 	(record_alias_subset): Update accordingly.
>>>>> 	* except.c (tree_hash_traits): Delete.
>>>>> 	(type_to_runtime_map): Use tree_hash as the first template parameter.
>>>>> 	(init_eh): Update accordingly.
>>>>> 	* genmatch.c (capture_id_map_hasher): Delete.
>>>>> 	(cid_map_t): Use nofree_string_hash as first template parameter.
>>>>> 	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>>>> 	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>>>> 	Use symbol_compare_hash as the first template parameter in
>>>>> 	subdivide_hash_map.
>>>>> 	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>>>> 	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>>>> 	template parameter.
>>>>> 	* passes.c (pass_registry_hasher): Delete.
>>>>> 	(name_to_pass_map): Use nofree_string_hash as the first template
>>>>> 	parameter.
>>>>> 	(register_pass_name): Update accordingly.
>>>>> 	* sanopt.c (sanopt_tree_map_traits): Delete.
>>>>> 	(sanopt_tree_triplet_map_traits): Delete.
>>>>> 	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>>>> 	template parameter.
>>>>> 	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>>>> 	the first template parameter.
>>>>> 	* sese.c (rename_map_hasher): Delete.
>>>>> 	(rename_map_type): Use tree_ssa_name_hash as the first template
>>>>> 	parameter.
>>>>> 	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>>>> 	(function_summary::m_map): Use map_hash as the first template
>>>>> 	parameter.
>>>>> 	(function_summary::release): Update accordingly.
>>>>> 	* tree-if-conv.c (phi_args_hash_traits): Delete.
>>>>> 	(predicate_scalar_phi): Use tree_operand_hash as the first template
>>>>> 	parameter to phi_arg_map.
>>>>> 	* tree-inline.h (dependence_hasher): Delete.
>>>>> 	(copy_body_data::dependence_map): Use dependence_hash as the first
>>>>> 	template parameter.
>>>>> 	* tree-inline.c (remap_dependence_clique): Update accordingly.
>>>>> 	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>>>> 	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>>>> 	parameter.
>>>>> 	(addr_stridxptr): Update accordingly.
>>>>> 	* value-prof.c (profile_id_traits): Delete.
>>>>> 	(cgraph_node_map): Use profile_id_hash as the first template
>>>>> 	parameter.
>>>>> 	(init_node_map): Update accordingly.
>>>>> 	* config/alpha/alpha.c (string_traits): Delete.
>>>>> 	(machine_function::links): Use nofree_string_hash as the first
>>>>> 	template parameter.
>>>>> 	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>>>> 	* config/m32c/m32c.c (pragma_traits): Delete.
>>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>> 	(m32c_note_pragma_address): Update accordingly.
>>>>> 	* config/mep/mep.c (pragma_traits): Delete.
>>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>> 	(mep_note_pragma_flag): Update accordingly.
>>>>> 	* config/mips/mips.c (mips16_flip_traits): Delete.
>>>>> 	(mflip_mips16_htab): Use nofree_string_hash as the first template
>>>>> 	parameter.
>>>>> 	(mflip_mips16_use_mips16_p): Update accordingly.
>>>>> 	(local_alias_traits): Delete.
>>>>> 	(mips16_local_aliases): Use nofree_string_hash as the first template
>>>>> 	parameter.
>>>>> 	(mips16_local_alias): Update accordingly.
>>>> Phew.  OK.
>>>
>>> According to a reghunt, this patch broke bootstrap (at least with g++
>>> 4.7 as bootstrap compiler):
>>
>> Which target are you using?  I just tried with a gcc 4.7 host compiler
>> on x86_64-linux-gnu and it seemed to work.
>
> I see it on i386-pc-solaris2.1[01] and sparc-sun-solaris2.1[01].
>
> gcc 4.9 works there, though.

OK, I can reproduce it with 4.7.2 but it seems to be fixed in 4.7.4.
Trying to find out what changed as well as find a workaround.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-26 16:17           ` Richard Sandiford
@ 2015-06-26 16:45             ` Richard Sandiford
  2015-06-26 17:03               ` Richard Sandiford
  0 siblings, 1 reply; 35+ messages in thread
From: Richard Sandiford @ 2015-06-26 16:45 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Jeff Law, gcc-patches

Richard Sandiford <richard.sandiford@arm.com> writes:
> Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
>> Richard Sandiford <richard.sandiford@arm.com> writes:
>>
>>> Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
>>>> Jeff Law <law@redhat.com> writes:
>>>>
>>>>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>>>>> At this point all hash_map traits know what kind of key they're
>>>>>> dealing with, so we can make that a traits typedef, like it is for
>>>>>> hash_table traits.  Then, if we make the default hash traits for
>>>>>> T be T, we can use hash_table-style traits as the first template
>>>>>> parameter to hash_map, without the need for a third.  That is, if
>>>>>> foo_hash hashes elements of type foo_type:
>>>>>>
>>>>>>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>>>>>>    hash_map <foo_type, value_type, foo_traits> x;
>>>>>>
>>>>>> becomes just:
>>>>>>
>>>>>>    hash_map <foo_hash, value_type> x;
>>>>>>
>>>>>> just like a hash_table of foo_types would be:
>>>>>>
>>>>>>    hash_table <foo_hash> y;
>>>>>>
>>>>>> This patch makes that simplification.
>>>>>>
>>>>>>
>>>>>> gcc/
>>>>>> 	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>>>>> 	(unbounded_int_hashmap_traits::key_type): Likewise.
>>>>>> 	* hash-map.h (hash_map): Get the key type from the traits.
>>>>>> 	* hash-traits.h (default_hash_traits): By default, inherit from the
>>>>>> 	template parameter.
>>>>>> 	* alias.c (alias_set_traits): Delete.
>>>>>> 	(alias_set_entry_d::children): Use alias_set_hash as the first
>>>>>> 	template parameter.
>>>>>> 	(record_alias_subset): Update accordingly.
>>>>>> 	* except.c (tree_hash_traits): Delete.
>>>>>> 	(type_to_runtime_map): Use tree_hash as the first template parameter.
>>>>>> 	(init_eh): Update accordingly.
>>>>>> 	* genmatch.c (capture_id_map_hasher): Delete.
>>>>>> 	(cid_map_t): Use nofree_string_hash as first template parameter.
>>>>>> 	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>>>>> 	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>>>>> 	Use symbol_compare_hash as the first template parameter in
>>>>>> 	subdivide_hash_map.
>>>>>> 	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>>>>> 	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>>>>> 	template parameter.
>>>>>> 	* passes.c (pass_registry_hasher): Delete.
>>>>>> 	(name_to_pass_map): Use nofree_string_hash as the first template
>>>>>> 	parameter.
>>>>>> 	(register_pass_name): Update accordingly.
>>>>>> 	* sanopt.c (sanopt_tree_map_traits): Delete.
>>>>>> 	(sanopt_tree_triplet_map_traits): Delete.
>>>>>> 	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>>>>> 	template parameter.
>>>>>> 	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>>>>> 	the first template parameter.
>>>>>> 	* sese.c (rename_map_hasher): Delete.
>>>>>> 	(rename_map_type): Use tree_ssa_name_hash as the first template
>>>>>> 	parameter.
>>>>>> 	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>>>>> 	(function_summary::m_map): Use map_hash as the first template
>>>>>> 	parameter.
>>>>>> 	(function_summary::release): Update accordingly.
>>>>>> 	* tree-if-conv.c (phi_args_hash_traits): Delete.
>>>>>> 	(predicate_scalar_phi): Use tree_operand_hash as the first template
>>>>>> 	parameter to phi_arg_map.
>>>>>> 	* tree-inline.h (dependence_hasher): Delete.
>>>>>> 	(copy_body_data::dependence_map): Use dependence_hash as the first
>>>>>> 	template parameter.
>>>>>> 	* tree-inline.c (remap_dependence_clique): Update accordingly.
>>>>>> 	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>>>>> 	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>>>>> 	parameter.
>>>>>> 	(addr_stridxptr): Update accordingly.
>>>>>> 	* value-prof.c (profile_id_traits): Delete.
>>>>>> 	(cgraph_node_map): Use profile_id_hash as the first template
>>>>>> 	parameter.
>>>>>> 	(init_node_map): Update accordingly.
>>>>>> 	* config/alpha/alpha.c (string_traits): Delete.
>>>>>> 	(machine_function::links): Use nofree_string_hash as the first
>>>>>> 	template parameter.
>>>>>> 	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>>>>> 	* config/m32c/m32c.c (pragma_traits): Delete.
>>>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>>> 	(m32c_note_pragma_address): Update accordingly.
>>>>>> 	* config/mep/mep.c (pragma_traits): Delete.
>>>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>>> 	(mep_note_pragma_flag): Update accordingly.
>>>>>> 	* config/mips/mips.c (mips16_flip_traits): Delete.
>>>>>> 	(mflip_mips16_htab): Use nofree_string_hash as the first template
>>>>>> 	parameter.
>>>>>> 	(mflip_mips16_use_mips16_p): Update accordingly.
>>>>>> 	(local_alias_traits): Delete.
>>>>>> 	(mips16_local_aliases): Use nofree_string_hash as the first template
>>>>>> 	parameter.
>>>>>> 	(mips16_local_alias): Update accordingly.
>>>>> Phew.  OK.
>>>>
>>>> According to a reghunt, this patch broke bootstrap (at least with g++
>>>> 4.7 as bootstrap compiler):
>>>
>>> Which target are you using?  I just tried with a gcc 4.7 host compiler
>>> on x86_64-linux-gnu and it seemed to work.
>>
>> I see it on i386-pc-solaris2.1[01] and sparc-sun-solaris2.1[01].
>>
>> gcc 4.9 works there, though.
>
> OK, I can reproduce it with 4.7.2 but it seems to be fixed in 4.7.4.
> Trying to find out what changed as well as find a workaround.

This seems to work for me.

Thanks,
Richard


gcc/
	* hash-map.h (hash_map::traverse): Use the definition of the
	Key typedef rather than the typedef itself.

Index: gcc/hash-map.h
===================================================================
--- gcc/hash-map.h	2015-06-25 18:17:12.360905717 +0100
+++ gcc/hash-map.h	2015-06-26 17:36:36.187837149 +0100
@@ -169,7 +169,8 @@ class GTY((user)) hash_map
   /* Call the call back on each pair of key and value with the passed in
      arg.  */
 
-  template<typename Arg, bool (*f)(const Key &, const Value &, Arg)>
+  template<typename Arg, bool (*f)(const typename Traits::key_type &,
+				   const Value &, Arg)>
   void traverse (Arg a) const
     {
       for (typename hash_table<hash_entry>::iterator iter = m_table.begin ();
@@ -177,7 +178,8 @@ class GTY((user)) hash_map
 	f ((*iter).m_key, (*iter).m_value, a);
     }
 
-  template<typename Arg, bool (*f)(const Key &, Value *, Arg)>
+  template<typename Arg, bool (*f)(const typename Traits::key_type &,
+				   Value *, Arg)>
   void traverse (Arg a) const
     {
       for (typename hash_table<hash_entry>::iterator iter = m_table.begin ();

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [12/12] Simplify uses of hash_map
  2015-06-26 16:45             ` Richard Sandiford
@ 2015-06-26 17:03               ` Richard Sandiford
  0 siblings, 0 replies; 35+ messages in thread
From: Richard Sandiford @ 2015-06-26 17:03 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Jeff Law, gcc-patches

Richard Sandiford <richard.sandiford@arm.com> writes:
> Richard Sandiford <richard.sandiford@arm.com> writes:
>> Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
>>> Richard Sandiford <richard.sandiford@arm.com> writes:
>>>
>>>> Rainer Orth <ro@cebitec.uni-bielefeld.de> writes:
>>>>> Jeff Law <law@redhat.com> writes:
>>>>>
>>>>>> On 06/23/2015 08:57 AM, Richard Sandiford wrote:
>>>>>>> At this point all hash_map traits know what kind of key they're
>>>>>>> dealing with, so we can make that a traits typedef, like it is for
>>>>>>> hash_table traits.  Then, if we make the default hash traits for
>>>>>>> T be T, we can use hash_table-style traits as the first template
>>>>>>> parameter to hash_map, without the need for a third.  That is, if
>>>>>>> foo_hash hashes elements of type foo_type:
>>>>>>>
>>>>>>>    typedef simple_hashmap_traits <foo_hash> foo_traits;
>>>>>>>    hash_map <foo_type, value_type, foo_traits> x;
>>>>>>>
>>>>>>> becomes just:
>>>>>>>
>>>>>>>    hash_map <foo_hash, value_type> x;
>>>>>>>
>>>>>>> just like a hash_table of foo_types would be:
>>>>>>>
>>>>>>>    hash_table <foo_hash> y;
>>>>>>>
>>>>>>> This patch makes that simplification.
>>>>>>>
>>>>>>>
>>>>>>> gcc/
>>>>>>> 	* hash-map-traits.h (simple_hashmap_traits::key_type): New typedef.
>>>>>>> 	(unbounded_int_hashmap_traits::key_type): Likewise.
>>>>>>> 	* hash-map.h (hash_map): Get the key type from the traits.
>>>>>>> 	* hash-traits.h (default_hash_traits): By default, inherit from the
>>>>>>> 	template parameter.
>>>>>>> 	* alias.c (alias_set_traits): Delete.
>>>>>>> 	(alias_set_entry_d::children): Use alias_set_hash as the first
>>>>>>> 	template parameter.
>>>>>>> 	(record_alias_subset): Update accordingly.
>>>>>>> 	* except.c (tree_hash_traits): Delete.
>>>>>>> 	(type_to_runtime_map): Use tree_hash as the first template parameter.
>>>>>>> 	(init_eh): Update accordingly.
>>>>>>> 	* genmatch.c (capture_id_map_hasher): Delete.
>>>>>>> 	(cid_map_t): Use nofree_string_hash as first template parameter.
>>>>>>> 	* ipa-icf.h (symbol_compare_hashmap_traits): Delete.
>>>>>>> 	* ipa-icf.c (sem_item_optimizer::subdivide_classes_by_sensitive_refs):
>>>>>>> 	Use symbol_compare_hash as the first template parameter in
>>>>>>> 	subdivide_hash_map.
>>>>>>> 	* mem-stats.h (mem_usage_pair::mem_alloc_hashmap_traits): Delete.
>>>>>>> 	(mem_usage_pair::mem_map_t): Use mem_location_hash as the first
>>>>>>> 	template parameter.
>>>>>>> 	* passes.c (pass_registry_hasher): Delete.
>>>>>>> 	(name_to_pass_map): Use nofree_string_hash as the first template
>>>>>>> 	parameter.
>>>>>>> 	(register_pass_name): Update accordingly.
>>>>>>> 	* sanopt.c (sanopt_tree_map_traits): Delete.
>>>>>>> 	(sanopt_tree_triplet_map_traits): Delete.
>>>>>>> 	(sanopt_ctx::asan_check_map): Use tree_operand_hash as the first
>>>>>>> 	template parameter.
>>>>>>> 	(sanopt_ctx::vptr_check_map): Use sanopt_tree_triplet_hash as
>>>>>>> 	the first template parameter.
>>>>>>> 	* sese.c (rename_map_hasher): Delete.
>>>>>>> 	(rename_map_type): Use tree_ssa_name_hash as the first template
>>>>>>> 	parameter.
>>>>>>> 	* symbol-summary.h (function_summary::summary_hashmap_traits): Delete.
>>>>>>> 	(function_summary::m_map): Use map_hash as the first template
>>>>>>> 	parameter.
>>>>>>> 	(function_summary::release): Update accordingly.
>>>>>>> 	* tree-if-conv.c (phi_args_hash_traits): Delete.
>>>>>>> 	(predicate_scalar_phi): Use tree_operand_hash as the first template
>>>>>>> 	parameter to phi_arg_map.
>>>>>>> 	* tree-inline.h (dependence_hasher): Delete.
>>>>>>> 	(copy_body_data::dependence_map): Use dependence_hash as the first
>>>>>>> 	template parameter.
>>>>>>> 	* tree-inline.c (remap_dependence_clique): Update accordingly.
>>>>>>> 	* tree-ssa-strlen.c (stridxlist_hash_traits): Delete.
>>>>>>> 	(decl_to_stridxlist_htab): Use tree_decl_hash as the first template
>>>>>>> 	parameter.
>>>>>>> 	(addr_stridxptr): Update accordingly.
>>>>>>> 	* value-prof.c (profile_id_traits): Delete.
>>>>>>> 	(cgraph_node_map): Use profile_id_hash as the first template
>>>>>>> 	parameter.
>>>>>>> 	(init_node_map): Update accordingly.
>>>>>>> 	* config/alpha/alpha.c (string_traits): Delete.
>>>>>>> 	(machine_function::links): Use nofree_string_hash as the first
>>>>>>> 	template parameter.
>>>>>>> 	(alpha_use_linkage, alpha_write_linkage): Update accordingly.
>>>>>>> 	* config/m32c/m32c.c (pragma_traits): Delete.
>>>>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>>>> 	(m32c_note_pragma_address): Update accordingly.
>>>>>>> 	* config/mep/mep.c (pragma_traits): Delete.
>>>>>>> 	(pragma_htab): Use nofree_string_hash as the first template parameter.
>>>>>>> 	(mep_note_pragma_flag): Update accordingly.
>>>>>>> 	* config/mips/mips.c (mips16_flip_traits): Delete.
>>>>>>> 	(mflip_mips16_htab): Use nofree_string_hash as the first template
>>>>>>> 	parameter.
>>>>>>> 	(mflip_mips16_use_mips16_p): Update accordingly.
>>>>>>> 	(local_alias_traits): Delete.
>>>>>>> 	(mips16_local_aliases): Use nofree_string_hash as the first template
>>>>>>> 	parameter.
>>>>>>> 	(mips16_local_alias): Update accordingly.
>>>>>> Phew.  OK.
>>>>>
>>>>> According to a reghunt, this patch broke bootstrap (at least with g++
>>>>> 4.7 as bootstrap compiler):
>>>>
>>>> Which target are you using?  I just tried with a gcc 4.7 host compiler
>>>> on x86_64-linux-gnu and it seemed to work.
>>>
>>> I see it on i386-pc-solaris2.1[01] and sparc-sun-solaris2.1[01].
>>>
>>> gcc 4.9 works there, though.
>>
>> OK, I can reproduce it with 4.7.2 but it seems to be fixed in 4.7.4.
>> Trying to find out what changed as well as find a workaround.
>
> This seems to work for me.

Applied as obvious after bootstrap succeeded.

Thanks,
Richard

> gcc/
> 	* hash-map.h (hash_map::traverse): Use the definition of the
> 	Key typedef rather than the typedef itself.
>
> Index: gcc/hash-map.h
> ===================================================================
> --- gcc/hash-map.h	2015-06-25 18:17:12.360905717 +0100
> +++ gcc/hash-map.h	2015-06-26 17:36:36.187837149 +0100
> @@ -169,7 +169,8 @@ class GTY((user)) hash_map
>    /* Call the call back on each pair of key and value with the passed in
>       arg.  */
>  
> -  template<typename Arg, bool (*f)(const Key &, const Value &, Arg)>
> +  template<typename Arg, bool (*f)(const typename Traits::key_type &,
> +				   const Value &, Arg)>
>    void traverse (Arg a) const
>      {
>        for (typename hash_table<hash_entry>::iterator iter = m_table.begin ();
> @@ -177,7 +178,8 @@ class GTY((user)) hash_map
>  	f ((*iter).m_key, (*iter).m_value, a);
>      }
>  
> -  template<typename Arg, bool (*f)(const Key &, Value *, Arg)>
> +  template<typename Arg, bool (*f)(const typename Traits::key_type &,
> +				   Value *, Arg)>
>    void traverse (Arg a) const
>      {
>        for (typename hash_table<hash_entry>::iterator iter = m_table.begin ();

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2015-06-26 16:51 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87egl2bicm.fsf@e105548-lin.cambridge.arm.com>
2015-06-23 14:44 ` [01/12] Add hash_map traits that use existing hash_table-like traits Richard Sandiford
2015-06-25 16:34   ` Jeff Law
2015-06-23 14:45 ` [02/12] Move tree operand hashers to a new header file Richard Sandiford
2015-06-25 16:34   ` Jeff Law
2015-06-23 14:47 ` [03/12] Move decl hasher to " Richard Sandiford
2015-06-25 16:34   ` Jeff Law
2015-06-23 14:48 ` [04/12] Move ssa_name " Richard Sandiford
2015-06-25 16:35   ` Jeff Law
2015-06-23 14:49 ` [05/12] Move TREE_HASH " Richard Sandiford
2015-06-25 16:36   ` Jeff Law
2015-06-23 14:50 ` [06/12] Consolidate string hashers Richard Sandiford
2015-06-24 10:13   ` Mikhail Maltsev
2015-06-24 11:39     ` Richard Sandiford
2015-06-25 16:37   ` Jeff Law
2015-06-23 14:52 ` [07/12] Use new string hasher for MIPS Richard Sandiford
2015-06-25 16:39   ` Jeff Law
2015-06-23 14:53 ` [08/12] Add common traits for integer hash keys Richard Sandiford
2015-06-25 16:40   ` Jeff Law
2015-06-23 14:55 ` [09/12] Remove all but one use of default_hashmap_traits Richard Sandiford
2015-06-25 16:41   ` Jeff Law
2015-06-23 14:56 ` [10/12] Add helper class for valued-based empty and deleted slots Richard Sandiford
2015-06-25 16:41   ` Jeff Law
2015-06-23 14:57 ` [11/12] Remove default_hashmap_traits Richard Sandiford
2015-06-25 16:42   ` Jeff Law
2015-06-23 14:58 ` [12/12] Simplify uses of hash_map Richard Sandiford
2015-06-25 16:57   ` Jeff Law
2015-06-26 13:50     ` Rainer Orth
2015-06-26 14:38       ` Richard Sandiford
2015-06-26 14:39         ` Jan-Benedict Glaw
2015-06-26 15:34         ` Rainer Orth
2015-06-26 16:17           ` Richard Sandiford
2015-06-26 16:45             ` Richard Sandiford
2015-06-26 17:03               ` Richard Sandiford
2015-06-26 16:09       ` Mikhail Maltsev
2015-06-26 14:36   ` [BUILDROBOT] could not convert template argument ‘fill_decls_vec’ to ‘bool (*)(tree_node*&, tree_node**, auto_vec<cilk_decls>*)’ (was: [12/12] Simplify uses of hash_map) Jan-Benedict Glaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).