Release RTL bodies after compilation (sometimes)

Jan Hubicka jh@suse.cz
Thu Sep 2 18:53:00 GMT 2004



Hi,

This patch save about 3MB of garbage on -O0 combine.c compilation by
explicitely freeing some and annotations CFG edges.  Additionally it
makes RTL function bodies to be released again in majority of cases
after compilation.  This reduce peak memory usage from 9MB to 5MB on
Gerald testcase I get from 21 garbage collection runs to 18.  This can
still be significantly improved by followup patches I broke out as they
are slightly more controversal.

On gcc modules compilation test I didn't measured any actual performance
differences but for Gerald's testcase it is about 6%.

Bootstraped/regtested on i686-pc-gnu-linux, OK?

Honza
2004-09-01  Jan Hubicka  <jh@suse.cz>
	* cfg.c (fre_edge): Use ggc_free.
	(expunge_block): Use ggc_free.
	* cfglayout.c (cfg_layout_initialize): Free RBI info.
	* tree-ssa-dce.c (remove_dead_stmt): Free STMT annotation.
	* tree-ssa.c (delete_tree_ssa): Free annotations.
Index: gcc/cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.63
diff -c -3 -p -r1.63 cfg.c
*** gcc/cfg.c	25 Aug 2004 07:25:06 -0000	1.63
--- gcc/cfg.c	2 Sep 2004 18:25:04 -0000
*************** static void
*** 134,140 ****
  free_edge (edge e ATTRIBUTE_UNUSED)
  {
    n_edges--;
!   /* ggc_free (e);  */
  }
  
  /* Free the memory associated with the edge structures.  */
--- 134,140 ----
  free_edge (edge e ATTRIBUTE_UNUSED)
  {
    n_edges--;
!   ggc_free (e);
  }
  
  /* Free the memory associated with the edge structures.  */
*************** expunge_block (basic_block b)
*** 269,275 ****
    unlink_block (b);
    BASIC_BLOCK (b->index) = NULL;
    n_basic_blocks--;
!   /* ggc_free (b); */
  }
  
  /* Create an edge connecting SRC and DEST with flags FLAGS.  Return newly
--- 269,275 ----
    unlink_block (b);
    BASIC_BLOCK (b->index) = NULL;
    n_basic_blocks--;
!   ggc_free (b);
  }
  
  /* Create an edge connecting SRC and DEST with flags FLAGS.  Return newly
Index: gcc/passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.41
diff -c -3 -p -r2.41 passes.c
*** gcc/passes.c	1 Sep 2004 20:58:52 -0000	2.41
--- gcc/passes.c	2 Sep 2004 18:25:04 -0000
*************** rest_of_clean_state (void)
*** 1685,1690 ****
--- 1685,1691 ----
  
    /* We're done with this function.  Free up memory if we can.  */
    free_after_parsing (cfun);
+   free_after_compilation (cfun);
  }
  
  
Index: gcc/tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.30
diff -c -3 -p -r2.30 tree-ssa.c
*** gcc/tree-ssa.c	1 Sep 2004 22:06:20 -0000	2.30
--- gcc/tree-ssa.c	2 Sep 2004 18:25:05 -0000
*************** delete_tree_ssa (void)
*** 641,653 ****
    /* Remove annotations from every tree in the function.  */
    FOR_EACH_BB (bb)
      for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
!       bsi_stmt (bsi)->common.ann = NULL;
  
    /* Remove annotations from every referenced variable.  */
    if (referenced_vars)
      {
        for (i = 0; i < num_referenced_vars; i++)
! 	referenced_var (i)->common.ann = NULL;
        referenced_vars = NULL;
      }
  
--- 641,662 ----
    /* Remove annotations from every tree in the function.  */
    FOR_EACH_BB (bb)
      for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi))
!       {
! 	tree stmt = bsi_stmt (bsi);
!         release_defs (stmt);
! 	ggc_free (stmt->common.ann);
! 	stmt->common.ann = NULL;
!       }
  
    /* Remove annotations from every referenced variable.  */
    if (referenced_vars)
      {
        for (i = 0; i < num_referenced_vars; i++)
! 	{
! 	  tree var = referenced_var (i);
! 	  ggc_free (var->common.ann);
! 	  var->common.ann = NULL;
! 	}
        referenced_vars = NULL;
      }
  
Index: gcc/tree-ssanames.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssanames.c,v
retrieving revision 2.8
diff -c -3 -p -r2.8 tree-ssanames.c
*** gcc/tree-ssanames.c	25 Aug 2004 21:21:19 -0000	2.8
--- gcc/tree-ssanames.c	2 Sep 2004 18:25:05 -0000
*************** release_defs (tree stmt)
*** 300,306 ****
    ssa_op_iter iter;
  
    FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
!     release_ssa_name (def);
  }
  
  
--- 300,307 ----
    ssa_op_iter iter;
  
    FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_ALL_DEFS)
!     if (TREE_CODE (def) == SSA_NAME)
!       release_ssa_name (def);
  }
  
  



More information about the Gcc-patches mailing list