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]

IPA merge part 1: localize SSA variables


Hi,
this is first part of IPA branch merge.  The aim of this patch is to localize
most of neccesary variables that are needed to hold function local SSA form.
This is about the most noisy part of the diff to IPA branch so further patches
will be more localized.

I took same path as with localizing CFG some time ago by adding cfun->ssa
structure and using accestor macros.  This avoids need to rewrite all
apperances of the variables in the sources. At time of merging CFG we discussed
plan to replace those by direct references to cfun->cfg structure.  This part
of plan sadly never matherialized, I sent patch replacing
ENTRY_BLOCK/EXIT_BLOCK, but there didn't seem to be good time for fitting it in
(it is painful for open branches).  I can update that one too and proceed with
other cfun->cfg/cfun->ssa fields in incremental patches.

Where the polution of namespace would be really anoying, like for aliasing
info, I already took path of using direct references.  Also note that the patch
takes just the easy part, some of nastier details, like annotations are to
come in separate patch for easier consideration.  Only questional bit is,
I believe, localization of operand caches that can be quite easilly made shared
across multiple bodies, so I added FIXME there.

Patch was bootstrapped/regtested i686-linux, x86_64-linux, ppc testing failed
for unrelated reasons, I am re-running it now.

OK for mainline?
Honza

2006-06-09  Jan Hubicka  <jh@suse.cz>
	* tree-into-ssa.c: (in_ssa_p): Localize to SSA structure.
	(rewrite_into_ssa): Access dirrectly cfun->x_in_ssa_p
	* tree-ssa-alias.c (aliases_computed_p, call_clobbered_vars,
	addressable_vars, global_var, nonlocal_all): Localize to SSA structure.
	(init_alias_info, setup_pointers_and_addressables,
	maybe_create_global_var): Update uses of localized vars.
	* function.h (struct function): Add SSA field.
	* tree-flow-inline.h (mark_stmt_modified, is_call_clobbered,
	mark_call_clobbered, clear_call_cobbered, mark_non_addressable):
	Update for localized vars.
	* tree-dfa.c (referenced_vars, referenced_vars_dup_list, default_defs):
	Localize.
	(default_def): Break out major functionality to ....
	(default_def_fn)
	(set_default_def): Update for localized vars.
	* tree-cfgcleanup (modified_noreturn_calls): Localize.
	(cleanup_control_flow): Update use.
	* tree-ssa.c (verify_call_clobbering): Update for localized vars.
	(init_tree_ssa, delete_tree_ssa): Likewise.
	* tree-outof-ssa.c (rewrite_out_of_ssa): Likewise.
	* tree-flow.h (in_ssa_p
	(referenced_vars, referenced_vars_dup_list, ssa_names,
	modified_noreturn_calls, global_var, nonlocal_all, aliases_computed_p,
	in_ssa_p, free_ssanames, operand_memory, operand_memory_index,
	free_defs, free_uses, free_vuses, free_maydefs, free_mustdefs):
	New macros.
	(struct ssa): New struct.
	* Makefile.in (tree-ssa-operands): No longer produce GGC file.
	* tree-ssa-structalias.c (update_alias_info): Update for localized vars.
	* tree-ssanames.c (ssa_names, free_ssanames): Bring to SSA structure.
	* tree-ssa-operands.c (ops_active, operand_memory_index, free_defs,
	free_uses_free_vuses, free_maydefs, free_mustdefs): Bring local; update
	all uses.
Index: tree-into-ssa.c
===================================================================
*** tree-into-ssa.c	(revision 117933)
--- tree-into-ssa.c	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 55,63 ****
     Graph. ACM Transactions on Programming Languages and Systems,
     13(4):451-490, October 1991.  */
  
- /* True if the code is in ssa form.  */
- bool in_ssa_p;
- 
  /* Structure to map a variable VAR to the set of blocks that contain
     definitions for VAR.  */
  struct def_blocks_d
--- 55,60 ----
*************** rewrite_into_ssa (void)
*** 2122,2128 ****
    sbitmap_free (interesting_blocks);
  
    timevar_pop (TV_TREE_SSA_OTHER);
!   in_ssa_p = true;
    return 0;
  }
  
--- 2119,2125 ----
    sbitmap_free (interesting_blocks);
  
    timevar_pop (TV_TREE_SSA_OTHER);
!   cfun->ssa->x_in_ssa_p = true;
    return 0;
  }
  
Index: tree-ssa-alias.c
===================================================================
*** tree-ssa-alias.c	(revision 117933)
--- tree-ssa-alias.c	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 46,60 ****
  #include "ipa-type-escape.h"
  #include "vec.h"
  #include "bitmap.h"
  #include "vecprim.h"
  
  /* Obstack used to hold grouping bitmaps and other temporary bitmaps used by
     aliasing  */
  static bitmap_obstack alias_obstack;
  
- /* 'true' after aliases have been computed (see compute_may_aliases).  */
- bool aliases_computed_p;
- 
  /* Structure to map a variable to its alias set and keep track of the
     virtual operands that will be needed to represent it.  */
  struct alias_map_d
--- 46,58 ----
  #include "ipa-type-escape.h"
  #include "vec.h"
  #include "bitmap.h"
+ #include "ipa-prop.h"
  #include "vecprim.h"
  
  /* Obstack used to hold grouping bitmaps and other temporary bitmaps used by
     aliasing  */
  static bitmap_obstack alias_obstack;
  
  /* Structure to map a variable to its alias set and keep track of the
     virtual operands that will be needed to represent it.  */
  struct alias_map_d
*************** static void set_pt_anything (tree ptr);
*** 117,142 ****
  
  /* Global declarations.  */
  
