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]

[tree-ssa] What started as plugging a memory leak...


Hi,

On 2003-12-08, I commited a patch to make the CFG garbage
collectable.  Apparently one hunk of the patch got lot when
I prepared the commit, because a change to varray is missing
that causes us to leak for bb/edge varrays when they need to
grow.

This all isn't so bad, except that it means that in various
places we would explicitly free VARRAYs for edges and basic
blocks (including `basic_block_info'), and most of then also
were not even GTY'ized.  Oh boy...

Bootstrapped C,C++,ObjC,Java on i686-pc-linux-gnu, OK to commit
when testing finishes without new regressions?

Gr.
Steven

	* varray.c (struct elements): Make varray_heads for edges
	and basic blocks garbage collectable.
	* tree-ssa-dom.c (tree_ssa_dominator_optimize): Don't free
	redirection_edges, just clear it.
	(redirection_edges): Add GTY marker.
	* tree-ssa-ccp.c (cfg_blocks): Likewise.
	* basic-block.h (basic_block_info): Likewise.
	* tree-cfg.c (label_to_block_map): Likewise.
	(delete_tree_cfg): Clear basic_block_info.
	* cfgbuild.c (find_basic_blocks): Likewise.
	* flow.c (free_basic_block_vars): Likewise.
	
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.153.2.43
diff -c -3 -p -r1.153.2.43 basic-block.h
*** basic-block.h	14 Jan 2004 22:39:33 -0000	1.153.2.43
--- basic-block.h	28 Jan 2004 18:39:32 -0000
*************** extern int n_edges;
*** 301,307 ****
  
  /* Index by basic block number, get basic block struct info.  */
  
! extern varray_type basic_block_info;
  
  #define BASIC_BLOCK(N)  (VARRAY_BB (basic_block_info, (N)))
  
--- 301,307 ----
  
  /* Index by basic block number, get basic block struct info.  */
  
! extern GTY(()) varray_type basic_block_info;
  
  #define BASIC_BLOCK(N)  (VARRAY_BB (basic_block_info, (N)))
  
Index: cfgbuild.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgbuild.c,v
retrieving revision 1.25.2.12
diff -c -3 -p -r1.25.2.12 cfgbuild.c
*** cfgbuild.c	3 Jan 2004 23:01:37 -0000	1.25.2.12
--- cfgbuild.c	28 Jan 2004 18:39:33 -0000
*************** find_basic_blocks (rtx f, int nregs ATTR
*** 605,611 ****
        FOR_EACH_BB (bb)
  	bb->aux = NULL;
  
!       VARRAY_FREE (basic_block_info);
      }
  
    n_basic_blocks = count_basic_blocks (f);
--- 605,611 ----
        FOR_EACH_BB (bb)
  	bb->aux = NULL;
  
!       basic_block_info = NULL;
      }
  
    n_basic_blocks = count_basic_blocks (f);
Index: flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.534.2.21
diff -c -3 -p -r1.534.2.21 flow.c
*** flow.c	3 Jan 2004 23:01:51 -0000	1.534.2.21
--- flow.c	28 Jan 2004 18:39:42 -0000
*************** free_basic_block_vars (int keep_head_end
*** 791,797 ****
        if (basic_block_info)
  	{
  	  clear_edges ();
! 	  VARRAY_FREE (basic_block_info);
  	}
        n_basic_blocks = 0;
        last_basic_block = 0;
--- 791,797 ----
        if (basic_block_info)
  	{
  	  clear_edges ();
! 	  basic_block_info = NULL;
  	}
        n_basic_blocks = 0;
        last_basic_block = 0;
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.262
diff -c -3 -p -r1.1.4.262 tree-cfg.c
*** tree-cfg.c	23 Jan 2004 01:13:52 -0000	1.1.4.262
--- tree-cfg.c	28 Jan 2004 18:39:49 -0000
*************** static const int initial_cfg_capacity = 
*** 54,60 ****
  
  /* Mapping of labels to their associated blocks.  This can greatly speed up
     building of the CFG in code with lots of gotos.  */
! static varray_type label_to_block_map;
  
  /* CFG statistics.  */
  struct cfg_stats_d
--- 54,60 ----
  
  /* Mapping of labels to their associated blocks.  This can greatly speed up
     building of the CFG in code with lots of gotos.  */
! static GTY(()) varray_type label_to_block_map;
  
  /* CFG statistics.  */
  struct cfg_stats_d
*************** delete_tree_cfg (void)
*** 2346,2351 ****
--- 2346,2352 ----
      free_blocks_annotations ();
  
    free_basic_block_vars (0);
+   basic_block_info = NULL;
    label_to_block_map = NULL;
  }
  
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.134
diff -c -3 -p -r1.1.2.134 tree-ssa-ccp.c
*** tree-ssa-ccp.c	22 Jan 2004 02:11:07 -0000	1.1.2.134
--- tree-ssa-ccp.c	28 Jan 2004 18:39:55 -0000
*************** typedef struct
*** 83,89 ****
  static sbitmap executable_blocks;
  
  /* Array of control flow edges on the worklist.  */
! static varray_type cfg_blocks;
  
  static unsigned int cfg_blocks_num = 0;
  static int cfg_blocks_tail;
--- 83,89 ----
  static sbitmap executable_blocks;
  
  /* Array of control flow edges on the worklist.  */
! static GTY(()) varray_type cfg_blocks;
  
  static unsigned int cfg_blocks_num = 0;
  static int cfg_blocks_tail;
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.120
diff -c -3 -p -r1.1.2.120 tree-ssa-dom.c
*** tree-ssa-dom.c	21 Jan 2004 21:57:09 -0000	1.1.2.120
--- tree-ssa-dom.c	28 Jan 2004 18:40:02 -0000
*************** static struct opt_stats_d opt_stats;
*** 156,162 ****
     final target block itself we can correctly handle redirections
     when the target block had PHIs which required edge insertions/splitting
     to remove the PHIs.  */
! static varray_type redirection_edges;
  
  /* A virtual array holding value range records for the variable identified
     by the index, SSA_VERSION.  */
--- 156,162 ----
     final target block itself we can correctly handle redirections
     when the target block had PHIs which required edge insertions/splitting
     to remove the PHIs.  */
! static GTY(()) varray_type redirection_edges;
  
  /* A virtual array holding value range records for the variable identified
     by the index, SSA_VERSION.  */
*************** tree_ssa_dominator_optimize (void)
*** 588,594 ****
    htab_delete (true_exprs);
    htab_delete (false_exprs);
  
!   VARRAY_FREE (redirection_edges);
    VARRAY_CLEAR (currdefs);
  
    /* And finalize the dominator walker.  */
--- 588,594 ----
    htab_delete (true_exprs);
    htab_delete (false_exprs);
  
!   VARRAY_CLEAR (redirection_edges);
    VARRAY_CLEAR (currdefs);
  
    /* And finalize the dominator walker.  */
Index: varray.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varray.c,v
retrieving revision 1.15.2.8
diff -c -3 -p -r1.15.2.8 varray.c
*** varray.c	25 Oct 2003 17:48:24 -0000	1.15.2.8
--- varray.c	28 Jan 2004 18:40:02 -0000
*************** static const struct {
*** 56,64 ****
    { sizeof (struct bitmap_head_def *), 1 },
    { sizeof (struct reg_info_def *), 0 },
    { sizeof (struct const_equiv_data), 0 },
!   { sizeof (struct basic_block_def *), 0 },
    { sizeof (struct elt_list *), 1 },
!   { sizeof (struct edge_def *), 0 },
    { sizeof (tree *), 1 },
  };
  
--- 56,64 ----
    { sizeof (struct bitmap_head_def *), 1 },
    { sizeof (struct reg_info_def *), 0 },
    { sizeof (struct const_equiv_data), 0 },
!   { sizeof (struct basic_block_def *), 1 },
    { sizeof (struct elt_list *), 1 },
!   { sizeof (struct edge_def *), 1 },
    { sizeof (tree *), 1 },
  };
  


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