Patchwork Fix memory leaks in ldist_gen (PR middle-end/56461)

login
register
mail settings
Submitter Jakub Jelinek
Date March 1, 2013, 8:07 p.m.
Message ID <20130301200757.GE12913@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/224438/
State New
Headers show

Comments

Jakub Jelinek - March 1, 2013, 8:07 p.m.
Hi!

When merging partitions together, we remove them from partitions vector,
thus don't free them at all.  Fixed thusly, 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-loop-distribution.c (ldist_gen): Call partition_free after each
	partitions.ordered_remove.


	Jakub
Richard Guenther - March 4, 2013, 9:59 a.m.
On Fri, 1 Mar 2013, Jakub Jelinek wrote:

> Hi!
> 
> When merging partitions together, we remove them from partitions vector,
> thus don't free them at all.  Fixed thusly, 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-loop-distribution.c (ldist_gen): Call partition_free after each
> 	partitions.ordered_remove.
> 
> --- gcc/tree-loop-distribution.c.jj	2013-01-28 17:06:51.000000000 +0100
> +++ gcc/tree-loop-distribution.c	2013-03-01 13:17:11.851331653 +0100
> @@ -1306,6 +1306,7 @@ ldist_gen (struct loop *loop, struct gra
>  		if (partition->kind == PKIND_REDUCTION)
>  		  into->kind = PKIND_REDUCTION;
>  		partitions.ordered_remove (i);
> +		partition_free (partition);
>  		i--;
>  	      }
>  	    else
> @@ -1342,6 +1343,7 @@ ldist_gen (struct loop *loop, struct gra
>  		  if (partition->kind == PKIND_REDUCTION)
>  		    into->kind = PKIND_REDUCTION;
>  		  partitions.ordered_remove (j);
> +		  partition_free (partition);
>  		  j--;
>  		}
>  	    }
> @@ -1367,6 +1369,7 @@ ldist_gen (struct loop *loop, struct gra
>  	      bitmap_ior_into (into->stmts, what->stmts);
>  	      into->kind = PKIND_REDUCTION;
>  	      partitions.ordered_remove (i);
> +	      partition_free (what);
>  	    }
>  	}
>      }
> 
> 	Jakub
> 
>

Patch

--- gcc/tree-loop-distribution.c.jj	2013-01-28 17:06:51.000000000 +0100
+++ gcc/tree-loop-distribution.c	2013-03-01 13:17:11.851331653 +0100
@@ -1306,6 +1306,7 @@  ldist_gen (struct loop *loop, struct gra
 		if (partition->kind == PKIND_REDUCTION)
 		  into->kind = PKIND_REDUCTION;
 		partitions.ordered_remove (i);
+		partition_free (partition);
 		i--;
 	      }
 	    else
@@ -1342,6 +1343,7 @@  ldist_gen (struct loop *loop, struct gra
 		  if (partition->kind == PKIND_REDUCTION)
 		    into->kind = PKIND_REDUCTION;
 		  partitions.ordered_remove (j);
+		  partition_free (partition);
 		  j--;
 		}
 	    }
@@ -1367,6 +1369,7 @@  ldist_gen (struct loop *loop, struct gra
 	      bitmap_ior_into (into->stmts, what->stmts);
 	      into->kind = PKIND_REDUCTION;
 	      partitions.ordered_remove (i);
+	      partition_free (what);
 	    }
 	}
     }