aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-11-22 22:38:44 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-11-22 22:38:44 +0100
commitdf418f1d3cba53a4d3d20c2f640a250dd4c1bfa3 (patch)
treef66e383f251a8499f4d34c9d8662bca6f50413af /gcc/tree.h
parent839e636a9abe65f4880fb5d9609f8ee5ff277fe5 (diff)
downloadgcc-df418f1d3cba53a4d3d20c2f640a250dd4c1bfa3.zip
gcc-df418f1d3cba53a4d3d20c2f640a250dd4c1bfa3.tar.gz
gcc-df418f1d3cba53a4d3d20c2f640a250dd4c1bfa3.tar.bz2
re PR c++/92458 (Constraints do not work with precompiled headers)
PR c++/92458 * tree-hash-traits.h (tree_decl_hash, tree_ssa_name_hash, tree_hash): Move to ... * tree.h (tree_decl_hash, tree_ssa_name_hash, tree_hash): ... here. (struct decl_tree_cache_traits, struct type_tree_cache_traits): New types. (decl_tree_cache_map, tree_tree_cache_map): New typedefs. * init.c (nsdmi_inst): Change type to decl_tree_cache_map * from tree_cache_map *. * constraint.cc (decl_constraints): Likewise. * decl.c (get_tuple_decomp_init): Likewise. * pt.c (defarg_inst, explicit_specifier_map): Likewise. (tsubst_default_argument, store_explicit_specifier): Use decl_tree_cache_map::create_ggc rather than tree_cache_map::create_ggc. * cp-objcp-common.c (debug_type_map): Change type to type_tree_cache_map * from tree_cache_map *. * g++.dg/pch/pr92458.C: New test. * g++.dg/pch/pr92458.Hs: New test. From-SVN: r278633
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index 89114e2..60b6eae 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5351,6 +5351,58 @@ struct tree_decl_map_cache_hasher : ggc_cache_ptr_hash<tree_decl_map>
#define tree_vec_map_hash tree_decl_map_hash
#define tree_vec_map_marked_p tree_map_base_marked_p
+/* 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. Additionally it can be used across PCH save/restore. */
+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);
+}
+
+/* Similarly for types. Uses TYPE_UID as hash function. */
+struct tree_type_hash : ggc_ptr_hash <tree_node>
+{
+ static inline hashval_t hash (tree);
+};
+
+inline hashval_t
+tree_type_hash::hash (tree t)
+{
+ return TYPE_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);
+}
+
+/* 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);
+}
+
/* A hash_map of two trees for use with GTY((cache)). Garbage collection for
such a map will not mark keys, and will mark values if the key is already
marked. */
@@ -5358,6 +5410,18 @@ struct tree_cache_traits
: simple_cache_map_traits<default_hash_traits<tree>, tree> { };
typedef hash_map<tree,tree,tree_cache_traits> tree_cache_map;
+/* Similarly, but use DECL_UID as hash function rather than pointer hashing.
+ This is for hash_maps from decls to trees that need to work across PCH. */
+struct decl_tree_cache_traits
+ : simple_cache_map_traits<tree_decl_hash, tree> { };
+typedef hash_map<tree,tree,decl_tree_cache_traits> decl_tree_cache_map;
+
+/* Similarly, but use TYPE_UID as hash function rather than pointer hashing.
+ This is for hash_maps from types to trees that need to work across PCH. */
+struct type_tree_cache_traits
+ : simple_cache_map_traits<tree_type_hash, tree> { };
+typedef hash_map<tree,tree,type_tree_cache_traits> type_tree_cache_map;
+
/* Initialize the abstract argument list iterator object ITER with the
arguments from CALL_EXPR node EXP. */
static inline void