[PATCH] Fix memory leaks

Richard Biener rguenther@suse.de
Fri Nov 6 12:18:00 GMT 2015


A few, spotted with valgrind.  One is even mine ;)

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

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.

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);
 }
 
 



More information about the Gcc-patches mailing list