Release RTL bodies after compilation (sometimes)

Jan Hubicka jh@suse.cz
Tue Sep 14 20:15:00 GMT 2004


> 
> On Fri, 2004-09-03 at 01:39, Mark Mitchell wrote:
> 
> > >Oops,  I've broke out the patch twice from larger set of changes and
> > >forgot to check the changelog.  Here is fixed one.
> > >
> > >	* cfg.c (fre_edge): Use ggc_free.
> > >	(expunge_block): Use ggc_free.
> >
> Jan,
> 
> This is causing the bootstrap failure on x86_64 and others reported in
> other/17437.  I think that it may be safer to revert this patch for now.

Interesting-the bootstrap allways breaks on wrong platform ;).  I've
bootstrapped this patch with gcac sucesfully, but I did that on i386.  
> 
> The problem is that out of DU chains we end up wanting to traverse into
> a basic block that has been explicitly ggc_free'd.
> 
> Could you please revert this and investigate who may be holding on to DU
> information longer than the life time of the block?

Sure.  I see this is another problem with leaking SSA nodes.  There are
actually few problems with this.  At first place the released SSA nodes 
are not cleared out so they still points to dead statements.  Making
them to be cleared one gets segfaults as few loops still walk the dead
ssanames.  I've made patch for this part with the zeroing patch as
followup.  I would bet I sent it out, but I can't find it in the
archives, so I am attaching it.

Thank you for working this out and I apologize for the breakage!

Hi,
the patch also has interesting side effect on i686-pc-gnu-linux bootstrap & regtest:
Tests that now work, but didn't before:

gfortran.fortran-torture/execute/elemental.f90 execution,  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions
gfortran.fortran-torture/execute/elemental.f90 execution,  -O3 -fomit-frame-pointer -funroll-loops

I didn't tracked down why this happends for the very moment, but I would
attribute it to tree-ssa-alias.c change.

Bootstrapped/regtested i686-pc-gnu-linux with and w/o checking and
ppc-pc-gnu-linux with checking and no slowdowns measured (and slight speedup on
non checking i686 build, non-checking PPC build died for unrealed reasons I am
trying to look into now)

Memory savings of this patch per se are small (400Kb for combine.c) but I need
it for some further work - I want to clear out pointers in released nodes (thus
I need them to not be walked by loops - after all it seems quite crazy design
to keep dead arrays in ssa_names array) and this saves about 30% of peak memory
usage for rt-3.4.ii (huge template testcase I grabbed somewhere from bugzilla)
as most of statements gets simply elliminated by first DCE so we can recycle
them before burning a lot of memory elsewhere.

I also want to try the goal of releasing all SSA names.  For this I need few
further changes that are more dubious so I decided to not send them in the
first round.

Honza
2004-09-10  Jan Hubicka  <jh@suse.cz>
	* tree-cfg.c (remove_bb): Release SSA defs.
	* tree-ssa-alias.c (init_alias_info): Do not walk pointers in freelist.
	* tree-ssa-loop-ivopts (remove_statements): Release SSA defs.
	* tree-ssa.c (verify_flow_sensitive_alias_info): Do not walk dead nodes.
	* tree-tailcall.c (eliminate_tail_call): Release SSA name.

Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.47
diff -c -3 -p -r2.47 tree-cfg.c
*** tree-cfg.c	6 Sep 2004 10:07:56 -0000	2.47
--- tree-cfg.c	7 Sep 2004 13:26:46 -0000
*************** remove_bb (basic_block bb)
*** 1818,1823 ****
--- 1818,1824 ----
    for (i = bsi_start (bb); !bsi_end_p (i); bsi_remove (&i))
      {
        tree stmt = bsi_stmt (i);
+       release_defs (stmt);
  
        set_bb_for_stmt (stmt, NULL);
  
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.28
diff -c -3 -p -r2.28 tree-ssa-alias.c
*** tree-ssa-alias.c	6 Sep 2004 10:08:05 -0000	2.28
--- tree-ssa-alias.c	7 Sep 2004 13:26:46 -0000
*************** init_alias_info (void)
*** 417,423 ****
  	{
  	  tree name = ssa_name (i);
  
! 	  if (!POINTER_TYPE_P (TREE_TYPE (name)))
  	    continue;
  
  	  if (SSA_NAME_PTR_INFO (name))
--- 417,423 ----
  	{
  	  tree name = ssa_name (i);
  
! 	  if (SSA_NAME_IN_FREE_LIST (name) || !POINTER_TYPE_P (TREE_TYPE (name)))
  	    continue;
  
  	  if (SSA_NAME_PTR_INFO (name))
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.3
diff -c -3 -p -r2.3 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c	6 Sep 2004 18:38:27 -0000	2.3
--- tree-ssa-loop-ivopts.c	7 Sep 2004 13:26:47 -0000
*************** remove_statement (tree stmt, bool includ
*** 3777,3782 ****
--- 3777,3784 ----
        block_stmt_iterator bsi = stmt_for_bsi (stmt);
  
        bsi_remove (&bsi);
+       if (including_defined_name)
+         release_defs (stmt);
      }
  }
  
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.32
diff -c -3 -p -r2.32 tree-ssa.c
*** tree-ssa.c	6 Sep 2004 10:08:11 -0000	2.32
--- tree-ssa.c	7 Sep 2004 13:26:47 -0000
*************** verify_flow_sensitive_alias_info (void)
*** 408,413 ****
--- 408,415 ----
        struct ptr_info_def *pi;
  
        ptr = ssa_name (i);
+       if (!TREE_VISITED (ptr))
+ 	continue;
        ann = var_ann (SSA_NAME_VAR (ptr));
        pi = SSA_NAME_PTR_INFO (ptr);
  
Index: tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-tailcall.c,v
retrieving revision 2.23
diff -c -3 -p -r2.23 tree-tailcall.c
*** tree-tailcall.c	6 Sep 2004 10:08:13 -0000	2.23
--- tree-tailcall.c	7 Sep 2004 13:26:47 -0000
*************** eliminate_tail_call (struct tailcall *t)
*** 681,692 ****
    bsi_next (&bsi);
    while (!bsi_end_p (bsi))
      {
        /* Do not remove the return statement, so that redirect_edge_and_branch
  	 sees how the block ends.  */
!       if (TREE_CODE (bsi_stmt (bsi)) == RETURN_EXPR)
  	break;
  
        bsi_remove (&bsi);
      }
  
    /* Replace the call by a jump to the start of function.  */
--- 681,694 ----
    bsi_next (&bsi);
    while (!bsi_end_p (bsi))
      {
+       tree t = bsi_stmt (bsi);
        /* Do not remove the return statement, so that redirect_edge_and_branch
  	 sees how the block ends.  */
!       if (TREE_CODE (t) == RETURN_EXPR)
  	break;
  
        bsi_remove (&bsi);
+       release_defs (t);
      }
  
    /* Replace the call by a jump to the start of function.  */
*************** eliminate_tail_call (struct tailcall *t)
*** 772,777 ****
--- 774,780 ----
      }
  
    bsi_remove (&t->call_bsi);
+   release_defs (call);
  }
  
  /* Optimizes the tailcall described by T.  If OPT_TAILCALLS is true, also



More information about the Gcc-patches mailing list