]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
destroy values as well as keys when removing them from hash maps
authortbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Nov 2015 11:46:10 +0000 (11:46 +0000)
committertbsaunde <tbsaunde@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Nov 2015 11:46:10 +0000 (11:46 +0000)
gcc/ChangeLog:

2015-11-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

* hash-map-traits.h (simple_hashmap_traits ::remove): call
destructors on values that are being removed.
* mem-stats.h (hash_map): Pass type of values to
simple_hashmap_traits.
* tree-sra.c (sra_deinitialize): Remove work around for hash
maps not destructing values.
* genmatch.c (sinfo_hashmap_traits): Adjust.
* tree-ssa-uncprop.c (val_ssa_equiv_hash_traits): Likewise.

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

gcc/ChangeLog
gcc/genmatch.c
gcc/hash-map-traits.h
gcc/mem-stats.h
gcc/tree-sra.c
gcc/tree-ssa-uncprop.c

index cffa083cea49b9b5a0796aa0204868e03fafd35a..452f724765fb3ffe9d4763095f9b5dd8b5a77641 100644 (file)
@@ -1,3 +1,14 @@
+2015-11-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
+
+       * hash-map-traits.h (simple_hashmap_traits ::remove): call
+       destructors on values that are being removed.
+       * mem-stats.h (hash_map): Pass type of values to
+       simple_hashmap_traits.
+       * tree-sra.c (sra_deinitialize): Remove work around for hash
+       maps not destructing values.
+       * genmatch.c (sinfo_hashmap_traits): Adjust.
+       * tree-ssa-uncprop.c (val_ssa_equiv_hash_traits): Likewise.
+
 2015-11-24  Richard Biener  <rguenther@suse.de>
             Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
index 3a20a48b49774fec8b0d6250a396aefffcbea22e..76c8f1fa1e260e1f550d3d541e959d51947aa013 100644 (file)
@@ -1397,7 +1397,8 @@ struct sinfo
   unsigned cnt;
 };
 
-struct sinfo_hashmap_traits : simple_hashmap_traits <pointer_hash <dt_simplify> >
+struct sinfo_hashmap_traits : simple_hashmap_traits<pointer_hash<dt_simplify>,
+                                                   sinfo *>
 {
   static inline hashval_t hash (const key_type &);
   static inline bool equal_keys (const key_type &, const key_type &);
index 2225426e365caac7832c4dd79ae15485ed292954..773ac1b3a9e178c5a1ed8611fa2b7d27c05fd77b 100644 (file)
@@ -28,7 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 /* 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>
+template <typename H, typename Value>
 struct simple_hashmap_traits
 {
   typedef typename H::value_type key_type;
@@ -41,56 +41,58 @@ struct simple_hashmap_traits
   template <typename T> static inline void mark_deleted (T &);
 };
 
-template <typename H>
+template <typename H, typename Value>
 inline hashval_t
-simple_hashmap_traits <H>::hash (const key_type &h)
+simple_hashmap_traits <H, Value>::hash (const key_type &h)
 {
   return H::hash (h);
 }
 
-template <typename H>
+template <typename H, typename Value>
 inline bool
-simple_hashmap_traits <H>::equal_keys (const key_type &k1, const key_type &k2)
+simple_hashmap_traits <H, Value>::equal_keys (const key_type &k1,
+                                             const key_type &k2)
 {
   return H::equal (k1, k2);
 }
 
-template <typename H>
+template <typename H, typename Value>
 template <typename T>
 inline void
-simple_hashmap_traits <H>::remove (T &entry)
+simple_hashmap_traits <H, Value>::remove (T &entry)
 {
   H::remove (entry.m_key);
+  entry.m_value.~Value ();
 }
 
-template <typename H>
+template <typename H, typename Value>
 template <typename T>
 inline bool
-simple_hashmap_traits <H>::is_empty (const T &entry)
+simple_hashmap_traits <H, Value>::is_empty (const T &entry)
 {
   return H::is_empty (entry.m_key);
 }
 
-template <typename H>
+template <typename H, typename Value>
 template <typename T>
 inline bool
-simple_hashmap_traits <H>::is_deleted (const T &entry)
+simple_hashmap_traits <H, Value>::is_deleted (const T &entry)
 {
   return H::is_deleted (entry.m_key);
 }
 
-template <typename H>
+template <typename H, typename Value>
 template <typename T>
 inline void
-simple_hashmap_traits <H>::mark_empty (T &entry)
+simple_hashmap_traits <H, Value>::mark_empty (T &entry)
 {
   H::mark_empty (entry.m_key);
 }
 
-template <typename H>
+template <typename H, typename Value>
 template <typename T>
 inline void
-simple_hashmap_traits <H>::mark_deleted (T &entry)
+simple_hashmap_traits <H, Value>::mark_deleted (T &entry)
 {
   H::mark_deleted (entry.m_key);
 }
index a6489b500686767b410fb32bfbde84e7e213c545..2c68ca752ebd5f712a64346dacd3196b6987676c 100644 (file)
@@ -3,7 +3,8 @@
 
 /* Forward declaration.  */
 template<typename Key, typename Value,
-        typename Traits = simple_hashmap_traits<default_hash_traits<Key> > >
+        typename Traits = simple_hashmap_traits<default_hash_traits<Key>,
+                                                Value> >
 class hash_map;
 
 #define LOCATION_LINE_EXTRA_SPACE 30
index 2835c993588bc73491d193e105109172d95cd5ae..c4fea5b0c4d0e2e2c281ec7e9db310acbb17410f 100644 (file)
@@ -674,12 +674,6 @@ sra_deinitialize (void)
   assign_link_pool.release ();
   obstack_free (&name_obstack, NULL);
 
-  /* TODO: hash_map does not support traits that can release
-     value type of the hash_map.  */
-  for (hash_map<tree, auto_vec<access_p> >::iterator it =
-       base_access_vec->begin (); it != base_access_vec->end (); ++it)
-    (*it).second.release ();
-
   delete base_access_vec;
 }
 
index be6c209d7a40d9b165ceaf1e03837bbae7137062..23b4ca2a008ffb0330b2b9a6459a868f90524a20 100644 (file)
@@ -277,7 +277,8 @@ struct equiv_hash_elt
 
 /* Value to ssa name equivalence hashtable helpers.  */
 
-struct val_ssa_equiv_hash_traits : simple_hashmap_traits <tree_operand_hash>
+struct val_ssa_equiv_hash_traits : simple_hashmap_traits <tree_operand_hash,
+                                                         vec<tree> >
 {
   template<typename T> static inline void remove (T &);
 };