/* Constructor for key value pair, where _ITEM is key and _INDEX is a target. */
-sem_usage_pair::sem_usage_pair (sem_item *_item, unsigned int _index):
- item (_item), index (_index)
+sem_usage_pair::sem_usage_pair (sem_item *_item, unsigned int _index)
+: item (_item), index (_index)
{
}
-/* Semantic item constructor for a node of _TYPE, where STACK is used
- for bitmap memory allocation. */
-
-sem_item::sem_item (sem_item_type _type,
- bitmap_obstack *stack): type(_type), hash(0)
+sem_item::sem_item (sem_item_type _type, bitmap_obstack *stack)
+: type(_type), hash(-1), m_hash_set (false)
{
setup (stack);
}
with computed _HASH. */
sem_item::sem_item (sem_item_type _type, symtab_node *_node,
- hashval_t _hash, bitmap_obstack *stack): type(_type),
- node (_node), hash (_hash)
+ bitmap_obstack *stack)
+: type(_type), node (_node), hash (-1), m_hash_set (false)
{
decl = node->decl;
setup (stack);
#endif
}
+void sem_item::set_hash (hashval_t h)
+{
+ hash = h;
+ m_hash_set = true;
+}
+
/* Semantic function constructor that uses STACK as bitmap memory stack. */
sem_function::sem_function (bitmap_obstack *stack): sem_item (FUNC, stack),
bb_sorted.create (0);
}
-/* Constructor based on callgraph node _NODE with computed hash _HASH.
- Bitmap STACK is used for memory allocation. */
-sem_function::sem_function (cgraph_node *node, hashval_t hash,
- bitmap_obstack *stack):
- sem_item (FUNC, node, hash, stack),
- m_checker (NULL), m_compared_func (NULL)
+sem_function::sem_function (cgraph_node *node, bitmap_obstack *stack)
+: sem_item (FUNC, node, stack), m_checker (NULL), m_compared_func (NULL)
{
bb_sizes.create (0);
bb_sorted.create (0);
hashval_t
sem_function::get_hash (void)
{
- if(!hash)
+ if(!m_hash_set)
{
inchash::hash hstate;
hstate.add_int (177454); /* Random number for function type. */
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;
|| DECL_STATIC_DESTRUCTOR (node->decl))
return NULL;
- sem_function *f = new sem_function (node, 0, stack);
+ sem_function *f = new sem_function (node, stack);
f->init ();
return (*bb_dict)[source] == target;
}
-
-/* Semantic variable constructor that uses STACK as bitmap memory stack. */
-
sem_variable::sem_variable (bitmap_obstack *stack): sem_item (VAR, stack)
{
}
-/* Constructor based on varpool node _NODE with computed hash _HASH.
- Bitmap STACK is used for memory allocation. */
-
-sem_variable::sem_variable (varpool_node *node, hashval_t _hash,
- bitmap_obstack *stack): sem_item(VAR,
- node, _hash, stack)
+sem_variable::sem_variable (varpool_node *node, bitmap_obstack *stack)
+: sem_item (VAR, node, stack)
{
gcc_checking_assert (node);
gcc_checking_assert (get_node ());
|| node->alias)
return NULL;
- sem_variable *v = new sem_variable (node, 0, stack);
+ sem_variable *v = new sem_variable (node, stack);
v->init ();
hashval_t
sem_variable::get_hash (void)
{
- if (hash)
+ if (m_hash_set)
return hash;
/* All WPA streamed in symbols should have their hashes computed at compile
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;
}
unsigned int sem_item_optimizer::class_id = 0;
-sem_item_optimizer::sem_item_optimizer (): worklist (0), m_classes (0),
- m_classes_count (0), m_cgraph_node_hooks (NULL), m_varpool_node_hooks (NULL)
+sem_item_optimizer::sem_item_optimizer ()
+: worklist (0), m_classes (0), m_classes_count (0), m_cgraph_node_hooks (NULL),
+ m_varpool_node_hooks (NULL)
{
m_items.create (0);
bitmap_obstack_initialize (&m_bmstack);
{
cgraph_node *cnode = dyn_cast <cgraph_node *> (node);
- m_items.safe_push (new sem_function (cnode, hash, &m_bmstack));
+ sem_function *fn = new sem_function (cnode, &m_bmstack);
+ fn->set_hash (hash);
+ m_items.safe_push (fn);
}
else
{
varpool_node *vnode = dyn_cast <varpool_node *> (node);
- m_items.safe_push (new sem_variable (vnode, hash, &m_bmstack));
+ sem_variable *var = new sem_variable (vnode, &m_bmstack);
+ var->set_hash (hash);
+ m_items.safe_push (var);
}
}
{
tree class_type
= method_class_type (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 (sem_item_type _type, bitmap_obstack *stack);
/* Semantic item constructor for a node of _TYPE, where STACK is used
- for bitmap memory allocation. The item is based on symtab node _NODE
- with computed _HASH. */
- sem_item (sem_item_type _type, symtab_node *_node, hashval_t _hash,
- bitmap_obstack *stack);
+ for bitmap memory allocation. The item is based on symtab node _NODE. */
+ sem_item (sem_item_type _type, symtab_node *_node, bitmap_obstack *stack);
virtual ~sem_item ();
/* References independent hash function. */
virtual hashval_t get_hash (void) = 0;
+ /* Set new hash value of the item. */
+ void set_hash (hashval_t hash);
+
/* Merges instance with an ALIAS_ITEM, where alias, thunk or redirection can
be applied. */
virtual bool merge (sem_item *alias_item) = 0;
/* A set with symbol table references. */
hash_set <symtab_node *> refs_set;
- /* Hash of item. */
- hashval_t hash;
-
/* Temporary hash used where hash values of references are added. */
hashval_t global_hash;
protected:
symtab_node *n1, symtab_node *n2,
bool address);
+ /* Hash of item. */
+ hashval_t hash;
+
+ /* Indicated whether a hash value has been set or not. */
+ bool m_hash_set;
+
private:
/* Initialize internal data structures. Bitmap STACK is used for
bitmap memory allocation process. */
/* Semantic function constructor that uses STACK as bitmap memory stack. */
sem_function (bitmap_obstack *stack);
- /* Constructor based on callgraph node _NODE with computed hash _HASH.
+ /* Constructor based on callgraph node _NODE.
Bitmap STACK is used for memory allocation. */
- sem_function (cgraph_node *_node, hashval_t _hash, bitmap_obstack *stack);
+ sem_function (cgraph_node *_node, bitmap_obstack *stack);
~sem_function ();
/* Semantic variable constructor that uses STACK as bitmap memory stack. */
sem_variable (bitmap_obstack *stack);
- /* Constructor based on callgraph node _NODE with computed hash _HASH.
+ /* Constructor based on callgraph node _NODE.
Bitmap STACK is used for memory allocation. */
- sem_variable (varpool_node *_node, hashval_t _hash, bitmap_obstack *stack);
+ sem_variable (varpool_node *_node, bitmap_obstack *stack);
inline virtual void init_wpa (void) {}