]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Jun 2015 17:06:44 +0000 (17:06 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 25 Jun 2015 17:06:44 +0000 (17:06 +0000)
* hash-traits.h (ggc_cache_hasher): Rename to...
(ggc_cache_remove): ...this and remove typedefs.
(ggc_cache_ptr_hash): New class.
* hash-table.h: Update commentary.
* emit-rtl.c (const_int_hasher): Inherit from ggc_cache_ptr_hash
rather than ggc_cache_hasher.
(const_wide_int_hasher, reg_attr_hasher): Likewise.
(const_double_hasher, const_fixed_hasher): Likewise.
* function.c (insn_cache_hasher): Likewise.
* trans-mem.c (tm_wrapper_hasher): Likewise.
* tree.h (tree_decl_map_cache_hasher): Likewise.
* tree.c (type_cache_hasher, int_cst_hasher): Likewise.
(cl_option_hasher, tree_vec_map_cache_hasher): Likewise.
* ubsan.c (tree_type_map_cache_hasher): Likewise.
* varasm.c (tm_clone_hasher): Likewise.
* config/i386/i386.c (dllimport_hasher): Likewise.
* config/nvptx/nvptx.c (declared_libfunc_hasher): Likewise.
(tree_hasher): Likewise.

gcc/ada/
* gcc-interface/decl.c (value_annotation_hasher): Inherit from
ggc_cache_ptr_hash rather than ggc_cache_hasher.
* gcc-interface/utils.c (pad_type_hasher): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224960 138bc75d-0d04-0410-961f-82ee72b054a4

15 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/utils.c
gcc/config/i386/i386.c
gcc/config/nvptx/nvptx.c
gcc/emit-rtl.c
gcc/function.c
gcc/hash-table.h
gcc/hash-traits.h
gcc/trans-mem.c
gcc/tree.c
gcc/tree.h
gcc/ubsan.c
gcc/varasm.c

index 9737e4ada5c8ac1fde1ee3dad726521e22f66e04..3f906d8eff60a90e0fbc5105c6dab95b51222b36 100644 (file)
@@ -1,3 +1,24 @@
+2015-06-25  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * hash-traits.h (ggc_cache_hasher): Rename to...
+       (ggc_cache_remove): ...this and remove typedefs.
+       (ggc_cache_ptr_hash): New class.
+       * hash-table.h: Update commentary.
+       * emit-rtl.c (const_int_hasher): Inherit from ggc_cache_ptr_hash
+       rather than ggc_cache_hasher.
+       (const_wide_int_hasher, reg_attr_hasher): Likewise.
+       (const_double_hasher, const_fixed_hasher): Likewise.
+       * function.c (insn_cache_hasher): Likewise.
+       * trans-mem.c (tm_wrapper_hasher): Likewise.
+       * tree.h (tree_decl_map_cache_hasher): Likewise.
+       * tree.c (type_cache_hasher, int_cst_hasher): Likewise.
+       (cl_option_hasher, tree_vec_map_cache_hasher): Likewise.
+       * ubsan.c (tree_type_map_cache_hasher): Likewise.
+       * varasm.c (tm_clone_hasher): Likewise.
+       * config/i386/i386.c (dllimport_hasher): Likewise.
+       * config/nvptx/nvptx.c (declared_libfunc_hasher): Likewise.
+       (tree_hasher): Likewise.
+
 2015-06-25  Richard Sandiford  <richard.sandiford@arm.com>
 
        * hash-traits.h (ggc_hasher): Rename to...
index e4fc125017425d8db1cf0ba7330778a213319882..d07340a459c2e6046f7e522660fe26148b6ea74e 100644 (file)
@@ -1,3 +1,9 @@
+2015-06-25  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * gcc-interface/decl.c (value_annotation_hasher): Inherit from
+       ggc_cache_ptr_hash rather than ggc_cache_hasher.
+       * gcc-interface/utils.c (pad_type_hasher): Likewise.
+
 2015-06-25  Richard Sandiford  <richard.sandiford@arm.com>
 
        * gcc-interface/decl.c (value_annotation_hasher::handle_cache_entry):
index 7511c560814ebb40948dd5a4b28f28709a3bc19e..1c82b6eb9260ee4a58a8c3ef4b8800cc7481e593 100644 (file)
@@ -134,7 +134,7 @@ typedef struct variant_desc_d {
 
 /* A hash table used to cache the result of annotate_value.  */
 
-struct value_annotation_hasher : ggc_cache_hasher<tree_int_map *>
+struct value_annotation_hasher : ggc_cache_ptr_hash<tree_int_map>
 {
   static inline hashval_t
   hash (tree_int_map *m)
index 60446009070c25e28e77b0d92f1ea8429b5b3bbb..f09db5946146448e3cd44eeed8147b6d545228be 100644 (file)
@@ -237,7 +237,7 @@ struct GTY((for_user)) pad_type_hash {
   tree type;
 };
 
-struct pad_type_hasher : ggc_cache_hasher<pad_type_hash *>
+struct pad_type_hasher : ggc_cache_ptr_hash<pad_type_hash>
 {
   static inline hashval_t hash (pad_type_hash *t) { return t->hash; }
   static bool equal (pad_type_hash *a, pad_type_hash *b);
index a05f226ef57d9b16c79bfd9c3b0a6c75bbd42a7c..5c904409bbae1a0fb8ab12b5529d07d1e6b3a762 100644 (file)
@@ -14212,7 +14212,7 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov)
    to symbol DECL if BEIMPORT is true.  Otherwise create or return the
    unique refptr-DECL symbol corresponding to symbol DECL.  */
 
-struct dllimport_hasher : ggc_cache_hasher<tree_map *>
+struct dllimport_hasher : ggc_cache_ptr_hash<tree_map>
 {
   static inline hashval_t hash (tree_map *m) { return m->hash; }
   static inline bool
index 98e7422520ff865a343a385745f1df08d6321a13..af08abefa5e696c99d130dedb4545b83c44c58b8 100644 (file)
@@ -66,7 +66,7 @@
    decls corresponding to them.  */
 static std::stringstream func_decls;
 
-struct declared_libfunc_hasher : ggc_cache_hasher<rtx>
+struct declared_libfunc_hasher : ggc_cache_ptr_hash<rtx_def>
 {
   static hashval_t hash (rtx x) { return htab_hash_pointer (x); }
   static bool equal (rtx a, rtx b) { return a == b; }
@@ -75,7 +75,7 @@ struct declared_libfunc_hasher : ggc_cache_hasher<rtx>
 static GTY((cache))
   hash_table<declared_libfunc_hasher> *declared_libfuncs_htab;
 
-  struct tree_hasher : ggc_cache_hasher<tree>
+struct tree_hasher : ggc_cache_ptr_hash<tree_node>
 {
   static hashval_t hash (tree t) { return htab_hash_pointer (t); }
   static bool equal (tree a, tree b) { return a == b; }
index bab02fe76c58f5661fe5f56c2fe1e60285bf66e3..e7f7eab4fe2d08100369584722a8c0584ba0c09c 100644 (file)
@@ -140,7 +140,7 @@ rtx_insn *invalid_insn_rtx;
 /* A hash table storing CONST_INTs whose absolute value is greater
    than MAX_SAVED_CONST_INT.  */
 
-struct const_int_hasher : ggc_cache_hasher<rtx>
+struct const_int_hasher : ggc_cache_ptr_hash<rtx_def>
 {
   typedef HOST_WIDE_INT compare_type;
 
@@ -150,7 +150,7 @@ struct const_int_hasher : ggc_cache_hasher<rtx>
 
 static GTY ((cache)) hash_table<const_int_hasher> *const_int_htab;
 
-struct const_wide_int_hasher : ggc_cache_hasher<rtx>
+struct const_wide_int_hasher : ggc_cache_ptr_hash<rtx_def>
 {
   static hashval_t hash (rtx x);
   static bool equal (rtx x, rtx y);
@@ -159,7 +159,7 @@ struct const_wide_int_hasher : ggc_cache_hasher<rtx>
 static GTY ((cache)) hash_table<const_wide_int_hasher> *const_wide_int_htab;
 
 /* A hash table storing register attribute structures.  */
-struct reg_attr_hasher : ggc_cache_hasher<reg_attrs *>
+struct reg_attr_hasher : ggc_cache_ptr_hash<reg_attrs>
 {
   static hashval_t hash (reg_attrs *x);
   static bool equal (reg_attrs *a, reg_attrs *b);
@@ -168,7 +168,7 @@ struct reg_attr_hasher : ggc_cache_hasher<reg_attrs *>
 static GTY ((cache)) hash_table<reg_attr_hasher> *reg_attrs_htab;
 
 /* A hash table storing all CONST_DOUBLEs.  */
-struct const_double_hasher : ggc_cache_hasher<rtx>
+struct const_double_hasher : ggc_cache_ptr_hash<rtx_def>
 {
   static hashval_t hash (rtx x);
   static bool equal (rtx x, rtx y);
@@ -177,7 +177,7 @@ struct const_double_hasher : ggc_cache_hasher<rtx>
 static GTY ((cache)) hash_table<const_double_hasher> *const_double_htab;
 
 /* A hash table storing all CONST_FIXEDs.  */
-struct const_fixed_hasher : ggc_cache_hasher<rtx>
+struct const_fixed_hasher : ggc_cache_ptr_hash<rtx_def>
 {
   static hashval_t hash (rtx x);
   static bool equal (rtx x, rtx y);
index f6b7d30b07b82371317d18e52cb57b4216b432ec..cb3e9bb4ca00f54a96970933c4305b19012f4470 100644 (file)
@@ -122,7 +122,7 @@ struct function *cfun = 0;
 
 /* These hashes record the prologue and epilogue insns.  */
 
-struct insn_cache_hasher : ggc_cache_hasher<rtx>
+struct insn_cache_hasher : ggc_cache_ptr_hash<rtx_def>
 {
   static hashval_t hash (rtx x) { return htab_hash_pointer (x); }
   static bool equal (rtx a, rtx b) { return a == b; }
index 3f49345a909eb34b9b2186f72fe1668e8fc4518a..5f3dbede8c16737a658c2e72482c85a224b94644 100644 (file)
@@ -91,7 +91,7 @@ along with GCC; see the file COPYING3.  If not see
    We compose this into a few steps.
 
       1. Decide on a removal policy for values stored in the table.
-         hash-traits.h provides class templates for the three most common
+         hash-traits.h provides class templates for the four most common
          policies:
 
          * typed_free_remove implements the static 'remove' member function
@@ -105,6 +105,13 @@ along with GCC; see the file COPYING3.  If not see
          Use this for garbage-collected data that needs to be preserved across
          collections.
 
+         * ggc_cache_remove is like ggc_remove, except that it does not
+         mark the entries during the normal gc mark phase.  Instead it
+         uses 'keep_cache_entry' (described above) to keep elements that
+         were not collected and delete those that were.  Use this for
+         garbage-collected caches that should not in themselves stop
+         the data from being collected.
+
          You can use these policies by simply deriving the descriptor type
          from one of those class template, with the appropriate argument.
 
index 77f88f30dc643c39cb9fed0a22ac080b6ef1bf68..5fd43f1f54fa902df8317c19ce8c7c105a52397d 100644 (file)
@@ -149,14 +149,12 @@ struct ggc_remove
   }
 };
 
-/* Hasher for cache entry in gc memory.  */
+/* Remover and marker for "cache" entries in gc memory.  These entries can
+   be deleted if there are no non-cache references to the data.  */
 
 template<typename T>
-struct ggc_cache_hasher : ggc_remove<T>
+struct ggc_cache_remove : ggc_remove<T>
 {
-  typedef T value_type;
-  typedef T compare_type;
-
   /* Entries are weakly held because this is for caches.  */
   static void ggc_mx (T &) {}
 
@@ -185,4 +183,11 @@ struct free_ptr_hash : pointer_hash <T>, typed_free_remove <T> {};
 template <typename T>
 struct ggc_ptr_hash : pointer_hash <T>, ggc_remove <T *> {};
 
+/* Traits for elements that point to gc memory.  The elements don't
+   in themselves keep the pointed-to data alive and they can be deleted
+   if the pointed-to data is going to be collected.  */
+
+template <typename T>
+struct ggc_cache_ptr_hash : pointer_hash <T>, ggc_cache_remove <T *> {};
+
 #endif
index b3dbcbd795ca4beb0da7e882fafbad7a8e22e608..9e860ce794262d17f4310d2600e26e20885f24ae 100644 (file)
@@ -471,7 +471,7 @@ build_tm_abort_call (location_t loc, bool is_outer)
 /* Map for aribtrary function replacement under TM, as created
    by the tm_wrap attribute.  */
 
-struct tm_wrapper_hasher : ggc_cache_hasher<tree_map *>
+struct tm_wrapper_hasher : ggc_cache_ptr_hash<tree_map>
 {
   static inline hashval_t hash (tree_map *m) { return m->hash; }
   static inline bool
index 25112467bec89a8dd5ebcda4befab9778af97128..139544d603efda6bbe2ef48885edd4592a1497da 100644 (file)
@@ -196,7 +196,7 @@ struct GTY((for_user)) type_hash {
 /* Initial size of the hash table (rounded to next prime).  */
 #define TYPE_HASH_INITIAL_SIZE 1000
 
-struct type_cache_hasher : ggc_cache_hasher<type_hash *>
+struct type_cache_hasher : ggc_cache_ptr_hash<type_hash>
 {
   static hashval_t hash (type_hash *t) { return t->hash; }
   static bool equal (type_hash *a, type_hash *b);
@@ -220,7 +220,7 @@ static GTY ((cache)) hash_table<type_cache_hasher> *type_hash_table;
 /* Hash table and temporary node for larger integer const values.  */
 static GTY (()) tree int_cst_node;
 
-struct int_cst_hasher : ggc_cache_hasher<tree>
+struct int_cst_hasher : ggc_cache_ptr_hash<tree_node>
 {
   static hashval_t hash (tree t);
   static bool equal (tree x, tree y);
@@ -236,7 +236,7 @@ static GTY ((cache)) hash_table<int_cst_hasher> *int_cst_hash_table;
 static GTY (()) tree cl_optimization_node;
 static GTY (()) tree cl_target_option_node;
 
-struct cl_option_hasher : ggc_cache_hasher<tree>
+struct cl_option_hasher : ggc_cache_ptr_hash<tree_node>
 {
   static hashval_t hash (tree t);
   static bool equal (tree x, tree y);
@@ -253,7 +253,7 @@ static GTY ((cache))
 static GTY ((cache))
      hash_table<tree_decl_map_cache_hasher> *value_expr_for_decl;
 
-struct tree_vec_map_cache_hasher : ggc_cache_hasher<tree_vec_map *>
+struct tree_vec_map_cache_hasher : ggc_cache_ptr_hash<tree_vec_map>
 {
   static hashval_t hash (tree_vec_map *m) { return DECL_UID (m->base.from); }
 
index 51465e25b6172921cb3e5a7c005d8595a17b33ff..250f99d14b325c554e6ef0d9e1bd90b2da85aa69 100644 (file)
@@ -4626,7 +4626,7 @@ extern unsigned int tree_map_hash (const void *);
 extern unsigned int tree_decl_map_hash (const void *);
 #define tree_decl_map_marked_p tree_map_base_marked_p
 
-struct tree_decl_map_cache_hasher : ggc_cache_hasher<tree_decl_map *>
+struct tree_decl_map_cache_hasher : ggc_cache_ptr_hash<tree_decl_map>
 {
   static hashval_t hash (tree_decl_map *m) { return tree_decl_map_hash (m); }
   static bool
index 14e54ef5e703cccee934fe57d9641844dfb05c3a..ded725a55d0480cec1dbc8dbe5447de41df4bd2d 100644 (file)
@@ -83,7 +83,7 @@ struct GTY((for_user)) tree_type_map {
   tree decl;
 };
 
-struct tree_type_map_cache_hasher : ggc_cache_hasher<tree_type_map *>
+struct tree_type_map_cache_hasher : ggc_cache_ptr_hash<tree_type_map>
 {
   static inline hashval_t
   hash (tree_type_map *t)
index 0f87228600bb7c2b1f6b4f581387e3ff988d039b..611b6ca4940924f96f525f2aac739ff8eb05597d 100644 (file)
@@ -5790,7 +5790,7 @@ assemble_alias (tree decl, tree target)
    to its transaction aware clone.  Note that tm_pure functions are
    considered to be their own clone.  */
 
-struct tm_clone_hasher : ggc_cache_hasher<tree_map *>
+struct tm_clone_hasher : ggc_cache_ptr_hash<tree_map>
 {
   static hashval_t hash (tree_map *m) { return tree_map_hash (m); }
   static bool equal (tree_map *a, tree_map *b) { return tree_map_eq (a, b); }