Patchwork Make sure free_gimple_bb is called on all graphite created bbs (PR tree-optimization/46966)

login
register
mail settings
Submitter Jakub Jelinek
Date Dec. 16, 2010, 9:57 p.m.
Message ID <20101216215717.GD2198@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/75806/
State New
Headers show

Comments

Jakub Jelinek - Dec. 16, 2010, 9:57 p.m.
Hi!

graphite-sese-to-poly.c wasn't calling free_gimple_bb on some bbs it removed
from SCOP_BBS vector, which means both small memory leak and, more
importantly, leaving bb->aux as non-NULL.  Later passes assert that
bb->aux is NULL.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2010-12-16  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/46966
	* graphite-sese-to-poly.c (build_scop_drs): Call free_gimple_bb for
	for bbs that are removed from SCOP_BBS vector.

	* gcc.dg/graphite/pr46966.c: New test.


	Jakub
Sebastian Pop - Dec. 16, 2010, 10:42 p.m.
On Thu, Dec 16, 2010 at 15:57, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> graphite-sese-to-poly.c wasn't calling free_gimple_bb on some bbs it removed
> from SCOP_BBS vector, which means both small memory leak and, more
> importantly, leaving bb->aux as non-NULL.  Later passes assert that
> bb->aux is NULL.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Yes, please install.  Thanks for fixing this.

Sebastian

>
> 2010-12-16  Jakub Jelinek  <jakub@redhat.com>
>
>        PR tree-optimization/46966
>        * graphite-sese-to-poly.c (build_scop_drs): Call free_gimple_bb for
>        for bbs that are removed from SCOP_BBS vector.
>
>        * gcc.dg/graphite/pr46966.c: New test.
>
> --- gcc/graphite-sese-to-poly.c.jj      2010-12-02 11:51:32.000000000 +0100
> +++ gcc/graphite-sese-to-poly.c 2010-12-16 14:42:49.000000000 +0100
> @@ -1971,6 +1971,7 @@ build_scop_drs (scop_p scop)
>   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
>     if (VEC_empty (data_reference_p, GBB_DATA_REFS (PBB_BLACK_BOX (pbb))))
>       {
> +       free_gimple_bb (PBB_BLACK_BOX (pbb));
>        VEC_ordered_remove (poly_bb_p, SCOP_BBS (scop), i);
>        i--;
>       }
> --- gcc/testsuite/gcc.dg/graphite/pr46966.c.jj  2010-12-16 14:49:37.000000000 +0100
> +++ gcc/testsuite/gcc.dg/graphite/pr46966.c     2010-12-16 14:50:48.000000000 +0100
> @@ -0,0 +1,13 @@
> +/* PR tree-optimization/46966 */
> +/* { dg-do compile } */
> +/* { dg-options "-O -floop-interchange -ffast-math -fno-tree-copy-prop -fno-tree-loop-im" } */
> +
> +int a[1000][1000];
> +
> +void foo ()
> +{
> +  int i, j;
> +  for (i = 0; i < 1000; i++)
> +    for (j = 0; j < 1000; j++)
> +      a[i][j] = 0;
> +}
>
>        Jakub
>

Patch

--- gcc/graphite-sese-to-poly.c.jj	2010-12-02 11:51:32.000000000 +0100
+++ gcc/graphite-sese-to-poly.c	2010-12-16 14:42:49.000000000 +0100
@@ -1971,6 +1971,7 @@  build_scop_drs (scop_p scop)
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
     if (VEC_empty (data_reference_p, GBB_DATA_REFS (PBB_BLACK_BOX (pbb))))
       {
+	free_gimple_bb (PBB_BLACK_BOX (pbb));
 	VEC_ordered_remove (poly_bb_p, SCOP_BBS (scop), i);
 	i--;
       }
--- gcc/testsuite/gcc.dg/graphite/pr46966.c.jj	2010-12-16 14:49:37.000000000 +0100
+++ gcc/testsuite/gcc.dg/graphite/pr46966.c	2010-12-16 14:50:48.000000000 +0100
@@ -0,0 +1,13 @@ 
+/* PR tree-optimization/46966 */
+/* { dg-do compile } */
+/* { dg-options "-O -floop-interchange -ffast-math -fno-tree-copy-prop -fno-tree-loop-im" } */
+
+int a[1000][1000];
+
+void foo ()
+{
+  int i, j;
+  for (i = 0; i < 1000; i++)
+    for (j = 0; j < 1000; j++)
+      a[i][j] = 0;
+}