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]

Fix bug compiling Ada RTS file a-nllcty.ads on x86


This showed a serious inconsistency between the use of alias sets when
processing a CONSTRUCTOR and COMPONENT_REF.  Fixed by adding a new
flag in a MEM.  I don't fully like this, but haven't found a better way
yet: perhaps one will become clearer as code gets cleaned up by using
MEM attributes.  Some minor changes in related areas were also made.

Not as well tested as I'd like due to unrelated bootstrap failures.

Thu Oct 25 08:46:06 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* alias.c (can_address_p): No longer static.
	* emit-rtl.c (get_mem_attrs): New parameter, MODE; all callers changed.
	Return 0 if all parameters are default values.
	(set_mem_attributes): Set MEM_KEEP_ALIAS_SET_P.
	(adjust_address_1): Try harder to compute a size.
	* expr.c (expand_assignment, store_constructor): If can't address,
	set MEM_KEEP_ALIAS_SET_P.
	(store_constructor_field): Don't change set if MEM_KEEP_ALIAS_SET_P.
	(store_field): Likewise.
	(store_constructor): Simplify call to store_constructor_field.
	* expr.h (can_address_p): New declaration.
	* gensupport.c (gen_rtx_CONST_INT): New function.
	* rtl.h (MEM_KEEP_ALIAS_SET_P): New macro.
	(MEM_SIZE): Get size from mode, if not set and not BLKmode.
	(MEM_COPY_ATTRIBUTES): Copy MEM_KEEP_ALIAS_SET_P.

*** alias.c	2001/10/23 18:51:00	1.147
--- alias.c	2001/10/25 12:43:59
*************** static int base_alias_check		PARAMS ((rt
*** 96,100 ****
  						 enum machine_mode));
  static int handled_component_p		PARAMS ((tree));
- static int can_address_p		PARAMS ((tree));
  static rtx find_base_value		PARAMS ((rtx));
  static int mems_in_disjoint_alias_sets_p PARAMS ((rtx, rtx));
--- 96,99 ----
*************** handled_component_p (t)
*** 427,431 ****
     get_inner_reference in T are such that we can address the object in T.  */
  
! static int
  can_address_p (t)
       tree t;
--- 426,430 ----
     get_inner_reference in T are such that we can address the object in T.  */
  
! int
  can_address_p (t)
       tree t;
*** emit-rtl.c	2001/10/24 16:38:50	1.216
--- emit-rtl.c	2001/10/25 12:44:12
*************** static int mem_attrs_htab_eq            
*** 193,197 ****
  static void mem_attrs_mark		PARAMS ((const void *));
  static mem_attrs *get_mem_attrs		PARAMS ((HOST_WIDE_INT, tree, rtx,
! 						 rtx, unsigned int));
  
  /* Probability of the conditional branch currently proceeded by try_split.
--- 193,198 ----
  static void mem_attrs_mark		PARAMS ((const void *));
  static mem_attrs *get_mem_attrs		PARAMS ((HOST_WIDE_INT, tree, rtx,
! 						 rtx, unsigned int,
! 						 enum machine_mode));
  
  /* Probability of the conditional branch currently proceeded by try_split.
*************** mem_attrs_mark (x)
*** 270,277 ****
  
  /* Allocate a new mem_attrs structure and insert it into the hash table if
!    one identical to it is not already in the table.  */
  
  static mem_attrs *
! get_mem_attrs (alias, decl, offset, size, align)
       HOST_WIDE_INT alias;
       tree decl;
--- 271,279 ----
  
  /* Allocate a new mem_attrs structure and insert it into the hash table if
!    one identical to it is not already in the table.  We are doing this for
!    MEM of mode MODE.  */
  
  static mem_attrs *
! get_mem_attrs (alias, decl, offset, size, align, mode)
       HOST_WIDE_INT alias;
       tree decl;