- /* Call clobbered variables in the function.  If bit I is set, then
-    REFERENCED_VARS (I) is call-clobbered.  */
- bitmap call_clobbered_vars;
- 
- /* Addressable variables in the function.  If bit I is set, then
-    REFERENCED_VARS (I) has had its address taken.  Note that
-    CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related.  An
-    addressable variable is not necessarily call-clobbered (e.g., a
-    local addressable whose address does not escape) and not all
-    call-clobbered variables are addressable (e.g., a local static
-    variable).  */
- bitmap addressable_vars;
- 
- /* When the program has too many call-clobbered variables and call-sites,
-    this variable is used to represent the clobbering effects of function
-    calls.  In these cases, all the call clobbered variables in the program
-    are forced to alias this variable.  This reduces compile times by not
-    having to keep track of too many V_MAY_DEF expressions at call sites.  */
- tree global_var;
- 
  /* qsort comparison function to sort type/name tags by DECL_UID.  */
  
  static int
--- 115,120 ----
*************** init_alias_info (void)
*** 890,896 ****
        /* Similarly, clear the set of addressable variables.  In this
  	 case, we can just clear the set because addressability is
  	 only computed here.  */
!       bitmap_clear (addressable_vars);
  
        /* Clear flow-insensitive alias information from each symbol.  */
        FOR_EACH_REFERENCED_VAR (var, rvi)
--- 868,874 ----
        /* Similarly, clear the set of addressable variables.  In this
  	 case, we can just clear the set because addressability is
  	 only computed here.  */
!       bitmap_clear (cfun->ssa->addressable_vars);
  
        /* Clear flow-insensitive alias information from each symbol.  */
        FOR_EACH_REFERENCED_VAR (var, rvi)
