[PATCH] Fix a slp leak caused by vec.h conversion (PR middle-end/56461)

Diego Novillo dnovillo@google.com
Thu Feb 28 21:16:00 GMT 2013


On Thu, Feb 28, 2013 at 3:06 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This is small, but quite common memory leak in slp vectorization.
> vec_alloc (vec_defs, number_of_vects);
> on vl_ptr-ish vec<tree> *vec_defs; first calls new on the vec<tree>
> (i.e. allocates sizeof (void *) bytes), and then actually creates vector
> pointed to by that.  Later on we copy the content of what it points to,
> but don't actually free the void * sized allocation.
> Fixed by changing the vector to be actually vec<vec<tree> > *, which also
> simplifies the callers.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2013-02-28  Jakub Jelinek  <jakub@redhat.com>
>
>         PR middle-end/56461
>         * tree-vectorizer.h (vect_get_slp_defs): Change 3rd argument
>         type to vec<vec<tree> > *.
>         * tree-vect-slp.c (vect_get_slp_defs): Likewise.  Change vec_defs
>         to be vec<tree> instead of vec<tree> *, set vec_defs
>         to vNULL and call vec_defs.create (number_of_vects), adjust other
>         uses of vec_defs.
>         * tree-vect-stmts.c (vect_get_vec_defs, vectorizable_call,
>         vectorizable_condition): Adjust vect_get_slp_defs callers.

OK.


Diego.



More information about the Gcc-patches mailing list