From fdbdc4b5626aea76d0ee6d8b2ae3753db735014d Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 25 Mar 2015 12:47:04 +0100 Subject: [PATCH] re PR tree-optimization/65538 (Memory leak of ipa_node_params_sum elements) Fix PR65538. PR tree-optimization/65538 * symbol-summary.h (function_summary::~function_summary): Relese memory for allocated summaries. (function_summary::release): New function. From-SVN: r221658 --- gcc/ChangeLog | 7 +++++++ gcc/symbol-summary.h | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f450b7d8799..66e0b2c7cfb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-03-25 Martin Liska + + PR tree-optimization/65538 + * symbol-summary.h (function_summary::~function_summary): + Relese memory for allocated summaries. + (function_summary::release): New function. + 2015-03-25 Jakub Jelinek PR lto/65515 diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h index 8d7e42c52ad..04483103a94 100644 --- a/gcc/symbol-summary.h +++ b/gcc/symbol-summary.h @@ -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 ::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() : 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.30.2