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