+2015-11-12 Martin Liska <mliska@suse.cz>
+
+ PR ipa/68035
+ * ipa-icf.c (void sem_item::set_hash): New function.
+ (sem_function::get_hash): Use renamed m_hash member variable.
+ (sem_item::update_hash_by_addr_refs): Utilize get_hash.
+ (sem_item::update_hash_by_local_refs): Likewise.
+ (sem_variable::get_hash): Use renamed m_hash member variable.
+ (sem_item_optimizer::update_hash_by_addr_refs): Utilize get_hash.
+ (sem_item_optimizer::build_hash_based_classes): Utilize set_hash.
+ (sem_item_optimizer::build_graph): As the hash value of an item
+ is lazy initialized, force the calculation.
+ * ipa-icf.h (set_hash): Declare new function and rename hash member
+ variable to m_hash.
+
2015-11-12 Richard Biener <rguenther@suse.de>
* tree-vectorizer.h (vect_slp_analyze_data_ref_dependences):
for bitmap memory allocation. */
sem_item::sem_item (sem_item_type _type,
- bitmap_obstack *stack): type(_type), hash(0)
+ bitmap_obstack *stack): type (_type), m_hash (0)
{
setup (stack);
}
sem_item::sem_item (sem_item_type _type, symtab_node *_node,
hashval_t _hash, bitmap_obstack *stack): type(_type),
- node (_node), hash (_hash)
+ node (_node), m_hash (_hash)
{
decl = node->decl;
setup (stack);
#endif
}
+void sem_item::set_hash (hashval_t hash)
+{
+ m_hash = hash;
+}
+
/* Semantic function constructor that uses STACK as bitmap memory stack. */
sem_function::sem_function (bitmap_obstack *stack): sem_item (FUNC, stack),
hashval_t
sem_function::get_hash (void)
{
- if(!hash)
+ if (!m_hash)
{
inchash::hash hstate;
hstate.add_int (177454); /* Random number for function type. */
for (unsigned i = 0; i < bb_sizes.length (); i++)
hstate.add_int (bb_sizes[i]);
-
/* Add common features of declaration itself. */
if (DECL_FUNCTION_SPECIFIC_TARGET (decl))
hstate.add_wide_int
hstate.add_flag (DECL_CXX_CONSTRUCTOR_P (decl));
hstate.add_flag (DECL_CXX_DESTRUCTOR_P (decl));
- hash = hstate.end ();
+ set_hash (hstate.end ());
}
- return hash;
+ return m_hash;
}
/* Return ture if A1 and A2 represent equivalent function attribute lists.
sem_item *> &m_symtab_node_map)
{
ipa_ref* ref;
- inchash::hash hstate (hash);
+ inchash::hash hstate (get_hash ());
for (unsigned i = 0; node->iterate_reference (i, ref); i++)
{
}
}
- hash = hstate.end ();
+ set_hash (hstate.end ());
}
/* Update hash by computed local hash values taken from different
sem_item *> &m_symtab_node_map)
{
ipa_ref* ref;
- inchash::hash state (hash);
+ inchash::hash state (get_hash ());
for (unsigned j = 0; node->iterate_reference (j, ref); j++)
{
sem_item **result = m_symtab_node_map.get (ref->referring);
if (result)
- state.merge_hash ((*result)->hash);
+ state.merge_hash ((*result)->get_hash ());
}
if (type == FUNC)
{
sem_item **result = m_symtab_node_map.get (e->caller);
if (result)
- state.merge_hash ((*result)->hash);
+ state.merge_hash ((*result)->get_hash ());
}
}
hashval_t
sem_variable::get_hash (void)
{
- if (hash)
- return hash;
+ if (m_hash)
+ return m_hash;
/* All WPA streamed in symbols should have their hashes computed at compile
time. At this point, the constructor may not be in memory at all.
if (DECL_SIZE (decl) && tree_fits_shwi_p (DECL_SIZE (decl)))
hstate.add_wide_int (tree_to_shwi (DECL_SIZE (decl)));
add_expr (ctor, hstate);
- hash = hstate.end ();
+ set_hash (hstate.end ());
- return hash;
+ return m_hash;
}
/* Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can
{
tree class_type
= TYPE_METHOD_BASETYPE (TREE_TYPE (m_items[i]->decl));
- inchash::hash hstate (m_items[i]->hash);
+ inchash::hash hstate (m_items[i]->get_hash ());
if (TYPE_NAME (class_type)
&& DECL_ASSEMBLER_NAME_SET_P (TYPE_NAME (class_type)))
(IDENTIFIER_HASH_VALUE
(DECL_ASSEMBLER_NAME (TYPE_NAME (class_type))));
- m_items[i]->hash = hstate.end ();
+ m_items[i]->set_hash (hstate.end ());
}
}
}
/* Global hash value replace current hash values. */
for (unsigned i = 0; i < m_items.length (); i++)
- m_items[i]->hash = m_items[i]->global_hash;
+ m_items[i]->set_hash (m_items[i]->global_hash);
}
/* Congruence classes are built by hash value. */
{
sem_item *item = m_items[i];
- congruence_class_group *group = get_group_by_hash (item->hash,
+ congruence_class_group *group = get_group_by_hash (item->get_hash (),
item->type);
if (!group->classes.length ())
{
sem_item *item = m_items[i];
m_symtab_node_map.put (item->node, item);
+
+ /* Initialize hash values if we are not in LTO mode. */
+ if (!in_lto_p)
+ item->get_hash ();
}
for (unsigned i = 0; i < m_items.length (); i++)