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: [tree-ssa] Make PHI nodes reachable by GGC


> On Fri, Nov 28, 2003 at 11:59:24PM +0100, Jan Hubicka wrote:
> > This still seems to be better than moving whole CFG into GGC memory, but
> > I can implement that too if this is preferred.
> 
> I'd prefer the whole CFG be GCed.
> 
> >     ann = bb_ann (bb);
> >     TREE_CHAIN (phi) = ann->phi_nodes;
> >     ann->phi_nodes = phi;
> > +   VARRAY_TREE (tree_phi_root, bb->index) = phi;
> 
> This just wastes space in the bb annotation.  We might as well just
> move the PHI out to the array entirely and be done with it.
Here is updated patch.  tested on i686-pc-gnu-linux.  OK?

2003-11-28  Jan Hubicka  <jh@suse.cz>
	* basic-block.h (tree_phi_root): New variable.
	* cfg.c: Include tree-flow.h.
	(compact_blocks): Compact tree_phi_root
	* tree-cfg.c (build_tree-cfg): Initialize tree_phi_root.
	(create_bb, remove_bb, delete_tree_cfg): Update tree_phi_root.
	* tree-dfa.c (tree_phi_root): Declare.
	(create_phi_node, add_phi_arg, remove_phi_node,
	remove_all_phi_nodes_for):  Always use ancesor functions for
	getting, varray for setting phis.
	* tree-ssa-pre.c (code_motion): Likewsie.
	* tree-flow-inline.h (phi_nodes): Use varray.
	* tree-flow.h (bb_ann_d): Remove phi_nodes.
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.153.2.36
diff -c -3 -p -r1.153.2.36 basic-block.h
*** basic-block.h	12 Nov 2003 22:06:24 -0000	1.153.2.36
--- basic-block.h	29 Nov 2003 01:29:47 -0000
*************** extern varray_type basic_block_info;
*** 292,297 ****
--- 292,298 ----
  /* The root of statement_lists of basic blocks for the garbage collector.
     This is a hack; we really should GC the entire CFG structure.  */
  extern GTY(()) varray_type tree_bb_root;
+ extern GTY(()) varray_type tree_phi_root;
  
  /* For iterating over basic blocks.  */
  #define FOR_BB_BETWEEN(BB, FROM, TO, DIR) \
Index: cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.34.2.16
diff -c -3 -p -r1.34.2.16 cfg.c
*** cfg.c	12 Nov 2003 22:06:24 -0000	1.34.2.16
--- cfg.c	29 Nov 2003 01:29:47 -0000
*************** compact_blocks (void)
*** 258,271 ****
    basic_block bb;
  
    i = 0;
    FOR_EACH_BB (bb)
      {
        BASIC_BLOCK (i) = bb;
        if (tree_bb_root)
! 	VARRAY_TREE (tree_bb_root, i) = bb->stmt_list;
        bb->index = i;
        i++;
      }
  
    if (i != n_basic_blocks)
      abort ();
--- 258,280 ----
    basic_block bb;
  
    i = 0;
+   if (tree_phi_root)
+     FOR_EACH_BB (bb)
+       bb->aux = VARRAY_TREE (tree_phi_root, bb->index);
    FOR_EACH_BB (bb)
      {
        BASIC_BLOCK (i) = bb;
        if (tree_bb_root)
!         {
! 	  VARRAY_TREE (tree_bb_root, i) = bb->stmt_list;
! 	  VARRAY_TREE (tree_phi_root, i) = bb->aux;
!         }
        bb->index = i;
        i++;
      }
+   if (tree_phi_root)
+     FOR_EACH_BB (bb)
+       bb->aux = NULL;
  
    if (i != n_basic_blocks)
      abort ();
*************** compact_blocks (void)
*** 274,280 ****
      {
        BASIC_BLOCK (i) = NULL;
        if (tree_bb_root)
! 	VARRAY_TREE (tree_bb_root, i) = NULL_TREE;
      }
  
    last_basic_block = n_basic_blocks;
