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][alias-improvements] Fix PR38721 in a better way


This fixes PR38721 by relying on TREE_ADDRESSABLE again in may_be_aliased.
I also took the opportunity to document the semantic differences in
the handling of what is "global" in is_global_var and may_be_aliased
(which can use TREE_PUBLIC instead of TREE_STATIC).

This also removes the gimple_addressable_vars bitmap completely.  As it
is not kept up-to-date properly it's value is dubious.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to the
branch.

Richard.

2009-01-09  Richard Guenther  <rguenther@suse.de>

	* tree-flow-inline.h (gimple_addressable_vars): Remove.
	(is_global_var): Adjust documentation.
	(may_be_aliased): Rely on TREE_ADDRESSABLE, do not use
	is_global_var.
	* tree-flow.h (struct gimple_df): Remove addressable_vars.
	* tree-ssa-structalias.c (compute_call_used_vars): Iterate
	over addressable variables with FOR_EACH_REFERENCED_VAR.
	(compute_call_clobbered): Likewise.
	* tree-ssa.c (init_tree_ssa): Do not initialize addressable_vars.
	(delete_tree_ssa): Do not free it.
	(execute_update_addresses_taken): Use a local bitmap.

Index: alias-improvements/gcc/tree-flow-inline.h
===================================================================
*** alias-improvements.orig/gcc/tree-flow-inline.h	2009-01-09 11:14:22.000000000 +0100
--- alias-improvements/gcc/tree-flow-inline.h	2009-01-09 11:23:40.000000000 +0100
*************** gimple_in_ssa_p (const struct function *
*** 35,54 ****
    return fun && fun->gimple_df && fun->gimple_df->in_ssa_p;
  }
  
- /* 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).  */
- static inline bitmap
- gimple_addressable_vars (const struct function *fun)
- {
-   gcc_assert (fun && fun->gimple_df);
-   return fun->gimple_df->addressable_vars;
- }
- 
  /* Call clobbered variables in the function.  If bit I is set, then
     REFERENCED_VARS (I) is call-clobbered.  */
  static inline bitmap
--- 35,40 ----
*************** set_is_used (tree var)
*** 576,582 ****
  }
  
  
! /* Return true if T (assumed to be a DECL) is a global variable.  */
  
  static inline bool
  is_global_var (const_tree t)
--- 562,569 ----
  }
  
  
! /* Return true if T (assumed to be a DECL) is a global variable.
!    A variable is considered global if its storage is not automatic.  */
  
  static inline bool
  is_global_var (const_tree t)
*************** is_global_var (const_tree t)
*** 585,603 ****
  }
  
  
! /* Return true if VAR may be aliased.  */
  
  static inline bool
  may_be_aliased (tree var)
  {
!   return (is_global_var (var)
! 	  || (TREE_ADDRESSABLE (var)
! 	      /* TREE_ADDRESSABLE is a pre-requesite for sth to have its
! 	         address taken, but for aggregates only the addressable
! 		 vars bitmap is a precise answer.  */
! 	      && (!gimple_addressable_vars (cfun)
! 		  || bitmap_bit_p (gimple_addressable_vars (cfun),
! 				   DECL_UID (var)))));
  }
  
  
--- 572,585 ----
  }
  
  
! /* Return true if VAR may be aliased.  A variable is considered as
!    maybe aliased if it has its address taken by the local TU
!    or possibly by another TU.  */
  
  static inline bool
  may_be_aliased (tree var)
  {
!   return (TREE_PUBLIC (var) || DECL_EXTERNAL (var) || TREE_ADDRESSABLE (var));
  }
  
  
Index: alias-improvements/gcc/tree-flow.h
===================================================================
*** alias-improvements.orig/gcc/tree-flow.h	2009-01-09 11:14:22.000000000 +0100
--- alias-improvements/gcc/tree-flow.h	2009-01-09 11:14:35.000000000 +0100
*************** struct gimple_df GTY(())
*** 75,89 ****
       REFERENCED_VARS (I) is call-used at pure function call-sites.  */
    bitmap call_used_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;
- 
    /* Free list of SSA_NAMEs.  */
    tree free_ssanames;
  
--- 75,80 ----
Index: alias-improvements/gcc/tree-ssa-structalias.c
===================================================================
*** alias-improvements.orig/gcc/tree-ssa-structalias.c	2009-01-09 11:14:22.000000000 +0100
--- alias-improvements/gcc/tree-ssa-structalias.c	2009-01-09 11:15:31.000000000 +0100
*************** compute_call_used_vars (void)
*** 5108,5115 ****
  
    /* If anything is call-used, add all addressable locals to the set.  */
    if (has_anything_id)
