aboutsummaryrefslogtreecommitdiff
path: root/gcc/symbol-summary.h
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2017-02-03 09:20:02 +0100
committerMartin Liska <marxin@gcc.gnu.org>2017-02-03 08:20:02 +0000
commite806796de03b50f1b8cddaa6e0696ab652f268ef (patch)
treefdc17253740fdcce9e854af3c077c20bd504fc47 /gcc/symbol-summary.h
parent6d5b4f9e713a7e6804d589dfef76ce8cad3d0f02 (diff)
downloadgcc-e806796de03b50f1b8cddaa6e0696ab652f268ef.zip
gcc-e806796de03b50f1b8cddaa6e0696ab652f268ef.tar.gz
gcc-e806796de03b50f1b8cddaa6e0696ab652f268ef.tar.bz2
Fix memory leaks in IPA CP (PR ipa/79337).
2017-02-03 Martin Liska <mliska@suse.cz> PR ipa/79337 * ipa-prop.c (ipa_node_params_t::insert): Remove current implementation. (ipa_node_params_t::remove): Likewise. * ipa-prop.h (ipa_node_params::ipa_node_params): Make default initialization from removed ipa_node_params_t::insert. (ipa_node_params::~ipa_node_params): Move from removed ipa_node_params_t::release. * symbol-summary.h (symbol_summary::m_released): New member. Do not release a summary twice. Do not allow to call finalizer for types of a summary that live in GGC memory. From-SVN: r245145
Diffstat (limited to 'gcc/symbol-summary.h')
-rw-r--r--gcc/symbol-summary.h27
1 files changed, 14 insertions, 13 deletions
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index 1274be7..3bcd145 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -37,7 +37,8 @@ class GTY((user)) function_summary <T *>
public:
/* Default construction takes SYMTAB as an argument. */
function_summary (symbol_table *symtab, bool ggc = false): m_ggc (ggc),
- m_map (13, ggc), m_insertion_enabled (true), m_symtab (symtab)
+ m_map (13, ggc), m_insertion_enabled (true), m_released (false),
+ m_symtab (symtab)
{
m_symtab_insertion_hook =
symtab->add_cgraph_insertion_hook
@@ -60,23 +61,19 @@ public:
/* Destruction method that can be called for GGT purpose. */
void release ()
{
- if (m_symtab_insertion_hook)
- m_symtab->remove_cgraph_insertion_hook (m_symtab_insertion_hook);
+ if (m_released)
+ return;
- if (m_symtab_removal_hook)
- m_symtab->remove_cgraph_removal_hook (m_symtab_removal_hook);
-
- if (m_symtab_duplication_hook)
- m_symtab->remove_cgraph_duplication_hook (m_symtab_duplication_hook);
-
- m_symtab_insertion_hook = NULL;
- m_symtab_removal_hook = NULL;
- m_symtab_duplication_hook = NULL;
+ m_symtab->remove_cgraph_insertion_hook (m_symtab_insertion_hook);
+ m_symtab->remove_cgraph_removal_hook (m_symtab_removal_hook);
+ m_symtab->remove_cgraph_duplication_hook (m_symtab_duplication_hook);
/* Release all summaries. */
typedef typename hash_map <map_hash, T *>::iterator map_iterator;
for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
release ((*it).second);
+
+ m_released = true;
}
/* Traverses all summarys with a function F called with
@@ -99,7 +96,9 @@ public:
/* Allocates new data that are stored within map. */
T* allocate_new ()
{
- return m_ggc ? new (ggc_alloc <T> ()) T() : new T () ;
+ /* Call gcc_internal_because we do not want to call finalizer for
+ a type T. We call dtor explicitly. */
+ return m_ggc ? new (ggc_internal_alloc (sizeof (T))) T () : new T () ;
}
/* Release an item that is stored within map. */
@@ -216,6 +215,8 @@ private:
cgraph_2node_hook_list *m_symtab_duplication_hook;
/* Indicates if insertion hook is enabled. */
bool m_insertion_enabled;
+ /* Indicates if the summary is released. */
+ bool m_released;
/* Symbol table the summary is registered to. */
symbol_table *m_symtab;