*************** get_mem_attrs (alias, decl, offset, size
*** 279,286 ****
--- 281,297 ----
       rtx size;
       unsigned int align;
+      enum machine_mode mode;
  {
    mem_attrs attrs;
    void **slot;
  
+   /* If everything is the default, we can just return zero.  */
+   if (alias == 0 && decl == 0 && offset == 0
+       && (size == 0
+ 	  || (mode != BLKmode && GET_MODE_SIZE (mode) == INTVAL (size)))
+       && (align == 1
+ 	  || (mode != BLKmode && align == GET_MODE_ALIGNMENT (mode))))
+     return 0;
+ 
    attrs.alias = alias;
    attrs.decl = decl;
*************** set_mem_attributes (ref, t, objectp)
*** 1707,1710 ****
--- 1718,1726 ----
  	t = TREE_OPERAND (t, 0);
  
+       /* If this expression can't be addressed (e.g., it contains a reference
+ 	 to a non-addressable field), show we don't change its alias set.  */
+       if (! can_address_p (t))
+ 	MEM_KEEP_ALIAS_SET_P (ref) = 1;
+ 
        /* If this is a decl, set the attributes of the MEM from it.  */
        if (DECL_P (t))
*************** set_mem_attributes (ref, t, objectp)
*** 1724,1728 ****
  
    /* Now set the attributes we computed above.  */
!   MEM_ATTRS (ref) = get_mem_attrs (alias, decl, offset, size, align);
  
    /* If this is already known to be a scalar or aggregate, we are done.  */
--- 1740,1745 ----
  
    /* Now set the attributes we computed above.  */
!   MEM_ATTRS (ref)
!     = get_mem_attrs (alias, decl, offset, size, align, GET_MODE (ref));
  
    /* If this is already known to be a scalar or aggregate, we are done.  */
*************** set_mem_alias_set (mem, set)
*** 1752,1756 ****
  
    MEM_ATTRS (mem) = get_mem_attrs (set, MEM_DECL (mem), MEM_OFFSET (mem),
! 				   MEM_SIZE (mem), MEM_ALIGN (mem));
  }
  
--- 1769,1774 ----
  
    MEM_ATTRS (mem) = get_mem_attrs (set, MEM_DECL (mem), MEM_OFFSET (mem),
! 				   MEM_SIZE (mem), MEM_ALIGN (mem),
! 				   GET_MODE (mem));
  }
  
*************** set_mem_align (mem, align)
*** 1763,1767 ****
  {
    MEM_ATTRS (mem) = get_mem_attrs (MEM_ALIAS_SET (mem), MEM_DECL (mem),
! 				   MEM_OFFSET (mem), MEM_SIZE (mem), align);
  }
  
--- 1781,1786 ----
  {
    MEM_ATTRS (mem) = get_mem_attrs (MEM_ALIAS_SET (mem), MEM_DECL (mem),
! 				   MEM_OFFSET (mem), MEM_SIZE (mem), align,
! 				   GET_MODE (mem));
  }
  
*************** change_address (memref, mode, addr)
*** 1823,1827 ****
  		     mmode == BLKmode ? 0 : GEN_INT (GET_MODE_SIZE (mmode)),
  		     (mmode == BLKmode ? 1
! 		      : GET_MODE_ALIGNMENT (mmode) / BITS_PER_UNIT));
  
    return new;
--- 1842,1847 ----
  		     mmode == BLKmode ? 0 : GEN_INT (GET_MODE_SIZE (mmode)),
  		     (mmode == BLKmode ? 1
! 		      : GET_MODE_ALIGNMENT (mmode) / BITS_PER_UNIT),
! 		     mmode);
  
    return new;
