diff options
author | Martin Liska <mliska@suse.cz> | 2018-06-08 14:33:47 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2018-06-08 12:33:47 +0000 |
commit | 8b25212d3e960dd130d71330ad6d55b40c5be254 (patch) | |
tree | 5b0cf4f88de2297422b17172c003f1be6bc67986 /gcc | |
parent | 9fb50ad822bd57786b12a2fc90c61032c519a621 (diff) | |
download | gcc-8b25212d3e960dd130d71330ad6d55b40c5be254.zip gcc-8b25212d3e960dd130d71330ad6d55b40c5be254.tar.gz gcc-8b25212d3e960dd130d71330ad6d55b40c5be254.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cgraph.c | 10 | ||||
-rw-r--r-- | gcc/cgraph.h | 14 | ||||
-rw-r--r-- | gcc/symbol-summary.h | 21 |
4 files changed, 31 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c231a0..a7424bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,15 @@ 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. diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 6c6ecd8..cf6b35a 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -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--; diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 9a05867..6d5a2b8 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -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) { } diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h index 12e5020..8c80f30 100644 --- a/gcc/symbol-summary.h +++ b/gcc/symbol-summary.h @@ -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); } } |