Commit 78cd68c0 by Martin Liska Committed by Martin Liska

Release function and edge summaries allocated with GGC.

2019-10-29  Martin Liska  <mliska@suse.cz>

	* ggc.h (ggc_alloc_no_dtor): New function.
	* ipa-fnsummary.c (ipa_free_fn_summary): Call
	destructor and ggc_free.
	(ipa_free_size_summary): Call delete instead
	of release.
	* ipa-fnsummary.h: Use new function ggc_alloc_no_dtor.
	* ipa-prop.c (ipa_check_create_edge_args): Likewise.
	(ipa_free_all_edge_args): Call destructor and ggc_free.
	(ipa_free_all_node_params): Likewise.
	(ipcp_free_transformation_sum): Likewise.
	* ipa-prop.h (ipa_check_create_node_params):
	Call new ggc_alloc_no_dtor.
	* ipa-sra.c (ipa_sra_generate_summary): Likewise.
	(ipa_sra_analysis): Call destructor and ggc_free.
	Replace release with delete operator.
	* symbol-summary.h (release): Remove ..
	(V>::~fast_function_summary): and move logic here.
	Likewise for other classes.

From-SVN: r277572
parent 318bd8c6
2019-10-29 Martin Liska <mliska@suse.cz>
* ggc.h (ggc_alloc_no_dtor): New function.
* ipa-fnsummary.c (ipa_free_fn_summary): Call
destructor and ggc_free.
(ipa_free_size_summary): Call delete instead
of release.
* ipa-fnsummary.h: Use new function ggc_alloc_no_dtor.
* ipa-prop.c (ipa_check_create_edge_args): Likewise.
(ipa_free_all_edge_args): Call destructor and ggc_free.
(ipa_free_all_node_params): Likewise.
(ipcp_free_transformation_sum): Likewise.
* ipa-prop.h (ipa_check_create_node_params):
Call new ggc_alloc_no_dtor.
* ipa-sra.c (ipa_sra_generate_summary): Likewise.
(ipa_sra_analysis): Call destructor and ggc_free.
Replace release with delete operator.
* symbol-summary.h (release): Remove ..
(V>::~fast_function_summary): and move logic here.
Likewise for other classes.
2019-10-29 Richard Biener <rguenther@suse.de> 2019-10-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/92260 PR tree-optimization/92260
...@@ -185,6 +185,18 @@ ggc_alloc (ALONE_CXX_MEM_STAT_INFO) ...@@ -185,6 +185,18 @@ ggc_alloc (ALONE_CXX_MEM_STAT_INFO)
PASS_MEM_STAT)); PASS_MEM_STAT));
} }
/* GGC allocation function that does not call finalizer for type
that have need_finalization_p equal to true. User is responsible
for calling of the destructor. */
template<typename T>
inline T *
ggc_alloc_no_dtor (ALONE_CXX_MEM_STAT_INFO)
{
return static_cast<T *> (ggc_internal_alloc (sizeof (T), NULL, 0, 1
PASS_MEM_STAT));
}
template<typename T> template<typename T>
inline T * inline T *
ggc_cleared_alloc (ALONE_CXX_MEM_STAT_INFO) ggc_cleared_alloc (ALONE_CXX_MEM_STAT_INFO)
......
...@@ -3873,9 +3873,9 @@ ipa_free_fn_summary (void) ...@@ -3873,9 +3873,9 @@ ipa_free_fn_summary (void)
{ {
if (!ipa_call_summaries) if (!ipa_call_summaries)
return; return;
ipa_fn_summaries->release (); ipa_fn_summaries->~fast_function_summary <ipa_fn_summary *, va_gc> ();
ggc_free (ipa_fn_summaries);
ipa_fn_summaries = NULL; ipa_fn_summaries = NULL;
ipa_call_summaries->release ();
delete ipa_call_summaries; delete ipa_call_summaries;
ipa_call_summaries = NULL; ipa_call_summaries = NULL;
edge_predicate_pool.release (); edge_predicate_pool.release ();
...@@ -3891,7 +3891,7 @@ ipa_free_size_summary (void) ...@@ -3891,7 +3891,7 @@ ipa_free_size_summary (void)
{ {
if (!ipa_size_summaries) if (!ipa_size_summaries)
return; return;
ipa_size_summaries->release (); delete ipa_size_summaries;
ipa_size_summaries = NULL; ipa_size_summaries = NULL;
} }
......
...@@ -194,8 +194,8 @@ public: ...@@ -194,8 +194,8 @@ public:
static ipa_fn_summary_t *create_ggc (symbol_table *symtab) static ipa_fn_summary_t *create_ggc (symbol_table *symtab)
{ {
class ipa_fn_summary_t *summary = new (ggc_alloc <ipa_fn_summary_t> ()) class ipa_fn_summary_t *summary
ipa_fn_summary_t (symtab); = new (ggc_alloc_no_dtor<ipa_fn_summary_t> ()) ipa_fn_summary_t (symtab);
summary->disable_insertion_hook (); summary->disable_insertion_hook ();
return summary; return summary;
} }
......
...@@ -3719,7 +3719,7 @@ ipa_check_create_edge_args (void) ...@@ -3719,7 +3719,7 @@ ipa_check_create_edge_args (void)
{ {
if (!ipa_edge_args_sum) if (!ipa_edge_args_sum)
ipa_edge_args_sum ipa_edge_args_sum
= (new (ggc_cleared_alloc <ipa_edge_args_sum_t> ()) = (new (ggc_alloc_no_dtor<ipa_edge_args_sum_t> ())
ipa_edge_args_sum_t (symtab, true)); ipa_edge_args_sum_t (symtab, true));
if (!ipa_bits_hash_table) if (!ipa_bits_hash_table)
ipa_bits_hash_table = hash_table<ipa_bit_ggc_hash_traits>::create_ggc (37); ipa_bits_hash_table = hash_table<ipa_bit_ggc_hash_traits>::create_ggc (37);
...@@ -3735,7 +3735,8 @@ ipa_free_all_edge_args (void) ...@@ -3735,7 +3735,8 @@ ipa_free_all_edge_args (void)
if (!ipa_edge_args_sum) if (!ipa_edge_args_sum)
return; return;
ipa_edge_args_sum->release (); ipa_edge_args_sum->~ipa_edge_args_sum_t ();
ggc_free (ipa_edge_args_sum);
ipa_edge_args_sum = NULL; ipa_edge_args_sum = NULL;
} }
...@@ -3744,7 +3745,8 @@ ipa_free_all_edge_args (void) ...@@ -3744,7 +3745,8 @@ ipa_free_all_edge_args (void)
void void
ipa_free_all_node_params (void) ipa_free_all_node_params (void)
{ {
ipa_node_params_sum->release (); ipa_node_params_sum->~ipa_node_params_t ();
ggc_free (ipa_node_params_sum);
ipa_node_params_sum = NULL; ipa_node_params_sum = NULL;
} }
...@@ -3770,7 +3772,8 @@ ipcp_free_transformation_sum (void) ...@@ -3770,7 +3772,8 @@ ipcp_free_transformation_sum (void)
if (!ipcp_transformation_sum) if (!ipcp_transformation_sum)
return; return;
ipcp_transformation_sum->release (); ipcp_transformation_sum->~function_summary<ipcp_transformation *> ();
ggc_free (ipcp_transformation_sum);
ipcp_transformation_sum = NULL; ipcp_transformation_sum = NULL;
} }
......
...@@ -672,7 +672,7 @@ public: ...@@ -672,7 +672,7 @@ public:
static ipcp_transformation_t *create_ggc (symbol_table *symtab) static ipcp_transformation_t *create_ggc (symbol_table *symtab)
{ {
ipcp_transformation_t *summary ipcp_transformation_t *summary
= new (ggc_cleared_alloc <ipcp_transformation_t> ()) = new (ggc_alloc_no_dtor <ipcp_transformation_t> ())
ipcp_transformation_t (symtab, true); ipcp_transformation_t (symtab, true);
return summary; return summary;
} }
...@@ -710,7 +710,7 @@ ipa_check_create_node_params (void) ...@@ -710,7 +710,7 @@ ipa_check_create_node_params (void)
{ {
if (!ipa_node_params_sum) if (!ipa_node_params_sum)
ipa_node_params_sum ipa_node_params_sum
= (new (ggc_cleared_alloc <ipa_node_params_t> ()) = (new (ggc_alloc_no_dtor <ipa_node_params_t> ())
ipa_node_params_t (symtab, true)); ipa_node_params_t (symtab, true));
} }
......
...@@ -2546,7 +2546,7 @@ ipa_sra_generate_summary (void) ...@@ -2546,7 +2546,7 @@ ipa_sra_generate_summary (void)
gcc_checking_assert (!func_sums); gcc_checking_assert (!func_sums);
gcc_checking_assert (!call_sums); gcc_checking_assert (!call_sums);
func_sums func_sums
= (new (ggc_cleared_alloc <ipa_sra_function_summaries> ()) = (new (ggc_alloc_no_dtor <ipa_sra_function_summaries> ())
ipa_sra_function_summaries (symtab, true)); ipa_sra_function_summaries (symtab, true));
call_sums = new ipa_sra_call_summaries (symtab); call_sums = new ipa_sra_call_summaries (symtab);
...@@ -2805,7 +2805,7 @@ ipa_sra_read_summary (void) ...@@ -2805,7 +2805,7 @@ ipa_sra_read_summary (void)
gcc_checking_assert (!func_sums); gcc_checking_assert (!func_sums);
gcc_checking_assert (!call_sums); gcc_checking_assert (!call_sums);
func_sums func_sums
= (new (ggc_cleared_alloc <ipa_sra_function_summaries> ()) = (new (ggc_alloc_no_dtor <ipa_sra_function_summaries> ())
ipa_sra_function_summaries (symtab, true)); ipa_sra_function_summaries (symtab, true));
call_sums = new ipa_sra_call_summaries (symtab); call_sums = new ipa_sra_call_summaries (symtab);
...@@ -3989,9 +3989,10 @@ ipa_sra_analysis (void) ...@@ -3989,9 +3989,10 @@ ipa_sra_analysis (void)
process_isra_node_results (node, clone_num_suffixes); process_isra_node_results (node, clone_num_suffixes);
delete clone_num_suffixes; delete clone_num_suffixes;
func_sums->release (); func_sums->~ipa_sra_function_summaries ();
ggc_free (func_sums);
func_sums = NULL; func_sums = NULL;
call_sums->release (); delete call_sums;
call_sums = NULL; call_sums = NULL;
if (dump_file) if (dump_file)
......
...@@ -29,7 +29,7 @@ class function_summary_base ...@@ -29,7 +29,7 @@ class function_summary_base
public: public:
/* Default construction takes SYMTAB as an argument. */ /* Default construction takes SYMTAB as an argument. */
function_summary_base (symbol_table *symtab): m_symtab (symtab), function_summary_base (symbol_table *symtab): m_symtab (symtab),
m_insertion_enabled (true), m_released (false) m_insertion_enabled (true)
{} {}
/* Basic implementation of insert operation. */ /* Basic implementation of insert operation. */
...@@ -88,8 +88,6 @@ protected: ...@@ -88,8 +88,6 @@ protected:
/* Indicates if insertion hook is enabled. */ /* Indicates if insertion hook is enabled. */
bool m_insertion_enabled; bool m_insertion_enabled;
/* Indicates if the summary is released. */
bool m_released;
private: private:
/* Return true when the summary uses GGC memory for allocation. */ /* Return true when the summary uses GGC memory for allocation. */
...@@ -134,14 +132,7 @@ public: ...@@ -134,14 +132,7 @@ public:
function_summary (symbol_table *symtab, bool ggc = false); function_summary (symbol_table *symtab, bool ggc = false);
/* Destructor. */ /* Destructor. */
virtual ~function_summary () virtual ~function_summary ();
{
release ();
}
/* Destruction method that can be called for GGC purpose. */
using function_summary_base<T>::release;
void release ();
/* Traverses all summarys with a function F called with /* Traverses all summarys with a function F called with
ARG as argument. */ ARG as argument. */
...@@ -237,20 +228,14 @@ function_summary<T *>::function_summary (symbol_table *symtab, bool ggc): ...@@ -237,20 +228,14 @@ function_summary<T *>::function_summary (symbol_table *symtab, bool ggc):
} }
template <typename T> template <typename T>
void function_summary<T *>::~function_summary ()
function_summary<T *>::release ()
{ {
if (this->m_released)
return;
this->unregister_hooks (); this->unregister_hooks ();
/* Release all summaries. */ /* Release all summaries. */
typedef typename hash_map <map_hash, T *>::iterator map_iterator; typedef typename hash_map <map_hash, T *>::iterator map_iterator;
for (map_iterator it = m_map.begin (); it != m_map.end (); ++it) for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
this->release ((*it).second); this->release ((*it).second);
this->m_released = true;
} }
template <typename T> template <typename T>
...@@ -343,14 +328,7 @@ public: ...@@ -343,14 +328,7 @@ public:
fast_function_summary (symbol_table *symtab); fast_function_summary (symbol_table *symtab);
/* Destructor. */ /* Destructor. */
virtual ~fast_function_summary () virtual ~fast_function_summary ();
{
release ();
}
/* Destruction method that can be called for GGC purpose. */
using function_summary_base<T>::release;
void release ();
/* Traverses all summarys with a function F called with /* Traverses all summarys with a function F called with
ARG as argument. */ ARG as argument. */
...@@ -445,22 +423,15 @@ fast_function_summary<T *, V>::fast_function_summary (symbol_table *symtab): ...@@ -445,22 +423,15 @@ fast_function_summary<T *, V>::fast_function_summary (symbol_table *symtab):
} }
template <typename T, typename V> template <typename T, typename V>
void fast_function_summary<T *, V>::~fast_function_summary ()
fast_function_summary<T *, V>::release ()
{ {
if (this->m_released)
return;
this->unregister_hooks (); this->unregister_hooks ();
/* Release all summaries. */ /* Release all summaries. */
for (unsigned i = 0; i < m_vector->length (); i++) for (unsigned i = 0; i < m_vector->length (); i++)
if ((*m_vector)[i] != NULL) if ((*m_vector)[i] != NULL)
this->release ((*m_vector)[i]); this->release ((*m_vector)[i]);
vec_free (m_vector); vec_free (m_vector);
this->m_released = true;
} }
template <typename T, typename V> template <typename T, typename V>
...@@ -558,7 +529,7 @@ class call_summary_base ...@@ -558,7 +529,7 @@ class call_summary_base
public: public:
/* Default construction takes SYMTAB as an argument. */ /* Default construction takes SYMTAB as an argument. */
call_summary_base (symbol_table *symtab): m_symtab (symtab), call_summary_base (symbol_table *symtab): m_symtab (symtab),
m_initialize_when_cloning (true), m_released (false) m_initialize_when_cloning (true)
{} {}
/* Basic implementation of removal operation. */ /* Basic implementation of removal operation. */
...@@ -600,8 +571,6 @@ protected: ...@@ -600,8 +571,6 @@ protected:
cgraph_2edge_hook_list *m_symtab_duplication_hook; cgraph_2edge_hook_list *m_symtab_duplication_hook;
/* Initialize summary for an edge that is cloned. */ /* Initialize summary for an edge that is cloned. */
bool m_initialize_when_cloning; bool m_initialize_when_cloning;
/* Indicates if the summary is released. */
bool m_released;
private: private:
/* Return true when the summary uses GGC memory for allocation. */ /* Return true when the summary uses GGC memory for allocation. */
...@@ -645,14 +614,7 @@ public: ...@@ -645,14 +614,7 @@ public:
} }
/* Destructor. */ /* Destructor. */
virtual ~call_summary () virtual ~call_summary ();
{
release ();
}
/* Destruction method that can be called for GGC purpose. */
using call_summary_base<T>::release;
void release ();
/* Traverses all summarys with an edge E called with /* Traverses all summarys with an edge E called with
ARG as argument. */ ARG as argument. */
...@@ -730,20 +692,14 @@ private: ...@@ -730,20 +692,14 @@ private:
}; };
template <typename T> template <typename T>
void call_summary<T *>::~call_summary ()
call_summary<T *>::release ()
{ {
if (this->m_released)
return;
this->unregister_hooks (); this->unregister_hooks ();
/* Release all summaries. */ /* Release all summaries. */
typedef typename hash_map <map_hash, T *>::iterator map_iterator; typedef typename hash_map <map_hash, T *>::iterator map_iterator;
for (map_iterator it = m_map.begin (); it != m_map.end (); ++it) for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
this->release ((*it).second); this->release ((*it).second);
this->m_released = true;
} }
template <typename T> template <typename T>
...@@ -825,14 +781,7 @@ public: ...@@ -825,14 +781,7 @@ public:
} }
/* Destructor. */ /* Destructor. */
virtual ~fast_call_summary () virtual ~fast_call_summary ();
{
release ();
}
/* Destruction method that can be called for GGC purpose. */
using call_summary_base<T>::release;
void release ();
/* Traverses all summarys with an edge F called with /* Traverses all summarys with an edge F called with
ARG as argument. */ ARG as argument. */
...@@ -908,22 +857,15 @@ private: ...@@ -908,22 +857,15 @@ private:
}; };
template <typename T, typename V> template <typename T, typename V>
void fast_call_summary<T *, V>::~fast_call_summary ()
fast_call_summary<T *, V>::release ()
{ {
if (this->m_released)
return;
this->unregister_hooks (); this->unregister_hooks ();
/* Release all summaries. */ /* Release all summaries. */
for (unsigned i = 0; i < m_vector->length (); i++) for (unsigned i = 0; i < m_vector->length (); i++)
if ((*m_vector)[i] != NULL) if ((*m_vector)[i] != NULL)
this->release ((*m_vector)[i]); this->release ((*m_vector)[i]);
vec_free (m_vector); vec_free (m_vector);
this->m_released = true;
} }
template <typename T, typename V> template <typename T, typename V>
......
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