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]

[lto] tree-cfg.c: Move reinstall_phi_args to tree-ssa.c.


Hi,

Attached is a patch to move reinstall_phi_args to tree-ssa.c and teach
flush_pending_stmts to use reinstall_phi_args.

One of the things we'd like to do on the LTO branch is to eliminate
TREE_LIST.  I've noticed that flush_pending_stmts is a special case of
reinstall_phi_args.  By teaching flush_pending_stmts to use
reinstall_phi_args, less code needs to know that PENDING_STMT uses
TREE_LIST, which makes it easier to use some other data structure.  (I
am the one that introduced reinstall_phi_args.  Sorry for not noticing
that there had already been a similar function, namely
flush_pending_stmts).

The reason why I want to move reinstall_phi_args to tree-ssa.c is
because ssa_redirect_edge is the producer of PENDING_STMT, and I'd
like the producer and consumer, namely reinstall_phi_args, to be
sitting next to each other.

I thought about getting rid of flush_pending_stmts entirely, but the
CFG hook infrastructure currently uses flush_pending_stmts.  I'll
leave that as a separate patch.

I'll be posting a patch to stop using TREE_LIST in PENDING_STMT
shortly after this patch.

Tested on x86_64-pc-linux-gnu.  OK to apply to the LTO branch?

Diego, if you could review this patch (and any subsequent patches for
the LTO branch in the tree-ssa area), that would be greatly
appreciated.  Mark Mitchell would like to be able to merge LTO to
mainline without having to get an approval for individual patches at
the merge time.

Kazu Hirata

2006-05-31  Kazu Hirata  <kazu@codesourcery.com>

	* tree-cfg.c (reinstall_phi_args): Move to ...
	* tree-ssa.c: ... here.
	(flush_pending_stmts): Use reinstall_phi_args.
	* tree-flow.h: Add a prototype for reinstall_phi_args.

Index: tree-cfg.c
===================================================================
*** tree-cfg.c	(revision 114242)
--- tree-cfg.c	(working copy)
***************
*** 3096,3126 ****
  	     Tree specific functions for CFG manipulation
  ---------------------------------------------------------------------------*/
  
- /* Reinstall those PHI arguments queued in OLD_EDGE to NEW_EDGE.  */
- 
- static void
- reinstall_phi_args (edge new_edge, edge old_edge)
- {
-   tree var, phi;
- 
-   if (!PENDING_STMT (old_edge))
-     return;
- 
-   for (var = PENDING_STMT (old_edge), phi = phi_nodes (new_edge->dest);
-        var && phi;
-        var = TREE_CHAIN (var), phi = PHI_CHAIN (phi))
-     {
-       tree result = TREE_PURPOSE (var);
-       tree arg = TREE_VALUE (var);
- 
-       gcc_assert (result == PHI_RESULT (phi));
- 
-       add_phi_arg (phi, arg, new_edge);
-     }
- 
-   PENDING_STMT (old_edge) = NULL;
- }
- 
  /* Returns the basic block after that the new basic block created
     by splitting edge EDGE_IN should be placed.  Tries to keep the new block
     near its "logical" location.  This is of most help to humans looking
--- 3096,3101 ----
Index: tree-flow.h
===================================================================
*** tree-flow.h	(revision 114242)
--- tree-flow.h	(working copy)
***************
*** 689,694 ****
--- 689,695 ----
  /* In tree-ssa.c  */
  extern void init_tree_ssa (void);
  extern edge ssa_redirect_edge (edge, basic_block);
+ extern void reinstall_phi_args (edge, edge);
  extern void flush_pending_stmts (edge);
  extern bool tree_ssa_useless_type_conversion (tree);
  extern bool tree_ssa_useless_type_conversion_1 (tree, tree);
Index: tree-ssa.c
===================================================================
*** tree-ssa.c	(revision 114242)
--- tree-ssa.c	(working copy)
***************
*** 76,101 ****
    return e;
  }
  
! /* Add PHI arguments queued in PENDINT_STMT list on edge E to edge
!    E->dest.  */
  
  void
! flush_pending_stmts (edge e)
  {
!   tree phi, arg;
  
!   if (!PENDING_STMT (e))
      return;
  
!   for (phi = phi_nodes (e->dest), arg = PENDING_STMT (e);
!        phi;
!        phi = PHI_CHAIN (phi), arg = TREE_CHAIN (arg))
      {
!       tree def = TREE_VALUE (arg);
!       add_phi_arg (phi, def, e);
      }
  
!   PENDING_STMT (e) = NULL;
  }
  
  /* Return true if SSA_NAME is malformed and mark it visited.
--- 76,109 ----
    return e;
  }
  
! /* Reinstall those PHI arguments queued in OLD_EDGE to NEW_EDGE.  */
  
  void
! reinstall_phi_args (edge new_edge, edge old_edge)
  {
!   tree var, phi;
  
!   if (!PENDING_STMT (old_edge))
      return;
  
!   for (var = PENDING_STMT (old_edge), phi = phi_nodes (new_edge->dest);
!        var && phi;
!        var = TREE_CHAIN (var), phi = PHI_CHAIN (phi))
      {
!       tree arg = TREE_VALUE (var);
!       add_phi_arg (phi, arg, new_edge);
      }
  
!   PENDING_STMT (old_edge) = NULL;
! }
! 
! /* Add PHI arguments queued in PENDINT_STMT list on edge E to edge
!    E->dest.  */
! 
! void
! flush_pending_stmts (edge e)
! {
!   reinstall_phi_args (e, e);
  }
  
  /* Return true if SSA_NAME is malformed and mark it visited.


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