Message ID | 5511DD11.2070502@suse.cz |
---|---|
State | New |
Headers | show |
On Tue, Mar 24, 2015 at 10:54:25PM +0100, Martin Liška wrote: > --- a/gcc/symbol-summary.h > +++ b/gcc/symbol-summary.h > @@ -81,6 +81,12 @@ public: > m_symtab_insertion_hook = NULL; > m_symtab_removal_hook = NULL; > m_symtab_duplication_hook = NULL; > + > + /* Release all summaries in case we use non-GGC memory. */ > + typedef typename hash_map <int, T *, summary_hashmap_traits>::iterator map_iterator; > + if (!m_ggc) > + for (map_iterator it = m_map.begin (); it != m_map.end (); ++it) > + release ((*it).second); You haven't removed the now unnecessary if (!m_ggc) guard. > @@ -106,6 +112,15 @@ public: > return m_ggc ? new (ggc_alloc <T> ()) T() : new T () ; > } > > + /* Release an item that is stored within map. */ > + void release (T *item) > + { > + if (m_ggc) > + ggc_free (item); Perhaps run also the item's destructor first? I know that inline_summary doesn't have a user destructor, so it will expand to nothing, so it would be just for completeness. > + else > + delete item; > + } > + Jakub
> On Tue, Mar 24, 2015 at 10:54:25PM +0100, Martin Liška wrote: > > --- a/gcc/symbol-summary.h > > +++ b/gcc/symbol-summary.h > > @@ -81,6 +81,12 @@ public: > > m_symtab_insertion_hook = NULL; > > m_symtab_removal_hook = NULL; > > m_symtab_duplication_hook = NULL; > > + > > + /* Release all summaries in case we use non-GGC memory. */ > > + typedef typename hash_map <int, T *, summary_hashmap_traits>::iterator map_iterator; > > + if (!m_ggc) > > + for (map_iterator it = m_map.begin (); it != m_map.end (); ++it) > > + release ((*it).second); > > You haven't removed the now unnecessary if (!m_ggc) guard. > > > @@ -106,6 +112,15 @@ public: > > return m_ggc ? new (ggc_alloc <T> ()) T() : new T () ; > > } > > > > + /* Release an item that is stored within map. */ > > + void release (T *item) > > + { > > + if (m_ggc) > > + ggc_free (item); > > Perhaps run also the item's destructor first? I know that > inline_summary doesn't have a user destructor, so it will expand to nothing, > so it would be just for completeness. Yep, calling destructors is a good idea. OK with that change and fix Jakub pointed out. Honza > > > + else > > + delete item; > > + } > > + > > Jakub
From 8ae68cd2c69287c26543b22fa7afe2ff5cdcda8c Mon Sep 17 00:00:00 2001 From: mliska <mliska@suse.cz> Date: Tue, 24 Mar 2015 13:58:50 +0100 Subject: [PATCH] Fix PR65538. gcc/ChangeLog: 2015-03-24 Martin Liska <mliska@suse.cz> PR tree-optimization/65538 * symbol-summary.h (function_summary::~function_summary): Relese memory for allocated summaries in case non-GGC template instance. --- gcc/symbol-summary.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h index 8d7e42c..9a87891 100644 --- a/gcc/symbol-summary.h +++ b/gcc/symbol-summary.h @@ -81,6 +81,12 @@ public: m_symtab_insertion_hook = NULL; m_symtab_removal_hook = NULL; m_symtab_duplication_hook = NULL; + + /* Release all summaries in case we use non-GGC memory. */ + typedef typename hash_map <int, T *, summary_hashmap_traits>::iterator map_iterator; + if (!m_ggc) + for (map_iterator it = m_map.begin (); it != m_map.end (); ++it) + release ((*it).second); } /* Traverses all summarys with a function F called with @@ -106,6 +112,15 @@ public: return m_ggc ? new (ggc_alloc <T> ()) T() : new T () ; } + /* Release an item that is stored within map. */ + void release (T *item) + { + if (m_ggc) + ggc_free (item); + else + delete item; + } + /* Getter for summary callgraph node pointer. */ T* get (cgraph_node *node) { -- 2.1.4