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] Fix PR middle-end/17793


Hello,

This is the other ICE that prevents the Ada runtime from building on SPARC 
(and blocks PowerPC too).

Analysis: http://gcc.gnu.org/ml/gcc/2004-10/msg00651.html
Jeff's suggestion: http://gcc.gnu.org/ml/gcc/2004-10/msg00705.html

This patch implements the aforementioned suggestion.  Bootstrapped/regtested 
on sparc64-sun-solaris2.9, sparc-sun-solaris2.8 and amd64-mandrake-linux-gnu
with patch for PR middle-end/17746.


2004-10-19 ?Eric Botcazou ?<ebotcazou@libertysurf.fr>

	PR middle-end/17793
	* gimplify.c (gimplify_addr_expr) <VIEW_CONVERT_EXPR>: Look
	through the operand if it is itself a conversion.


-- 
Eric Botcazou
Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.83
diff -u -p -r2.83 gimplify.c
--- gimplify.c	11 Oct 2004 12:57:09 -0000	2.83
+++ gimplify.c	19 Oct 2004 21:50:27 -0000
@@ -3089,13 +3089,31 @@ gimplify_addr_expr (tree *expr_p, tree *
 
     case VIEW_CONVERT_EXPR:
       /* Take the address of our operand and then convert it to the type of
-	 this ADDR_EXPR.
+	 this ADDR_EXPR.  If the operand is a conversion, look through it.
 
-	 ??? The interactions of VIEW_CONVERT_EXPR and aliasing is not at
+	 ??? The interactions of VIEW_CONVERT_EXPR and aliasing are not at
 	 all clear.  The impact of this transformation is even less clear.  */
-      *expr_p = fold_convert (TREE_TYPE (expr),
-			      build_fold_addr_expr (TREE_OPERAND (op0, 0)));
-      ret = GS_OK;
+      {
+	bool through_conv_p;
+	tree addr;
+
+	if (TREE_CODE (TREE_OPERAND (op0, 0)) == NOP_EXPR)
+	  {
+	    op0 = TREE_OPERAND (op0, 0);
+	    through_conv_p = true;
+	  }
+	else
+	  through_conv_p = false;
+
+	addr = build_fold_addr_expr (TREE_OPERAND (op0, 0));
+
+	/* Rematerialize the stripped conversion on the pointer types.  */
+	if (through_conv_p)
+	  addr = fold_convert (build_pointer_type (TREE_TYPE (op0)), addr);
+
+	*expr_p = fold_convert (TREE_TYPE (expr), addr);
+	ret = GS_OK;
+      }
       break;
 
     default:

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