Commit db30281f by Martin Liska Committed by Martin Liska

Come up with fast {function,call}_summary classes (PR ipa/89306).

2019-02-18  Martin Liska  <mliska@suse.cz>

	PR ipa/89306
	* cgraph.c (symbol_table::create_edge): Set m_summary_id to -1
	by default.
	(symbol_table::free_edge): Recycle m_summary_id.
	* cgraph.h (get_summary_id): New.
	(symbol_table::release_symbol): Set m_summary_id to -1
	by default.
	(symbol_table::allocate_cgraph_symbol): Recycle m_summary_id.
	* ipa-fnsummary.c (ipa_fn_summary_t): Switch from
	function_summary to fast_function_summary.
	* ipa-fnsummary.h (ipa_fn_summary_t): Likewise.
	* ipa-pure-const.c (class funct_state_summary_t):
	Switch from function_summary to fast_function_summary.
	* ipa-reference.c (class ipa_ref_var_info_summary_t): Likewise.
	(class ipa_ref_opt_summary_t): Switch from function_summary
	to fast_function_summary.
	* symbol-summary.h (class function_summary_base): New class
	that is created from base of former function_summary.
	(function_summary_base::unregister_hooks): New.
	(class function_summary): Inherit from function_summary_base.
	(class call_summary_base): New class
	that is created from base of former call_summary.
	(class call_summary): Inherit from call_summary_base.
	(struct is_same): New.
	(class fast_function_summary): New summary class.
	(class fast_call_summary): New summary class.
	* vec.h (vec_safe_grow_cleared): New function.

