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] Clean up call clobber flag and MTAG flags usage


This makes the use of tree flags on MTAGs and the call clobber flag
handling consistent.  Basically I see no reason not to use
var_ann->call_clobbered for MTAGs as well.  Also checking any tree
flags on MTAGs is of no use - I guess those checks are from simply
copying the !MTAG cases.  Finally not clearing call-clobber info
on MTAGs leaves them clobbered even for later alias passes where
we might have more precise info.  And of course we are re-computing
call clobbering anyway, including for globals.

Bootstrapped and tested on x86_64-unknown-linux-gnu.  I'll apply this
after giving some time for comments.

Thanks,
Richard.

2008-06-03  Richard Guenther  <rguenther@suse.de>

	* tree-flow-inline.h (is_global_var): Do not check TREE_STATIC
	on MTAGs.
	(is_call_clobbered): Always check var_ann->call_clobbered.
	(mark_call_clobbered): Always set var_ann->call_clobbered.
	(clear_call_clobbered): Always clear var_ann->call_clobbered.
	* tree-ssa-alias.c (mark_non_addressable): Use clear_call_clobbered.
	(reset_alias_info): Clear call clobbering info on MTAGs and
	globals as well.
	(set_pt_anything): Set pt_global_mem.
	(create_tag_raw): Adjust comment.
	(may_be_aliased): Do not check TREE_PUBLIC on MTAGs.

Index: trunk/gcc/tree-flow-inline.h
===================================================================
*** trunk.orig/gcc/tree-flow-inline.h	2008-05-30 12:02:24.000000000 +0200
--- trunk/gcc/tree-flow-inline.h	2008-06-02 11:31:28.000000000 +0200
*************** static inline bool
*** 698,704 ****
  is_global_var (const_tree t)
  {
    if (MTAG_P (t))
!     return (TREE_STATIC (t) || MTAG_GLOBAL (t));
    else
      return (TREE_STATIC (t) || DECL_EXTERNAL (t));
  }
--- 698,704 ----
  is_global_var (const_tree t)
  {
    if (MTAG_P (t))
!     return MTAG_GLOBAL (t);
    else
      return (TREE_STATIC (t) || DECL_EXTERNAL (t));
  }
*************** factoring_name_p (const_tree name)
*** 875,884 ****
  static inline bool
  is_call_clobbered (const_tree var)
  {
!   if (!MTAG_P (var))
!     return var_ann (var)->call_clobbered;
!   else
!     return bitmap_bit_p (gimple_call_clobbered_vars (cfun), DECL_UID (var)); 
  }
  
  /* Mark variable VAR as being clobbered by function calls.  */
--- 875,881 ----
  static inline bool
  is_call_clobbered (const_tree var)
  {
!   return var_ann (var)->call_clobbered;
  }
  
  /* Mark variable VAR as being clobbered by function calls.  */
*************** static inline void
*** 886,893 ****
  mark_call_clobbered (tree var, unsigned int escape_type)
  {
    var_ann (var)->escape_mask |= escape_type;
!   if (!MTAG_P (var))
!     var_ann (var)->call_clobbered = true;
    bitmap_set_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
  }
  
--- 883,889 ----
  mark_call_clobbered (tree var, unsigned int escape_type)
  {
    var_ann (var)->escape_mask |= escape_type;
!   var_ann (var)->call_clobbered = true;
    bitmap_set_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
  }
  
*************** clear_call_clobbered (tree var)
*** 899,906 ****
    ann->escape_mask = 0;
    if (MTAG_P (var))
      MTAG_GLOBAL (var) = 0;
!   if (!MTAG_P (var))
!     var_ann (var)->call_clobbered = false;
    bitmap_clear_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
  }
  
--- 895,901 ----
    ann->escape_mask = 0;
    if (MTAG_P (var))
      MTAG_GLOBAL (var) = 0;
!   var_ann (var)->call_clobbered = false;
    bitmap_clear_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
  }
  
Index: trunk/gcc/tree-ssa-alias.c
===================================================================
*** trunk.orig/gcc/tree-ssa-alias.c	2008-05-30 21:53:47.000000000 +0200
--- trunk/gcc/tree-ssa-alias.c	2008-06-03 11:29:06.000000000 +0200
*************** mark_non_addressable (tree var)
*** 305,314 ****
  
    mpt = memory_partition (var);
  
