+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.
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;
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--;
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);
/* 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);
/* 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
/* 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);
friend class cgraph_node;
friend class cgraph_edge;
- symbol_table (): cgraph_max_uid (1)
+ symbol_table (): cgraph_max_uid (1), edges_max_uid (1)
{
}
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)
{
/* 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. */
/* 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. */
{
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)
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! */
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);
}
}