[PATCH 07/21] PR jit/63854: Fix leak of optimization_summary_obstack

2014-11-19 Thread David Malcolm
This was leaking ~4KB per iteration:

16,256 bytes in 4 blocks are definitely lost in loss record 234 of 239
   at 0x4A0645D: malloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x5D75C17: xmalloc (xmalloc.c:147)
   by 0x30958842DB: _obstack_begin (obstack.c:184)
   by 0x4DFECDE: bitmap_obstack_initialize(bitmap_obstack*) (bitmap.c:338)
   by 0x5CA3C1D: ipa_init() (ipa-reference.c:431)
   by 0x5CA3FB1: generate_summary() (ipa-reference.c:551)
   by 0x5CA4650: propagate() (ipa-reference.c:684)
   by 0x5CA5BEE: (anonymous namespace)::pass_ipa_reference::execute(function*) 
(ipa-reference.c:1178)
   by 0x522354D: execute_one_pass(opt_pass*) (passes.c:2306)
   by 0x5224427: execute_ipa_pass_list(opt_pass*) (passes.c:2700)
   by 0x4E495C1: ipa_passes() (cgraphunit.c:2088)
   by 0x4E498E0: symbol_table::compile() (cgraphunit.c:2172)

gcc/ChangeLog:
PR jit/63854
* ipa-reference.c (ipa_reference_c_finalize): Release
optimization_summary_obstack.
---
 gcc/ipa-reference.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
index b421f63..1ce06d1 100644
--- a/gcc/ipa-reference.c
+++ b/gcc/ipa-reference.c
@@ -1193,5 +1193,9 @@ make_pass_ipa_reference (gcc::context *ctxt)
 void
 ipa_reference_c_finalize (void)
 {
-  ipa_init_p = false;
+  if (ipa_init_p)
+{
+  bitmap_obstack_release (optimization_summary_obstack);
+  ipa_init_p = false;
+}
 }
-- 
1.8.5.3



Re: [PATCH 07/21] PR jit/63854: Fix leak of optimization_summary_obstack

2014-11-19 Thread Richard Biener
On Wed, Nov 19, 2014 at 11:46 AM, David Malcolm dmalc...@redhat.com wrote:
 This was leaking ~4KB per iteration:

Ok.

Thanks,
Richard.

 16,256 bytes in 4 blocks are definitely lost in loss record 234 of 239
at 0x4A0645D: malloc (in 
 /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x5D75C17: xmalloc (xmalloc.c:147)
by 0x30958842DB: _obstack_begin (obstack.c:184)
by 0x4DFECDE: bitmap_obstack_initialize(bitmap_obstack*) (bitmap.c:338)
by 0x5CA3C1D: ipa_init() (ipa-reference.c:431)
by 0x5CA3FB1: generate_summary() (ipa-reference.c:551)
by 0x5CA4650: propagate() (ipa-reference.c:684)
by 0x5CA5BEE: (anonymous 
 namespace)::pass_ipa_reference::execute(function*) (ipa-reference.c:1178)
by 0x522354D: execute_one_pass(opt_pass*) (passes.c:2306)
by 0x5224427: execute_ipa_pass_list(opt_pass*) (passes.c:2700)
by 0x4E495C1: ipa_passes() (cgraphunit.c:2088)
by 0x4E498E0: symbol_table::compile() (cgraphunit.c:2172)

 gcc/ChangeLog:
 PR jit/63854
 * ipa-reference.c (ipa_reference_c_finalize): Release
 optimization_summary_obstack.
 ---
  gcc/ipa-reference.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

 diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c
 index b421f63..1ce06d1 100644
 --- a/gcc/ipa-reference.c
 +++ b/gcc/ipa-reference.c
 @@ -1193,5 +1193,9 @@ make_pass_ipa_reference (gcc::context *ctxt)
  void
  ipa_reference_c_finalize (void)
  {
 -  ipa_init_p = false;
 +  if (ipa_init_p)
 +{
 +  bitmap_obstack_release (optimization_summary_obstack);
 +  ipa_init_p = false;
 +}
  }
 --
 1.8.5.3