diff mbox

Fix memory leak in tree_estimate_loop_size (PR middle-end/56461)

Message ID 20130301201820.GI12913@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek March 1, 2013, 8:18 p.m. UTC
Hi!

path vector has been only released when return false; later in the function,
but not in this case.  Bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

2013-03-01  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/56461
	* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Release path
	vector even when returning true.  Fix up function comment formatting.


	Jakub

Comments

Jeff Law March 1, 2013, 10:50 p.m. UTC | #1
On 03/01/2013 01:18 PM, Jakub Jelinek wrote:
> Hi!
>
> path vector has been only released when return false; later in the function,
> but not in this case.  Bootstrapped/regtested on x86_64-linux and
> i686-linux, ok for trunk?
>
> 2013-03-01  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR middle-end/56461
> 	* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Release path
> 	vector even when returning true.  Fix up function comment formatting.
OK.

Jeff
Richard Biener March 4, 2013, 10 a.m. UTC | #2
On Fri, 1 Mar 2013, Jakub Jelinek wrote:

> Hi!
> 
> path vector has been only released when return false; later in the function,
> but not in this case.  Bootstrapped/regtested on x86_64-linux and
> i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2013-03-01  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/56461
> 	* tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Release path
> 	vector even when returning true.  Fix up function comment formatting.
> 
> --- gcc/tree-ssa-loop-ivcanon.c.jj	2013-01-11 09:02:48.000000000 +0100
> +++ gcc/tree-ssa-loop-ivcanon.c	2013-03-01 17:16:51.955088637 +0100
> @@ -207,7 +207,7 @@ constant_after_peeling (tree op, gimple
>     EDGE_TO_CANCEL (if non-NULL) is an non-exit edge eliminated in the last iteration
>     of loop.
>     Return results in SIZE, estimate benefits for complete unrolling exiting by EXIT. 
> -   Stop estimating after UPPER_BOUND is met. Return true in this case */
> +   Stop estimating after UPPER_BOUND is met.  Return true in this case.  */
>  
>  static bool
>  tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, struct loop_size *size,
> @@ -321,6 +321,7 @@ tree_estimate_loop_size (struct loop *lo
>  	      - size->last_iteration_eliminated_by_peeling) > upper_bound)
>  	    {
>                free (body);
> +	      path.release ();
>  	      return true;
>  	    }
>  	}
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/tree-ssa-loop-ivcanon.c.jj	2013-01-11 09:02:48.000000000 +0100
+++ gcc/tree-ssa-loop-ivcanon.c	2013-03-01 17:16:51.955088637 +0100
@@ -207,7 +207,7 @@  constant_after_peeling (tree op, gimple
    EDGE_TO_CANCEL (if non-NULL) is an non-exit edge eliminated in the last iteration
    of loop.
    Return results in SIZE, estimate benefits for complete unrolling exiting by EXIT. 
-   Stop estimating after UPPER_BOUND is met. Return true in this case */
+   Stop estimating after UPPER_BOUND is met.  Return true in this case.  */
 
 static bool
 tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, struct loop_size *size,
@@ -321,6 +321,7 @@  tree_estimate_loop_size (struct loop *lo
 	      - size->last_iteration_eliminated_by_peeling) > upper_bound)
 	    {
               free (body);
+	      path.release ();
 	      return true;
 	    }
 	}