*************** adjust_address_1 (memref, mode, offset, 
*** 1842,1845 ****
--- 1862,1866 ----
    rtx new;
    rtx memoffset = MEM_OFFSET (memref);
+   rtx size = 0;
    unsigned int memalign = MEM_ALIGN (memref);
  
*************** adjust_address_1 (memref, mode, offset, 
*** 1871,1878 ****
      memalign = MIN (memalign, (offset & -offset) * BITS_PER_UNIT);
  
!   MEM_ATTRS (new)
!     = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_DECL (memref), memoffset,
! 		     mode == BLKmode
! 		     ? 0 : GEN_INT (GET_MODE_SIZE (mode)), memalign);
  
    /* At some point, we should validate that this offset is within the object,
--- 1892,1903 ----
      memalign = MIN (memalign, (offset & -offset) * BITS_PER_UNIT);
  
!   /* We can compute the size in a number of ways.  */
!   if (mode != BLKmode)
!     size = GEN_INT (GET_MODE_SIZE (mode));
!   else if (MEM_SIZE (memref))
!     size = plus_constant (MEM_SIZE (memref), -offset);
! 
!   MEM_ATTRS (new) = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_DECL (memref),
! 				   memoffset, size, memalign, GET_MODE (new));
  
    /* At some point, we should validate that this offset is within the object,
*************** offset_address (memref, offset, pow2)
*** 1899,1903 ****
    MEM_ATTRS (new) = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_DECL (memref),
  				   0, 0, MIN (MEM_ALIGN (memref),
! 					      pow2 * BITS_PER_UNIT));
    return new;
  }
--- 1924,1929 ----
    MEM_ATTRS (new) = get_mem_attrs (MEM_ALIAS_SET (memref), MEM_DECL (memref),
  				   0, 0, MIN (MEM_ALIGN (memref),
! 					      pow2 * BITS_PER_UNIT),
! 				   GET_MODE (new));
    return new;
  }
*** expr.c	2001/10/23 22:59:15	1.364
--- expr.c	2001/10/25 12:44:49
*************** expand_assignment (to, from, want_value,
*** 3842,3845 ****
--- 3842,3851 ----
        else
  	{
+ 	  if (! can_address_p (to))
+ 	    {
+ 	      to_rtx = copy_rtx (to_rtx);
+ 	      MEM_KEEP_ALIAS_SET_P (to_rtx) = 1;
+ 	    }
+ 
  	  result = store_field (to_rtx, bitsize, bitpos, mode1, from,
  				(want_value
*************** store_constructor_field (target, bitsize
*** 4480,4484 ****
        if (bitpos != 0)
  	align = MIN (align, (unsigned int) bitpos & - bitpos);
!       if (GET_CODE (target) == MEM)
  	set_mem_alias_set (target, alias_set);
  
--- 4486,4492 ----
        if (bitpos != 0)
  	align = MIN (align, (unsigned int) bitpos & - bitpos);
! 
!       if (GET_CODE (target) == MEM && ! MEM_KEEP_ALIAS_SET_P (target)
! 	  && MEM_ALIAS_SET (target) != 0)
  	set_mem_alias_set (target, alias_set);
  
*************** store_constructor (exp, target, align, c
*** 4682,4691 ****
  	    }
  #endif
  	  store_constructor_field (to_rtx, bitsize, bitpos, mode,
  				   TREE_VALUE (elt), type, align, cleared,
! 				   (DECL_NONADDRESSABLE_P (field)
! 				    && GET_CODE (to_rtx) == MEM)
! 				   ? MEM_ALIAS_SET (to_rtx)
! 				   : get_alias_set (TREE_TYPE (field)));
  	}
      }
--- 4690,4704 ----
  	    }
  #endif
+ 
+ 	  if (GET_CODE (to_rtx) == MEM && !MEM_KEEP_ALIAS_SET_P (to_rtx)
+ 	      && DECL_NONADDRESSABLE_P (field))
+ 	    {
+ 	      to_rtx = copy_rtx (to_rtx);
+ 	      MEM_KEEP_ALIAS_SET_P (to_rtx) = 1;
+ 	    }
+ 
  	  store_constructor_field (to_rtx, bitsize, bitpos, mode,
  				   TREE_VALUE (elt), type, align, cleared,
! 				   get_alias_set (TREE_TYPE (field)));
  	}
      }
*************** store_constructor (exp, target, align, c
*** 4825,4833 ****
  		    {
  		      bitpos = lo * tree_low_cst (TYPE_SIZE (elttype), 0);
  		      store_constructor_field
  			(target, bitsize, bitpos, mode, value, type, align,
! 			 cleared,
! 			 TYPE_NONALIASED_COMPONENT (type)
! 			 ? MEM_ALIAS_SET (target) : get_alias_set (elttype));
  		    }
  		}
--- 4838,4853 ----
  		    {
  		      bitpos = lo * tree_low_cst (TYPE_SIZE (elttype), 0);
+ 
+ 		      if (GET_CODE (target) == MEM
+ 			  && !MEM_KEEP_ALIAS_SET_P (target)
+ 			  && TYPE_NONALIASED_COMPONENT (type))
+ 			{
+ 			  target = copy_rtx (target);
+ 			  MEM_KEEP_ALIAS_SET_P (target) = 1;
+ 			}
+ 
  		      store_constructor_field
  			(target, bitsize, bitpos, mode, value, type, align,
! 			 cleared, get_alias_set (elttype));
  		    }
  		}
*************** store_constructor (exp, target, align, c
*** 4917,4925 ****
  		bitpos = (i * tree_low_cst (TYPE_SIZE (elttype), 1));
  
  	      store_constructor_field (target, bitsize, bitpos, mode, value,
  				       type, align, cleared,
- 				       TYPE_NONALIASED_COMPONENT (type)
- 				       && GET_CODE (target) == MEM
- 				       ? MEM_ALIAS_SET (target) :
  				       get_alias_set (elttype));
  
--- 4937,4949 ----
  		bitpos = (i * tree_low_cst (TYPE_SIZE (elttype), 1));
  
+ 	      if (GET_CODE (target) == MEM && !MEM_KEEP_ALIAS_SET_P (target)
+ 		  && TYPE_NONALIASED_COMPONENT (type))
+ 		{
+ 		  target = copy_rtx (target);
+ 		  MEM_KEEP_ALIAS_SET_P (target) = 1;
+ 		}
+ 
  	      store_constructor_field (target, bitsize, bitpos, mode, value,
  				       type, align, cleared,
  				       get_alias_set (elttype));
  
*************** store_field (target, bitsize, bitpos, mo
*** 5330,5334 ****
  
        MEM_SET_IN_STRUCT_P (to_rtx, 1);
!       set_mem_alias_set (to_rtx, alias_set);
  
        return store_expr (exp, to_rtx, value_mode != VOIDmode);
--- 5354,5359 ----
  
        MEM_SET_IN_STRUCT_P (to_rtx, 1);
!       if (!MEM_KEEP_ALIAS_SET_P (to_rtx) && MEM_ALIAS_SET (to_rtx) != 0)
! 	set_mem_alias_set (to_rtx, alias_set);
  
        return store_expr (exp, to_rtx, value_mode != VOIDmode);
*** expr.h	2001/10/23 18:51:03	1.99
--- expr.h	2001/10/25 12:44:52
*************** extern void record_alias_subset         
*** 372,375 ****
--- 372,376 ----
  						 HOST_WIDE_INT));
  extern HOST_WIDE_INT new_alias_set		PARAMS ((void));
+ extern int can_address_p		PARAMS ((tree));
  
  /* Functions from expr.c:  */