--- 283,292 ----
      {
        BASIC_BLOCK (i) = NULL;
        if (tree_bb_root)
!         {
! 	  VARRAY_TREE (tree_bb_root, i) = NULL_TREE;
! 	  VARRAY_TREE (tree_phi_root, i) = NULL_TREE;
!         }
      }
  
    last_basic_block = n_basic_blocks;
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.225
diff -c -3 -p -r1.1.4.225 tree-cfg.c
*** tree-cfg.c	25 Nov 2003 05:09:07 -0000	1.1.4.225
--- tree-cfg.c	29 Nov 2003 01:29:48 -0000
*************** build_tree_cfg (tree *fnbody)
*** 152,157 ****
--- 152,158 ----
    memset ((void *) &cfg_stats, 0, sizeof (cfg_stats));
  
    VARRAY_TREE_INIT (tree_bb_root, initial_cfg_capacity, "tree_bb_root");
+   VARRAY_TREE_INIT (tree_phi_root, initial_cfg_capacity, "tree_phi_root");
  
    /* Build a mapping of labels to their associated blocks.  */
    VARRAY_BB_INIT (label_to_block_map, initial_cfg_capacity,
*************** build_tree_cfg (tree *fnbody)
*** 176,181 ****
--- 177,183 ----
        /* Adjust the size of the array.  */
        VARRAY_GROW (basic_block_info, n_basic_blocks);
        VARRAY_GROW (tree_bb_root, n_basic_blocks);
+       VARRAY_GROW (tree_phi_root, n_basic_blocks);
  
        /* Create block annotations.  */
        create_blocks_annotations ();
*************** create_bb (tree stmt_list, basic_block a
*** 426,431 ****
--- 428,434 ----
        size_t new_size = n_basic_blocks + (n_basic_blocks + 3) / 4;
        VARRAY_GROW (basic_block_info, new_size);
        VARRAY_GROW (tree_bb_root, new_size);
+       VARRAY_GROW (tree_phi_root, new_size);
      }
  
    /* Add the newly created block to the array.  */
*************** remove_bb (basic_block bb)
*** 1564,1569 ****
--- 1567,1573 ----
      delete_from_dominance_info (pdom_info, bb);
  
    VARRAY_TREE (tree_bb_root, bb->index) = NULL_TREE;
+   VARRAY_TREE (tree_phi_root, bb->index) = NULL_TREE;
  
    /* Remove the basic block from the array.  */
    expunge_block (bb);
*************** delete_tree_cfg (void)
*** 2419,2424 ****
--- 2423,2429 ----
      free_blocks_annotations ();
    free_basic_block_vars (0);
    tree_bb_root = NULL;
+   tree_phi_root = NULL;
  }
  
  /* Return the first statement in basic block BB, stripped of any NOP
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.189
diff -c -3 -p -r1.1.4.189 tree-dfa.c
*** tree-dfa.c	27 Nov 2003 04:01:02 -0000	1.1.4.189
--- tree-dfa.c	29 Nov 2003 01:29:48 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 45,50 ****
--- 45,53 ----
  #include "tree-alias-common.h"
  #include "convert.h"
  
+ /* The root of statement_lists of basic blocks for the garbage collector.
+    This is a hack; we really should GC the entire CFG structure.  */
+ varray_type tree_phi_root;
  /* Build and maintain data flow information for trees.  */
  
  /* Counters used to display DFA and SSA statistics.  */