!     bitmap_ior_into (gimple_call_used_vars (cfun),
! 		     gimple_addressable_vars (cfun));
  }
  
  
--- 5108,5122 ----
  
    /* If anything is call-used, add all addressable locals to the set.  */
    if (has_anything_id)
!     {
!       referenced_var_iterator rvi;
!       tree var;
! 
!       FOR_EACH_REFERENCED_VAR (var, rvi)
! 	if (!is_global_var (var)
! 	    && TREE_ADDRESSABLE (var))
! 	  bitmap_set_bit (gimple_call_used_vars (cfun), DECL_UID (var));
!     }
  }
  
  
*************** compute_call_clobbered (void)
*** 5782,5794 ****
       variables call clobbered.  */
    if (any_pt_anything)
      {
!       bitmap_iterator bi;
!       unsigned int j;
  
!       EXECUTE_IF_SET_IN_BITMAP (gimple_addressable_vars (cfun), 0, j, bi)
  	{
! 	  tree var = referenced_var (j);
! 	  if (!unmodifiable_var_p (var))
  	    mark_call_clobbered (var, pt_anything_mask);
  	}
      }
--- 5789,5800 ----
       variables call clobbered.  */
    if (any_pt_anything)
      {
!       referenced_var_iterator rvi;
  
!       FOR_EACH_REFERENCED_VAR (var, rvi)
  	{
! 	  if (TREE_ADDRESSABLE (var)
! 	      && !unmodifiable_var_p (var))
  	    mark_call_clobbered (var, pt_anything_mask);
  	}
      }
Index: alias-improvements/gcc/tree-ssa.c
===================================================================
*** alias-improvements.orig/gcc/tree-ssa.c	2009-01-09 11:14:22.000000000 +0100
--- alias-improvements/gcc/tree-ssa.c	2009-01-09 11:14:35.000000000 +0100
*************** init_tree_ssa (struct function *fn)
*** 779,785 ****
  				                 uid_ssaname_map_eq, NULL);
    fn->gimple_df->call_clobbered_vars = BITMAP_GGC_ALLOC ();
    fn->gimple_df->call_used_vars = BITMAP_GGC_ALLOC ();
-   fn->gimple_df->addressable_vars = BITMAP_GGC_ALLOC ();
    init_ssanames (fn, 0);
    init_phinodes ();
  }
--- 779,784 ----
*************** delete_tree_ssa (void)
*** 863,869 ****
    cfun->gimple_df->default_defs = NULL;
    cfun->gimple_df->call_clobbered_vars = NULL;
    cfun->gimple_df->call_used_vars = NULL;
-   cfun->gimple_df->addressable_vars = NULL;
    cfun->gimple_df->modified_noreturn_calls = NULL;
    cfun->gimple_df = NULL;
  
--- 862,867 ----
*************** execute_update_addresses_taken (bool do_
*** 1476,1489 ****
    referenced_var_iterator rvi;
    gimple_stmt_iterator gsi;
    basic_block bb;
!   bitmap addresses_taken;
    bitmap not_reg_needs = BITMAP_ALLOC (NULL);
    bool update_vops = false;
  
-   /* Reset the addressable vars bitmap.  */
-   addresses_taken = gimple_addressable_vars (cfun);
-   bitmap_clear (addresses_taken);
- 
    /* Collect into ADDRESSES_TAKEN all variables whose address is taken within
       the function body.  */
    FOR_EACH_BB (bb)
--- 1474,1483 ----
    referenced_var_iterator rvi;
    gimple_stmt_iterator gsi;
    basic_block bb;
!   bitmap addresses_taken = BITMAP_ALLOC (NULL);
    bitmap not_reg_needs = BITMAP_ALLOC (NULL);
    bool update_vops = false;
  
    /* Collect into ADDRESSES_TAKEN all variables whose address is taken within
       the function body.  */
    FOR_EACH_BB (bb)
*************** execute_update_addresses_taken (bool do_
*** 1588,1593 ****
--- 1582,1588 ----
      }
  
    BITMAP_FREE (not_reg_needs);
+   BITMAP_FREE (addresses_taken);
  }
  
  struct gimple_opt_pass pass_update_address_taken =


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