Come up with cgraph_node::get_uid and make cgraph_node::uid private.

2018-06-08  Martin Liska  <mliska@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.

From-SVN: r261320
This commit is contained in:
Martin Liska 2018-06-08 14:36:26 +02:00 committed by Martin Liska
parent 8b25212d3e
commit 4325656f9f
10 changed files with 53 additions and 23 deletions

View File

@ -1,3 +1,22 @@
2018-06-08 Martin Liska <mliska@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.
2018-06-08 Martin Liska <mliska@suse.cz>
* cgraph.c (symbol_table::create_edge): Always assign a new

View File

@ -120,7 +120,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);
}
@ -129,7 +129,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. */

View File

@ -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;
@ -893,6 +895,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
@ -1271,6 +1275,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);
@ -1390,8 +1400,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. */
@ -1438,6 +1446,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 *),
@ -2617,7 +2628,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;
}

View File

@ -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)

View File

@ -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

View File

@ -1268,7 +1268,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);

View File

@ -1170,7 +1170,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));
@ -1635,7 +1635,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. */
@ -1644,7 +1644,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
@ -1675,7 +1675,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. */

View File

@ -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);
}
}

View File

@ -4056,7 +4056,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)"

View File

@ -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);