From 6eae938e34e36c461ebec1570ff0f3d2f5e1b8cf 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.
(function_summary::release): New function.
---
gcc/symbol-summary.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
@@ -81,6 +81,11 @@ public:
m_symtab_insertion_hook = NULL;
m_symtab_removal_hook = NULL;
m_symtab_duplication_hook = NULL;
+
+ /* Release all summaries. */
+ typedef typename hash_map <int, T *, summary_hashmap_traits>::iterator map_iterator;
+ 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 +111,18 @@ 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)
+ {
+ item->~T ();
+ ggc_free (item);
+ }
+ else
+ delete item;
+ }
+
/* Getter for summary callgraph node pointer. */
T* get (cgraph_node *node)
{
--
2.1.4