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 for tree-profiling branch to fix aliasing problem.


There is a fast test to see if the assignment to a variable of one type can kill another structure. This fast test did not properly handle the case where the assigned variable was a union type because it did not look inside the union to see if variants were pointer types.

This changes causes no additional regressions and was tested on i686 suse.

2005-03-29  Kenneth Zadeck <zadeck@naturalbridge.com>
   * ipa_static.h: Renamed ipa_static_address_not_taken_of_field to
   to ipa_static_field_does_not_clobber_p.
   * ipa_static_vars_anal: Renamed
   ipa_static_address_not_taken_of_field to
   to ipa_static_field_does_not_clobber_p.  Fixed fast test to
   understand that it could not be applied to unions.
          * alias.c (nonoverlapping_memrefs_p): Renamed call.
   * tree_ssa_alias.c (may_alias_p): Renamed call.

Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.176.2.21.2.19
diff -c -3 -p -r1.176.2.21.2.19 alias.c
*** alias.c	17 Feb 2005 17:53:20 -0000	1.176.2.21.2.19
--- alias.c	29 Mar 2005 18:36:57 -0000
*************** nonoverlapping_memrefs_p (rtx x, rtx y)
*** 2068,2074 ****
  	{
  	 tree field = TREE_OPERAND (exprx, 1);
  	 tree fieldcontext = DECL_FIELD_CONTEXT (field);
! 	 if (ipa_static_address_not_taken_of_field (fieldcontext,
  						    TREE_TYPE (field)))
  	   return 1;	 
  	}
--- 2068,2074 ----
  	{
  	 tree field = TREE_OPERAND (exprx, 1);
  	 tree fieldcontext = DECL_FIELD_CONTEXT (field);
! 	 if (ipa_static_field_does_not_clobber_p (fieldcontext,
  						    TREE_TYPE (field)))
  	   return 1;	 
  	}
*************** nonoverlapping_memrefs_p (rtx x, rtx y)
*** 2098,2104 ****
  	{
  	 tree field = TREE_OPERAND (expry, 1);
  	 tree fieldcontext = DECL_FIELD_CONTEXT (field);
! 	 if (ipa_static_address_not_taken_of_field (fieldcontext,
  						    TREE_TYPE (field)))
  	   return 1;	 
  	}
--- 2098,2104 ----
  	{
  	 tree field = TREE_OPERAND (expry, 1);
  	 tree fieldcontext = DECL_FIELD_CONTEXT (field);
! 	 if (ipa_static_field_does_not_clobber_p (fieldcontext,
  						    TREE_TYPE (field)))
  	   return 1;	 
  	}
Index: ipa-static-vars-anal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ipa-static-vars-anal.c,v
retrieving revision 1.1.2.13
diff -c -3 -p -r1.1.2.13 ipa-static-vars-anal.c
*** ipa-static-vars-anal.c	16 Mar 2005 14:29:23 -0000	1.1.2.13
--- ipa-static-vars-anal.c	29 Mar 2005 18:36:58 -0000
*************** ipa_static_type_contained_p (tree type)
*** 521,531 ****
    return !bitmap_bit_p (global_types_full_escape, uid);
  }
  
! /* Return true if no fields with type FIELD_TYPE within a record of
!    RECORD_TYPE has its address taken.  */
  
  bool 
! ipa_static_address_not_taken_of_field (tree record_type, tree field_type)
  { 
    splay_tree_node result;
    int uid;
--- 521,531 ----
    return !bitmap_bit_p (global_types_full_escape, uid);
  }
  
! /* Return true a modification to a field of type FIELD_TYPE cannot
!    clobber a record of RECORD_TYPE.  */
  
  bool 
! ipa_static_field_does_not_clobber_p (tree record_type, tree field_type)
  { 
    splay_tree_node result;
    int uid;
*************** ipa_static_address_not_taken_of_field (t
*** 544,550 ****
        if (POINTER_TYPE_P (field_type)) 
  	field_type = TYPE_MAIN_VARIANT (TREE_TYPE (field_type));
        else 
! 	return true;
      }
    
    /* The record type must be contained.  The field type may
--- 544,563 ----
        if (POINTER_TYPE_P (field_type)) 
  	field_type = TYPE_MAIN_VARIANT (TREE_TYPE (field_type));
        else 
! 	/* However, if field_type is a union, this quick test is not
! 	   correct since one of the variants of the union may be a
! 	   pointer to type and we cannot see across that here.  So we
! 	   just strip the remaining pointer tos off the record type
! 	   and fall thru to the more precise code.  */
! 	if (TREE_CODE (field_type) == QUAL_UNION_TYPE 
! 	    || TREE_CODE (field_type) == UNION_TYPE)
! 	  {
! 	    while (POINTER_TYPE_P (record_type))
! 	      record_type = TYPE_MAIN_VARIANT (TREE_TYPE (record_type));
! 	    break;
! 	  } 
! 	else 
! 	  return true;
      }
    
    /* The record type must be contained.  The field type may
Index: ipa-static.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ipa-static.h,v
retrieving revision 1.1.2.4
diff -c -3 -p -r1.1.2.4 ipa-static.h
*** ipa-static.h	22 Jan 2005 17:52:56 -0000	1.1.2.4
--- ipa-static.h	29 Mar 2005 18:36:58 -0000
*************** bitmap ipa_get_statics_written_global (t
*** 121,127 ****
  bitmap ipa_get_statics_not_read_global (tree fn);
  bitmap ipa_get_statics_not_written_global (tree fn);
  bool   ipa_static_type_contained_p (tree type);
! bool   ipa_static_address_not_taken_of_field (tree record_type, tree field_type);
  int    ipa_static_star_count_of_interesting_type (tree type); 
  int ipa_static_star_count_of_interesting_or_array_type (tree type);
  
--- 121,127 ----
  bitmap ipa_get_statics_not_read_global (tree fn);
  bitmap ipa_get_statics_not_written_global (tree fn);
  bool   ipa_static_type_contained_p (tree type);
! bool   ipa_static_field_does_not_clobber_p (tree record_type, tree field_type);
  int    ipa_static_star_count_of_interesting_type (tree type); 
  int ipa_static_star_count_of_interesting_or_array_type (tree type);
  
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 1.1.2.1.2.23
diff -c -3 -p -r1.1.2.1.2.23 tree-ssa-alias.c
*** tree-ssa-alias.c	23 Mar 2005 14:35:44 -0000	1.1.2.1.2.23
--- tree-ssa-alias.c	29 Mar 2005 18:36:58 -0000
*************** may_alias_p (tree ptr, HOST_WIDE_INT mem
*** 1760,1766 ****
  /* 	    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"); */
--- 1760,1766 ----
  /* 	    fprintf(stderr, "\n"); */
  
   	    alias_stats.structnoaddress_queries++;
!  	    if (ipa_static_field_does_not_clobber_p (var_type,
   						       TREE_TYPE (TREE_TYPE (ptr))))
   	      {
  /* 		fprintf(stderr, "success\n"); */

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