*** gensupport.c	2001/10/24 01:46:50	1.22
--- gensupport.c	2001/10/25 12:44:53
*************** message_with_line VPARAMS ((int lineno, 
*** 93,96 ****
--- 93,110 ----
    VA_CLOSE (ap);
  }
+ 
+ /* Make a version of gen_rtx_CONST_INT so that GEN_INT can be used in
+    the gensupport programs.  */
+ 
+ rtx
+ gen_rtx_CONST_INT (mode, arg)
+      enum machine_mode mode ATTRIBUTE_UNUSED;
+      HOST_WIDE_INT arg;
+ {
+   rtx rt = rtx_alloc (CONST_INT);
+ 
+   XWINT (rt, 0) = arg;
+   return rt;
+ }
  
  /* Queue PATTERN on LIST_TAIL.  */
*** rtl.h	2001/10/23 18:51:12	1.308
--- rtl.h	2001/10/25 12:45:05
*************** struct rtx_def
*** 130,133 ****
--- 130,134 ----
    /* 1 in an INSN if it can alter flow of control
       within this function.
+      MEM_KEEP_ALIAS_SET_P in a MEM.
       LINK_COST_ZERO in an INSN_LIST.  */
    unsigned int jump : 1;
*************** extern unsigned int subreg_regno 	PARAMS
*** 856,859 ****
--- 857,865 ----
  #define ASM_OPERANDS_SOURCE_LINE(RTX) XCINT ((RTX), 6, ASM_OPERANDS)
  
+ /* For a MEM RTX, 1 if we should keep the alias set for this mem
+    unchanged when we access a component.  Set to 1, or example, when we
+    are already in a non-addressable component of an aggregate.  */
+ #define MEM_KEEP_ALIAS_SET_P(RTX) ((RTX)->jump)
+ 
  /* For a MEM rtx, 1 if it's a volatile reference.
     Also in an ASM_OPERANDS rtx.  */
*************** extern unsigned int subreg_regno 	PARAMS
*** 911,915 ****
  /* For a MEM rtx, the size in bytes of the MEM, if known, as an RTX that
     is always a CONST_INT.  */
! #define MEM_SIZE(RTX) (MEM_ATTRS (RTX) == 0 ? 0 : MEM_ATTRS (RTX)->size)
  
  /* For a MEM rtx, the alignment in bits.  */
--- 917,924 ----
  /* For a MEM rtx, the size in bytes of the MEM, if known, as an RTX that
     is always a CONST_INT.  */
! #define MEM_SIZE(RTX)							\
! (MEM_ATTRS (RTX) != 0 ? MEM_ATTRS (RTX)->size				\
!  : GET_MODE (RTX) != BLKmode ? GEN_INT (GET_MODE_SIZE (GET_MODE (RTX)))	\
!  : 0)
  
  /* For a MEM rtx, the alignment in bits.  */
*************** extern unsigned int subreg_regno 	PARAMS
*** 921,929 ****
  
  /* Copy the attributes that apply to memory locations from RHS to LHS.  */
! #define MEM_COPY_ATTRIBUTES(LHS, RHS)			\
!   (MEM_VOLATILE_P (LHS) = MEM_VOLATILE_P (RHS),		\
!    MEM_IN_STRUCT_P (LHS) = MEM_IN_STRUCT_P (RHS),	\
!    MEM_SCALAR_P (LHS) = MEM_SCALAR_P (RHS),		\
!    RTX_UNCHANGING_P (LHS) = RTX_UNCHANGING_P (RHS),	\
     MEM_ATTRS (LHS) = MEM_ATTRS (RHS))
  
--- 930,939 ----
  
  /* Copy the attributes that apply to memory locations from RHS to LHS.  */
! #define MEM_COPY_ATTRIBUTES(LHS, RHS)				\
!   (MEM_VOLATILE_P (LHS) = MEM_VOLATILE_P (RHS),			\
!    MEM_IN_STRUCT_P (LHS) = MEM_IN_STRUCT_P (RHS),		\
!    MEM_SCALAR_P (LHS) = MEM_SCALAR_P (RHS),			\
!    RTX_UNCHANGING_P (LHS) = RTX_UNCHANGING_P (RHS),		\
!    MEM_KEEP_ALIAS_SET_P (LHS) = MEM_KEEP_ALIAS_SET_P (RHS),	\
     MEM_ATTRS (LHS) = MEM_ATTRS (RHS))
  


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