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]

[PATCH][3/n] referenced-vars TLC


This is the next patch in the series to move us to the state not
having global variables in referenced-vars but restricting the
reverse lookup UID -> DECL to automatic variables (the main
consumer is the SSA rewriter - which obviously only needs autos).

It introduces a DECL flag to mark virtual operands so we can
let those pass through (for the SSA renamer again).  The benefit
is also a cheaper is_gimple_reg which is used to decide whether
you are faced with a virtual SSA name or a real one.

On the way this changes the virtual var creation to work on
a specific function, thereby avoiding a cfun switch in omp lowering.

It also removes some unused cruft.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-05-22  Richard Guenther  <rguenther@suse.de>

	* tree.h (VAR_DECL_IS_VIRTUAL_OPERAND): New.
	(init_function_for_compilation): Remove.
	* tree-dfa.c (find_vars_r): Take struct function argument.
	(find_referenced_vars_in): Adjust.
	* tree-ssa-operands.c (clobber_stats): Remove.
	(create_vop_var): Take struct function argument.  Mark
	virtual operand with VAR_DECL_IS_VIRTUAL_OPERAND.
	(init_ssa_operands): Take struct function argument.
	(fini_ssa_operands): Do not dump dead stats.
	* tree-ssa-operands.h (init_ssa_operands): Take struct function
	argument.
	* cgraphunit.c (init_lowered_empty_function): Adjust.
	* lto-streamer-in.c (input_cfg): Likewise.
	* tree-inline.c (initialize_cfun): Likewise.
	* tree-into-ssa.c (rewrite_into_ssa): Likewise.
	* omp-low.c (expand_omp_taskreg): Likewise.  Avoid switching
	cfun.
	* gimple.c (is_gimple_reg): Optimize the SSA_NAME case,
	virtual operands are not registers.

