Commit dbea5bf9 by Martin Liska Committed by Martin Liska

Add call_summary::get method and m_initialize_when_cloning.

2018-06-08  Martin Liska  <mliska@suse.cz>

	* symbol-summary.h (get): New function.
	(call_summary::m_initialize_when_cloning): New class member.

From-SVN: r261316
parent 74644756
2018-06-08 Martin Liska <mliska@suse.cz>
* symbol-summary.h (get): New function.
(call_summary::m_initialize_when_cloning): New class member.
2018-06-08 Martin Liska <mliska@suse.cz>
* cgraph.c (cgraph_node::remove): Do not recycle uid.
* cgraph.h (symbol_table::release_symbol): Do not pass uid.
(symbol_table::allocate_cgraph_symbol): Do not set uid.
......
......@@ -326,7 +326,8 @@ class GTY((user)) call_summary <T *>
public:
/* Default construction takes SYMTAB as an argument. */
call_summary (symbol_table *symtab, bool ggc = false): m_ggc (ggc),
m_map (13, ggc), m_released (false), m_symtab (symtab)
m_initialize_when_cloning (false), m_map (13, ggc), m_released (false),
m_symtab (symtab)
{
m_symtab_removal_hook =
symtab->add_edge_removal_hook
......@@ -374,7 +375,13 @@ public:
If a summary for an edge does not exist, it will be created. */
T* get_create (cgraph_edge *edge)
{
return get_create (hashable_uid (edge));
return get (hashable_uid (edge), true);
}
/* Getter for summary callgraph edge pointer. */
T* get (cgraph_edge *edge)
{
return get (hashable_uid (edge), false);
}
/* Return number of elements handled by data structure. */
......@@ -400,19 +407,14 @@ protected:
/* Indication if we use ggc summary. */
bool m_ggc;
/* Initialize summary for an edge that is cloned. */
bool m_initialize_when_cloning;
private:
typedef int_hash <int, 0, -1> map_hash;
/* Getter for summary callgraph ID. */
T* get_create (int uid)
{
bool existed;
T **v = &m_map.get_or_insert (uid, &existed);
if (!existed)
*v = allocate_new ();
return *v;
}
T *get (int uid, bool lazy_insert);
/* Get a hashable uid of EDGE. */
int hashable_uid (cgraph_edge *edge)
......@@ -439,6 +441,28 @@ private:
};
template <typename T>
T*
call_summary<T *>::get (int uid, bool lazy_insert)
{
gcc_checking_assert (uid > 0);
if (lazy_insert)
{
bool existed;
T **v = &m_map.get_or_insert (uid, &existed);
if (!existed)
*v = allocate_new ();
return *v;
}
else
{
T **v = m_map.get (uid);
return v == NULL ? NULL : *v;
}
}
template <typename T>
void
call_summary<T *>::release ()
{
......@@ -492,15 +516,25 @@ call_summary<T *>::symtab_duplication (cgraph_edge *edge1,
cgraph_edge *edge2, void *data)
{
call_summary *summary = (call_summary <T *> *) (data);
T **v = summary->m_map.get (summary->hashable_uid (edge1));
T *edge1_summary = NULL;
if (v)
if (summary->m_initialize_when_cloning)
edge1_summary = summary->get_create (edge1);
else
{
T **v = summary->m_map.get (summary->hashable_uid (edge1));
if (v)
{
/* This load is necessary, because we insert a new value! */
edge1_summary = *v;
}
}
if (edge1_summary)
{
/* This load is necessary, because we insert a new value! */
T *data = *v;
T *duplicate = summary->allocate_new ();
summary->m_map.put (summary->hashable_uid (edge2), duplicate);
summary->duplicate (edge1, edge2, data, 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