This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix memory leaks
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 6 Nov 2015 14:43:13 +0100 (CET)
- Subject: Re: [PATCH] Fix memory leaks
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1511061317400 dot 10078 at zhemvz dot fhfr dot qr>
On Fri, 6 Nov 2015, Richard Biener wrote:
>
> A few, spotted with valgrind. One is even mine ;)
>
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
And this is what I committed (one extra leak in postreload-gcse).
Richard.
2015-11-06 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.c (class sccvn_dom_walker): Add destructor.
* lra.c (init_reg_info): Truncate copy_vec instead of
re-allocating a new one and leaking the old.
* ipa-inline-analysis.c (estimate_function_body_sizes): Free
bb_infos vec.
* sched-deps.c (sched_deps_finish): Free the dn/dl pools.
* postreload-gcse.c (free_mem): Free modify_mem_list and
canon_modify_mem_list.
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c (revision 229842)
--- gcc/tree-ssa-sccvn.c (working copy)
*************** class sccvn_dom_walker : public dom_walk
*** 4154,4159 ****
--- 4199,4205 ----
public:
sccvn_dom_walker ()
: dom_walker (CDI_DOMINATORS), fail (false), cond_stack (vNULL) {}
+ ~sccvn_dom_walker ();
virtual void before_dom_children (basic_block);
virtual void after_dom_children (basic_block);
*************** public:
*** 4168,4173 ****
--- 4214,4224 ----
cond_stack;
};
+ sccvn_dom_walker::~sccvn_dom_walker ()
+ {
+ cond_stack.release ();
+ }
+
/* Record a temporary condition for the BB and its dominated blocks. */
void
Index: gcc/ipa-inline-analysis.c
===================================================================
*** gcc/ipa-inline-analysis.c (revision 229842)
--- gcc/ipa-inline-analysis.c (working copy)
*************** estimate_function_body_sizes (struct cgr
*** 2853,2858 ****
--- 2853,2859 ----
inline_summaries->get (node)->self_time = time;
inline_summaries->get (node)->self_size = size;
nonconstant_names.release ();
+ fbi.bb_infos.release ();
if (opt_for_fn (node->decl, optimize))
{
if (!early)
Index: gcc/sched-deps.c
===================================================================
*** gcc/sched-deps.c (revision 229842)
--- gcc/sched-deps.c (working copy)
*************** void
*** 4092,4100 ****
sched_deps_finish (void)
{
gcc_assert (deps_pools_are_empty_p ());
! dn_pool->release_if_empty ();
dn_pool = NULL;
- dl_pool->release_if_empty ();
dl_pool = NULL;
h_d_i_d.release ();
--- 4092,4100 ----
sched_deps_finish (void)
{
gcc_assert (deps_pools_are_empty_p ());
! delete dn_pool;
! delete dl_pool;
dn_pool = NULL;
dl_pool = NULL;
h_d_i_d.release ();
Index: gcc/lra.c
===================================================================
--- gcc/lra.c (revision 229843)
+++ gcc/lra.c (working copy)
@@ -1293,7 +1293,7 @@ init_reg_info (void)
lra_reg_info = XNEWVEC (struct lra_reg, reg_info_size);
for (i = 0; i < reg_info_size; i++)
initialize_lra_reg_info_element (i);
- copy_vec.create (100);
+ copy_vec.truncate (0);
}
Index: gcc/postreload-gcse.c
===================================================================
--- gcc/postreload-gcse.c (revision 229842)
+++ gcc/postreload-gcse.c (working copy)
@@ -348,6 +348,8 @@ free_mem (void)
BITMAP_FREE (blocks_with_calls);
BITMAP_FREE (modify_mem_list_set);
free (reg_avail_info);
+ free (modify_mem_list);
+ free (canon_modify_mem_list);
}