From-SVN: r268979
parent e8cecccc
2019-02-18 Martin Liska <mliska@suse.cz>
PR ipa/89306
* cgraph.c (symbol_table::create_edge): Set m_summary_id to -1
by default.
(symbol_table::free_edge): Recycle m_summary_id.
* cgraph.h (get_summary_id): New.
(symbol_table::release_symbol): Set m_summary_id to -1
by default.
(symbol_table::allocate_cgraph_symbol): Recycle m_summary_id.
* ipa-fnsummary.c (ipa_fn_summary_t): Switch from
function_summary to fast_function_summary.
* ipa-fnsummary.h (ipa_fn_summary_t): Likewise.
* ipa-pure-const.c (class funct_state_summary_t):
Switch from function_summary to fast_function_summary.
* ipa-reference.c (class ipa_ref_var_info_summary_t): Likewise.
(class ipa_ref_opt_summary_t): Switch from function_summary
to fast_function_summary.
* symbol-summary.h (class function_summary_base): New class
that is created from base of former function_summary.
(function_summary_base::unregister_hooks): New.
(class function_summary): Inherit from function_summary_base.
(class call_summary_base): New class
that is created from base of former call_summary.
(class call_summary): Inherit from call_summary_base.
(struct is_same): New.
(class fast_function_summary): New summary class.
(class fast_call_summary): New summary class.
* vec.h (vec_safe_grow_cleared): New function.
2019-02-18 Martin Liska <mliska@suse.cz>
* config/i386/i386.c (ix86_get_multilib_abi_name): New function.
(TARGET_GET_MULTILIB_ABI_NAME): New macro defined.
* doc/tm.texi: Document new target hook.
......
......@@ -852,7 +852,10 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee,
free_edges = NEXT_FREE_EDGE (edge);
}
else
edge = ggc_alloc<cgraph_edge> ();
{
edge = ggc_alloc<cgraph_edge> ();
edge->m_summary_id = -1;
}
edges_count++;
......@@ -1014,7 +1017,9 @@ symbol_table::free_edge (cgraph_edge *e)
ggc_free (e->indirect_info);
/* 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--;
......
......@@ -1302,6 +1302,12 @@ public:
return m_uid;
}
/* Get summary id of the node. */
inline int get_summary_id ()
{
return m_summary_id;
}
/* Record that DECL1 and DECL2 are semantically identical function
versions. */
static void record_function_versions (tree decl1, tree decl2);
......@@ -1470,6 +1476,9 @@ private:
/* Unique id of the node. */
int m_uid;
/* Summary id that is recycled. */
int m_summary_id;
/* Worker for call_for_symbol_and_aliases. */
bool call_for_symbol_and_aliases_1 (bool (*callback) (cgraph_node *,
void *),
......@@ -1728,6 +1737,12 @@ struct GTY((chain_next ("%h.next_caller"), chain_prev ("%h.prev_caller"),
return m_uid;
}
/* Get summary id of the edge. */
inline int get_summary_id ()
{
return m_summary_id;
}
/* 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);
......@@ -1805,6 +1820,9 @@ private:
/* Unique id of the edge. */
int m_uid;
/* Summary id that is recycled. */
int m_summary_id;
/* Remove the edge from the list of the callers of the callee. */
void remove_caller (void);
......@@ -2051,7 +2069,8 @@ public:
friend class cgraph_node;
friend class cgraph_edge;
symbol_table (): cgraph_max_uid (1), edges_max_uid (1)
symbol_table (): cgraph_max_uid (1), cgraph_max_summary_id (0),
edges_max_uid (1), edges_max_summary_id (0)
{
}
......@@ -2254,15 +2273,31 @@ public:
/* Dump symbol table to stderr. */
void DEBUG_FUNCTION debug (void);
/* Assign a new summary ID for the callgraph NODE. */
inline int assign_summary_id (cgraph_node *node)
{
node->m_summary_id = cgraph_max_summary_id++;
return node->m_summary_id;
}
/* Assign a new summary ID for the callgraph EDGE. */
inline int assign_summary_id (cgraph_edge *edge)
{
edge->m_summary_id = edges_max_summary_id++;
return edge->m_summary_id;
}
/* Return true if assembler names NAME1 and NAME2 leads to the same symbol
name. */
static bool assembler_names_equal_p (const char *name1, const char *name2);
int cgraph_count;
int cgraph_max_uid;
int cgraph_max_summary_id;
int edges_count;
int edges_max_uid;
int edges_max_summary_id;
symtab_node* GTY(()) nodes;
asm_node* GTY(()) asmnodes;
......@@ -2634,8 +2669,10 @@ symbol_table::release_symbol (cgraph_node *node)
/* Clear out the node to NULL all pointers and add the node to the free
list. */
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;
}
......@@ -2653,7 +2690,10 @@ symbol_table::allocate_cgraph_symbol (void)
free_nodes = NEXT_FREE_NODE (node);
}
else
node = ggc_cleared_alloc<cgraph_node> ();
{
node = ggc_cleared_alloc<cgraph_node> ();
node->m_summary_id = -1;
}
node->m_uid = cgraph_max_uid++;
return node;
......
......@@ -85,8 +85,8 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
/* Summaries. */
function_summary <ipa_fn_summary *> *ipa_fn_summaries;
call_summary <ipa_call_summary *> *ipa_call_summaries;
fast_function_summary <ipa_fn_summary *, va_gc> *ipa_fn_summaries;
fast_call_summary <ipa_call_summary *, va_heap> *ipa_call_summaries;
/* Edge predicates goes here. */
static object_allocator<predicate> edge_predicate_pool ("edge predicates");
......@@ -532,7 +532,7 @@ ipa_fn_summary_alloc (void)
{
gcc_checking_assert (!ipa_fn_summaries);
ipa_fn_summaries = ipa_fn_summary_t::create_ggc (symtab);
ipa_call_summaries = new ipa_call_summary_t (symtab, false);
ipa_call_summaries = new ipa_call_summary_t (symtab);
}
ipa_call_summary::~ipa_call_summary ()
......
......@@ -173,16 +173,17 @@ struct GTY(()) ipa_fn_summary
static const int size_scale = 2;
};
class GTY((user)) ipa_fn_summary_t: public function_summary <ipa_fn_summary *>
class GTY((user)) ipa_fn_summary_t:
public fast_function_summary <ipa_fn_summary *, va_gc>
{
public:
ipa_fn_summary_t (symbol_table *symtab, bool ggc):
function_summary <ipa_fn_summary *> (symtab, ggc) {}
ipa_fn_summary_t (symbol_table *symtab):
fast_function_summary <ipa_fn_summary *, va_gc> (symtab) {}
static ipa_fn_summary_t *create_ggc (symbol_table *symtab)
{
struct ipa_fn_summary_t *summary = new (ggc_alloc <ipa_fn_summary_t> ())
ipa_fn_summary_t(symtab, true);
ipa_fn_summary_t (symtab);
summary->disable_insertion_hook ();
return summary;
}
......@@ -200,7 +201,8 @@ public:
ipa_fn_summary *src_data, ipa_fn_summary *dst_data);
};
extern GTY(()) function_summary <ipa_fn_summary *> *ipa_fn_summaries;
extern GTY(()) fast_function_summary <ipa_fn_summary *, va_gc>
*ipa_fn_summaries;
/* Information kept about callgraph edges. */
struct ipa_call_summary
......@@ -236,11 +238,11 @@ struct ipa_call_summary
bool is_return_callee_uncaptured;
};
class ipa_call_summary_t: public call_summary <ipa_call_summary *>
class ipa_call_summary_t: public fast_call_summary <ipa_call_summary *, va_heap>
{
public:
ipa_call_summary_t (symbol_table *symtab, bool ggc):
call_summary <ipa_call_summary *> (symtab, ggc) {}
ipa_call_summary_t (symbol_table *symtab):
fast_call_summary <ipa_call_summary *, va_heap> (symtab) {}
/* Hook that is called by summary when an edge is duplicated. */
virtual void duplicate (cgraph_edge *src, cgraph_edge *dst,
......@@ -248,7 +250,7 @@ public:
ipa_call_summary *dst_data);
};
extern call_summary <ipa_call_summary *> *ipa_call_summaries;
extern fast_call_summary <ipa_call_summary *, va_heap> *ipa_call_summaries;
/* In ipa-fnsummary.c */
void ipa_debug_fn_summary (struct cgraph_node *);
......
......@@ -128,11 +128,12 @@ typedef struct funct_state_d * funct_state;
possibility that it may be desirable to move this to the cgraph
local info. */
class funct_state_summary_t: public function_summary <funct_state_d *>
class funct_state_summary_t:
public fast_function_summary <funct_state_d *, va_heap>
{
public:
funct_state_summary_t (symbol_table *symtab):
function_summary <funct_state_d *> (symtab) {}
fast_function_summary <funct_state_d *, va_heap> (symtab) {}
virtual void insert (cgraph_node *, funct_state_d *state);
virtual void duplicate (cgraph_node *src_node, cgraph_node *dst_node,
......
......@@ -110,23 +110,22 @@ static bitmap_obstack local_info_obstack;
/* Obstack holding global analysis live forever. */
static bitmap_obstack optimization_summary_obstack;
class ipa_ref_var_info_summary_t: public function_summary
<ipa_reference_vars_info_d *>
class ipa_ref_var_info_summary_t: public fast_function_summary
<ipa_reference_vars_info_d *, va_heap>
{
public:
ipa_ref_var_info_summary_t (symbol_table *symtab):
function_summary <ipa_reference_vars_info_d *> (symtab) {}
fast_function_summary <ipa_reference_vars_info_d *, va_heap> (symtab) {}
};
static ipa_ref_var_info_summary_t *ipa_ref_var_info_summaries = NULL;
class ipa_ref_opt_summary_t: public function_summary
<ipa_reference_optimization_summary_d *>
class ipa_ref_opt_summary_t: public fast_function_summary
<ipa_reference_optimization_summary_d *, va_heap>
{
public:
ipa_ref_opt_summary_t (symbol_table *symtab):
function_summary <ipa_reference_optimization_summary_d *> (symtab) {}
fast_function_summary <ipa_reference_optimization_summary_d *, va_heap> (symtab) {}
virtual void remove (cgraph_node *src_node,
ipa_reference_optimization_summary_d *data);
......
......@@ -732,6 +732,17 @@ vec_safe_grow_cleared (vec<T, A, vl_embed> *&v, unsigned len CXX_MEM_STAT_INFO)
}
/* Assume V is not NULL. */
template<typename T>
inline void
vec_safe_grow_cleared (vec<T, va_heap, vl_ptr> *&v,
unsigned len CXX_MEM_STAT_INFO)
{
v->safe_grow_cleared (len);
}
/* If V is NULL return false, otherwise return V->iterate(IX, PTR). */
template<typename T, typename A>
inline bool
......
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