Commit fe248a88 by Martin Liska Committed by Martin Liska

Release cgraph_{node,edge} via ggc_free (PR ipa/89330).

2019-07-28  Martin Liska  <mliska@suse.cz>

	PR ipa/89330
	* cgraph.c (symbol_table::create_edge): Always allocate
	a cgraph_edge.
	(symbol_table::free_edge): Store summary_id to
	edge_released_summary_ids if != -1;
	* cgraph.h (NEXT_FREE_NODE): Remove.
	(SET_NEXT_FREE_NODE): Likewise.
	(NEXT_FREE_EDGE): Likewise.
	(symbol_table::release_symbol): Store summary_id to
	cgraph_released_summary_ids if != -1;
	(symbol_table::allocate_cgraph_symbol): Always allocate
	a cgraph_node.

From-SVN: r273857
parent 4f394a9e
2019-07-28 Martin Liska <mliska@suse.cz>
PR ipa/89330
* cgraph.c (symbol_table::create_edge): Always allocate
a cgraph_edge.
(symbol_table::free_edge): Store summary_id to
edge_released_summary_ids if != -1;
* cgraph.h (NEXT_FREE_NODE): Remove.
(SET_NEXT_FREE_NODE): Likewise.
(NEXT_FREE_EDGE): Likewise.
(symbol_table::release_symbol): Store summary_id to
cgraph_released_summary_ids if != -1;
(symbol_table::allocate_cgraph_symbol): Always allocate
a cgraph_node.
2019-07-28 Alan Modra <amodra@gmail.com> 2019-07-28 Alan Modra <amodra@gmail.com>
* gcc/config/rs6000/rs6000-call.c (rs6000_output_mi_thunk): Use * gcc/config/rs6000/rs6000-call.c (rs6000_output_mi_thunk): Use
......
...@@ -846,17 +846,8 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee, ...@@ -846,17 +846,8 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
gcc_assert (is_gimple_call (call_stmt)); gcc_assert (is_gimple_call (call_stmt));
} }
if (free_edges) edge = ggc_alloc<cgraph_edge> ();
{ edge->m_summary_id = -1;
edge = free_edges;
free_edges = NEXT_FREE_EDGE (edge);
}
else
{
edge = ggc_alloc<cgraph_edge> ();
edge->m_summary_id = -1;
}
edges_count++; edges_count++;
gcc_assert (++edges_max_uid != 0); gcc_assert (++edges_max_uid != 0);
...@@ -1013,16 +1004,13 @@ cgraph_edge::remove_caller (void) ...@@ -1013,16 +1004,13 @@ cgraph_edge::remove_caller (void)
void void
symbol_table::free_edge (cgraph_edge *e) symbol_table::free_edge (cgraph_edge *e)
{ {
edges_count--;
if (e->m_summary_id != -1)
edge_released_summary_ids.safe_push (e->m_summary_id);
if (e->indirect_info) if (e->indirect_info)
ggc_free (e->indirect_info); ggc_free (e->indirect_info);
ggc_free (e);
/* Clear out the edge so we do not dangle pointers. */
int summary_id = e->m_summary_id;
memset (e, 0, sizeof (*e));
e->m_summary_id = summary_id;
NEXT_FREE_EDGE (e) = free_edges;
free_edges = e;
edges_count--;
} }
/* Remove the edge in the cgraph. */ /* Remove the edge in the cgraph. */
......
...@@ -2027,12 +2027,6 @@ is_a_helper <varpool_node *>::test (symtab_node *p) ...@@ -2027,12 +2027,6 @@ is_a_helper <varpool_node *>::test (symtab_node *p)
return p && p->type == SYMTAB_VARIABLE; return p && p->type == SYMTAB_VARIABLE;
} }
/* Macros to access the next item in the list of free cgraph nodes and
edges. */
#define NEXT_FREE_NODE(NODE) dyn_cast<cgraph_node *> ((NODE)->next)
#define SET_NEXT_FREE_NODE(NODE,NODE2) ((NODE))->next = NODE2
#define NEXT_FREE_EDGE(EDGE) (EDGE)->prev_caller
typedef void (*cgraph_edge_hook)(cgraph_edge *, void *); typedef void (*cgraph_edge_hook)(cgraph_edge *, void *);
typedef void (*cgraph_node_hook)(cgraph_node *, void *); typedef void (*cgraph_node_hook)(cgraph_node *, void *);
typedef void (*varpool_node_hook)(varpool_node *, void *); typedef void (*varpool_node_hook)(varpool_node *, void *);
...@@ -2088,7 +2082,8 @@ public: ...@@ -2088,7 +2082,8 @@ public:
friend struct cgraph_edge; friend struct cgraph_edge;
symbol_table (): cgraph_max_uid (1), cgraph_max_summary_id (0), symbol_table (): cgraph_max_uid (1), cgraph_max_summary_id (0),
edges_max_uid (1), edges_max_summary_id (0) edges_max_uid (1), edges_max_summary_id (0),
cgraph_released_summary_ids (), edge_released_summary_ids ()
{ {
} }
...@@ -2297,14 +2292,22 @@ public: ...@@ -2297,14 +2292,22 @@ public:
/* Assign a new summary ID for the callgraph NODE. */ /* Assign a new summary ID for the callgraph NODE. */
inline int assign_summary_id (cgraph_node *node) inline int assign_summary_id (cgraph_node *node)
{ {
node->m_summary_id = cgraph_max_summary_id++; if (!cgraph_released_summary_ids.is_empty ())
node->m_summary_id = cgraph_released_summary_ids.pop ();
else
node->m_summary_id = cgraph_max_summary_id++;
return node->m_summary_id; return node->m_summary_id;
} }
/* Assign a new summary ID for the callgraph EDGE. */ /* Assign a new summary ID for the callgraph EDGE. */
inline int assign_summary_id (cgraph_edge *edge) inline int assign_summary_id (cgraph_edge *edge)
{ {
edge->m_summary_id = edges_max_summary_id++; if (!edge_released_summary_ids.is_empty ())
edge->m_summary_id = edge_released_summary_ids.pop ();
else
edge->m_summary_id = edges_max_summary_id++;
return edge->m_summary_id; return edge->m_summary_id;
} }
...@@ -2320,14 +2323,15 @@ public: ...@@ -2320,14 +2323,15 @@ public:
int edges_max_uid; int edges_max_uid;
int edges_max_summary_id; int edges_max_summary_id;
/* Vector of released summary IDS for cgraph nodes. */
vec<int> GTY ((skip)) cgraph_released_summary_ids;
/* Vector of released summary IDS for cgraph nodes. */
vec<int> GTY ((skip)) edge_released_summary_ids;
symtab_node* GTY(()) nodes; symtab_node* GTY(()) nodes;
asm_node* GTY(()) asmnodes; asm_node* GTY(()) asmnodes;
asm_node* GTY(()) asm_last_node; asm_node* GTY(()) asm_last_node;
cgraph_node* GTY(()) free_nodes;
/* Head of a linked list of unused (freed) call graph edges.
Do not GTY((delete)) this list so UIDs gets reliably recycled. */
cgraph_edge * GTY(()) free_edges;
/* The order index of the next symtab node to be created. This is /* The order index of the next symtab node to be created. This is
used so that we can sort the cgraph nodes in order by when we saw used so that we can sort the cgraph nodes in order by when we saw
...@@ -2687,15 +2691,9 @@ inline void ...@@ -2687,15 +2691,9 @@ inline void
symbol_table::release_symbol (cgraph_node *node) symbol_table::release_symbol (cgraph_node *node)
{ {
cgraph_count--; cgraph_count--;
if (node->m_summary_id != -1)
/* Clear out the node to NULL all pointers and add the node to the free cgraph_released_summary_ids.safe_push (node->m_summary_id);
list. */ ggc_free (node);
int summary_id = node->m_summary_id;
memset (node, 0, sizeof (*node));
node->type = SYMTAB_FUNCTION;
node->m_summary_id = summary_id;
SET_NEXT_FREE_NODE (node, free_nodes);
free_nodes = node;
} }
/* Allocate new callgraph node. */ /* Allocate new callgraph node. */
...@@ -2705,17 +2703,9 @@ symbol_table::allocate_cgraph_symbol (void) ...@@ -2705,17 +2703,9 @@ symbol_table::allocate_cgraph_symbol (void)
{ {
cgraph_node *node; cgraph_node *node;
if (free_nodes) node = ggc_cleared_alloc<cgraph_node> ();
{ node->type = SYMTAB_FUNCTION;
node = free_nodes; node->m_summary_id = -1;
free_nodes = NEXT_FREE_NODE (node);
}
else
{
node = ggc_cleared_alloc<cgraph_node> ();
node->m_summary_id = -1;
}
node->m_uid = cgraph_max_uid++; node->m_uid = cgraph_max_uid++;
return node; return node;
} }
......
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