Patchwork Fix ipa-cp memory leaks (PR middle-end/56461)

login
register
mail settings
Submitter Jakub Jelinek
Date Feb. 27, 2013, 3:59 p.m.
Message ID <20130227155959.GK12913@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/223647/
State New
Headers show

Comments

Jakub Jelinek - Feb. 27, 2013, 3:59 p.m.
Hi!

known_aggs is freed/released in another function, but not in
decide_whether_version_node, where it leaks memory.

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

2013-02-27  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/56461
	* ipa-cp.c (decide_whether_version_node): Call vec_free on
	known_aggs[i].items and release known_aggs vector.


	Jakub
Richard Guenther - Feb. 27, 2013, 7:51 p.m.
On 2/27/13 4:59 PM, Jakub Jelinek wrote:
> Hi!
> 
> known_aggs is freed/released in another function, but not in
> decide_whether_version_node, where it leaks memory.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk?

Ok.

Thanks,
Richard.

> 2013-02-27  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/56461
> 	* ipa-cp.c (decide_whether_version_node): Call vec_free on
> 	known_aggs[i].items and release known_aggs vector.
> 
> --- gcc/ipa-cp.c.jj	2013-02-21 22:24:12.000000000 +0100
> +++ gcc/ipa-cp.c	2013-02-27 09:25:48.557980184 +0100
> @@ -3406,6 +3406,9 @@ decide_whether_version_node (struct cgra
>        info = IPA_NODE_REF (node);
>        info->do_clone_for_all_contexts = false;
>        IPA_NODE_REF (clone)->is_all_contexts_clone = true;
> +      for (i = 0; i < count ; i++)
> +	vec_free (known_aggs[i].items);
> +      known_aggs.release ();
>        ret = true;
>      }
>    else
> 
> 	Jakub
>

Patch

--- gcc/ipa-cp.c.jj	2013-02-21 22:24:12.000000000 +0100
+++ gcc/ipa-cp.c	2013-02-27 09:25:48.557980184 +0100
@@ -3406,6 +3406,9 @@  decide_whether_version_node (struct cgra
       info = IPA_NODE_REF (node);
       info->do_clone_for_all_contexts = false;
       IPA_NODE_REF (clone)->is_all_contexts_clone = true;
+      for (i = 0; i < count ; i++)
+	vec_free (known_aggs[i].items);
+      known_aggs.release ();
       ret = true;
     }
   else