+2020-01-14 David Malcolm <dmalcolm@redhat.com>
+
+ * attribs.c (excl_hash_traits::empty_zero_p): New static constant.
+ * gcov.c (function_start_pair_hash::empty_zero_p): Likewise.
+ * graphite.c (struct sese_scev_hash::empty_zero_p): Likewise.
+ * hash-map-tests.c (selftest::test_nonzero_empty_key): New selftest.
+ (selftest::hash_map_tests_c_tests): Call it.
+ * hash-map-traits.h (simple_hashmap_traits::empty_zero_p):
+ New static constant, using the value of = H::empty_zero_p.
+ (unbounded_hashmap_traits::empty_zero_p): Likewise, using the value
+ from default_hash_traits <Value>.
+ * hash-map.h (hash_map::empty_zero_p): Likewise, using the value
+ from Traits.
+ * hash-set-tests.c (value_hash_traits::empty_zero_p): Likewise.
+ * hash-table.h (hash_table::alloc_entries): Guard the loop of
+ calls to mark_empty with !Descriptor::empty_zero_p.
+ (hash_table::empty_slow): Conditionalize the memset call with a
+ check that Descriptor::empty_zero_p; otherwise, loop through the
+ entries calling mark_empty on them.
+ * hash-traits.h (int_hash::empty_zero_p): New static constant.
+ (pointer_hash::empty_zero_p): Likewise.
+ (pair_hash::empty_zero_p): Likewise.
+ * ipa-devirt.c (default_hash_traits <type_pair>::empty_zero_p):
+ Likewise.
+ * ipa-prop.c (ipa_bit_ggc_hash_traits::empty_zero_p): Likewise.
+ (ipa_vr_ggc_hash_traits::empty_zero_p): Likewise.
+ * profile.c (location_triplet_hash::empty_zero_p): Likewise.
+ * sanopt.c (sanopt_tree_triplet_hash::empty_zero_p): Likewise.
+ (sanopt_tree_couple_hash::empty_zero_p): Likewise.
+ * tree-hasher.h (int_tree_hasher::empty_zero_p): Likewise.
+ * tree-ssa-sccvn.c (vn_ssa_aux_hasher::empty_zero_p): Likewise.
+ * tree-vect-slp.c (bst_traits::empty_zero_p): Likewise.
+ * tree-vectorizer.h
+ (default_hash_traits<scalar_cond_masked_key>::empty_zero_p):
+ Likewise.
+
2020-01-14 Kewen Lin <linkw@gcc.gnu.org>
* cfgloopanal.c (average_num_loop_insns): Free bbs when early return,
x = value_type (NULL, NULL);
}
+ static const bool empty_zero_p = false;
+
static void mark_empty (value_type &x)
{
x = value_type ("", "");
+2020-01-14 David Malcolm <dmalcolm@redhat.com>
+
+ * cp-gimplify.c (source_location_table_entry_hash::empty_zero_p):
+ New static constant.
+ * cp-tree.h (named_decl_hash::empty_zero_p): Likewise.
+ (struct named_label_hash::empty_zero_p): Likewise.
+ * decl2.c (mangled_decl_hash::empty_zero_p): Likewise.
+
2020-01-14 Jason Merrill <jason@redhat.com>
PR c++/92594 - ICE with inherited trivial default ctor.
ref.var = NULL_TREE;
}
+ static const bool empty_zero_p = true;
+
static void
mark_empty (source_location_table_entry &ref)
{
inline static hashval_t hash (const value_type decl);
inline static bool equal (const value_type existing, compare_type candidate);
+ static const bool empty_zero_p = true;
static inline void mark_empty (value_type &p) {p = NULL_TREE;}
static inline bool is_empty (value_type p) {return !p;}
inline static hashval_t hash (value_type);
inline static bool equal (const value_type, compare_type);
+ static const bool empty_zero_p = true;
inline static void mark_empty (value_type &p) {p = NULL;}
inline static bool is_empty (value_type p) {return !p;}
return candidate == name;
}
+ static const bool empty_zero_p = true;
static inline void mark_empty (value_type &p) {p = NULL_TREE;}
static inline bool is_empty (value_type p) {return !p;}
ref.start_line = ~1U;
}
+ static const bool empty_zero_p = false;
+
static void
mark_empty (function_start &ref)
{
&& operand_equal_p (key1.expr, key2.expr, 0));
}
static void mark_deleted (seir_cache_key &key) { key.expr = NULL_TREE; }
+ static const bool empty_zero_p = false;
static void mark_empty (seir_cache_key &key) { key.entry_dest = 0; }
static bool is_deleted (const seir_cache_key &key) { return !key.expr; }
static bool is_empty (const seir_cache_key &key) { return key.entry_dest == 0; }
}
}
+/* Test calling empty on a hash_map that has a key type with non-zero
+ "empty" value. */
+
+static void
+test_nonzero_empty_key ()
+{
+ typedef int_hash<int, INT_MIN, INT_MAX> IntHash;
+ hash_map<int, int, simple_hashmap_traits<IntHash, int> > x;
+
+ for (int i = 1; i != 32; ++i)
+ x.put (i, i);
+
+ ASSERT_EQ (x.get (0), NULL);
+ ASSERT_EQ (*x.get (1), 1);
+
+ x.empty ();
+
+ ASSERT_EQ (x.get (0), NULL);
+ ASSERT_EQ (x.get (1), NULL);
+}
+
/* Run all of the selftests within this file. */
void
test_map_of_strings_to_int ();
test_map_of_int_to_strings ();
test_map_of_type_with_ctor_and_dtor ();
+ test_nonzero_empty_key ();
}
} // namespace selftest
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 &);
+ static const bool empty_zero_p = H::empty_zero_p;
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 &);
struct unbounded_hashmap_traits
{
template <typename T> static inline void remove (T &);
+ static const bool empty_zero_p = default_hash_traits <Value>::empty_zero_p;
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 &);
return Traits::is_deleted (e);
}
+ static const bool empty_zero_p = Traits::empty_zero_p;
static void mark_empty (hash_entry &e) { Traits::mark_empty (e); }
static bool is_empty (const hash_entry &e) { return Traits::is_empty (e); }
base_type::mark_deleted (v.val);
}
+ static const bool empty_zero_p = false;
+
static void mark_empty (value_type &v)
{
base_type::mark_empty (v.val);
nentries = ::ggc_cleared_vec_alloc<value_type> (n PASS_MEM_STAT);
gcc_assert (nentries != NULL);
- for (size_t i = 0; i < n; i++)
- mark_empty (nentries[i]);
+ if (!Descriptor::empty_zero_p)
+ for (size_t i = 0; i < n; i++)
+ mark_empty (nentries[i]);
return nentries;
}
m_size = nsize;
m_size_prime_index = nindex;
}
- else
+ else if (Descriptor::empty_zero_p)
memset ((void *) entries, 0, size * sizeof (value_type));
+ else
+ for (size_t i = 0; i < size; i++)
+ mark_empty (entries[i]);
m_n_deleted = 0;
m_n_elements = 0;
static inline hashval_t hash (value_type);
static inline bool equal (value_type existing, value_type candidate);
static inline void mark_deleted (Type &);
+ static const bool empty_zero_p = Empty == 0;
static inline void mark_empty (Type &);
static inline bool is_deleted (Type);
static inline bool is_empty (Type);
static inline bool equal (const value_type &existing,
const compare_type &candidate);
static inline void mark_deleted (Type *&);
+ static const bool empty_zero_p = true;
static inline void mark_empty (Type *&);
static inline bool is_deleted (Type *);
static inline bool is_empty (Type *);
static inline bool equal (const value_type &, const compare_type &);
static inline void remove (value_type &);
static inline void mark_deleted (value_type &);
+ static const bool empty_zero_p = T1::empty_zero_p;
static inline void mark_empty (value_type &);
static inline bool is_deleted (const value_type &);
static inline bool is_empty (const value_type &);
{
return TYPE_UID (p.first) ^ TYPE_UID (p.second);
}
+ static const bool empty_zero_p = true;
static bool
is_empty (type_pair p)
{
{
return a->value == b->value && a->mask == b->mask;
}
+ static const bool empty_zero_p = true;
static void
mark_empty (ipa_bits *&p)
{
{
return a->equal_p (*b);
}
+ static const bool empty_zero_p = true;
static void
mark_empty (value_range *&p)
{
ref.lineno = -1;
}
+ static const bool empty_zero_p = false;
+
static void
mark_empty (location_triplet &ref)
{
ref.t1 = reinterpret_cast<tree> (1);
}
+ static const bool empty_zero_p = true;
+
static void
mark_empty (sanopt_tree_triplet &ref)
{
ref.ptr = reinterpret_cast<tree> (1);
}
+ static const bool empty_zero_p = true;
+
static void
mark_empty (sanopt_tree_couple &ref)
{
}
static void mark_deleted (value_type &v) { v.to = reinterpret_cast<tree> (0x1); }
static bool is_empty (const value_type &v) { return v.to == NULL; }
+ static const bool empty_zero_p = true;
static void mark_empty (value_type &v) { v.to = NULL; }
static void remove (value_type &) {}
};
static inline hashval_t hash (const value_type &);
static inline bool equal (const value_type &, const compare_type &);
static inline void mark_deleted (value_type &) {}
+ static const bool empty_zero_p = true;
static inline void mark_empty (value_type &e) { e = NULL; }
static inline bool is_deleted (value_type &) { return false; }
static inline bool is_empty (value_type &e) { return e == NULL; }
static inline bool equal (value_type existing, value_type candidate);
static inline bool is_empty (value_type x) { return !x.exists (); }
static inline bool is_deleted (value_type x) { return !x.exists (); }
+ static const bool empty_zero_p = true;
static inline void mark_empty (value_type &x) { x.release (); }
static inline void mark_deleted (value_type &x) { x.release (); }
static inline void remove (value_type &x) { x.release (); }
&& operand_equal_p (existing.op1, candidate.op1, 0));
}
+ static const bool empty_zero_p = true;
+
static inline void
mark_empty (value_type &v)
{