> > gcc/ChangeLog: > > 2018-04-24 Martin Liska <mli...@suse.cz> > > * cgraph.c (function_version_hasher::hash): Use > cgraph_node::get_uid (). > (function_version_hasher::equal): > * cgraph.h (cgraph_node::get_uid): New method. > * ipa-inline.c (update_caller_keys): Use > cgraph_node::get_uid (). > (update_callee_keys): Likewise. > * ipa-utils.c (searchc): Likewise. > (ipa_reduced_postorder): Likewise. > * lto-cgraph.c (input_node): Likewise. > * passes.c (is_pass_explicitly_enabled_or_disabled): Likewise. > * symbol-summary.h (symtab_insertion): Likewise. > (symtab_removal): Likewise. > (symtab_duplication): Likewise. > * tree-pretty-print.c (dump_function_header): Likewise. > * tree-sra.c (convert_callers_for_node): Likewise.
OK Honza > --- > gcc/cgraph.c | 4 ++-- > gcc/cgraph.h | 17 ++++++++++++++--- > gcc/ipa-inline.c | 4 ++-- > gcc/ipa-utils.c | 4 ++-- > gcc/lto-cgraph.c | 2 +- > gcc/passes.c | 8 ++++---- > gcc/symbol-summary.h | 14 +++++++------- > gcc/tree-pretty-print.c | 2 +- > gcc/tree-sra.c | 2 +- > 9 files changed, 34 insertions(+), 23 deletions(-) > > diff --git a/gcc/cgraph.c b/gcc/cgraph.c > index 572c775c14c..e7c9632a8c8 100644 > --- a/gcc/cgraph.c > +++ b/gcc/cgraph.c > @@ -121,7 +121,7 @@ static GTY(()) hash_table<function_version_hasher> > *cgraph_fnver_htab = NULL; > hashval_t > function_version_hasher::hash (cgraph_function_version_info *ptr) > { > - int uid = ptr->this_node->uid; > + int uid = ptr->this_node->get_uid (); > return (hashval_t)(uid); > } > > @@ -130,7 +130,7 @@ bool > function_version_hasher::equal (cgraph_function_version_info *n1, > cgraph_function_version_info *n2) > { > - return n1->this_node->uid == n2->this_node->uid; > + return n1->this_node->get_uid () == n2->this_node->get_uid (); > } > > /* Mark as GC root all allocated nodes. */ > diff --git a/gcc/cgraph.h b/gcc/cgraph.h > index 1966893343d..a10ea04ef0d 100644 > --- a/gcc/cgraph.h > +++ b/gcc/cgraph.h > @@ -97,6 +97,8 @@ class GTY((desc ("%h.type"), tag ("SYMTAB_SYMBOL"), > symtab_node > { > public: > + friend class symbol_table; > + > /* Return name. */ > const char *name () const; > > @@ -890,6 +892,8 @@ struct cgraph_edge_hasher : ggc_ptr_hash<cgraph_edge> > > struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node { > public: > + friend class symbol_table; > + > /* Remove the node from cgraph and all inline clones inlined into it. > Skip however removal of FORBIDDEN_NODE and return true if it needs to be > removed. This allows to call the function from outer loop walking clone > @@ -1268,6 +1272,12 @@ public: > dump_cgraph (stderr); > } > > + /* Get unique identifier of the node. */ > + inline int get_uid () > + { > + return m_uid; > + } > + > /* Record that DECL1 and DECL2 are semantically identical function > versions. */ > static void record_function_versions (tree decl1, tree decl2); > @@ -1394,8 +1404,6 @@ public: > /* How to scale counts at materialization time; used to merge > LTO units with different number of profile runs. */ > int count_materialization_scale; > - /* Unique id of the node. */ > - int uid; > /* ID assigned by the profiling. */ > unsigned int profile_id; > /* Time profiler: first run of function. */ > @@ -1445,6 +1453,9 @@ public: > unsigned indirect_call_target : 1; > > private: > + /* Unique id of the node. */ > + int m_uid; > + > /* Worker for call_for_symbol_and_aliases. */ > bool call_for_symbol_and_aliases_1 (bool (*callback) (cgraph_node *, > void *), > @@ -2629,7 +2640,7 @@ symbol_table::allocate_cgraph_symbol (void) > else > node = ggc_cleared_alloc<cgraph_node> (); > > - node->uid = cgraph_max_uid++; > + node->m_uid = cgraph_max_uid++; > return node; > } > > diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c > index 97164716af8..9d22d208f3d 100644 > --- a/gcc/ipa-inline.c > +++ b/gcc/ipa-inline.c > @@ -1337,7 +1337,7 @@ update_caller_keys (edge_heap_t *heap, struct > cgraph_node *node, > if ((!node->alias && !ipa_fn_summaries->get_create (node)->inlinable) > || node->global.inlined_to) > return; > - if (!bitmap_set_bit (updated_nodes, node->uid)) > + if (!bitmap_set_bit (updated_nodes, node->get_uid ())) > return; > > FOR_EACH_ALIAS (node, ref) > @@ -1395,7 +1395,7 @@ update_callee_keys (edge_heap_t *heap, struct > cgraph_node *node, > && (callee = e->callee->ultimate_alias_target (&avail, e->caller)) > && ipa_fn_summaries->get_create (callee)->inlinable > && avail >= AVAIL_AVAILABLE > - && !bitmap_bit_p (updated_nodes, callee->uid)) > + && !bitmap_bit_p (updated_nodes, callee->get_uid ())) > { > if (can_inline_edge_p (e, false) > && want_inline_small_function_p (e, false) > diff --git a/gcc/ipa-utils.c b/gcc/ipa-utils.c > index aa586f5feb2..9985721f7da 100644 > --- a/gcc/ipa-utils.c > +++ b/gcc/ipa-utils.c > @@ -86,7 +86,7 @@ searchc (struct searchc_env* env, struct cgraph_node *v, > > /* mark node as old */ > v_info->new_node = false; > - splay_tree_remove (env->nodes_marked_new, v->uid); > + splay_tree_remove (env->nodes_marked_new, v->get_uid ()); > > v_info->dfn_number = env->count; > v_info->low_link = env->count; > @@ -195,7 +195,7 @@ ipa_reduced_postorder (struct cgraph_node **order, > node->aux = info; > > splay_tree_insert (env.nodes_marked_new, > - (splay_tree_key)node->uid, > + (splay_tree_key)node->get_uid (), > (splay_tree_value)node); > } > else > diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c > index dcd5391012c..90a77028bcc 100644 > --- a/gcc/lto-cgraph.c > +++ b/gcc/lto-cgraph.c > @@ -1292,7 +1292,7 @@ input_node (struct lto_file_decl_data *file_data, > functions, they are expected to be read more than once. */ > if (node->aux && !DECL_BUILT_IN (node->decl)) > internal_error ("bytecode stream: found multiple instances of cgraph " > - "node with uid %d", node->uid); > + "node with uid %d", node->get_uid ()); > > node->tp_first_run = streamer_read_uhwi (ib); > > diff --git a/gcc/passes.c b/gcc/passes.c > index ee9c09e9a79..39638a33cd6 100644 > --- a/gcc/passes.c > +++ b/gcc/passes.c > @@ -1208,7 +1208,7 @@ is_pass_explicitly_enabled_or_disabled (opt_pass *pass, > if (!slot) > return false; > > - cgraph_uid = func ? cgraph_node::get (func)->uid : 0; > + cgraph_uid = func ? cgraph_node::get (func)->get_uid () : 0; > if (func && DECL_ASSEMBLER_NAME_SET_P (func)) > aname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func)); > > @@ -1673,7 +1673,7 @@ do_per_function (void (*callback) (function *, void > *data), void *data) > static int nnodes; > static GTY ((length ("nnodes"))) cgraph_node **order; > > -#define uid_hash_t hash_set<int_hash <int, 0, -1>> > +#define uid_hash_t hash_set<int_hash <int, 0, -1> > > > /* Hook called when NODE is removed and therefore should be > excluded from order vector. DATA is a hash set with removed nodes. */ > @@ -1682,7 +1682,7 @@ static void > remove_cgraph_node_from_order (cgraph_node *node, void *data) > { > uid_hash_t *removed_nodes = (uid_hash_t *)data; > - removed_nodes->add (node->uid); > + removed_nodes->add (node->get_uid ()); > } > > /* If we are in IPA mode (i.e., current_function_decl is NULL), call > @@ -1713,7 +1713,7 @@ do_per_function_toporder (void (*callback) (function *, > void *data), void *data) > cgraph_node *node = order[i]; > > /* Function could be inlined and removed as unreachable. */ > - if (node == NULL || removed_nodes.contains (node->uid)) > + if (node == NULL || removed_nodes.contains (node->get_uid ())) > continue; > > /* Allow possibly removed nodes to be garbage collected. */ > diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h > index 8c80f309372..ebf4b175e71 100644 > --- a/gcc/symbol-summary.h > +++ b/gcc/symbol-summary.h > @@ -90,13 +90,13 @@ public: > does not exist it will be created. */ > T* get_create (cgraph_node *node) > { > - return get (node->uid, true); > + return get (node->get_uid (), true); > } > > /* Getter for summary callgraph node pointer. */ > T* get (cgraph_node *node) > { > - return get (node->uid, false); > + return get (node->get_uid (), false); > } > > /* Return number of elements handled by data structure. */ > @@ -108,7 +108,7 @@ public: > /* Return true if a summary for the given NODE already exists. */ > bool exists (cgraph_node *node) > { > - return m_map.get (node->uid) != NULL; > + return m_map.get (node->get_uid ()) != NULL; > } > > /* Enable insertion hook invocation. */ > @@ -216,7 +216,7 @@ template <typename T> > void > function_summary<T *>::symtab_insertion (cgraph_node *node, void *data) > { > - gcc_checking_assert (node->uid); > + gcc_checking_assert (node->get_uid ()); > function_summary *summary = (function_summary <T *> *) (data); > > if (summary->m_insertion_enabled) > @@ -227,10 +227,10 @@ template <typename T> > void > function_summary<T *>::symtab_removal (cgraph_node *node, void *data) > { > - gcc_checking_assert (node->uid); > + gcc_checking_assert (node->get_uid ()); > function_summary *summary = (function_summary <T *> *) (data); > > - int uid = node->uid; > + int uid = node->get_uid (); > T **v = summary->m_map.get (uid); > > if (v) > @@ -256,7 +256,7 @@ function_summary<T *>::symtab_duplication (cgraph_node > *node, > { > /* This load is necessary, because we insert a new value! */ > T *duplicate = summary->allocate_new (); > - summary->m_map.put (node2->uid, duplicate); > + summary->m_map.put (node2->get_uid (), duplicate); > summary->duplicate (node, node2, v, duplicate); > } > } > diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c > index 276ad00a7b2..387d56fe42f 100644 > --- a/gcc/tree-pretty-print.c > +++ b/gcc/tree-pretty-print.c > @@ -4043,7 +4043,7 @@ dump_function_header (FILE *dump_file, tree fdecl, > dump_flags_t flags) > fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl)); > if (node) > { > - fprintf (dump_file, ", cgraph_uid=%d", node->uid); > + fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ()); > fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order, > node->frequency == NODE_FREQUENCY_HOT > ? " (hot)" > diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c > index 09d56d10e7f..494afd83046 100644 > --- a/gcc/tree-sra.c > +++ b/gcc/tree-sra.c > @@ -5279,7 +5279,7 @@ convert_callers_for_node (struct cgraph_node *node, > } > > for (cs = node->callers; cs; cs = cs->next_caller) > - if (bitmap_set_bit (recomputed_callers, cs->caller->uid) > + if (bitmap_set_bit (recomputed_callers, cs->caller->get_uid ()) > && gimple_in_ssa_p (DECL_STRUCT_FUNCTION (cs->caller->decl))) > compute_fn_summary (cs->caller, true); > BITMAP_FREE (recomputed_callers);