!   if (!MTAG_P (var))
!     var_ann (var)->call_clobbered = false;
! 
!   bitmap_clear_bit (gimple_call_clobbered_vars (cfun), DECL_UID (var));
    TREE_ADDRESSABLE (var) = 0;
  
    if (mpt)
--- 305,311 ----
  
    mpt = memory_partition (var);
  
!   clear_call_clobbered (var);
    TREE_ADDRESSABLE (var) = 0;
  
    if (mpt)
*************** reset_alias_info (void)
*** 2003,2024 ****
  	bitmap_set_bit (all_nmts, DECL_UID (var));
  
        /* Since we are about to re-discover call-clobbered
! 	 variables, clear the call-clobbered flag.  Variables that
! 	 are intrinsically call-clobbered (globals, local statics,
! 	 etc) will not be marked by the aliasing code, so we can't
! 	 remove them from CALL_CLOBBERED_VARS.  
! 
! 	 NB: STRUCT_FIELDS are still call clobbered if they are for a
! 	 global variable, so we *don't* clear their call clobberedness
! 	 just because they are tags, though we will clear it if they
! 	 aren't for global variables.  */
!       if (TREE_CODE (var) == NAME_MEMORY_TAG
! 	  || TREE_CODE (var) == SYMBOL_MEMORY_TAG
! 	  || TREE_CODE (var) == MEMORY_PARTITION_TAG
! 	  || !is_global_var (var))
! 	clear_call_clobbered (var);
      }
  
    /* Clear flow-sensitive points-to information from each SSA name.  */
    for (i = 1; i < num_ssa_names; i++)
      {
--- 2000,2012 ----
  	bitmap_set_bit (all_nmts, DECL_UID (var));
  
        /* Since we are about to re-discover call-clobbered
! 	 variables, clear the call-clobbered flag.  */
!       clear_call_clobbered (var);
      }
  
+   /* There should be no call-clobbered variable left.  */
+   gcc_assert (bitmap_empty_p (gimple_call_clobbered_vars (cfun)));
+ 
    /* Clear flow-sensitive points-to information from each SSA name.  */
    for (i = 1; i < num_ssa_names; i++)
      {
*************** set_pt_anything (tree ptr)
*** 2830,2835 ****
--- 2811,2818 ----
    struct ptr_info_def *pi = get_ptr_info (ptr);
  
    pi->pt_anything = 1;
+   /* Anything includes global memory.  */
+   pi->pt_global_mem = 1;
    pi->pt_vars = NULL;
  
    /* The pointer used to have a name tag, but we now found it pointing
*************** create_tag_raw (enum tree_code code, tre
*** 2926,2937 ****
  
    tmp_var = build_decl (code, create_tmp_var_name (prefix), type);
  
!   /* Make the variable writable.  */
    TREE_READONLY (tmp_var) = 0;
  
    /* It doesn't start out global.  */
    MTAG_GLOBAL (tmp_var) = 0;
-   TREE_STATIC (tmp_var) = 0;
    TREE_USED (tmp_var) = 1;
  
    return tmp_var;
--- 2909,2920 ----
  
    tmp_var = build_decl (code, create_tmp_var_name (prefix), type);
  
!   /* Memory tags are always writable and non-static.  */
    TREE_READONLY (tmp_var) = 0;
+   TREE_STATIC (tmp_var) = 0;
  
    /* It doesn't start out global.  */
    MTAG_GLOBAL (tmp_var) = 0;
    TREE_USED (tmp_var) = 1;
  
    return tmp_var;
*************** may_be_aliased (tree var)
*** 3365,3371 ****
    /* Globally visible variables can have their addresses taken by other
       translation units.  */
    if (MTAG_P (var)
!       && (MTAG_GLOBAL (var) || TREE_PUBLIC (var)))
      return true;
    else if (!MTAG_P (var)
             && (DECL_EXTERNAL (var) || TREE_PUBLIC (var)))
--- 3348,3354 ----
    /* Globally visible variables can have their addresses taken by other
       translation units.  */
    if (MTAG_P (var)
!       && MTAG_GLOBAL (var))
      return true;
    else if (!MTAG_P (var)
             && (DECL_EXTERNAL (var) || TREE_PUBLIC (var)))


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