From: Richard Sandiford Date: Thu, 25 Jun 2015 17:16:02 +0000 (+0000) Subject: tree-hash-traits.h (tree_ssa_name_hasher): New class. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5d6678ae80850da572b28776ef9dd19b04d5fefd;p=gcc.git tree-hash-traits.h (tree_ssa_name_hasher): New class. 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. From-SVN: r224969 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 30b7cdc121a..f95f2dcc947 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-06-25 Richard Sandiford + + * 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. + 2015-06-25 Richard Sandiford * tree-hash-traits.h (tree_decl_hash): New class. diff --git a/gcc/sese.c b/gcc/sese.c index 45deda1a4fa..95ef7e80372 100644 --- a/gcc/sese.c +++ b/gcc/sese.c @@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see #include "value-prof.h" #include "sese.h" #include "tree-ssa-propagate.h" +#include "tree-hash-traits.h" /* Helper function for debug_rename_map. */ @@ -75,22 +76,7 @@ debug_rename_map_1 (tree_node *const &old_name, tree_node *const &expr, return true; } - -/* 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 rename_map_hasher; typedef hash_map rename_map_type; diff --git a/gcc/tree-hash-traits.h b/gcc/tree-hash-traits.h index 9a2fda7bac6..1f4364f591e 100644 --- a/gcc/tree-hash-traits.h +++ b/gcc/tree-hash-traits.h @@ -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 +{ + static inline hashval_t hash (tree); +}; + +inline hashval_t +tree_ssa_name_hash::hash (tree t) +{ + return SSA_NAME_VERSION (t); +} + #endif