{
public:
/* Default construction takes SYMTAB as an argument. */
- call_summary_base (symbol_table *symtab CXX_MEM_STAT_INFO):
- m_symtab (symtab),
+ call_summary_base (symbol_table *symtab, cgraph_edge_hook symtab_removal,
+ cgraph_2edge_hook symtab_duplication CXX_MEM_STAT_INFO):
+ m_symtab (symtab), m_symtab_removal (symtab_removal),
+ m_symtab_duplication (symtab_duplication), m_symtab_duplication_hook (NULL),
m_initialize_when_cloning (false),
- m_duplication_enabled (true),
m_allocator ("call summary" PASS_MEM_STAT)
- {}
+ {
+ m_symtab_removal_hook
+ = m_symtab->add_edge_removal_hook (m_symtab_removal, this);
+ enable_duplication_hook ();
+ }
/* Basic implementation of removal operation. */
virtual void remove (cgraph_edge *, T *) {}
/* Enable duplication hook invocation. */
void enable_duplication_hook ()
{
- m_duplication_enabled = true;
+ if (m_symtab_duplication_hook == NULL)
+ m_symtab_duplication_hook
+ = m_symtab->add_edge_duplication_hook (m_symtab_duplication,
+ this);
}
/* Enable duplication hook invocation. */
void disable_duplication_hook ()
{
- m_duplication_enabled = false;
+ if (m_symtab_duplication_hook != NULL)
+ {
+ m_symtab->remove_edge_duplication_hook (m_symtab_duplication_hook);
+ m_symtab_duplication_hook = NULL;
+ }
}
protected:
/* Symbol table the summary is registered to. */
symbol_table *m_symtab;
+ /* Removal function defined by a summary. */
+ cgraph_edge_hook m_symtab_removal;
+ /* Duplication function defined by a summary. */
+ cgraph_2edge_hook m_symtab_duplication;
+
/* Internal summary removal hook pointer. */
cgraph_edge_hook_list *m_symtab_removal_hook;
/* Internal summary duplication hook pointer. */
cgraph_2edge_hook_list *m_symtab_duplication_hook;
/* Initialize summary for an edge that is cloned. */
bool m_initialize_when_cloning;
- /* Indicates if duplication hook is enabled. */
- bool m_duplication_enabled;
private:
/* Return true when the summary uses GGC memory for allocation. */
call_summary_base<T>::unregister_hooks ()
{
m_symtab->remove_edge_removal_hook (m_symtab_removal_hook);
- m_symtab->remove_edge_duplication_hook (m_symtab_duplication_hook);
+ disable_duplication_hook ();
}
/* An impossible class templated by non-pointers so, which makes sure that only
/* Default construction takes SYMTAB as an argument. */
call_summary (symbol_table *symtab, bool ggc = false
CXX_MEM_STAT_INFO)
- : call_summary_base<T> (symtab PASS_MEM_STAT), m_ggc (ggc),
- m_map (13, ggc, true, GATHER_STATISTICS PASS_MEM_STAT)
- {
- this->m_symtab_removal_hook
- = this->m_symtab->add_edge_removal_hook (call_summary::symtab_removal,
- this);
- this->m_symtab_duplication_hook
- = this->m_symtab->add_edge_duplication_hook (call_summary::symtab_duplication,
- this);
- }
+ : call_summary_base<T> (symtab, call_summary::symtab_removal,
+ call_summary::symtab_duplication PASS_MEM_STAT),
+ m_ggc (ggc), m_map (13, ggc, true, GATHER_STATISTICS PASS_MEM_STAT) {}
/* Destructor. */
virtual ~call_summary ();
cgraph_edge *edge2, void *data)
{
call_summary *summary = (call_summary <T *> *) (data);
- if (summary->m_duplication_enabled)
- {
- T *edge1_summary = NULL;
+ T *edge1_summary = NULL;
- if (summary->m_initialize_when_cloning)
- edge1_summary = summary->get_create (edge1);
- else
- edge1_summary = summary->get (edge1);
+ if (summary->m_initialize_when_cloning)
+ edge1_summary = summary->get_create (edge1);
+ else
+ edge1_summary = summary->get (edge1);
- if (edge1_summary)
- summary->duplicate (edge1, edge2, edge1_summary,
- summary->get_create (edge2));
- }
+ if (edge1_summary)
+ summary->duplicate (edge1, edge2, edge1_summary,
+ summary->get_create (edge2));
}
template <typename T>
public:
/* Default construction takes SYMTAB as an argument. */
fast_call_summary (symbol_table *symtab CXX_MEM_STAT_INFO)
- : call_summary_base<T> (symtab PASS_MEM_STAT), m_vector (NULL)
+ : call_summary_base<T> (symtab, fast_call_summary::symtab_removal,
+ fast_call_summary::symtab_duplication PASS_MEM_STAT),
+ m_vector (NULL)
{
vec_alloc (m_vector, 13 PASS_MEM_STAT);
- this->m_symtab_removal_hook
- = this->m_symtab->add_edge_removal_hook (fast_call_summary::symtab_removal,
- this);
- this->m_symtab_duplication_hook
- = this->m_symtab->add_edge_duplication_hook (fast_call_summary::symtab_duplication,
- this);
}
/* Destructor. */
cgraph_edge *edge2, void *data)
{
fast_call_summary *summary = (fast_call_summary <T *, V> *) (data);
- if (summary->m_duplication_enabled)
+ T *edge1_summary = NULL;
+
+ if (summary->m_initialize_when_cloning)
+ edge1_summary = summary->get_create (edge1);
+ else
+ edge1_summary = summary->get (edge1);
+
+ if (edge1_summary)
{
- T *edge1_summary = NULL;
-
- if (summary->m_initialize_when_cloning)
- edge1_summary = summary->get_create (edge1);
- else
- edge1_summary = summary->get (edge1);
-
- if (edge1_summary)
- {
- T *duplicate = summary->get_create (edge2);
- summary->duplicate (edge1, edge2, edge1_summary, duplicate);
- }
+ T *duplicate = summary->get_create (edge2);
+ summary->duplicate (edge1, edge2, edge1_summary, duplicate);
}
}