Message ID | edda86e9-23d6-c261-87ed-0b805f386b2f@suse.cz |
---|---|
State | New |
Headers | show |
> On 11/21/2016 04:50 PM, Jan Hubicka wrote: > > OK, > > thanks! > > Honza > > Hi. > > Patch to trunk is already installed. Equal patch can be installed to gcc-6 branch, > however gcc-5 branch needs more hunks to be adjusted. I did so, both patches survive > regression tests and the patch for gcc-5 provides equal results for gimp w/ -flto and -O2. > > Ready to be installed to both branches? OK, thanks! Honza > Thanks, > Martin > >From 4a1dfd4ef43e9bf5fe7c9252a5d9e48cc1d9d444 Mon Sep 17 00:00:00 2001 > From: marxin <mliska@suse.cz> > Date: Tue, 22 Nov 2016 11:06:37 +0100 > Subject: [PATCH] [PATCH] Add sem_item::m_hash_set (PR ipa/78309) > > gcc/ChangeLog: > > 2016-11-16 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. > --- > gcc/ipa-icf.c | 73 ++++++++++++++++++++++++++++------------------------------- > gcc/ipa-icf.h | 26 ++++++++++++--------- > 2 files changed, 50 insertions(+), 49 deletions(-) > > diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c > index 729bc06..216e4ed 100644 > --- a/gcc/ipa-icf.c > +++ b/gcc/ipa-icf.c > @@ -172,16 +172,13 @@ symbol_compare_collection::symbol_compare_collection (symtab_node *node) > > /* 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); > } > @@ -191,8 +188,8 @@ sem_item::sem_item (sem_item_type _type, > 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); > @@ -268,6 +265,12 @@ sem_item::target_supports_symbol_aliases_p (void) > #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), > @@ -277,12 +280,8 @@ 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); > @@ -315,7 +314,7 @@ sem_function::get_bb_hash (const sem_bb *basic_block) > 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. */ > @@ -345,7 +344,7 @@ sem_function::get_hash (void) > 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; > @@ -1533,7 +1532,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack *stack) > || 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 (); > > @@ -1637,19 +1636,12 @@ sem_function::bb_dict_test (vec<int> *bb_dict, int source, int 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) > { > } > > -/* 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 ()); > @@ -1947,7 +1939,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) > || node->alias) > return NULL; > > - sem_variable *v = new sem_variable (node, 0, stack); > + sem_variable *v = new sem_variable (node, stack); > > v->init (); > > @@ -1959,7 +1951,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) > 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 > @@ -1973,7 +1965,7 @@ sem_variable::get_hash (void) > 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; > } > @@ -2114,8 +2106,9 @@ sem_variable::dump_to_file (FILE *file) > > 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); > @@ -2235,13 +2228,17 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, > { > 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); > } > } > > @@ -2552,7 +2549,7 @@ sem_item_optimizer::update_hash_by_addr_refs () > { > 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))) > @@ -2560,7 +2557,7 @@ sem_item_optimizer::update_hash_by_addr_refs () > (IDENTIFIER_HASH_VALUE > (DECL_ASSEMBLER_NAME (TYPE_NAME (class_type)))); > > - m_items[i]->hash = hstate.end (); > + m_items[i]->set_hash (hstate.end ()); > } > } > } > @@ -2574,7 +2571,7 @@ sem_item_optimizer::update_hash_by_addr_refs () > > /* 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. */ > @@ -2586,7 +2583,7 @@ sem_item_optimizer::build_hash_based_classes (void) > { > 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 ()) > diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h > index 98a3d4a..7c476fc 100644 > --- a/gcc/ipa-icf.h > +++ b/gcc/ipa-icf.h > @@ -152,10 +152,8 @@ public: > 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 (); > > @@ -182,6 +180,9 @@ public: > /* 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; > @@ -235,9 +236,6 @@ public: > /* 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: > @@ -256,6 +254,12 @@ 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. */ > @@ -268,9 +272,9 @@ public: > /* 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 (); > > @@ -377,10 +381,10 @@ public: > /* 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) {} > > -- > 2.10.2 > > >From 558a24520f0b41d6835badc79a20f9ce150f95ea Mon Sep 17 00:00:00 2001 > From: marxin <mliska@suse.cz> > Date: Fri, 11 Nov 2016 16:15:20 +0100 > Subject: [PATCH] Add sem_item::m_hash_set (PR ipa/78309) > > gcc/ChangeLog: > > 2016-11-16 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. > --- > gcc/ipa-icf.c | 64 ++++++++++++++++++++++++----------------------------------- > gcc/ipa-icf.h | 17 ++++++++-------- > 2 files changed, 35 insertions(+), 46 deletions(-) > > diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c > index 8a18c2b..d143141 100644 > --- a/gcc/ipa-icf.c > +++ b/gcc/ipa-icf.c > @@ -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. */ > > -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), m_hash (0) > +sem_item::sem_item (sem_item_type _type, bitmap_obstack *stack) > +: type (_type), m_hash (-1), m_hash_set (false) > { > 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, > - hashval_t _hash, bitmap_obstack *stack): type(_type), > - node (_node), m_hash (_hash) > + bitmap_obstack *stack) > +: type (_type), node (_node), m_hash (-1), m_hash_set (false) > { > decl = node->decl; > setup (stack); > @@ -230,23 +223,20 @@ sem_item::target_supports_symbol_aliases_p (void) > void sem_item::set_hash (hashval_t hash) > { > m_hash = hash; > + 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), > - m_checker (NULL), m_compared_func (NULL) > +sem_function::sem_function (bitmap_obstack *stack) > +: sem_item (FUNC, stack), m_checker (NULL), m_compared_func (NULL) > { > bb_sizes.create (0); > 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); > @@ -279,7 +269,7 @@ sem_function::get_bb_hash (const sem_bb *basic_block) > hashval_t > sem_function::get_hash (void) > { > - if (!m_hash) > + if (!m_hash_set) > { > inchash::hash hstate; > hstate.add_int (177454); /* Random number for function type. */ > @@ -1703,7 +1693,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack *stack) > || 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 (); > > @@ -1806,19 +1796,12 @@ sem_function::bb_dict_test (vec<int> *bb_dict, int source, int 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) > { > } > > -/* 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 ()); > @@ -2103,7 +2086,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) > || node->alias) > return NULL; > > - sem_variable *v = new sem_variable (node, 0, stack); > + sem_variable *v = new sem_variable (node, stack); > > v->init (); > > @@ -2115,7 +2098,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) > hashval_t > sem_variable::get_hash (void) > { > - if (m_hash) > + if (m_hash_set) > return m_hash; > > /* All WPA streamed in symbols should have their hashes computed at compile > @@ -2282,8 +2265,9 @@ sem_variable::dump_to_file (FILE *file) > > 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); > @@ -2403,13 +2387,17 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, > { > 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); > } > } > > diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h > index d8de655..e02381c 100644 > --- a/gcc/ipa-icf.h > +++ b/gcc/ipa-icf.h > @@ -151,10 +151,8 @@ public: > 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 (); > > @@ -274,6 +272,9 @@ protected: > /* Hash of item. */ > hashval_t m_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. */ > @@ -286,9 +287,9 @@ public: > /* 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 (); > > @@ -394,10 +395,10 @@ public: > /* 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) {} > > -- > 2.10.2 >
From 558a24520f0b41d6835badc79a20f9ce150f95ea Mon Sep 17 00:00:00 2001 From: marxin <mliska@suse.cz> Date: Fri, 11 Nov 2016 16:15:20 +0100 Subject: [PATCH] Add sem_item::m_hash_set (PR ipa/78309) gcc/ChangeLog: 2016-11-16 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. --- gcc/ipa-icf.c | 64 ++++++++++++++++++++++++----------------------------------- gcc/ipa-icf.h | 17 ++++++++-------- 2 files changed, 35 insertions(+), 46 deletions(-) diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 8a18c2b..d143141 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -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. */ -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), m_hash (0) +sem_item::sem_item (sem_item_type _type, bitmap_obstack *stack) +: type (_type), m_hash (-1), m_hash_set (false) { 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, - hashval_t _hash, bitmap_obstack *stack): type(_type), - node (_node), m_hash (_hash) + bitmap_obstack *stack) +: type (_type), node (_node), m_hash (-1), m_hash_set (false) { decl = node->decl; setup (stack); @@ -230,23 +223,20 @@ sem_item::target_supports_symbol_aliases_p (void) void sem_item::set_hash (hashval_t hash) { m_hash = hash; + 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), - m_checker (NULL), m_compared_func (NULL) +sem_function::sem_function (bitmap_obstack *stack) +: sem_item (FUNC, stack), m_checker (NULL), m_compared_func (NULL) { bb_sizes.create (0); 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); @@ -279,7 +269,7 @@ sem_function::get_bb_hash (const sem_bb *basic_block) hashval_t sem_function::get_hash (void) { - if (!m_hash) + if (!m_hash_set) { inchash::hash hstate; hstate.add_int (177454); /* Random number for function type. */ @@ -1703,7 +1693,7 @@ sem_function::parse (cgraph_node *node, bitmap_obstack *stack) || 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 (); @@ -1806,19 +1796,12 @@ sem_function::bb_dict_test (vec<int> *bb_dict, int source, int 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) { } -/* 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 ()); @@ -2103,7 +2086,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) || node->alias) return NULL; - sem_variable *v = new sem_variable (node, 0, stack); + sem_variable *v = new sem_variable (node, stack); v->init (); @@ -2115,7 +2098,7 @@ sem_variable::parse (varpool_node *node, bitmap_obstack *stack) hashval_t sem_variable::get_hash (void) { - if (m_hash) + if (m_hash_set) return m_hash; /* All WPA streamed in symbols should have their hashes computed at compile @@ -2282,8 +2265,9 @@ sem_variable::dump_to_file (FILE *file) 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); @@ -2403,13 +2387,17 @@ sem_item_optimizer::read_section (lto_file_decl_data *file_data, { 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); } } diff --git a/gcc/ipa-icf.h b/gcc/ipa-icf.h index d8de655..e02381c 100644 --- a/gcc/ipa-icf.h +++ b/gcc/ipa-icf.h @@ -151,10 +151,8 @@ public: 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 (); @@ -274,6 +272,9 @@ protected: /* Hash of item. */ hashval_t m_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. */ @@ -286,9 +287,9 @@ public: /* 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 (); @@ -394,10 +395,10 @@ public: /* 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) {} -- 2.10.2