*************** create_phi_node (tree var, basic_block b
*** 932,939 ****
  
    /* Add the new PHI node to the list of PHI nodes for block BB.  */
    ann = bb_ann (bb);
!   TREE_CHAIN (phi) = ann->phi_nodes;
!   ann->phi_nodes = phi;
  
    /* Associate BB to the PHI node.  */
    set_bb_for_stmt (phi, bb);
--- 935,942 ----
  
    /* Add the new PHI node to the list of PHI nodes for block BB.  */
    ann = bb_ann (bb);
!   TREE_CHAIN (phi) = phi_nodes (bb);
!   VARRAY_TREE (tree_phi_root, bb->index) = phi;
  
    /* Associate BB to the PHI node.  */
    set_bb_for_stmt (phi, bb);
*************** add_phi_arg (tree *phi, tree def, edge e
*** 956,962 ****
    if (i >= PHI_ARG_CAPACITY (*phi))
      {
        /* Resize the phi.  Unfortunately, this also relocates it...  */
-       bb_ann_t ann = bb_ann (e->dest);
        tree old_phi = *phi;
  
        resize_phi_node (phi, i + 4);
--- 959,964 ----
*************** add_phi_arg (tree *phi, tree def, edge e
*** 965,977 ****
        SSA_NAME_DEF_STMT (PHI_RESULT (*phi)) = *phi;
  
        /* Update the list head if replacing the first listed phi.  */
!       if (ann->phi_nodes == old_phi)
! 	ann->phi_nodes = *phi;
        else
  	{
            /* Traverse the list looking for the phi node to chain to.  */
  	  tree p;
! 	  for (p = ann->phi_nodes;
  	       p && TREE_CHAIN (p) != old_phi;
  	       p = TREE_CHAIN (p));
  
--- 967,979 ----
        SSA_NAME_DEF_STMT (PHI_RESULT (*phi)) = *phi;
  
        /* Update the list head if replacing the first listed phi.  */
!       if (phi_nodes (e->dest) == old_phi)
! 	VARRAY_TREE (tree_phi_root, e->dest->index) = *phi;
        else
  	{
            /* Traverse the list looking for the phi node to chain to.  */
  	  tree p;
! 	  for (p = phi_nodes (e->dest);
  	       p && TREE_CHAIN (p) != old_phi;
  	       p = TREE_CHAIN (p));
  
*************** remove_phi_node (tree phi, tree prev, ba
*** 1067,1074 ****
    else if (phi == phi_nodes (bb))
      {
        /* Update the list head if removing the first element.  */
!       bb_ann_t ann = bb_ann (bb);
!       ann->phi_nodes = TREE_CHAIN (phi);
  
        /* If we are deleting the PHI node, then we should release the
  	 SSA_NAME node so that it can be reused.  */
--- 1069,1075 ----
    else if (phi == phi_nodes (bb))
      {
        /* Update the list head if removing the first element.  */
!       VARRAY_TREE (tree_phi_root, bb->index) = TREE_CHAIN (phi);
  
        /* If we are deleting the PHI node, then we should release the
  	 SSA_NAME node so that it can be reused.  */
*************** remove_all_phi_nodes_for (sbitmap vars)
*** 1098,1107 ****
      {
        /* Build a new PHI list for BB without variables in VARS.  */
        tree phi, new_phi_list, last_phi;
-       bb_ann_t ann = bb_ann (bb);
  
        last_phi = new_phi_list = NULL_TREE;
!       for (phi = ann->phi_nodes; phi; phi = TREE_CHAIN (phi))
  	{
  	  tree var = SSA_NAME_VAR (PHI_RESULT (phi));
  
--- 1099,1107 ----
      {
        /* Build a new PHI list for BB without variables in VARS.  */
        tree phi, new_phi_list, last_phi;
  
        last_phi = new_phi_list = NULL_TREE;
!       for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	{
  	  tree var = SSA_NAME_VAR (PHI_RESULT (phi));
  
*************** remove_all_phi_nodes_for (sbitmap vars)
*** 1132,1141 ****
        /* Make sure the last node in the new list has no successors.  */
        if (last_phi)
  	TREE_CHAIN (last_phi) = NULL_TREE;
!       ann->phi_nodes = new_phi_list;
  
  #if defined ENABLE_CHECKING
!       for (phi = ann->phi_nodes; phi; phi = TREE_CHAIN (phi))
  	{
  	  tree var = SSA_NAME_VAR (PHI_RESULT (phi));
  	  if (TEST_BIT (vars, var_ann (var)->uid))
--- 1132,1141 ----
        /* Make sure the last node in the new list has no successors.  */
        if (last_phi)
  	TREE_CHAIN (last_phi) = NULL_TREE;
!       VARRAY_TREE (tree_phi_root, bb->index) = new_phi_list;
  
  #if defined ENABLE_CHECKING
!       for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
  	{
  	  tree var = SSA_NAME_VAR (PHI_RESULT (phi));
  	  if (TEST_BIT (vars, var_ann (var)->uid))
Index: tree-flow-inline.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow-inline.h,v
retrieving revision 1.1.2.58
diff -c -3 -p -r1.1.2.58 tree-flow-inline.h
*** tree-flow-inline.h	16 Nov 2003 08:24:02 -0000	1.1.2.58
--- tree-flow-inline.h	29 Nov 2003 01:29:48 -0000
*************** bb_ann (basic_block bb)
*** 273,279 ****
  static inline tree
  phi_nodes (basic_block bb)
  {
!   return bb_ann (bb)->phi_nodes;
  }
  
  
--- 273,281 ----
  static inline tree
  phi_nodes (basic_block bb)
  {
!   if (bb->index < 0)
!     return NULL;
!   return VARRAY_TREE (tree_phi_root, bb->index);
  }
  
  
Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-flow.h,v
retrieving revision 1.1.4.160
diff -c -3 -p -r1.1.4.160 tree-flow.h
*** tree-flow.h	25 Nov 2003 05:09:08 -0000	1.1.4.160
--- tree-flow.h	29 Nov 2003 01:29:48 -0000
*************** static inline tree default_def (tree);
*** 305,313 ****
  ---------------------------------------------------------------------------*/
  struct bb_ann_d
  {
-   /* Chain of PHI nodes created in this block.  */
-   tree phi_nodes;
- 
    /* Chain of EPHI nodes created in this block.  */
    tree ephi_nodes;
    
--- 305,310 ----
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.111
diff -c -3 -p -r1.1.4.111 tree-ssa-pre.c
*** tree-ssa-pre.c	25 Nov 2003 05:09:09 -0000	1.1.4.111
--- tree-ssa-pre.c	29 Nov 2003 01:29:48 -0000
*************** code_motion (struct expr_info *ei)
*** 2631,2637 ****
    tree newtemp;
    size_t euse_iter;
    tree temp = ei->temp;
-   bb_ann_t ann;
    basic_block bb;
  
    /* First, add the phi node temporaries so the reaching defs are
--- 2631,2636 ----
*************** code_motion (struct expr_info *ei)
*** 2648,2658 ****
  	{
  	  bb = bb_for_stmt (use);
  	  /* Add the new PHI node to the list of PHI nodes for block BB.  */
! 	  ann = bb_ann (bb);
! 	  if (ann->phi_nodes == NULL)
! 	    ann->phi_nodes = EREF_TEMP (use);
  	  else
! 	    chainon (ann->phi_nodes, EREF_TEMP (use));
  	  VARRAY_PUSH_TREE (added_phis, EREF_TEMP (use));
  	}
        else if (EPHI_IDENTITY (use))
--- 2647,2656 ----
  	{
  	  bb = bb_for_stmt (use);
  	  /* Add the new PHI node to the list of PHI nodes for block BB.  */
! 	  if (phi_nodes (bb) == NULL)
! 	    VARRAY_TREE (tree_phi_root, bb->index) = EREF_TEMP (use);
  	  else
! 	    chainon (phi_nodes (bb), EREF_TEMP (use));
  	  VARRAY_PUSH_TREE (added_phis, EREF_TEMP (use));
  	}
        else if (EPHI_IDENTITY (use))


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