*************** setup_pointers_and_addressables (struct 
*** 1692,1698 ****
           cleanup passes.  */
        if (TREE_ADDRESSABLE (var))
  	{
! 	  if (!bitmap_bit_p (addressable_vars, DECL_UID (var))
  	      && TREE_CODE (var) != RESULT_DECL
  	      && !is_global_var (var))
  	    {
--- 1670,1676 ----
           cleanup passes.  */
        if (TREE_ADDRESSABLE (var))
  	{
! 	  if (!bitmap_bit_p (cfun->ssa->addressable_vars, DECL_UID (var))
  	      && TREE_CODE (var) != RESULT_DECL
  	      && !is_global_var (var))
  	    {
*************** setup_pointers_and_addressables (struct 
*** 1712,1718 ****
  
  		  for (sv = svars; sv; sv = sv->next)
  		    {	      
! 		      if (bitmap_bit_p (addressable_vars, DECL_UID (sv->var)))
  			okay_to_mark = false;
  		      mark_sym_for_renaming (sv->var);
  		    }
--- 1690,1696 ----
  
  		  for (sv = svars; sv; sv = sv->next)
  		    {	      
! 		      if (bitmap_bit_p (cfun->ssa->addressable_vars, DECL_UID (sv->var)))
  			okay_to_mark = false;
  		      mark_sym_for_renaming (sv->var);
  		    }
*************** maybe_create_global_var (struct alias_in
*** 1837,1843 ****
      {
        /* Count all the call-clobbered variables.  */
        n_clobbered = 0;
!       EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
  	{
  	  n_clobbered++;
  	}
--- 1815,1821 ----
      {
        /* Count all the call-clobbered variables.  */
        n_clobbered = 0;
!       EXECUTE_IF_SET_IN_BITMAP (cfun->ssa->call_clobbered_vars, 0, i, bi)
  	{
  	  n_clobbered++;
  	}
*************** maybe_create_global_var (struct alias_in
*** 1880,1886 ****
    /* Mark all call-clobbered symbols for renaming.  Since the initial
       rewrite into SSA ignored all call sites, we may need to rename
       .GLOBAL_VAR and the call-clobbered variables.   */
!   EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
      {
        tree var = referenced_var (i);
  
--- 1858,1864 ----
    /* Mark all call-clobbered symbols for renaming.  Since the initial
       rewrite into SSA ignored all call sites, we may need to rename
       .GLOBAL_VAR and the call-clobbered variables.   */
!   EXECUTE_IF_SET_IN_BITMAP (cfun->ssa->call_clobbered_vars, 0, i, bi)
      {
        tree var = referenced_var (i);
  
Index: function.h
===================================================================
*** function.h	(revision 117933)
--- function.h	(working copy)
*************** struct expr_status GTY(())
*** 159,164 ****
--- 159,165 ----
  #define forced_labels (cfun->expr->x_forced_labels)
  #define stack_pointer_delta (cfun->expr->x_stack_pointer_delta)
  
+ struct ssa;
  struct temp_slot;
  typedef struct temp_slot *temp_slot_p;
  
*************** struct function GTY(())
*** 188,193 ****
--- 189,196 ----
  
    /* The control flow graph for this function.  */
    struct control_flow_graph *cfg;
+   /* SSA and dataflow information.  */
+   struct ssa *ssa;
  
    /* For function.c.  */
  
*************** extern bool pass_by_reference (CUMULATIV
*** 577,582 ****
--- 580,586 ----
  extern bool reference_callee_copied (CUMULATIVE_ARGS *, enum machine_mode,
  				     tree, bool);
  
+ extern int get_last_funcdef_no (void);
  extern void used_types_insert (tree);
  
  #endif  /* GCC_FUNCTION_H */
Index: tree-flow-inline.h
===================================================================
*** tree-flow-inline.h	(revision 117933)
--- tree-flow-inline.h	(working copy)
*************** mark_stmt_modified (tree t)
*** 267,273 ****
    ann = stmt_ann (t);
    if (ann == NULL)
      ann = create_stmt_ann (t);
!   else if (noreturn_call_p (t))
      VEC_safe_push (tree, gc, modified_noreturn_calls, t);
    ann->modified = 1;
  }
--- 267,273 ----
    ann = stmt_ann (t);
    if (ann == NULL)
      ann = create_stmt_ann (t);
!   else if (noreturn_call_p (t) && cfun->ssa)
      VEC_safe_push (tree, gc, modified_noreturn_calls, t);
    ann->modified = 1;
  }
*************** is_call_clobbered (tree var)
*** 749,755 ****
    if (!MTAG_P (var))
      return DECL_CALL_CLOBBERED (var);
    else
!     return bitmap_bit_p (call_clobbered_vars, DECL_UID (var)); 
  }
  
  /* Mark variable VAR as being clobbered by function calls.  */
--- 749,755 ----
    if (!MTAG_P (var))
      return DECL_CALL_CLOBBERED (var);
    else
!     return bitmap_bit_p (cfun->ssa->call_clobbered_vars, DECL_UID (var)); 
  }
  
  /* Mark variable VAR as being clobbered by function calls.  */
*************** mark_call_clobbered (tree var, unsigned 
*** 759,765 ****
    var_ann (var)->escape_mask |= escape_type;
    if (!MTAG_P (var))
      DECL_CALL_CLOBBERED (var) = true;
!   bitmap_set_bit (call_clobbered_vars, DECL_UID (var));
  }
  
  /* Clear the call-clobbered attribute from variable VAR.  */
--- 759,765 ----
    var_ann (var)->escape_mask |= escape_type;
    if (!MTAG_P (var))
      DECL_CALL_CLOBBERED (var) = true;
!   bitmap_set_bit (cfun->ssa->call_clobbered_vars, DECL_UID (var));
  }
  
  /* Clear the call-clobbered attribute from variable VAR.  */
*************** clear_call_clobbered (tree var)
*** 772,778 ****
      MTAG_GLOBAL (var) = 0;
    if (!MTAG_P (var))
      DECL_CALL_CLOBBERED (var) = false;
!   bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
  }
  
  /* Mark variable VAR as being non-addressable.  */
--- 772,778 ----
      MTAG_GLOBAL (var) = 0;
    if (!MTAG_P (var))
      DECL_CALL_CLOBBERED (var) = false;
!   bitmap_clear_bit (cfun->ssa->call_clobbered_vars, DECL_UID (var));
  }
  
  /* Mark variable VAR as being non-addressable.  */
*************** mark_non_addressable (tree var)
*** 781,787 ****
  {
    if (!MTAG_P (var))
      DECL_CALL_CLOBBERED (var) = false;
!   bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
    TREE_ADDRESSABLE (var) = 0;
  }
  
--- 781,787 ----
  {
    if (!MTAG_P (var))
      DECL_CALL_CLOBBERED (var) = false;
!   bitmap_clear_bit (cfun->ssa->call_clobbered_vars, DECL_UID (var));
    TREE_ADDRESSABLE (var) = 0;
  }
  
Index: gimplify.c
===================================================================
*** gimplify.c	(revision 117933)
--- gimplify.c	(working copy)
*************** force_gimple_operand (tree expr, tree *s
*** 6368,6374 ****
  		       gimple_test_f, fb_rvalue);
    gcc_assert (ret != GS_ERROR);
  
!   if (referenced_vars)
      {
        for (t = gimplify_ctxp->temps; t ; t = TREE_CHAIN (t))
  	add_referenced_var (t);
--- 6368,6374 ----
  		       gimple_test_f, fb_rvalue);
    gcc_assert (ret != GS_ERROR);
  
!   if (cfun->ssa && referenced_vars)
      {
        for (t = gimplify_ctxp->temps; t ; t = TREE_CHAIN (t))
  	add_referenced_var (t);
Index: tree-dfa.c
===================================================================
*** tree-dfa.c	(revision 117933)
--- tree-dfa.c	(working copy)
*************** static tree collect_dfa_stats_r (tree *,
*** 71,88 ****
  static tree find_vars_r (tree *, int *, void *);
  
  
- /* Global declarations.  */
- 
- /* Array of all variables referenced in the function.  */
- htab_t referenced_vars;
- 
- /* Default definition for this symbols.  If set for symbol, it
-    means that the first reference to this variable in the function is a
-    USE or a VUSE.  In those cases, the SSA renamer creates an SSA name
-    for this variable with an empty defining statement.  */
- htab_t default_defs;
- 
- 
  /*---------------------------------------------------------------------------
  			Dataflow analysis (DFA) routines
  ---------------------------------------------------------------------------*/
--- 71,76 ----
*************** make_rename_temp (tree type, const char 
*** 222,228 ****
    if (TREE_CODE (type) == COMPLEX_TYPE)
      DECL_COMPLEX_GIMPLE_REG_P (t) = 1;
  
!   if (referenced_vars)
      {
        add_referenced_var (t);
        mark_sym_for_renaming (t);
--- 210,216 ----
    if (TREE_CODE (type) == COMPLEX_TYPE)
      DECL_COMPLEX_GIMPLE_REG_P (t) = 1;
  
!   if (cfun->ssa && referenced_vars)
      {
        add_referenced_var (t);
        mark_sym_for_renaming (t);
*************** referenced_var_check_and_insert (tree to
*** 652,669 ****
     variable.  */
  
  tree 
! default_def (tree var)
  {
    struct int_tree_map *h, in;
    gcc_assert (SSA_VAR_P (var));
    in.uid = DECL_UID (var);
!   h = (struct int_tree_map *) htab_find_with_hash (default_defs, &in,
                                                     DECL_UID (var));
    if (h)
      return h->to;
    return NULL_TREE;
  }
  
  /* Insert the pair VAR's UID, DEF into the default_defs hashtable.  */
  
  void
--- 640,663 ----
     variable.  */
  
  tree 
! default_def_fn (struct function *fn, tree var)
  {
    struct int_tree_map *h, in;
    gcc_assert (SSA_VAR_P (var));
    in.uid = DECL_UID (var);
!   h = (struct int_tree_map *) htab_find_with_hash (fn->ssa->default_defs, &in,
                                                     DECL_UID (var));
    if (h)
      return h->to;
    return NULL_TREE;
  }
  
+ tree 
+ default_def (tree var)
+ {
+   return default_def_fn (cfun, var);
+ }
+ 
  /* Insert the pair VAR's UID, DEF into the default_defs hashtable.  */
  
  void
*************** set_default_def (tree var, tree def)
*** 677,688 ****
    in.uid = DECL_UID (var);
    if (!def && default_def (var))
      {
!       loc = htab_find_slot_with_hash (default_defs, &in, DECL_UID (var), INSERT);
!       htab_remove_elt (default_defs, *loc);
        return;
      }
    gcc_assert (TREE_CODE (def) == SSA_NAME);
!   loc = htab_find_slot_with_hash (default_defs, &in, DECL_UID (var), INSERT);
    /* Default definition might be changed by tail call optimization.  */
    if (!*loc)
      {
--- 671,684 ----
    in.uid = DECL_UID (var);
    if (!def && default_def (var))
      {
!       loc = htab_find_slot_with_hash (cfun->ssa->default_defs, &in,
!             DECL_UID (var), INSERT);
!       htab_remove_elt (cfun->ssa->default_defs, *loc);
        return;
      }
    gcc_assert (TREE_CODE (def) == SSA_NAME);
!   loc = htab_find_slot_with_hash (cfun->ssa->default_defs, &in,
!                                   DECL_UID (var), INSERT);
    /* Default definition might be changed by tail call optimization.  */
    if (!*loc)
      {
Index: tree-cfgcleanup.c
===================================================================
*** tree-cfgcleanup.c	(revision 117933)
--- tree-cfgcleanup.c	(working copy)
*************** cleanup_control_expr_graph (basic_block 
*** 127,140 ****
    return retval;
  }
  
- /* A list of all the noreturn calls passed to modify_stmt.
-    cleanup_control_flow uses it to detect cases where a mid-block
-    indirect call has been turned into a noreturn call.  When this
-    happens, all the instructions after the call are no longer
-    reachable and must be deleted as dead.  */
- 
- VEC(tree,gc) *modified_noreturn_calls;
- 
  /* Try to remove superfluous control structures.  */
  
  static bool
--- 127,132 ----
*************** cleanup_control_flow (void)
*** 146,158 ****
    tree stmt;
  
    /* Detect cases where a mid-block call is now known not to return.  */
!   while (VEC_length (tree, modified_noreturn_calls))
!     {
!       stmt = VEC_pop (tree, modified_noreturn_calls);
!       bb = bb_for_stmt (stmt);
!       if (bb != NULL && last_stmt (bb) != stmt && noreturn_call_p (stmt))
! 	split_block (bb, stmt);
!     }
  
    FOR_EACH_BB (bb)
      {
--- 138,151 ----
    tree stmt;
  
    /* Detect cases where a mid-block call is now known not to return.  */
!   if (cfun->ssa)
!     while (VEC_length (tree, modified_noreturn_calls))
!       {
! 	stmt = VEC_pop (tree, modified_noreturn_calls);
! 	bb = bb_for_stmt (stmt);
! 	if (bb != NULL && last_stmt (bb) != stmt && noreturn_call_p (stmt))
! 	  split_block (bb, stmt);
!       }
  
    FOR_EACH_BB (bb)
      {
Index: tree-ssa.c
===================================================================
*** tree-ssa.c	(revision 117933)
--- tree-ssa.c	(working copy)
*************** verify_call_clobbering (void)
*** 627,633 ****
       that everything in call_clobbered_vars is marked
       DECL_CALL_CLOBBERED, and that everything marked
       DECL_CALL_CLOBBERED is in call_clobbered_vars.  */
!   EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
      {
        var = referenced_var (i);
        if (!MTAG_P (var) && !DECL_CALL_CLOBBERED (var))
--- 627,633 ----
       that everything in call_clobbered_vars is marked
       DECL_CALL_CLOBBERED, and that everything marked
       DECL_CALL_CLOBBERED is in call_clobbered_vars.  */
!   EXECUTE_IF_SET_IN_BITMAP (cfun->ssa->call_clobbered_vars, 0, i, bi)
      {
        var = referenced_var (i);
        if (!MTAG_P (var) && !DECL_CALL_CLOBBERED (var))
*************** verify_call_clobbering (void)
*** 640,646 ****
    FOR_EACH_REFERENCED_VAR (var, rvi)
      {
        if (!MTAG_P (var) && DECL_CALL_CLOBBERED (var)
! 	  && !bitmap_bit_p (call_clobbered_vars, DECL_UID (var)))
  	{
  	  error ("variable marked DECL_CALL_CLOBBERED but not in call_clobbered_vars bitmap.");
  	  debug_variable (var);
--- 640,646 ----
    FOR_EACH_REFERENCED_VAR (var, rvi)
      {
        if (!MTAG_P (var) && DECL_CALL_CLOBBERED (var)
! 	  && !bitmap_bit_p (cfun->ssa->call_clobbered_vars, DECL_UID (var)))
  	{
  	  error ("variable marked DECL_CALL_CLOBBERED but not in call_clobbered_vars bitmap.");
  	  debug_variable (var);
*************** int_tree_map_hash (const void *item)
*** 830,840 ****
  void
  init_tree_ssa (void)
  {
    referenced_vars = htab_create_ggc (20, int_tree_map_hash, 
  				     int_tree_map_eq, NULL);
!   default_defs = htab_create_ggc (20, int_tree_map_hash, int_tree_map_eq, NULL);
!   call_clobbered_vars = BITMAP_ALLOC (NULL);
!   addressable_vars = BITMAP_ALLOC (NULL);
    init_alias_heapvars ();
    init_ssanames ();
    init_phinodes ();
--- 830,842 ----
  void
  init_tree_ssa (void)
  {
+   cfun->ssa = ggc_alloc_cleared (sizeof (struct ssa));
    referenced_vars = htab_create_ggc (20, int_tree_map_hash, 
  				     int_tree_map_eq, NULL);
!   cfun->ssa->default_defs = htab_create_ggc (20, int_tree_map_hash, 
! 				             int_tree_map_eq, NULL);
!   cfun->ssa->call_clobbered_vars = BITMAP_GGC_ALLOC ();
!   cfun->ssa->addressable_vars = BITMAP_GGC_ALLOC ();
    init_alias_heapvars ();
    init_ssanames ();
    init_phinodes ();
*************** delete_tree_ssa (void)
*** 895,905 ****
  
    global_var = NULL_TREE;
    
!   htab_delete (default_defs);
!   BITMAP_FREE (call_clobbered_vars);
!   call_clobbered_vars = NULL;
!   BITMAP_FREE (addressable_vars);
!   addressable_vars = NULL;
    modified_noreturn_calls = NULL;
    aliases_computed_p = false;
    delete_alias_heapvars ();
--- 897,905 ----
  
    global_var = NULL_TREE;
    
!   htab_delete (cfun->ssa->default_defs);
!   cfun->ssa->call_clobbered_vars = NULL;
!   cfun->ssa->addressable_vars = NULL;
    modified_noreturn_calls = NULL;
    aliases_computed_p = false;
    delete_alias_heapvars ();
Index: tree-outof-ssa.c
===================================================================
*** tree-outof-ssa.c	(revision 117933)
--- tree-outof-ssa.c	(working copy)
*************** rewrite_out_of_ssa (void)
*** 2546,2552 ****
    /* Flush out flow graph and SSA data.  */
    delete_var_map (map);
  
!   in_ssa_p = false;
    return 0;
  }
  
--- 2546,2552 ----
    /* Flush out flow graph and SSA data.  */
    delete_var_map (map);
  
!   cfun->ssa->x_in_ssa_p = false;
    return 0;
  }
  
Index: tree-flow.h
===================================================================
*** tree-flow.h	(revision 117933)
--- tree-flow.h	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 30,35 ****
--- 30,36 ----
  #include "tree-ssa-operands.h"
  #include "cgraph.h"
  #include "ipa-reference.h"
+ #include "ipa-prop.h"
  
  /* Forward declare structures for the garbage collector GTY markers.  */
  #ifndef GCC_BASIC_BLOCK_H
*************** struct basic_block_def;
*** 39,47 ****
  typedef struct basic_block_def *basic_block;
  #endif
  
! /* True if the code is in ssa form.  */
! extern bool in_ssa_p;
  
  typedef struct
  {
--- 40,123 ----
  typedef struct basic_block_def *basic_block;
  #endif
  
! struct ssa GTY(()) {
!   /* Array of all variables referenced in the function.  */
!   htab_t GTY((param_is (struct int_tree_map))) x_referenced_vars;
!   /* A list of all the noreturn calls passed to modify_stmt.
!      cleanup_control_flow uses it to detect cases where a mid-block
!      indirect call has been turned into a noreturn call.  When this
!      happens, all the instructions after the call are no longer
!      reachable and must be deleted as dead.  */
!   VEC(tree,gc) *x_modified_noreturn_calls;
!   /* Array of all SSA_NAMEs used in the function.  */
!   VEC(tree,gc) *x_ssa_names;
! 
!   /* Artificial variable used to model the effects of function calls.  */
!   tree x_global_var;
! 
!   /* Artificial variable used to model the effects of nonlocal
!      variables.  */
!   tree x_nonlocal_all;
! 
!   /* Call clobbered variables in the function.  If bit I is set, then
!      REFERENCED_VARS (I) is call-clobbered.  */
!   bitmap call_clobbered_vars;
! 
!   /* Addressable variables in the function.  If bit I is set, then
!      REFERENCED_VARS (I) has had its address taken.  Note that
!      CALL_CLOBBERED_VARS and ADDRESSABLE_VARS are not related.  An
!      addressable variable is not necessarily call-clobbered (e.g., a
!      local addressable whose address does not escape) and not all
!      call-clobbered variables are addressable (e.g., a local static
!      variable).  */
!   bitmap addressable_vars;
! 
!   /* 'true' after aliases have been computed (see compute_may_aliases).  */
!   bool x_aliases_computed_p;
! 
!   /* True if the code is in ssa form.  */
!   bool x_in_ssa_p;
! 
!   /* Free list of SSA_NAMEs.  */
!   tree x_free_ssanames;
! 
!   bool ops_active;
! 
!   /* These arrays are the cached operand vectors for call clobbered calls.  */
!   struct ssa_operand_memory_d *x_operand_memory;
!   unsigned x_operand_memory_index;
! 
!   struct def_optype_d * GTY((skip)) x_free_defs;
!   struct use_optype_d * GTY((skip)) x_free_uses;
!   struct vuse_optype_d * GTY((skip)) x_free_vuses;
!   struct maydef_optype_d * GTY((skip)) x_free_maydefs;
!   struct mustdef_optype_d * GTY((skip)) x_free_mustdefs;
! 
!   /* Hashtable holding definition for symbol.  If this field is not NULL, it
!      means that the first reference to this variable in the function is a
!      USE or a VUSE.  In those cases, the SSA renamer creates an SSA name
!      for this variable with an empty defining statement.  */
!   htab_t GTY((param_is (struct int_tree_map))) default_defs;
! };
! #define referenced_vars cfun->ssa->x_referenced_vars
! #define ssa_names cfun->ssa->x_ssa_names
! #define modified_noreturn_calls cfun->ssa->x_modified_noreturn_calls
! #define global_var cfun->ssa->x_global_var
! #define nonlocal_all cfun->ssa->x_nonlocal_all
! #define aliases_computed_p cfun->ssa->x_aliases_computed_p
! #define in_ssa_p (cfun->ssa && cfun->ssa->x_in_ssa_p)
! 
! /* FIXME: Little rewrite of tree-ssa-operands could probably make those shared
!    across all functions avoiding need to privatize them.  Envolving
!    tree-ssa-operands implementation however makes this step bit impractircal.
!    */
! #define free_defs (cfun->ssa->x_free_defs)
! #define free_uses (cfun->ssa->x_free_uses)
! #define free_vuses (cfun->ssa->x_free_vuses)
! #define free_maydefs (cfun->ssa->x_free_maydefs)
! #define free_mustdefs (cfun->ssa->x_free_mustdefs)
! #define free_ssanames (cfun->ssa->x_free_ssanames)
! #define operand_memory (cfun->ssa->x_operand_memory)
! #define operand_memory_index (cfun->ssa->x_operand_memory_index)
  
  typedef struct
  {
*************** struct var_ann_d GTY(())
*** 203,209 ****
    /* During into-ssa and the dominator optimizer, this field holds the
       current version of this variable (an SSA_NAME).  */
    tree current_def;
!   
    /* If this variable is a structure, this fields holds a list of
       symbols representing each of the fields of the structure.  */
    subvar_t subvars;
--- 279,285 ----
    /* During into-ssa and the dominator optimizer, this field holds the
       current version of this variable (an SSA_NAME).  */
    tree current_def;
! 
    /* If this variable is a structure, this fields holds a list of
       symbols representing each of the fields of the structure.  */
    subvar_t subvars;
*************** union tree_ann_d GTY((desc ("ann_type ((
*** 326,333 ****
    struct stmt_ann_d GTY((tag ("STMT_ANN"))) stmt;
  };
  
- extern GTY(()) VEC(tree,gc) *modified_noreturn_calls;
- 
  typedef union tree_ann_d *tree_ann_t;
  typedef struct var_ann_d *var_ann_t;
  typedef struct function_ann_d *function_ann_t;
--- 402,407 ----
*************** typedef struct
*** 418,458 ****
         VEC_iterate (tree, (VEC), (ITER).i, (VAR)); \
         (ITER).i++)
  
- /* Array of all variables referenced in the function.  */
- extern GTY((param_is (struct int_tree_map))) htab_t referenced_vars;
- 
- /* Default defs for undefined symbols. */
- extern GTY((param_is (struct int_tree_map))) htab_t default_defs;
- 
  extern tree referenced_var_lookup (unsigned int);
  extern bool referenced_var_check_and_insert (tree);
  #define num_referenced_vars htab_elements (referenced_vars)
  #define referenced_var(i) referenced_var_lookup (i)
  
- /* Array of all SSA_NAMEs used in the function.  */
- extern GTY(()) VEC(tree,gc) *ssa_names;
- 
  #define num_ssa_names (VEC_length (tree, ssa_names))
  #define ssa_name(i) (VEC_index (tree, ssa_names, (i)))
  
- /* Artificial variable used to model the effects of function calls.  */
- extern GTY(()) tree global_var;
- 
- /* Artificial variable used to model the effects of nonlocal
-    variables.  */
- extern GTY(()) tree nonlocal_all;
- 
- /* Call clobbered variables in the function.  If bit I is set, then
-    REFERENCED_VARS (I) is call-clobbered.  */
- extern bitmap call_clobbered_vars;
- 
- /* Addressable variables in the function.  If bit I is set, then
-    REFERENCED_VARS (I) has had its address taken.  */
- extern bitmap addressable_vars;
- 
- /* 'true' after aliases have been computed (see compute_may_aliases).  */
- extern bool aliases_computed_p;
- 
  /* Macros for showing usage statistics.  */
  #define SCALE(x) ((unsigned long) ((x) < 1024*10	\
  		  ? (x)					\
--- 492,505 ----
Index: Makefile.in
===================================================================
*** Makefile.in	(revision 117933)
--- Makefile.in	(working copy)
*************** tree-dfa.o : tree-dfa.c $(TREE_FLOW_H) $
*** 1972,1978 ****
  tree-ssa-operands.o : tree-ssa-operands.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) errors.h $(TREE_INLINE_H) \
     $(FLAGS_H) $(FUNCTION_H) $(TM_H) $(TIMEVAR_H) tree-pass.h toplev.h \
!    gt-tree-ssa-operands.h coretypes.h langhooks.h $(IPA_REFERENCE_H)
  tree-eh.o : tree-eh.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_H) $(FLAGS_H) $(FUNCTION_H) except.h langhooks.h \
     $(GGC_H) tree-pass.h coretypes.h $(TIMEVAR_H) $(TM_P_H) \
--- 1972,1978 ----
  tree-ssa-operands.o : tree-ssa-operands.c $(TREE_FLOW_H) $(CONFIG_H) \
     $(SYSTEM_H) $(TREE_H) $(GGC_H) $(DIAGNOSTIC_H) errors.h $(TREE_INLINE_H) \
     $(FLAGS_H) $(FUNCTION_H) $(TM_H) $(TIMEVAR_H) tree-pass.h toplev.h \
!    coretypes.h langhooks.h $(IPA_REFERENCE_H)
  tree-eh.o : tree-eh.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
     $(RTL_H) $(TREE_H) $(TM_H) $(FLAGS_H) $(FUNCTION_H) except.h langhooks.h \
     $(GGC_H) tree-pass.h coretypes.h $(TIMEVAR_H) $(TM_P_H) \
*************** GTFILES = $(srcdir)/input.h $(srcdir)/co
*** 2864,2870 ****
    $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
    $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
    $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
!   $(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
    $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
    $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
    $(srcdir)/tree-ssa-structalias.c \
--- 2864,2870 ----
    $(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
    $(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
    $(srcdir)/tree-chrec.h $(srcdir)/tree-vect-generic.c \
!   $(srcdir)/tree-ssa-operands.h \
    $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
    $(srcdir)/ipa-reference.c $(srcdir)/tree-ssa-structalias.h \
    $(srcdir)/tree-ssa-structalias.c \
*************** gt-tree-mudflap.h gt-tree-vect-generic.h
*** 2899,2905 ****
  gt-tree-profile.h gt-tree-ssa-address.h \
  gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
  gt-tree-phinodes.h gt-tree-nested.h \
! gt-tree-ssa-operands.h gt-tree-ssa-propagate.h \
  gt-tree-ssa-structalias.h gt-ipa-inline.h gt-cgraphunit.h \
  gt-stringpool.h gt-targhooks.h gt-omp-low.h : s-gtype ; @true
  
--- 2899,2905 ----
  gt-tree-profile.h gt-tree-ssa-address.h \
  gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
  gt-tree-phinodes.h gt-tree-nested.h \
! gt-tree-ssa-propagate.h \
  gt-tree-ssa-structalias.h gt-ipa-inline.h gt-cgraphunit.h \
  gt-stringpool.h gt-targhooks.h gt-omp-low.h : s-gtype ; @true
  
Index: tree-ssa-structalias.c
===================================================================
*** tree-ssa-structalias.c	(revision 117933)
--- tree-ssa-structalias.c	(working copy)
*************** Foundation, Inc., 51 Franklin Street, Fi
*** 164,172 ****
  static GTY ((if_marked ("tree_map_marked_p"), param_is (struct tree_map))) 
  htab_t heapvar_for_stmt;
  
- /* One variable to represent all non-local accesses.  */
- tree nonlocal_all;
- 
  static bool use_field_sensitive = true;
  static int in_ipa_mode = 0;
  static bitmap_obstack predbitmap_obstack;
--- 164,169 ----
*************** update_alias_info (tree stmt, struct ali
*** 3075,3081 ****
    addr_taken = addresses_taken (stmt);
    if (addr_taken)
      {
!       bitmap_ior_into (addressable_vars, addr_taken);
  
        /* If STMT is an escape point, all the addresses taken by it are
  	 call-clobbered.  */
--- 3072,3078 ----
    addr_taken = addresses_taken (stmt);
    if (addr_taken)
      {
!       bitmap_ior_into (cfun->ssa->addressable_vars, addr_taken);
  
        /* If STMT is an escape point, all the addresses taken by it are
  	 call-clobbered.  */
*************** update_alias_info (tree stmt, struct ali
*** 3120,3126 ****
  	     so that they can be treated like regular statements?
  	     Currently, they are treated as second-class
  	     statements.  */
! 	  add_to_addressable_set (TREE_OPERAND (op, 0), &addressable_vars);
  	  continue;
  	}
  
--- 3117,3124 ----
  	     so that they can be treated like regular statements?
  	     Currently, they are treated as second-class
  	     statements.  */
! 	  add_to_addressable_set (TREE_OPERAND (op, 0),
!                                 &cfun->ssa->addressable_vars);
  	  continue;
  	}
  
Index: tree-ssanames.c
===================================================================
*** tree-ssanames.c	(revision 117933)
--- tree-ssanames.c	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 57,69 ****
     We could also use a zone allocator for these objects since they have
     a very well defined lifetime.  If someone wants to experiment with that
     this is the place to try it.  */
-    
- /* Array of all SSA_NAMEs used in the function.  */
- VEC(tree,gc) *ssa_names;
- 
- /* Free list of SSA_NAMEs.  This list is wiped at the end of each function
-    after we leave SSA form.  */
- static GTY (()) tree free_ssanames;
  
  /* Version numbers with special meanings.  We start allocating new version
     numbers after the special ones.  */
--- 57,62 ----
*************** replace_ssa_name_symbol (tree ssa_name, 
*** 307,311 ****
    SSA_NAME_VAR (ssa_name) = sym;
    TREE_TYPE (ssa_name) = TREE_TYPE (sym);
  }
- 
- #include "gt-tree-ssanames.h"
--- 300,302 ----
Index: tree-ssa-operands.c
===================================================================
*** tree-ssa-operands.c	(revision 117933)
--- tree-ssa-operands.c	(working copy)
*************** static VEC(tree,heap) *build_vuses;
*** 117,133 ****
  static VEC(tree,heap) *build_v_must_defs;
  
- /* These arrays are the cached operand vectors for call clobbered calls.  */
- static bool ops_active = false;
- 
- static GTY (()) struct ssa_operand_memory_d *operand_memory = NULL;
- static unsigned operand_memory_index;
  
  static void get_expr_operands (tree, tree *, int);
  
- static def_optype_p free_defs = NULL;
- static use_optype_p free_uses = NULL;
- static vuse_optype_p free_vuses = NULL;
- static maydef_optype_p free_maydefs = NULL;
- static mustdef_optype_p free_mustdefs = NULL;
  
  /* Allocates operand OP of given TYPE from the appropriate free list,
     or of the new value if the list is empty.  */
--- 117,125 ----
*************** operand_build_sort_virtual (VEC(tree,hea
*** 212,218 ****
  bool
  ssa_operands_active (void)
  {
!   return ops_active;
  }
  
  
--- 203,209 ----
  bool
  ssa_operands_active (void)
  {
!   return cfun->ssa && cfun->ssa->ops_active;
  }
  
  
*************** init_ssa_operands (void)
*** 258,264 ****
  
    gcc_assert (operand_memory == NULL);
    operand_memory_index = SSA_OPERAND_MEMORY_SIZE;
!   ops_active = true;
    memset (&clobber_stats, 0, sizeof (clobber_stats));
  }
  
--- 249,255 ----
  
    gcc_assert (operand_memory == NULL);
    operand_memory_index = SSA_OPERAND_MEMORY_SIZE;
!   cfun->ssa->ops_active = true;
    memset (&clobber_stats, 0, sizeof (clobber_stats));
  }
  
*************** fini_ssa_operands (void)
*** 285,291 ****
        ggc_free (ptr);
      }
  
!   ops_active = false;
    
    if (dump_file && (dump_flags & TDF_STATS))
      {
--- 276,282 ----
        ggc_free (ptr);
      }
  
!   cfun->ssa->ops_active = false;
    
    if (dump_file && (dump_flags & TDF_STATS))
      {
*************** add_call_clobber_ops (tree stmt, tree ca
*** 1559,1565 ****
    not_read_b = callee ? ipa_reference_get_not_read_global (callee) : NULL; 
    not_written_b = callee ? ipa_reference_get_not_written_global (callee) : NULL; 
    /* Add a V_MAY_DEF operand for every call clobbered variable.  */
!   EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, u, bi)
      {
        tree var = referenced_var_lookup (u);
        unsigned int escape_mask = var_ann (var)->escape_mask;
--- 1556,1562 ----
    not_read_b = callee ? ipa_reference_get_not_read_global (callee) : NULL; 
    not_written_b = callee ? ipa_reference_get_not_written_global (callee) : NULL; 
    /* Add a V_MAY_DEF operand for every call clobbered variable.  */
!   EXECUTE_IF_SET_IN_BITMAP (cfun->ssa->call_clobbered_vars, 0, u, bi)
      {
        tree var = referenced_var_lookup (u);
        unsigned int escape_mask = var_ann (var)->escape_mask;
*************** add_call_read_ops (tree stmt, tree calle
*** 1637,1643 ****
    not_read_b = callee ? ipa_reference_get_not_read_global (callee) : NULL; 
  
    /* Add a VUSE for each call-clobbered variable.  */
!   EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, u, bi)
      {
        tree var = referenced_var (u);
        tree real_var = var;
--- 1634,1640 ----
    not_read_b = callee ? ipa_reference_get_not_read_global (callee) : NULL; 
  
    /* Add a VUSE for each call-clobbered variable.  */
!   EXECUTE_IF_SET_IN_BITMAP (cfun->ssa->call_clobbered_vars, 0, u, bi)
      {
        tree var = referenced_var (u);
        tree real_var = var;
*************** get_call_expr_operands (tree stmt, tree 
*** 1684,1690 ****
       we avoid adding superfluous virtual operands, which can be a
       significant compile time sink (See PR 15855).  */
    if (aliases_computed_p
!       && !bitmap_empty_p (call_clobbered_vars)
        && !(call_flags & ECF_NOVOPS))
      {
        /* A 'pure' or a 'const' function never call-clobbers anything. 
--- 1681,1687 ----
       we avoid adding superfluous virtual operands, which can be a
       significant compile time sink (See PR 15855).  */
    if (aliases_computed_p
!       && !bitmap_empty_p (cfun->ssa->call_clobbered_vars)
        && !(call_flags & ECF_NOVOPS))
      {
        /* A 'pure' or a 'const' function never call-clobbers anything. 
*************** get_asm_expr_operands (tree stmt)
*** 1774,1787 ****
  	if (global_var)
  	  add_stmt_operand (&global_var, s_ann, opf_is_def);
  	else
! 	  EXECUTE_IF_SET_IN_BITMAP (call_clobbered_vars, 0, i, bi)
  	    {
  	      tree var = referenced_var (i);
  	      add_stmt_operand (&var, s_ann, opf_is_def | opf_non_specific);
  	    }
  
  	/* Now clobber all addressables.  */
! 	EXECUTE_IF_SET_IN_BITMAP (addressable_vars, 0, i, bi)
  	    {
  	      tree var = referenced_var (i);
  
--- 1771,1784 ----
  	if (global_var)
  	  add_stmt_operand (&global_var, s_ann, opf_is_def);
  	else
! 	  EXECUTE_IF_SET_IN_BITMAP (cfun->ssa->call_clobbered_vars, 0, i, bi)
  	    {
  	      tree var = referenced_var (i);
  	      add_stmt_operand (&var, s_ann, opf_is_def | opf_non_specific);
  	    }
  
  	/* Now clobber all addressables.  */
! 	EXECUTE_IF_SET_IN_BITMAP (cfun->ssa->addressable_vars, 0, i, bi)
  	    {
  	      tree var = referenced_var (i);
  
*************** debug_immediate_uses_for (tree var)
*** 2572,2576 ****
  {
    dump_immediate_uses_for (stderr, var);
  }
- 
- #include "gt-tree-ssa-operands.h"
--- 2569,2571 ----


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