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]

Re: Save GGC garbage produced by gimplifier


> Jan Hubicka wrote:
> 
> >Hi,
> >the memory usage of varrays increased dramatically since 3.4 accounting now
> >about 20% of memory overhead.  About 60% of it (at -O0) accounts to varray
> >"stack" used by gimplifier that needs not to live in ggc at all.
> >
> >Bootstrapped/regtessed on i686-pc-gnu-linux.
> >I don't like the need to use GENERIC_PTR for trees.  An alternative is
> >to add explicit ggc_free to release the varray that looks slightly
> >inferrior because of the fragmentation, but if it is preffered, I can do
> >that too.
> > 
> >
> Thanks for doing this!  I had planned to work on this same patch.

No prob ;)
I have one patch for you as well.  In C++ frontend the local_names names
pointer often keeps pointing into function body making it alive for GGC
even after we compiled it and curefully elliminated the DECL_SAVED_TREE
pointer. This cause serious memory leaks on Gerald's testcase (about
100MB).

I added following code to clean the pointers after gimplification (patch
attached).  It has bootstrapped/regtested i686-pc-gnu-linux the gcac
bootstrap is pending.

But it seems like number of pointers are alive only during
finish_function that means that perhaps we can move most of these into
local datastructures and stop bloating the tree nodes.  You definitly
know more about dataflow in C++ frotnend, so perhaps you have some
ideas?

Honza

2004-09-03  Jan Hubicka  <jh@suse.cz>

	* cp/decl.c (finish_function): Clean out pointers we no longer need.

Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.911.2.62.2.10
diff -c -3 -p -r1.911.2.62.2.10 decl.c
*** cp/decl.c	2 Aug 2004 23:13:40 -0000	1.911.2.62.2.10
--- cp/decl.c	2 Sep 2004 15:09:11 -0000
*************** finish_function (int flags)
*** 10411,10421 ****
--- 10411,10433 ----
    /* Genericize before inlining.  */
    if (!processing_template_decl)
      {
+       struct language_function *f = DECL_SAVED_FUNCTION_DATA (fndecl);
        cp_genericize (fndecl);
+       /* Clear out the bits we don't need.  */
+       f->x_current_class_ptr = NULL;
+       f->x_current_class_ref = NULL;
+       f->x_eh_spec_block = NULL;
+       f->x_in_charge_parm = NULL;
+       f->x_vtt_parm = NULL;
+       f->x_return_value = NULL;
+       f->bindings = NULL;
  
        /* Handle attribute((warn_unused_result)).  Relies on gimple input.  */
        c_warn_unused_result (&DECL_SAVED_TREE (fndecl));
      }
+   /* Clear out the bits we don't need.  */
+   local_names = NULL;
+   named_label_uses = NULL;
  
    /* We're leaving the context of this function, so zap cfun.  It's still in
       DECL_STRUCT_FUNCTION, and we'll restore it in tree_rest_of_compilation.  */


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