{
public:
/* Default construction takes SYMTAB as an argument. */
- function_summary_base (symbol_table *symtab CXX_MEM_STAT_INFO):
- m_symtab (symtab),
- m_insertion_enabled (true),
- m_duplication_enabled (true),
+ function_summary_base (symbol_table *symtab,
+ cgraph_node_hook symtab_insertion,
+ cgraph_node_hook symtab_removal,
+ cgraph_2node_hook symtab_duplication
+ CXX_MEM_STAT_INFO):
+ m_symtab (symtab), m_symtab_insertion (symtab_insertion),
+ m_symtab_removal (symtab_removal),
+ m_symtab_duplication (symtab_duplication),
+ m_symtab_insertion_hook (NULL), m_symtab_duplication_hook (NULL),
m_allocator ("function summary" PASS_MEM_STAT)
- {}
+ {
+ enable_insertion_hook ();
+ m_symtab_removal_hook
+ = m_symtab->add_cgraph_removal_hook (m_symtab_removal, this);
+ enable_duplication_hook ();
+ }
/* Basic implementation of insert operation. */
virtual void insert (cgraph_node *, T *)
/* Enable insertion hook invocation. */
void enable_insertion_hook ()
{
- m_insertion_enabled = true;
+ if (m_symtab_insertion_hook == NULL)
+ m_symtab_insertion_hook
+ = m_symtab->add_cgraph_insertion_hook (m_symtab_insertion, this);
}
/* Enable insertion hook invocation. */
void disable_insertion_hook ()
{
- m_insertion_enabled = false;
+ if (m_symtab_insertion_hook != NULL)
+ {
+ m_symtab->remove_cgraph_insertion_hook (m_symtab_insertion_hook);
+ m_symtab_insertion_hook = NULL;
+ }
}
/* 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_cgraph_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_cgraph_duplication_hook (m_symtab_duplication_hook);
+ m_symtab_duplication_hook = NULL;
+ }
}
protected:
/* Unregister all call-graph hooks. */
void unregister_hooks ();
+ /* Symbol table the summary is registered to. */
+ symbol_table *m_symtab;
+
+ /* Insertion function defined by a summary. */
+ cgraph_node_hook m_symtab_insertion;
+ /* Removal function defined by a summary. */
+ cgraph_node_hook m_symtab_removal;
+ /* Duplication function defined by a summary. */
+ cgraph_2node_hook m_symtab_duplication;
+
/* Internal summary insertion hook pointer. */
cgraph_node_hook_list *m_symtab_insertion_hook;
/* Internal summary removal hook pointer. */
cgraph_node_hook_list *m_symtab_removal_hook;
/* Internal summary duplication hook pointer. */
cgraph_2node_hook_list *m_symtab_duplication_hook;
- /* Symbol table the summary is registered to. */
- symbol_table *m_symtab;
-
- /* Indicates if insertion hook is enabled. */
- bool m_insertion_enabled;
- /* Indicates if duplication hook is enabled. */
- bool m_duplication_enabled;
private:
/* Return true when the summary uses GGC memory for allocation. */
void
function_summary_base<T>::unregister_hooks ()
{
- m_symtab->remove_cgraph_insertion_hook (m_symtab_insertion_hook);
+ disable_insertion_hook ();
m_symtab->remove_cgraph_removal_hook (m_symtab_removal_hook);
- m_symtab->remove_cgraph_duplication_hook (m_symtab_duplication_hook);
+ disable_duplication_hook ();
}
/* We want to pass just pointer types as argument for function_summary
template <typename T>
function_summary<T *>::function_summary (symbol_table *symtab, bool ggc
MEM_STAT_DECL):
- function_summary_base<T> (symtab PASS_MEM_STAT), m_ggc (ggc),
- m_map (13, ggc, true, GATHER_STATISTICS PASS_MEM_STAT)
-{
- this->m_symtab_insertion_hook
- = this->m_symtab->add_cgraph_insertion_hook (function_summary::symtab_insertion,
- this);
- this->m_symtab_removal_hook
- = this->m_symtab->add_cgraph_removal_hook (function_summary::symtab_removal,
- this);
- this->m_symtab_duplication_hook
- = this->m_symtab->add_cgraph_duplication_hook (function_summary::symtab_duplication,
- this);
-}
+ function_summary_base<T> (symtab, function_summary::symtab_insertion,
+ function_summary::symtab_removal,
+ function_summary::symtab_duplication
+ PASS_MEM_STAT),
+ m_ggc (ggc), m_map (13, ggc, true, GATHER_STATISTICS PASS_MEM_STAT) {}
template <typename T>
function_summary<T *>::~function_summary ()
{
gcc_checking_assert (node->get_uid ());
function_summary *summary = (function_summary <T *> *) (data);
-
- if (summary->m_insertion_enabled)
- summary->insert (node, summary->get_create (node));
+ summary->insert (node, summary->get_create (node));
}
template <typename T>
cgraph_node *node2, void *data)
{
function_summary *summary = (function_summary <T *> *) (data);
- if (summary->m_duplication_enabled)
- {
- T *v = summary->get (node);
+ T *v = summary->get (node);
- if (v)
- summary->duplicate (node, node2, v, summary->get_create (node2));
- }
+ if (v)
+ summary->duplicate (node, node2, v, summary->get_create (node2));
}
template <typename T>
};
template <typename T, typename V>
-fast_function_summary<T *, V>::fast_function_summary (symbol_table *symtab MEM_STAT_DECL):
- function_summary_base<T> (symtab PASS_MEM_STAT), m_vector (NULL)
+fast_function_summary<T *, V>::fast_function_summary (symbol_table *symtab
+ MEM_STAT_DECL):
+ function_summary_base<T> (symtab,
+ fast_function_summary::symtab_insertion,
+ fast_function_summary::symtab_removal,
+ fast_function_summary::symtab_duplication
+ PASS_MEM_STAT), m_vector (NULL)
{
vec_alloc (m_vector, 13 PASS_MEM_STAT);
- this->m_symtab_insertion_hook
- = this->m_symtab->add_cgraph_insertion_hook (fast_function_summary::symtab_insertion,
- this);
- this->m_symtab_removal_hook
- = this->m_symtab->add_cgraph_removal_hook (fast_function_summary::symtab_removal,
- this);
- this->m_symtab_duplication_hook
- = this->m_symtab->add_cgraph_duplication_hook (fast_function_summary::symtab_duplication,
- this);
}
template <typename T, typename V>
{
gcc_checking_assert (node->get_uid ());
fast_function_summary *summary = (fast_function_summary <T *, V> *) (data);
-
- if (summary->m_insertion_enabled)
- summary->insert (node, summary->get_create (node));
+ summary->insert (node, summary->get_create (node));
}
template <typename T, typename V>
void *data)
{
fast_function_summary *summary = (fast_function_summary <T *, V> *) (data);
- if (summary->m_duplication_enabled)
- {
- T *v = summary->get (node);
+ T *v = summary->get (node);
- if (v)
- {
- T *duplicate = summary->get_create (node2);
- summary->duplicate (node, node2, v, duplicate);
- }
+ if (v)
+ {
+ T *duplicate = summary->get_create (node2);
+ summary->duplicate (node, node2, v, duplicate);
}
}