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]

Re: [PATCH] Fix ICE in get_memory_rtx


> That's the case for the attached testcase on SPARC/Solaris.  The problem is
> that get_memory_rtx stops on any field with DECL_BIT_FIELD set on it.

The following version is probably better since it explicitly tests for byte 
alignment instead of blindly trusting the mode.


2008-06-10  Eric Botcazou  <ebotcazou@adacore.com>
            Olivier Hainque  <hainque@adacore.com>

	* builtins.c (get_memory_rtx): Accept byte-addressable bitfields.
	Use DECL_SIZE_UNIT to retrieve the size of the field.


-- 
Eric Botcazou
Index: builtins.c
===================================================================
--- builtins.c	(revision 136584)
+++ builtins.c	(working copy)
@@ -1114,16 +1114,22 @@ get_memory_rtx (tree exp, tree len)
 	  while (TREE_CODE (inner) == COMPONENT_REF)
 	    {
 	      tree field = TREE_OPERAND (inner, 1);
-	      gcc_assert (! DECL_BIT_FIELD (field));
 	      gcc_assert (TREE_CODE (mem_expr) == COMPONENT_REF);
 	      gcc_assert (field == TREE_OPERAND (mem_expr, 1));
 
+	      /* Bitfields are generally not byte-addressable.  */
+	      gcc_assert (!DECL_BIT_FIELD (field)
+			  || ((tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1)
+			       % BITS_PER_UNIT) == 0
+			      && host_integerp (DECL_SIZE (field), 0)
+			      && (TREE_INT_CST_LOW (DECL_SIZE (field))
+				  % BITS_PER_UNIT) == 0));
+
 	      if (length >= 0
-		  && TYPE_SIZE_UNIT (TREE_TYPE (inner))
-		  && host_integerp (TYPE_SIZE_UNIT (TREE_TYPE (inner)), 0))
+		  && host_integerp (DECL_SIZE_UNIT (field), 0))
 		{
 		  HOST_WIDE_INT size
-		    = tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (inner)), 0);
+		    = TREE_INT_CST_LOW (DECL_SIZE_UNIT (field));
 		  /* If we can prove the memory starting at XEXP (mem, 0)
 		     and ending at XEXP (mem, 0) + LENGTH will fit into
 		     this field, we can keep that COMPONENT_REF in MEM_EXPR.  */
@@ -1135,7 +1141,7 @@ get_memory_rtx (tree exp, tree len)
 
 	      if (offset >= 0
 		  && host_integerp (DECL_FIELD_OFFSET (field), 0))
-		offset += tree_low_cst (DECL_FIELD_OFFSET (field), 0)
+		offset += TREE_INT_CST_LOW (DECL_FIELD_OFFSET (field))
 			  + tree_low_cst (DECL_FIELD_BIT_OFFSET (field), 1)
 			    / BITS_PER_UNIT;
 	      else

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