Index: gcc/tree.h
===================================================================
*** gcc/tree.h	(revision 187767)
--- gcc/tree.h	(working copy)
*************** struct GTY(()) tree_common {
*** 689,694 ****
--- 689,697 ----
         TYPE_SATURATING in
             all types
  
+        VAR_DECL_IS_VIRTUAL_OPERAND in
+ 	   VAR_DECL
+ 
     nowarning_flag:
  
         TREE_NO_WARNING in
*************** extern void decl_fini_priority_insert (t
*** 3333,3338 ****
--- 3336,3344 ----
     libraries.  */
  #define MAX_RESERVED_INIT_PRIORITY 100
  
+ #define VAR_DECL_IS_VIRTUAL_OPERAND(NODE) \
+   (VAR_DECL_CHECK (NODE)->base.saturating_flag)
+ 
  #define DECL_VAR_ANN_PTR(NODE) \
    (TREE_CODE (NODE) == VAR_DECL ? &(NODE)->var_decl.ann \
     : TREE_CODE (NODE) == PARM_DECL ? &(NODE)->parm_decl.ann \
*************** extern void stack_protect_prologue (void
*** 5537,5543 ****
  extern void stack_protect_epilogue (void);
  extern void init_dummy_function_start (void);
  extern void expand_dummy_function_end (void);
- extern unsigned int init_function_for_compilation (void);
  extern void allocate_struct_function (tree, bool);
  extern void push_struct_function (tree fndecl);
  extern void init_function_start (tree);
--- 5543,5548 ----
Index: gcc/tree-ssa-operands.c
===================================================================
*** gcc/tree-ssa-operands.c	(revision 187767)
--- gcc/tree-ssa-operands.c	(working copy)
*************** along with GCC; see the file COPYING3.
*** 76,109 ****
     operand vector for VUSE, then the new vector will also be modified
     such that it contains 'a_5' rather than 'a'.  */
  
- /* Structure storing statistics on how many call clobbers we have, and
-    how many where avoided.  */
- 
- static struct
- {
-   /* Number of call-clobbered ops we attempt to add to calls in
-      add_call_clobbered_mem_symbols.  */
-   unsigned int clobbered_vars;
- 
-   /* Number of write-clobbers (VDEFs) avoided by using
-      not_written information.  */
-   unsigned int static_write_clobbers_avoided;
- 
-   /* Number of reads (VUSEs) avoided by using not_read information.  */
-   unsigned int static_read_clobbers_avoided;
- 
-   /* Number of write-clobbers avoided because the variable can't escape to
-      this call.  */
-   unsigned int unescapable_clobbers_avoided;
- 
-   /* Number of read-only uses we attempt to add to calls in
-      add_call_read_mem_symbols.  */
-   unsigned int readonly_clobbers;
- 
-   /* Number of read-only uses we avoid using not_read information.  */
-   unsigned int static_readonly_clobbers_avoided;
- } clobber_stats;
- 
  
  /* Flags to describe operand properties in helpers.  */
  
--- 76,81 ----
*************** ssa_operands_active (void)
*** 186,196 ****
     representative of all of the virtual operands FUD chain.  */
  
  static void
! create_vop_var (void)
  {
    tree global_var;
  
!   gcc_assert (cfun->gimple_df->vop == NULL_TREE);
  
    global_var = build_decl (BUILTINS_LOCATION, VAR_DECL,
  			   get_identifier (".MEM"),
--- 158,168 ----
     representative of all of the virtual operands FUD chain.  */
  
  static void
! create_vop_var (struct function *fn)
  {
    tree global_var;
  
!   gcc_assert (fn->gimple_df->vop == NULL_TREE);
  
    global_var = build_decl (BUILTINS_LOCATION, VAR_DECL,
  			   get_identifier (".MEM"),
*************** create_vop_var (void)
*** 203,212 ****
    DECL_CONTEXT (global_var) = NULL_TREE;
    TREE_THIS_VOLATILE (global_var) = 0;
    TREE_ADDRESSABLE (global_var) = 0;
  
    create_var_ann (global_var);
!   add_referenced_var (global_var);
!   cfun->gimple_df->vop = global_var;
  }
  
  /* These are the sizes of the operand memory buffer in bytes which gets
--- 175,185 ----
    DECL_CONTEXT (global_var) = NULL_TREE;
    TREE_THIS_VOLATILE (global_var) = 0;
    TREE_ADDRESSABLE (global_var) = 0;
+   VAR_DECL_IS_VIRTUAL_OPERAND (global_var) = 1;
  
    create_var_ann (global_var);
!   add_referenced_var_1 (global_var, fn);
!   fn->gimple_df->vop = global_var;
  }
  
  /* These are the sizes of the operand memory buffer in bytes which gets
*************** create_vop_var (void)
*** 224,230 ****
  /* Initialize the operand cache routines.  */
  
  void
! init_ssa_operands (void)
  {
    if (!n_initialized++)
      {
--- 197,203 ----
  /* Initialize the operand cache routines.  */
  
  void
! init_ssa_operands (struct function *fn)
  {
    if (!n_initialized++)
      {
*************** init_ssa_operands (void)
*** 235,247 ****
        bitmap_obstack_initialize (&operands_bitmap_obstack);
      }
  
!   gcc_assert (gimple_ssa_operands (cfun)->operand_memory == NULL);
!   gimple_ssa_operands (cfun)->operand_memory_index
!      = gimple_ssa_operands (cfun)->ssa_operand_mem_size;
!   gimple_ssa_operands (cfun)->ops_active = true;
!   memset (&clobber_stats, 0, sizeof (clobber_stats));
!   gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_INIT;
!   create_vop_var ();
  }
  
  
--- 208,219 ----
        bitmap_obstack_initialize (&operands_bitmap_obstack);
      }
  
!   gcc_assert (gimple_ssa_operands (fn)->operand_memory == NULL);
!   gimple_ssa_operands (fn)->operand_memory_index
!      = gimple_ssa_operands (fn)->ssa_operand_mem_size;
!   gimple_ssa_operands (fn)->ops_active = true;
!   gimple_ssa_operands (fn)->ssa_operand_mem_size = OP_SIZE_INIT;
!   create_vop_var (fn);
  }
  
  
*************** fini_ssa_operands (void)
*** 276,297 ****
      bitmap_obstack_release (&operands_bitmap_obstack);
  
    cfun->gimple_df->vop = NULL_TREE;
- 
-   if (dump_file && (dump_flags & TDF_STATS))
-     {
-       fprintf (dump_file, "Original clobbered vars:           %d\n",
- 	       clobber_stats.clobbered_vars);
-       fprintf (dump_file, "Static write clobbers avoided:     %d\n",
- 	       clobber_stats.static_write_clobbers_avoided);
-       fprintf (dump_file, "Static read clobbers avoided:      %d\n",
- 	       clobber_stats.static_read_clobbers_avoided);
-       fprintf (dump_file, "Unescapable clobbers avoided:      %d\n",
- 	       clobber_stats.unescapable_clobbers_avoided);
-       fprintf (dump_file, "Original read-only clobbers:       %d\n",
- 	       clobber_stats.readonly_clobbers);
-       fprintf (dump_file, "Static read-only clobbers avoided: %d\n",
- 	       clobber_stats.static_readonly_clobbers_avoided);
-     }
  }
  
  
--- 248,253 ----
Index: gcc/tree-ssa-operands.h
===================================================================
*** gcc/tree-ssa-operands.h	(revision 187767)
--- gcc/tree-ssa-operands.h	(working copy)
*************** struct GTY(()) ssa_operands {
*** 100,106 ****
  #define PHI_ARG_INDEX_FROM_USE(USE)   phi_arg_index_from_use (USE)
  
  
! extern void init_ssa_operands (void);
  extern void fini_ssa_operands (void);
  extern void update_stmt_operands (gimple);
  extern void free_stmt_operands (gimple);
--- 100,106 ----
  #define PHI_ARG_INDEX_FROM_USE(USE)   phi_arg_index_from_use (USE)
  
  
! extern void init_ssa_operands (struct function *fn);
  extern void fini_ssa_operands (void);
  extern void update_stmt_operands (gimple);
  extern void free_stmt_operands (gimple);
Index: gcc/cgraphunit.c
===================================================================
*** gcc/cgraphunit.c	(revision 187767)
--- gcc/cgraphunit.c	(working copy)
*************** init_lowered_empty_function (tree decl)
*** 1211,1217 ****
    gimple_register_cfg_hooks ();
    init_empty_tree_cfg ();
    init_tree_ssa (cfun);
!   init_ssa_operands ();
    cfun->gimple_df->in_ssa_p = true;
    DECL_INITIAL (decl) = make_node (BLOCK);
  
--- 1211,1217 ----
    gimple_register_cfg_hooks ();
    init_empty_tree_cfg ();
    init_tree_ssa (cfun);
!   init_ssa_operands (cfun);
    cfun->gimple_df->in_ssa_p = true;
    DECL_INITIAL (decl) = make_node (BLOCK);
  
Index: gcc/lto-streamer-in.c
===================================================================
*** gcc/lto-streamer-in.c	(revision 187767)
--- gcc/lto-streamer-in.c	(working copy)
*************** input_cfg (struct lto_input_block *ib, s
*** 616,622 ****
    int index;
  
    init_empty_tree_cfg_for_function (fn);
!   init_ssa_operands ();
  
    profile_status_for_function (fn) = streamer_read_enum (ib, profile_status_d,
  							 PROFILE_LAST);
--- 616,622 ----
    int index;
  
    init_empty_tree_cfg_for_function (fn);
!   init_ssa_operands (fn);
  
    profile_status_for_function (fn) = streamer_read_enum (ib, profile_status_d,
  							 PROFILE_LAST);
Index: gcc/tree-inline.c
===================================================================
*** gcc/tree-inline.c	(revision 187767)
--- gcc/tree-inline.c	(working copy)
*************** initialize_cfun (tree new_fndecl, tree c
*** 2123,2129 ****
      {
        init_tree_ssa (cfun);
        cfun->gimple_df->in_ssa_p = true;
!       init_ssa_operands ();
      }
    pop_cfun ();
  }
--- 2123,2129 ----
      {
        init_tree_ssa (cfun);
        cfun->gimple_df->in_ssa_p = true;
!       init_ssa_operands (cfun);
      }
    pop_cfun ();
  }
Index: gcc/tree-into-ssa.c
===================================================================
*** gcc/tree-into-ssa.c	(revision 187767)
--- gcc/tree-into-ssa.c	(working copy)
*************** rewrite_into_ssa (void)
*** 2471,2477 ****
    basic_block bb;
  
    /* Initialize operand data structures.  */
!   init_ssa_operands ();
  
    /* Initialize internal data needed by the renamer.  */
    init_ssa_renamer ();
--- 2471,2477 ----
    basic_block bb;
  
    /* Initialize operand data structures.  */
!   init_ssa_operands (cfun);
  
    /* Initialize internal data needed by the renamer.  */
    init_ssa_renamer ();
Index: gcc/gimple.c
===================================================================
*** gcc/gimple.c	(revision 187767)
--- gcc/gimple.c	(working copy)
*************** bool
*** 2786,2792 ****
  is_gimple_reg (tree t)
  {
    if (TREE_CODE (t) == SSA_NAME)
!     t = SSA_NAME_VAR (t);
  
    if (!is_gimple_variable (t))
      return false;
--- 2786,2802 ----
  is_gimple_reg (tree t)
  {
    if (TREE_CODE (t) == SSA_NAME)
!     {
!       t = SSA_NAME_VAR (t);
!       if (TREE_CODE (t) == VAR_DECL
! 	  && VAR_DECL_IS_VIRTUAL_OPERAND (t))
! 	return false;
!       return true;
!     }
! 
!   if (TREE_CODE (t) == VAR_DECL
!       && VAR_DECL_IS_VIRTUAL_OPERAND (t))
!     return false;
  
    if (!is_gimple_variable (t))
      return false;

Index: gcc/omp-low.c
===================================================================
*** gcc/omp-low.c	(revision 187767)
--- gcc/omp-low.c	(working copy)
*************** expand_omp_taskreg (struct omp_region *r
*** 3543,3553 ****
  
        if (gimple_in_ssa_p (cfun))
  	{
- 	  push_cfun (child_cfun);
  	  init_tree_ssa (child_cfun);
! 	  init_ssa_operands ();
! 	  cfun->gimple_df->in_ssa_p = true;
! 	  pop_cfun ();
  	  block = NULL_TREE;
  	}
        else
--- 3543,3551 ----
  
        if (gimple_in_ssa_p (cfun))
  	{
  	  init_tree_ssa (child_cfun);
! 	  init_ssa_operands (child_cfun);
! 	  child_cfun->gimple_df->in_ssa_p = true;
  	  block = NULL_TREE;
  	}
        else
Index: gcc/tree-dfa.c
===================================================================
*** gcc/tree-dfa.c	(revision 187767)
--- gcc/tree-dfa.c	(working copy)
*************** struct dfa_stats_d
*** 62,68 ****
  
  /* Local functions.  */
  static void collect_dfa_stats (struct dfa_stats_d *);
- static tree find_vars_r (tree *, int *, void *);
  
  
  /*---------------------------------------------------------------------------
--- 62,67 ----
*************** collect_dfa_stats (struct dfa_stats_d *d
*** 441,457 ****
     the function.  */
  
  static tree
! find_vars_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
  {
    /* If we are reading the lto info back in, we need to rescan the
       referenced vars.  */
    if (TREE_CODE (*tp) == SSA_NAME)
!     add_referenced_var (SSA_NAME_VAR (*tp));
  
    /* If T is a regular variable that the optimizers are interested
       in, add it to the list of variables.  */
    else if (SSA_VAR_P (*tp))
!     add_referenced_var (*tp);
  
    /* Type, _DECL and constant nodes have no interesting children.
       Ignore them.  */
--- 440,458 ----
     the function.  */
  
  static tree
! find_vars_r (tree *tp, int *walk_subtrees, void *data)
  {
+   struct function *fn = (struct function *) data;
+ 
    /* If we are reading the lto info back in, we need to rescan the
       referenced vars.  */
    if (TREE_CODE (*tp) == SSA_NAME)
!     add_referenced_var_1 (SSA_NAME_VAR (*tp), fn);
  
    /* If T is a regular variable that the optimizers are interested
       in, add it to the list of variables.  */
    else if (SSA_VAR_P (*tp))
!     add_referenced_var_1 (*tp, fn);
  
    /* Type, _DECL and constant nodes have no interesting children.
       Ignore them.  */
*************** find_referenced_vars_in (gimple stmt)
*** 471,486 ****
    if (gimple_code (stmt) != GIMPLE_PHI)
      {
        for (i = 0; i < gimple_num_ops (stmt); i++)
! 	walk_tree (gimple_op_ptr (stmt, i), find_vars_r, NULL, NULL);
      }
    else
      {
!       walk_tree (gimple_phi_result_ptr (stmt), find_vars_r, NULL, NULL);
  
        for (i = 0; i < gimple_phi_num_args (stmt); i++)
  	{
  	  tree arg = gimple_phi_arg_def (stmt, i);
! 	  walk_tree (&arg, find_vars_r, NULL, NULL);
  	}
      }
  }
--- 472,487 ----
    if (gimple_code (stmt) != GIMPLE_PHI)
      {
        for (i = 0; i < gimple_num_ops (stmt); i++)
! 	walk_tree (gimple_op_ptr (stmt, i), find_vars_r, cfun, NULL);
      }
    else
      {
!       walk_tree (gimple_phi_result_ptr (stmt), find_vars_r, cfun, NULL);
  
        for (i = 0; i < gimple_phi_num_args (stmt); i++)
  	{
  	  tree arg = gimple_phi_arg_def (stmt, i);
! 	  walk_tree (&arg, find_vars_r, cfun, NULL);
  	}
      }
  }


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