diff mbox

Fix memory leak within ipa_inline

Message ID 1381363842.30976.10.camel@surprise
State New
Headers show

Commit Message

David Malcolm Oct. 10, 2013, 12:10 a.m. UTC
ipa-inline.c:ipa_inline leaks "order" when optimizations are disabled.
This potentially becomes significant in my JIT branch since the
compilation code could be invoked many times within one process.

Bootstrapped and regtested against trunk on x86_64-unknown-linux.

OK for trunk?

(Seen using valgrind; I've already committed this on my dmalcolm/jit
branch as:
http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=8c61655effbb29cba2cc342c35bd47a6dda2df16
)

Comments

Richard Biener Oct. 10, 2013, 7:53 a.m. UTC | #1
On Thu, Oct 10, 2013 at 2:10 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> ipa-inline.c:ipa_inline leaks "order" when optimizations are disabled.
> This potentially becomes significant in my JIT branch since the
> compilation code could be invoked many times within one process.
>
> Bootstrapped and regtested against trunk on x86_64-unknown-linux.
>
> OK for trunk?

Ok.

Thanks,
Richard.

> (Seen using valgrind; I've already committed this on my dmalcolm/jit
> branch as:
> http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=8c61655effbb29cba2cc342c35bd47a6dda2df16
> )
>
David Malcolm Oct. 10, 2013, 6:12 p.m. UTC | #2
On Thu, 2013-10-10 at 09:53 +0200, Richard Biener wrote:
> On Thu, Oct 10, 2013 at 2:10 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> > ipa-inline.c:ipa_inline leaks "order" when optimizations are disabled.
> > This potentially becomes significant in my JIT branch since the
> > compilation code could be invoked many times within one process.
> >
> > Bootstrapped and regtested against trunk on x86_64-unknown-linux.
> >
> > OK for trunk?
> 
> Ok.
Thanks; committed to trunk as r203389.
diff mbox

Patch

commit 090cc42be462de08068014ce371fb68d15945f8e
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Wed Oct 9 13:50:23 2013 -0400

    ipa-inline.c:ipa_inline: Fix leak of "order" when optimizations are disabled.
    
    gcc/
    	* ipa-inline.c (ipa_inline): Fix leak of "order" when
    	optimizations are disabled.

diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index f51178b..f93cc45 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1962,8 +1962,7 @@  ipa_inline (void)
 {
   struct cgraph_node *node;
   int nnodes;
-  struct cgraph_node **order =
-    XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
+  struct cgraph_node **order;
   int i;
   int cold;
   bool remove_functions = false;
@@ -1971,6 +1970,8 @@  ipa_inline (void)
   if (!optimize)
     return 0;
 
+  order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
+
   if (in_lto_p && optimize)
     ipa_update_after_lto_read ();