This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

memory leak in reorg_loops


hi,

In hw-doloop.c,  is there a memory leak?

void
reorg_loops (bool do_reorder, struct hw_doloop_hooks *hooks)
{
  hwloop_info loops = NULL;
  hwloop_info loop;
  bitmap_obstack loop_stack;

  df_live_add_problem ();
  df_live_set_all_dirty ();
  df_analyze ();

  *bitmap_obstack_initialize (&loop_stack);*
  if (dump_file)
    fprintf (dump_file, ";; Find loops, first pass\n\n");

  loops = discover_loops (&loop_stack, hooks);

  if (do_reorder)
    {
      reorder_loops (loops);
      free_loops (loops);

      if (dump_file)
	fprintf (dump_file, ";; Find loops, second pass\n\n");

      loops = discover_loops (&loop_stack, hooks);
    }

  for (loop = loops; loop; loop = loop->next)
    scan_loop (loop);

  /* Now apply the optimizations.  */
  for (loop = loops; loop; loop = loop->next)
    optimize_loop (loop, hooks);

  if (dump_file)
    {
      fprintf (dump_file, ";; After hardware loops optimization:\n\n");
      dump_hwloops (loops);
    }

  free_loops (loops);

  if (dump_file)
    print_rtl (dump_file, get_insns ());
}

valgrind checking shows:

==18622== 1,479,296 bytes in 364 blocks are definitely lost in loss record
559 of 559
==18622==    at 0x4006ADD: malloc (vg_replace_malloc.c:291)
==18622==    by 0x8C0A9D5: xmalloc (xmalloc.c:147)
==18622==    by 0x910457: _obstack_begin (in /lib/libc-2.5.so)
==18622==    by 0x81EDD24: bitmap_obstack_initialize (bitmap.c:318)
==18622==    by 0x8B22BBE: reorg_loops (hw-doloop.c:635)
...
...
==18622==    by 0x8688B3E: rest_of_handle_machine_reorg (reorg.c:4183)
==18622==    by 0x861D2A6: execute_one_pass (passes.c:2097)
==18622==    by 0x861D6A0: execute_pass_list (passes.c:2152)
==18622==    by 0x861D6BC: execute_pass_list (passes.c:2153)
==18622==    by 0x861D6BC: execute_pass_list (passes.c:2153)

should loop_stack be freed at the end of reorg_loops? please confirm!
if it's true, commit for me, thanks! 

    free_loops (loops);
+  bitmap_obstack_release (&loop_stack);

   if (dump_file)
     print_rtl (dump_file, get_insns ());

thanks!

dxq 



--
View this message in context: http://gcc.1065356.n5.nabble.com/memory-leak-in-reorg-loops-tp999219.html
Sent from the gcc - patches mailing list archive at Nabble.com.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]