Commit fedf2718 by Martin Liska Committed by Martin Liska

Add sem_item::m_hash_set (PR ipa/78309)

	PR ipa/78309
	* ipa-icf.c (void sem_item::set_hash): Update m_hash_set.
	(sem_function::get_hash): Use the new field.
	(sem_function::parse): Remove an argument from ctor.
	(sem_variable::parse): Likewise.
	(sem_variable::get_hash): Use the new field.
	(sem_item_optimizer::read_section): Use new ctor and set hash.
	* ipa-icf.h: _hash is removed from sem_item::sem_item,
	sem_variable::sem_variable, sem_function::sem_function.

From-SVN: r242687
parent 876f7313
2016-11-22 Martin Liska <mliska@suse.cz>
PR ipa/78309
* ipa-icf.c (void sem_item::set_hash): Update m_hash_set.
(sem_function::get_hash): Use the new field.
(sem_function::parse): Remove an argument from ctor.
(sem_variable::parse): Likewise.
(sem_variable::get_hash): Use the new field.
(sem_item_optimizer::read_section): Use new ctor and set hash.
* ipa-icf.h: _hash is removed from sem_item::sem_item,
sem_variable::sem_variable, sem_function::sem_function.
2016-11-21 Jeff Law <law@redhat.com> 2016-11-21 Jeff Law <law@redhat.com>
PR target/68538 PR target/68538
...@@ -131,27 +131,20 @@ symbol_compare_collection::symbol_compare_collection (symtab_node *node) ...@@ -131,27 +131,20 @@ symbol_compare_collection::symbol_compare_collection (symtab_node *node)
/* Constructor for key value pair, where _ITEM is key and _INDEX is a target. */ /* 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): sem_usage_pair::sem_usage_pair (sem_item *_item, unsigned int _index)
item (_item), index (_index) : item (_item), index (_index)
{ {
} }
/* Semantic item constructor for a node of _TYPE, where STACK is used sem_item::sem_item (sem_item_type _type, bitmap_obstack *stack)
for bitmap memory allocation. */ : type (_type), m_hash (-1), m_hash_set (false)
sem_item::sem_item (sem_item_type _type,
bitmap_obstack *stack): type (_type), m_hash (0)
{ {
setup (stack); setup (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 (sem_item_type _type, symtab_node *_node, sem_item::sem_item (sem_item_type _type, symtab_node *_node,
hashval_t _hash, bitmap_obstack *stack): type(_type), bitmap_obstack *stack)
node (_node), m_hash (_hash) : type (_type), node (_node), m_hash (-1), m_hash_set (false)
{ {
decl = node->decl; decl = node->decl;
setup (stack); setup (stack);
...@@ -230,23 +223,20 @@ sem_item::target_supports_symbol_aliases_p (void) ...@@ -230,23 +223,20 @@ sem_item::target_supports_symbol_aliases_p (void)
void sem_item::set_hash (hashval_t hash) void sem_item::set_hash (hashval_t hash)
{ {
m_hash = hash; m_hash = hash;
m_hash_set = true;
} }
/* Semantic function constructor that uses STACK as bitmap memory stack. */ /* Semantic function constructor that uses STACK as bitmap memory stack. */
sem_function::sem_function (bitmap_obstack *stack): sem_item (FUNC, stack), sem_function::sem_function (bitmap_obstack *stack)
m_checker (NULL), m_compared_func (NULL) : sem_item (FUNC, stack), m_checker (NULL), m_compared_func (NULL)
{ {
bb_sizes.create (0); bb_sizes.create (0);
bb_sorted.create (0); bb_sorted.create (0);
} }
/* Constructor based on callgraph node _NODE with computed hash _HASH. sem_function::sem_function (cgraph_node *node, bitmap_obstack *stack)
Bitmap STACK is used for memory allocation. */ : sem_item (FUNC, node, stack), m_checker (NULL), m_compared_func (NULL)
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)
{ {
bb_sizes.create (0); bb_sizes.create (0);
bb_sorted.create (0); bb_sorted.create (0);
...@@ -279,7 +269,7 @@ sem_function::get_bb_hash (const sem_bb *basic_block) ...@@ -279,7 +269,7 @@ sem_function::get_bb_hash (const sem_bb *basic_block)
hashval_t hashval_t
sem_function::get_hash (void) sem_function::get_hash (void)
{ {
if (!m_hash) if (!m_hash_set)
{ {
inchash::hash hstate; inchash::hash hstate;
hstate.add_int (177454); /* Random number for function type. */ hstate.add_int (177454); /* Random number for function type. */
...@@ -1704,7 +1694,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack *stack) ...@@ -1704,7 +1694,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack *stack)
|| DECL_STATIC_DESTRUCTOR (node->decl)) || DECL_STATIC_DESTRUCTOR (node->decl))
return NULL; return NULL;
sem_function *f = new sem_function (node, 0, stack); sem_function *f = new sem_function (node, stack);
f->init (); f->init ();
...@@ -1807,19 +1797,12 @@ sem_function::bb_dict_test (vec<int> *bb_dict, int source, int target) ...@@ -1807,19 +1797,12 @@ sem_function::bb_dict_test (vec<int> *bb_dict, int source, int target)
return (*bb_dict)[source] == target; 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) sem_variable::sem_variable (bitmap_obstack *stack): sem_item (VAR, stack)
{ {
} }
/* Constructor based on varpool node _NODE with computed hash _HASH. sem_variable::sem_variable (varpool_node *node, bitmap_obstack *stack)
Bitmap STACK is used for memory allocation. */ : sem_item (VAR, node, stack)
sem_variable::sem_variable (varpool_node *node, hashval_t _hash,
bitmap_obstack *stack): sem_item(VAR,
node, _hash, stack)
{ {
gcc_checking_assert (node); gcc_checking_assert (node);
gcc_checking_assert (get_node ()); gcc_checking_assert (get_node ());
...@@ -2104,7 +2087,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) ...@@ -2104,7 +2087,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack)
|| node->alias) || node->alias)
return NULL; return NULL;
sem_variable *v = new sem_variable (node, 0, stack); sem_variable *v = new sem_variable (node, stack);
v->init (); v->init ();
...@@ -2116,7 +2099,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) ...@@ -2116,7 +2099,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack)
hashval_t hashval_t
sem_variable::get_hash (void) sem_variable::get_hash (void)
{ {
if (m_hash) if (m_hash_set)
return m_hash; return m_hash;
/* All WPA streamed in symbols should have their hashes computed at compile /* All WPA streamed in symbols should have their hashes computed at compile
...@@ -2296,8 +2279,9 @@ sem_variable::dump_to_file (FILE *file) ...@@ -2296,8 +2279,9 @@ sem_variable::dump_to_file (FILE *file)
unsigned int sem_item_optimizer::class_id = 0; unsigned int sem_item_optimizer::class_id = 0;
sem_item_optimizer::sem_item_optimizer (): worklist (0), m_classes (0), sem_item_optimizer::sem_item_optimizer ()
m_classes_count (0), m_cgraph_node_hooks (NULL), m_varpool_node_hooks (NULL) : worklist (0), m_classes (0), m_classes_count (0), m_cgraph_node_hooks (NULL),
m_varpool_node_hooks (NULL)
{ {
m_items.create (0); m_items.create (0);
bitmap_obstack_initialize (&m_bmstack); bitmap_obstack_initialize (&m_bmstack);
...@@ -2417,13 +2401,17 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, ...@@ -2417,13 +2401,17 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data,
{ {
cgraph_node *cnode = dyn_cast <cgraph_node *> (node); 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 else
{ {
varpool_node *vnode = dyn_cast <varpool_node *> (node); 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);
} }
} }
......
...@@ -151,10 +151,8 @@ public: ...@@ -151,10 +151,8 @@ public:
sem_item (sem_item_type _type, bitmap_obstack *stack); sem_item (sem_item_type _type, bitmap_obstack *stack);
/* Semantic item constructor for a node of _TYPE, where STACK is used /* Semantic item constructor for a node of _TYPE, where STACK is used
for bitmap memory allocation. The item is based on symtab node _NODE for bitmap memory allocation. The item is based on symtab node _NODE. */
with computed _HASH. */ sem_item (sem_item_type _type, symtab_node *_node, bitmap_obstack *stack);
sem_item (sem_item_type _type, symtab_node *_node, hashval_t _hash,
bitmap_obstack *stack);
virtual ~sem_item (); virtual ~sem_item ();
...@@ -274,6 +272,9 @@ protected: ...@@ -274,6 +272,9 @@ protected:
/* Hash of item. */ /* Hash of item. */
hashval_t m_hash; hashval_t m_hash;
/* Indicated whether a hash value has been set or not. */
bool m_hash_set;
private: private:
/* Initialize internal data structures. Bitmap STACK is used for /* Initialize internal data structures. Bitmap STACK is used for
bitmap memory allocation process. */ bitmap memory allocation process. */
...@@ -286,9 +287,9 @@ public: ...@@ -286,9 +287,9 @@ public:
/* Semantic function constructor that uses STACK as bitmap memory stack. */ /* Semantic function constructor that uses STACK as bitmap memory stack. */
sem_function (bitmap_obstack *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. */ 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 (); ~sem_function ();
...@@ -394,10 +395,10 @@ public: ...@@ -394,10 +395,10 @@ public:
/* Semantic variable constructor that uses STACK as bitmap memory stack. */ /* Semantic variable constructor that uses STACK as bitmap memory stack. */
sem_variable (bitmap_obstack *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. */ 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) {} inline virtual void init_wpa (void) {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment