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]

various fixes for type analysis for tree-profiling branch.


tested on x86-suse.

2005-02-17 Kenneth Zadeck <zadeck@naturalbridge.com>

   *bitmap.h: added useful documentation.
   *builtin-attrs.def: added ATTR_POINTER_NO_ESCAPE_CONST_NOTHROW_LIST.
   *builtins.def: changed constant_p to use
   ATTR_POINTER_NO_ESCAPE_CONST_NOTHROW_LIST.
   *ipa-static-vars-anal.c (ipa_static_star_count_of_interesting_type,
   ipa_static_star_count_of_interesting_or_array_type,
   ipa_static_type_contained_p, ipa_static_address_not_taken_of_field,
   mark_any_type_seen, mark_type, count_stars,
   check_function_parameter_and_return_type, check_call, close_type_seen,
   close_type_full_escape): Changed way types were traversed.
   *ipa-static-vars-anal.c (has_proper_scope_for_analysis, check_call):
   Fixed scanning call parms code.
   *ipa-static-vars-anal.c (do_type_analysis):
   Fixed improper use of bitvector iterators.
   *tree-ssa-alias.c (may_alias_p): Changed the way calls into
   ipa_static_address_not_taken_of_field are set up.
   *tree-ssa-operands: (add_call_clobber_ops): Added comment to
   point out future work.

Index: gcc/alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.176.2.21.2.18
diff -c -3 -p -r1.176.2.21.2.18 alias.c
*** gcc/alias.c	12 Feb 2005 14:31:50 -0000	1.176.2.21.2.18
--- gcc/alias.c	17 Feb 2005 17:25:53 -0000
*************** nonoverlapping_component_refs_p (tree x,
*** 1965,1971 ****
  	  x = TREE_OPERAND (x, 0);
  	}
        while (x && TREE_CODE (x) == COMPONENT_REF);
- #define AGRESSIVE_ALIASING
        /* Never found a common type.  */
  #ifdef AGRESSIVE_ALIASING
        return true;
--- 1965,1970 ----
Index: gcc/bitmap.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bitmap.h,v
retrieving revision 1.28.2.4.2.2
diff -c -3 -p -r1.28.2.4.2.2 bitmap.h
*** gcc/bitmap.h	15 Dec 2004 22:17:28 -0000	1.28.2.4.2.2
--- gcc/bitmap.h	17 Feb 2005 17:25:53 -0000
***************
*** 1,5 ****
  /* Functions to support general ended bitmaps.
!    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
     Free Software Foundation, Inc.
  
  This file is part of GCC.
--- 1,5 ----
  /* Functions to support general ended bitmaps.
!    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
     Free Software Foundation, Inc.
  
  This file is part of GCC.
*************** extern bitmap_obstack bitmap_default_obs
*** 80,86 ****
  /* Clear a bitmap by freeing up the linked list.  */
  extern void bitmap_clear (bitmap);
  
! /* Copy a bitmap to another bitmap.  */
  extern void bitmap_copy (bitmap, bitmap);
  
  /* True if two bitmaps are identical.  */
--- 80,86 ----
  /* Clear a bitmap by freeing up the linked list.  */
  extern void bitmap_clear (bitmap);
  
! /* Copy the second bitmap to the first bitmap.  */
  extern void bitmap_copy (bitmap, bitmap);
  
  /* True if two bitmaps are identical.  */
Index: gcc/builtin-attrs.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtin-attrs.def,v
retrieving revision 1.3.2.6.4.4
diff -c -3 -p -r1.3.2.6.4.4 builtin-attrs.def
*** gcc/builtin-attrs.def	22 Jan 2005 17:52:52 -0000	1.3.2.6.4.4
--- gcc/builtin-attrs.def	17 Feb 2005 17:25:53 -0000
*************** DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_
*** 105,110 ****
--- 105,114 ----
  DEF_ATTR_TREE_LIST (ATTR_SENTINEL_NOTHROW_LIST, ATTR_SENTINEL,	\
  			ATTR_NULL, ATTR_NOTHROW_LIST)
  
+ DEF_ATTR_TREE_LIST (ATTR_POINTER_NO_ESCAPE_CONST_NOTHROW_LIST,	\
+ 			ATTR_POINTER_NO_ESCAPE,			\
+ 			ATTR_NULL, ATTR_CONST_NOTHROW_LIST)
+ 
  DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
  DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
  /* Functions whose first and second parameters are nonnull pointers.  */
Index: gcc/builtins.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.def,v
retrieving revision 1.29.2.25.2.11
diff -c -3 -p -r1.29.2.25.2.11 builtins.def
*** gcc/builtins.def	12 Feb 2005 14:31:55 -0000	1.29.2.25.2.11
--- gcc/builtins.def	17 Feb 2005 17:25:54 -0000
*************** DEF_GCC_BUILTIN        (BUILT_IN_CLZ, "c
*** 553,559 ****
  DEF_GCC_BUILTIN        (BUILT_IN_CLZIMAX, "clzimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CLZL, "clzl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CLZLL, "clzll", BT_FN_INT_ULONGLONG, ATTR_CONST_NOTHROW_LIST)
! DEF_GCC_BUILTIN        (BUILT_IN_CONSTANT_P, "constant_p", BT_FN_INT_VAR, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CTZ, "ctz", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CTZIMAX, "ctzimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CTZL, "ctzl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST)
--- 553,559 ----
  DEF_GCC_BUILTIN        (BUILT_IN_CLZIMAX, "clzimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CLZL, "clzl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CLZLL, "clzll", BT_FN_INT_ULONGLONG, ATTR_CONST_NOTHROW_LIST)
! DEF_GCC_BUILTIN        (BUILT_IN_CONSTANT_P, "constant_p", BT_FN_INT_VAR, ATTR_POINTER_NO_ESCAPE_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CTZ, "ctz", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CTZIMAX, "ctzimax", BT_FN_INT_UINTMAX, ATTR_CONST_NOTHROW_LIST)
  DEF_GCC_BUILTIN        (BUILT_IN_CTZL, "ctzl", BT_FN_INT_ULONG, ATTR_CONST_NOTHROW_LIST)
Index: gcc/ipa-static-vars-anal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ipa-static-vars-anal.c,v
retrieving revision 1.1.2.9
diff -c -3 -p -r1.1.2.9 ipa-static-vars-anal.c
*** gcc/ipa-static-vars-anal.c	7 Feb 2005 00:53:44 -0000	1.1.2.9
--- gcc/ipa-static-vars-anal.c	17 Feb 2005 17:25:54 -0000
*************** ipa_static_star_count_of_interesting_typ
*** 457,465 ****
  {
    int count = 0;
    /* Strip the *'s off.  */
    while (POINTER_TYPE_P (type))
      {
!       type = TREE_TYPE (type);
        count++;
      }
  
--- 457,466 ----
  {
    int count = 0;
    /* Strip the *'s off.  */
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type))
      {
!       type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
        count++;
      }
  
*************** ipa_static_star_count_of_interesting_or_
*** 483,491 ****
  {
    int count = 0;
    /* Strip the *'s off.  */
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
      {
!       type = TREE_TYPE (type);
        count++;
      }
  
--- 484,493 ----
  {
    int count = 0;
    /* Strip the *'s off.  */
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
      {
!       type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
        count++;
      }
  
*************** ipa_static_type_contained_p (tree type)
*** 510,519 ****
    if (initialization_status == UNINITIALIZED)
      return false;
  
    while (POINTER_TYPE_P (type))
!     type = TREE_TYPE (type);
  
-   type = TYPE_MAIN_VARIANT (type);
    uid = unique_type_id_for (TYPE_UID (type), true);
    return !bitmap_bit_p (global_types_full_escape, uid);
  }
--- 512,521 ----
    if (initialization_status == UNINITIALIZED)
      return false;
  
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type))
!     type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
  
    uid = unique_type_id_for (TYPE_UID (type), true);
    return !bitmap_bit_p (global_types_full_escape, uid);
  }
*************** ipa_static_address_not_taken_of_field (t
*** 533,543 ****
    /* Strip off all of the pointer tos on the record type.  Strip the
       same number of pointer tos from the field type.  If the field
       type has fewer, it could not have been aliased. */
    while (POINTER_TYPE_P (record_type))
      {
!       record_type = TREE_TYPE (record_type);
        if (POINTER_TYPE_P (field_type)) 
! 	field_type = TREE_TYPE (field_type);
        else 
  	return true;
      }
--- 535,547 ----
    /* Strip off all of the pointer tos on the record type.  Strip the
       same number of pointer tos from the field type.  If the field
       type has fewer, it could not have been aliased. */
+   record_type = TYPE_MAIN_VARIANT (record_type);
+   field_type = TYPE_MAIN_VARIANT (field_type);
    while (POINTER_TYPE_P (record_type))
      {
!       record_type = TYPE_MAIN_VARIANT (TREE_TYPE (record_type));
        if (POINTER_TYPE_P (field_type)) 
! 	field_type = TYPE_MAIN_VARIANT (TREE_TYPE (field_type));
        else 
  	return true;
      }
*************** ipa_static_address_not_taken_of_field (t
*** 547,560 ****
    if (!ipa_static_type_contained_p (record_type))
      return false;
  
-   record_type = TYPE_MAIN_VARIANT (record_type);
    uid = unique_type_id_for (TYPE_UID (record_type), false);
    result = splay_tree_lookup (uid_to_addressof_map, (splay_tree_key) uid);
    
    if (result) 
      {
        bitmap field_type_map = (bitmap) result->value;
-       field_type = TYPE_MAIN_VARIANT (field_type);
        uid = unique_type_id_for (TYPE_UID (field_type), true);
        /* If the bit is there, the address was taken. If not, it
  	 wasn't.  */
--- 551,562 ----
*************** reduced_inorder (struct cgraph_node **or
*** 716,724 ****
  
  
  
! /* Mark a TYPE as being seen.  This is only called from two places:
!    mark_type_seen which only calls it with record and union types and
!    mark_interesting_addressof which can mark any field type.  */ 
  
  static bool
  mark_any_type_seen (tree type)
--- 718,724 ----
  
  
  
! /* Mark a TYPE as being seen.  */ 
  
  static bool
  mark_any_type_seen (tree type)
*************** mark_any_type_seen (tree type)
*** 746,753 ****
  static bool
  mark_type_seen (tree type)
  {
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
!     type = TREE_TYPE (type);
  
    /* We are interested in records, and unions only.  */
    if (TREE_CODE (type) == RECORD_TYPE 
--- 746,754 ----
  static bool
  mark_type_seen (tree type)
  {
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
!     type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
  
    /* We are interested in records, and unions only.  */
    if (TREE_CODE (type) == RECORD_TYPE 
*************** mark_type (tree type, enum escape_t esca
*** 773,780 ****
    bitmap map = NULL;
    int uid;
  
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
!     type = TREE_TYPE (type);
    
    switch (escape_status) 
      {
--- 774,782 ----
    bitmap map = NULL;
    int uid;
  
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
!     type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
    
    switch (escape_status) 
      {
*************** mark_type (tree type, enum escape_t esca
*** 786,798 ****
        break;
      }
  
!   uid = TYPE_UID (TYPE_MAIN_VARIANT (type));
    if (bitmap_bit_p (map, uid))
      return false;
    else
      {
        bitmap_set_bit (map, uid);
!       mark_type_seen (type);
  
        if (escape_status == FULL_ESCAPE)
  	{
--- 788,800 ----
        break;
      }
  
!   uid = TYPE_UID (type);
    if (bitmap_bit_p (map, uid))
      return false;
    else
      {
        bitmap_set_bit (map, uid);
!       mark_any_type_seen (type);
  
        if (escape_status == FULL_ESCAPE)
  	{
*************** count_stars (tree* type_ptr)
*** 918,926 ****
  {
    tree type = *type_ptr;
    int i = 0;
    while (POINTER_TYPE_P (type))
      {
!       type = TREE_TYPE (type);
        i++;
      }
  
--- 920,929 ----
  {
    tree type = *type_ptr;
    int i = 0;
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type))
      {
!       type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
        i++;
      }
  
*************** check_function_parameter_and_return_type
*** 1033,1038 ****
--- 1036,1045 ----
      }
    else
      {
+       /* FIXME - According to Geoff Keating, we should never have to
+ 	 do this; the front ends should always process the arg list
+ 	 from the TYPE_ARG_LIST. */
+ 
        for (arg = DECL_ARGUMENTS (fn); arg; arg = TREE_CHAIN (arg))
  	{
  	  if (escapes)
*************** has_proper_scope_for_analysis (ipa_local
*** 1108,1119 ****
  	  && is_gimple_min_invariant (DECL_INITIAL (t)))
  	; /* Read of a constant, do not change the function state.  */
        else 
! 	/* Just a regular read.  */
! 	if (local 
! 	    && local->pure_const_not_set_in_source
! 	    && local->pure_const_state == IPA_CONST)
! 	  local->pure_const_state = IPA_PURE;
! 
        return false;
      }
  
--- 1115,1130 ----
  	  && is_gimple_min_invariant (DECL_INITIAL (t)))
  	; /* Read of a constant, do not change the function state.  */
        else 
! 	{
! 	  /* Just a regular read.  */
! 	  if (local 
! 	      && local->pure_const_not_set_in_source
! 	      && local->pure_const_state == IPA_CONST)
! 	    local->pure_const_state = IPA_PURE;
! 	 
! 	  /* The type escapes for all public and externs. */
! 	  mark_interesting_type (TREE_TYPE (t), FULL_ESCAPE);
! 	}
        return false;
      }
  
*************** check_call (ipa_local_static_vars_info_t
*** 1446,1471 ****
  	      tree call_expr) 
  {
    int flags = call_expr_flags(call_expr);
!   tree operandList = TREE_OPERAND (call_expr, 1);
    tree operand;
    tree callee_t = get_callee_fndecl (call_expr);
    tree argument;
    struct cgraph_node* callee;
    enum availability avail = AVAIL_NOT_AVAILABLE;
  
!   for (operand = operandList;
         operand != NULL_TREE;
         operand = TREE_CHAIN (operand))
      {
        tree argument = TREE_VALUE (operand);
        check_rhs_var (local, argument);
      }
! 
    /* The const and pure flags are set by a variety of places in the
       compiler (including here).  If someone has already set the flags
       for the callee, (such as for some of the builtins) we will use
       them, otherwise we will compute our own information.  */
! 
    /* Const and pure functions have less clobber effects than other
       functions so we process these first.  Otherwise if it is a call
       outside the compilation unit or an indirect call we punt.  This
--- 1457,1482 ----
  	      tree call_expr) 
  {
    int flags = call_expr_flags(call_expr);
!   tree operand_list = TREE_OPERAND (call_expr, 1);
    tree operand;
    tree callee_t = get_callee_fndecl (call_expr);
    tree argument;
    struct cgraph_node* callee;
    enum availability avail = AVAIL_NOT_AVAILABLE;
  
!   for (operand = operand_list;
         operand != NULL_TREE;
         operand = TREE_CHAIN (operand))
      {
        tree argument = TREE_VALUE (operand);
        check_rhs_var (local, argument);
      }
!   
    /* The const and pure flags are set by a variety of places in the
       compiler (including here).  If someone has already set the flags
       for the callee, (such as for some of the builtins) we will use
       them, otherwise we will compute our own information.  */
!   
    /* Const and pure functions have less clobber effects than other
       functions so we process these first.  Otherwise if it is a call
       outside the compilation unit or an indirect call we punt.  This
*************** check_call (ipa_local_static_vars_info_t
*** 1476,1501 ****
    if (callee_t)
      {
        tree arg_type;
!       tree last_arg_type;
        callee = cgraph_node(callee_t);
        avail = cgraph_function_body_availability (callee);
  
        /* If the function is POINTER_NO_ESCAPE or a wrapper it is
  	 allowed to make an implicit cast to void* without causing the
  	 type to escape.  */
!       if (!flags & ECF_POINTER_NO_ESCAPE) 
  	{
  	  /* Check that there are no implicit casts in the passing of
  	     parameters.  */
! 	  operand = operandList;
! 	  for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t));
! 	       arg_type && TREE_VALUE (arg_type) != void_type_node;
! 	       arg_type = TREE_CHAIN (arg_type))
  	    {
! 	      operand = TREE_CHAIN (operand);
! 	      argument = TREE_VALUE (operand);
! 	      check_cast (arg_type, argument);
! 	      last_arg_type = arg_type;
  	    }
  	  
  	  /* In the case where we have a var_args function, we need to
--- 1487,1547 ----
    if (callee_t)
      {
        tree arg_type;
!       tree last_arg_type = NULL;
        callee = cgraph_node(callee_t);
        avail = cgraph_function_body_availability (callee);
  
        /* If the function is POINTER_NO_ESCAPE or a wrapper it is
  	 allowed to make an implicit cast to void* without causing the
  	 type to escape.  */
!       if (!(flags & ECF_POINTER_NO_ESCAPE)) 
  	{
  	  /* Check that there are no implicit casts in the passing of
  	     parameters.  */
! 	  if (TYPE_ARG_TYPES (TREE_TYPE (callee_t)))
  	    {
! 	      operand = operand_list;
! 	      for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t));
! 		   arg_type && TREE_VALUE (arg_type) != void_type_node;
! 		   arg_type = TREE_CHAIN (arg_type))
! 		{
! 		  if (operand)
! 		    {
! 		      argument = TREE_VALUE (operand);
! 		      last_arg_type = TREE_VALUE(arg_type);
! 		      check_cast (last_arg_type, argument);
! 		      operand = TREE_CHAIN (operand);
! 		    }
! 		  else 
! 		    /* The code reaches here for some unfortunate
! 		       builtin functions that do not have a list of
! 		       argument types.  */
! 		    break; 
! 		}
! 	    } 
! 	  else  
! 	    { 
! 	      /* FIXME - According to Geoff Keating, we should never
! 		 have to do this; the front ends should always process
! 		 the arg list from the TYPE_ARG_LIST. */
! 	      operand = operand_list;
! 	      for (arg_type = DECL_ARGUMENTS (callee_t); 
! 		   arg_type;
! 		   arg_type = TREE_CHAIN (arg_type))
! 		{
! 		  if (operand)
! 		    {
! 		      argument = TREE_VALUE (operand);
! 		      last_arg_type = TREE_TYPE(arg_type);
! 		      check_cast (last_arg_type, argument);
! 		      operand = TREE_CHAIN (operand);
! 		    } 
! 		  else 
! 		    /* The code reaches here for some unfortunate
! 		       builtin functions that do not have a list of
! 		       argument types.  */
! 		    break; 
! 		}
  	    }
  	  
  	  /* In the case where we have a var_args function, we need to
*************** check_call (ipa_local_static_vars_info_t
*** 1506,1512 ****
  	       operand = TREE_CHAIN (operand))
  	    {
  	      argument = TREE_VALUE (operand);
! 	      check_cast (arg_type, argument);
  	    }
  	}
  
--- 1552,1568 ----
  	       operand = TREE_CHAIN (operand))
  	    {
  	      argument = TREE_VALUE (operand);
! 	      if (arg_type)
! 		check_cast (arg_type, argument);
! 	      else 
! 		{
! 		  /* The code reaches here for some unfortunate
! 		     builtin functions that do not have a list of
! 		     argument types.  Most of these functions have
! 		     been marked as having their parameters not
! 		     escape, but for the rest, the type is doomed.  */
! 		  mark_interesting_type (TREE_TYPE (argument), FULL_ESCAPE);
! 		}
  	    }
  	}
  
*************** check_call (ipa_local_static_vars_info_t
*** 1536,1546 ****
  
    if (avail == AVAIL_NOT_AVAILABLE || avail == AVAIL_OVERWRITABLE)
      {
!       if (!flags & ECF_POINTER_NO_ESCAPE) 
  	{
  	  /* If this is a direct call to an external function, mark all of
  	     the parameter and return types.  */
! 	  for (operand = operandList;
  	       operand != NULL_TREE;
  	       operand = TREE_CHAIN (operand))
  	    {
--- 1592,1602 ----
  
    if (avail == AVAIL_NOT_AVAILABLE || avail == AVAIL_OVERWRITABLE)
      {
!       if (!(flags & ECF_POINTER_NO_ESCAPE))
  	{
  	  /* If this is a direct call to an external function, mark all of
  	     the parameter and return types.  */
! 	  for (operand = operand_list;
  	       operand != NULL_TREE;
  	       operand = TREE_CHAIN (operand))
  	    {
*************** check_call (ipa_local_static_vars_info_t
*** 1593,1600 ****
  static bool 
  okay_pointer_operation (enum tree_code code,  tree op0, tree op1)
  {
!   tree op0type = TREE_TYPE (op0);
!   tree op1type = TREE_TYPE (op1);
    if (POINTER_TYPE_P (op1type))
      return false;
    switch (code)
--- 1649,1656 ----
  static bool 
  okay_pointer_operation (enum tree_code code,  tree op0, tree op1)
  {
!   tree op0type = TYPE_MAIN_VARIANT (TREE_TYPE (op0));
!   tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
    if (POINTER_TYPE_P (op1type))
      return false;
    switch (code)
*************** close_type_seen (tree type)
*** 2179,2188 ****
    tree binfo, base_binfo;
  
    /* See thru all pointer tos and array ofs. */
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
!     type = TREE_TYPE (type);
    
-   type = TYPE_MAIN_VARIANT (type);
    uid = TYPE_UID (type);
  
    if (bitmap_bit_p (been_there_done_that, uid))
--- 2235,2244 ----
    tree binfo, base_binfo;
  
    /* See thru all pointer tos and array ofs. */
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
!     type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
    
    uid = TYPE_UID (type);
  
    if (bitmap_bit_p (been_there_done_that, uid))
*************** close_type_full_escape (tree type)
*** 2372,2381 ****
    bitmap subtype_map;
  
    /* Strip off any pointer or array types.  */
    while (POINTER_TYPE_P (type) || TREE_CODE(type) == ARRAY_TYPE)
!     type = TREE_TYPE (type);
  
-   type = TYPE_MAIN_VARIANT (type);
    uid = TYPE_UID (type);
  
    if (bitmap_bit_p (been_there_done_that, uid))
--- 2428,2437 ----
    bitmap subtype_map;
  
    /* Strip off any pointer or array types.  */
+   type = TYPE_MAIN_VARIANT (type);
    while (POINTER_TYPE_P (type) || TREE_CODE(type) == ARRAY_TYPE)
!     type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
  
    uid = TYPE_UID (type);
  
    if (bitmap_bit_p (been_there_done_that, uid))
*************** do_type_analysis (void)
*** 2579,2585 ****
    
    /* If a type is set in global_types_full_escape, make sure that the
       unique type is also set in that map.  */
!   EXECUTE_IF_SET_IN_BITMAP (global_types_full_escape, 0, i, bi)
      {
        unsigned int j = unique_type_id_for (i, false);
        if (i != j)
--- 2635,2642 ----
    
    /* If a type is set in global_types_full_escape, make sure that the
       unique type is also set in that map.  */
!   bitmap_copy (been_there_done_that, global_types_full_escape);
!   EXECUTE_IF_SET_IN_BITMAP (been_there_done_that, 0, i, bi)
      {
        unsigned int j = unique_type_id_for (i, false);
        if (i != j)
*************** do_type_analysis (void)
*** 2588,2593 ****
--- 2645,2651 ----
  	  bitmap_clear_bit(global_types_full_escape, i);
  	}
      }
+   bitmap_clear (been_there_done_that);
  
    if (dump_file)
      { 
*************** static_execute (void)
*** 3087,3100 ****
  	    switch (node_g->pure_const_state)
  	      {
  	      case IPA_CONST:
!   		TREE_READONLY (w->decl) = 1;
  		if (dump_file)
  		  fprintf (dump_file, "$$$$CONST: %s\n",  
  			   lang_hooks.decl_printable_name(w->decl, 2)); 
  		break;
  		
  	      case IPA_PURE:
!   		DECL_IS_PURE (w->decl) = 1;
  		if (dump_file)
  		  fprintf (dump_file, "$$$$PURE: %s\n",  
  			   lang_hooks.decl_printable_name(w->decl, 2)); 
--- 3145,3158 ----
  	    switch (node_g->pure_const_state)
  	      {
  	      case IPA_CONST:
!    		TREE_READONLY (w->decl) = 1;
  		if (dump_file)
  		  fprintf (dump_file, "$$$$CONST: %s\n",  
  			   lang_hooks.decl_printable_name(w->decl, 2)); 
  		break;
  		
  	      case IPA_PURE:
!    		DECL_IS_PURE (w->decl) = 1;
  		if (dump_file)
  		  fprintf (dump_file, "$$$$PURE: %s\n",  
  			   lang_hooks.decl_printable_name(w->decl, 2)); 
Index: gcc/tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 1.1.2.1.2.17
diff -c -3 -p -r1.1.2.1.2.17 tree-ssa-alias.c
*** gcc/tree-ssa-alias.c	12 Feb 2005 14:33:31 -0000	1.1.2.1.2.17
--- gcc/tree-ssa-alias.c	17 Feb 2005 17:25:55 -0000
*************** static struct alias_stats_d alias_stats;
*** 135,141 ****
  /* Local functions.  */
  static void compute_flow_insensitive_aliasing (struct alias_info *);
  static void dump_alias_stats (FILE *);
! static bool may_alias_p (tree, HOST_WIDE_INT, tree, HOST_WIDE_INT);
  static tree create_memory_tag (tree type, bool is_type_tag);
  static tree get_tmt_for (tree, struct alias_info *);
  static tree get_nmt_for (tree);
--- 135,141 ----
  /* Local functions.  */
  static void compute_flow_insensitive_aliasing (struct alias_info *);
  static void dump_alias_stats (FILE *);
! static bool may_alias_p (tree, HOST_WIDE_INT, tree, HOST_WIDE_INT, bool);
  static tree create_memory_tag (tree type, bool is_type_tag);
  static tree get_tmt_for (tree, struct alias_info *);
  static tree get_nmt_for (tree);
*************** compute_flow_insensitive_aliasing (struc
*** 1039,1045 ****
  	  if (!tag_stored_p && !var_stored_p)
  	    continue;
  	     
! 	  if (may_alias_p (p_map->var, p_map->set, var, v_map->set))
  	    {
  	      size_t num_tag_refs, num_var_refs;
  
--- 1039,1045 ----
  	  if (!tag_stored_p && !var_stored_p)
  	    continue;
  	     
! 	  if (may_alias_p (p_map->var, p_map->set, var, v_map->set, false))
  	    {
  	      size_t num_tag_refs, num_var_refs;
  
*************** compute_flow_insensitive_aliasing (struc
*** 1099,1105 ****
  	  sbitmap may_aliases2 = p_map2->may_aliases;
  
  	  /* If the pointers may not point to each other, do nothing.  */
! 	  if (!may_alias_p (p_map1->var, p_map1->set, p_map2->var, p_map2->set))
  	    continue;
  
  	  /* The two pointers may alias each other.  If they already have
--- 1099,1106 ----
  	  sbitmap may_aliases2 = p_map2->may_aliases;
  
  	  /* If the pointers may not point to each other, do nothing.  */
! 	  if (!may_alias_p (p_map1->var, p_map1->set, 
! 			    p_map2->var, p_map2->set, true))
  	    continue;
  
  	  /* The two pointers may alias each other.  If they already have
*************** maybe_create_global_var (struct alias_in
*** 1621,1627 ****
  
  static bool
  may_alias_p (tree ptr, HOST_WIDE_INT mem_alias_set,
! 	     tree var, HOST_WIDE_INT var_alias_set)
  {
    tree mem;
    var_ann_t v_ann, m_ann;
--- 1622,1629 ----
  
  static bool
  may_alias_p (tree ptr, HOST_WIDE_INT mem_alias_set,
! 	     tree var, HOST_WIDE_INT var_alias_set,
! 	     bool alias_set_only)
  {
    tree mem;
    var_ann_t v_ann, m_ann;
*************** may_alias_p (tree ptr, HOST_WIDE_INT mem
*** 1680,1729 ****
  
    {
      tree ptr_type = TREE_TYPE (ptr);
  
!     /* The star counts are -1 if the type at the end of the pointer_to
!        chain is not a record or union type. */
!     if (ipa_static_star_count_of_interesting_type (var) >= 0)
        {
! 	int ptr_star_count = 0;
! 	/* ipa_static_star_count_of_interesting_type is a little too
  	   restrictive for the pointer type, need to allow pointers to
  	   primitive types as long as those types cannot be pointers
  	   to everything.  */
! 	/* Strip the *'s off.  */
! 	while (POINTER_TYPE_P (ptr_type))
! 	  {
! 	    ptr_type = TREE_TYPE (ptr_type);
! 	    ptr_star_count++;
! 	  }
! 
! 	/* There does not appear to be a better test to see if the
! 	   pointer type was one of the pointer to everything
! 	   types.  */
! 	if (TREE_CODE (ptr_type) == CHAR_TYPE
! 	    && TREE_CODE (ptr_type) == VOID_TYPE)
! 	  ptr_star_count = -1;
! 
! 	if (ptr_star_count > 0)
! 	  {
! 	    alias_stats.structnoaddress_queries++;
! 	    if (ipa_static_address_not_taken_of_field (TREE_TYPE (var), 
! 						TREE_TYPE (ptr_type)))
! 	      {
! 		alias_stats.structnoaddress_resolved++;
! 		alias_stats.alias_noalias++;
! 		return false;
! 	      }
! 	  }
! 	else if (ptr_star_count == 0)
! 	  {
! 	    /* If ptr_type was not really a pointer to type, it cannot
! 	       alias.  */
! 	    alias_stats.structnoaddress_queries++;
! 	    alias_stats.structnoaddress_resolved++;
! 	    alias_stats.alias_noalias++;
! 	    return false;
! 	  }
        }
    }
  
--- 1682,1740 ----
  
    {
      tree ptr_type = TREE_TYPE (ptr);
+     tree var_type = TREE_TYPE (var);
  
!      /* The star count is -1 if the type at the end of the pointer_to 
!         chain is not a record or union type. */ 
!     if ((!alias_set_only) &&
! 	ipa_static_star_count_of_interesting_type (var_type) >= 0)
        {
!  	int ptr_star_count = 0;
! 	/* Ipa_static_star_count_of_interesting_type is a little to
  	   restrictive for the pointer type, need to allow pointers to
  	   primitive types as long as those types cannot be pointers
  	   to everything.  */
!  	/* Strip the *'s off.  */ 
!  	while (POINTER_TYPE_P (ptr_type))
!  	  {
!  	    ptr_type = TREE_TYPE (ptr_type);
!  	    ptr_star_count++;
!  	  }
! 
!  	/* There does not appear to be a better test to see if the 
!  	   pointer type was one of the pointer to everything 
!  	   types.  */
!  	if (TREE_CODE (ptr_type) == CHAR_TYPE
!  	    && TREE_CODE (ptr_type) == VOID_TYPE)
!  	  ptr_star_count = -1;
! 
!  	if (ptr_star_count > 0)
!  	  {
! /* 	    fprintf(stderr, "calling address_not_taken_of_field\n   var = "); */
! /* 	    print_generic_expr (stderr, var_type, 0); */
! /* 	    fprintf(stderr, "\n   ptr = "); */
! /* 	    print_generic_expr (stderr, TREE_TYPE (TREE_TYPE (ptr)), 0); */
! /* 	    fprintf(stderr, "\n"); */
! 
!  	    alias_stats.structnoaddress_queries++;
!  	    if (ipa_static_address_not_taken_of_field (var_type,
!  						       TREE_TYPE (TREE_TYPE (ptr))))
!  	      {
! /* 		fprintf(stderr, "success\n"); */
!  		alias_stats.structnoaddress_resolved++;
!  		alias_stats.alias_noalias++;
!  		return false;
!  	      }
!  	  }
!  	else if (ptr_star_count == 0)
!  	  {
! 	    /* If ptr_type was not really a pointer to type, it cannot 
!  	       alias.  */ 
!  	    alias_stats.structnoaddress_queries++;
!  	    alias_stats.structnoaddress_resolved++;
!  	    alias_stats.alias_noalias++;
!  	    return false;
!  	  }
        }
    }
  
Index: gcc/tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v
retrieving revision 1.1.2.9.2.19
diff -c -3 -p -r1.1.2.9.2.19 tree-ssa-operands.c
*** gcc/tree-ssa-operands.c	12 Feb 2005 14:33:34 -0000	1.1.2.9.2.19
--- gcc/tree-ssa-operands.c	17 Feb 2005 17:25:56 -0000
*************** add_call_clobber_ops (tree stmt, tree ca
*** 1728,1733 ****
--- 1728,1738 ----
        return;
      }
  
+   /* FIXME - if we have better information from the static vars
+      analysis, we need to make the cache call site specific.  This way
+      we can have the performance benefits even if we are doing good
+      optimization.  */
+ 
    /* Get info for local and module level statics.  There is a bit
       set for each static if the call being processed does not read
       or write that variable.  */

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