Commit 8b25212d by Martin Liska Committed by Martin Liska

Make cgraph_edge::uid really unique.

2018-06-08  Martin Liska  <mliska@suse.cz>

	* cgraph.c (symbol_table::create_edge): Always assign a new
	unique number.
	(symbol_table::free_edge): Do not recycle numbers.
	* cgraph.h (cgraph_edge::get): New method.
	* symbol-summary.h (symtab_removal): Use it.
	(symtab_duplication): Likewise.
	(call_summary::hashable_uid): Remove.

From-SVN: r261319
parent 9fb50ad8
2018-06-08 Martin Liska <mliska@suse.cz>
* cgraph.c (symbol_table::create_edge): Always assign a new
unique number.
(symbol_table::free_edge): Do not recycle numbers.
* cgraph.h (cgraph_edge::get): New method.
* symbol-summary.h (symtab_removal): Use it.
(symtab_duplication): Likewise.
(call_summary::hashable_uid): Remove.
2018-06-08 Martin Liska <mliska@suse.cz>
* ipa-inline-analysis.c (inline_edge_removal_hook): Remove.
(initialize_growth_caches): Remove.
(free_growth_caches): Likewise.
......
......@@ -850,13 +850,12 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
free_edges = NEXT_FREE_EDGE (edge);
}
else
{
edge = ggc_alloc<cgraph_edge> ();
edge->uid = edges_max_uid++;
}
edge = ggc_alloc<cgraph_edge> ();
edges_count++;
gcc_assert (++edges_max_uid != 0);
edge->m_uid = edges_max_uid;
edge->aux = NULL;
edge->caller = caller;
edge->callee = callee;
......@@ -1010,14 +1009,11 @@ cgraph_edge::remove_caller (void)
void
symbol_table::free_edge (cgraph_edge *e)
{
int uid = e->uid;
if (e->indirect_info)
ggc_free (e->indirect_info);
/* Clear out the edge so we do not dangle pointers. */
memset (e, 0, sizeof (*e));
e->uid = uid;
NEXT_FREE_EDGE (e) = free_edges;
free_edges = e;
edges_count--;
......
......@@ -1626,6 +1626,7 @@ struct GTY(()) cgraph_indirect_call_info
struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
for_user)) cgraph_edge {
friend class cgraph_node;
friend class symbol_table;
/* Remove the edge in the cgraph. */
void remove (void);
......@@ -1689,6 +1690,12 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
/* Return true if the call can be hot. */
bool maybe_hot_p (void);
/* Get unique identifier of the edge. */
inline int get_uid ()
{
return m_uid;
}
/* Rebuild cgraph edges for current function node. This needs to be run after
passes that don't update the cgraph. */
static unsigned int rebuild_edges (void);
......@@ -1716,8 +1723,6 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
/* The stmt_uid of call_stmt. This is used by LTO to recover the call_stmt
when the function is serialized in. */
unsigned int lto_stmt_uid;
/* Unique id of the edge. */
int uid;
/* Whether this edge was made direct by indirect inlining. */
unsigned int indirect_inlining_edge : 1;
/* Whether this edge describes an indirect call with an undetermined
......@@ -1761,6 +1766,9 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
/* Expected frequency of executions within the function. */
sreal sreal_frequency ();
private:
/* Unique id of the edge. */
int m_uid;
/* Remove the edge from the list of the callers of the callee. */
void remove_caller (void);
......@@ -2011,7 +2019,7 @@ public:
friend class cgraph_node;
friend class cgraph_edge;
symbol_table (): cgraph_max_uid (1)
symbol_table (): cgraph_max_uid (1), edges_max_uid (1)
{
}
......
......@@ -375,19 +375,19 @@ public:
If a summary for an edge does not exist, it will be created. */
T* get_create (cgraph_edge *edge)
{
return get (hashable_uid (edge), true);
return get (edge->get_uid (), true);
}
/* Getter for summary callgraph edge pointer. */
T* get (cgraph_edge *edge)
{
return get (hashable_uid (edge), false);
return get (edge->get_uid (), false);
}
/* Remove edge from summary. */
void remove (cgraph_edge *edge)
{
int uid = hashable_uid (edge);
int uid = edge->get_uid ();
T **v = m_map.get (uid);
if (v)
{
......@@ -405,7 +405,7 @@ public:
/* Return true if a summary for the given EDGE already exists. */
bool exists (cgraph_edge *edge)
{
return m_map.get (hashable_uid (edge)) != NULL;
return m_map.get (edge->get_uid ()) != NULL;
}
/* Symbol removal hook that is registered to symbol table. */
......@@ -428,13 +428,6 @@ private:
/* Getter for summary callgraph ID. */
T *get (int uid, bool lazy_insert);
/* Get a hashable uid of EDGE. */
int hashable_uid (cgraph_edge *edge)
{
/* Edge uids start at zero which our hash_map does not like. */
return edge->uid + 1;
}
/* Main summary store, where summary ID is used as key. */
hash_map <map_hash, T *> m_map;
/* Internal summary removal hook pointer. */
......@@ -511,7 +504,7 @@ call_summary<T *>::symtab_removal (cgraph_edge *edge, void *data)
{
call_summary *summary = (call_summary <T *> *) (data);
int h_uid = summary->hashable_uid (edge);
int h_uid = edge->get_uid ();
T **v = summary->m_map.get (h_uid);
if (v)
......@@ -534,7 +527,7 @@ call_summary<T *>::symtab_duplication (cgraph_edge *edge1,
edge1_summary = summary->get_create (edge1);
else
{
T **v = summary->m_map.get (summary->hashable_uid (edge1));
T **v = summary->m_map.get (edge1->get_uid ());
if (v)
{
/* This load is necessary, because we insert a new value! */
......@@ -545,7 +538,7 @@ call_summary<T *>::symtab_duplication (cgraph_edge *edge1,
if (edge1_summary)
{
T *duplicate = summary->allocate_new ();
summary->m_map.put (summary->hashable_uid (edge2), duplicate);
summary->m_map.put (edge2->get_uid (), duplicate);
summary->duplicate (edge1, edge2, edge1_summary, duplicate);
}
}
......
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