This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR middle-end/17746
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Oct 2004 23:35:25 +0200
- Subject: [PATCH] Fix PR middle-end/17746
Hello,
This is the first of the two ICEs that prevent the Ada runtime from building
on SPARC. The compiler aborts in expand_expr_addr_expr_1 on
/* We must have made progress. */
gcc_assert (inner != exp);
expand_expr_addr_expr_1 is passed the following tree:
COMPONENT_REF
VIEW_CONVERT_EXPR <record_type1 ... align-ok>
INDIRECT_REF <record_type2>
VAR_DECL <pointer_type <record_type2>>
record_type1 is a derived type of record_type2 and the expression is a
dereference through a polymorphic access type (pointer).
expand_expr_addr_expr_1 essentially uses get_inner_reference to recurse until
it finds an interesting node, here the INDIRECT_REF node. This works fine on
x86 but not always on SPARC because get_inner_reference may refuse to look
through the VIEW_CONVERT_EXPR because of
/* We can go inside most conversions: all NON_VALUE_EXPRs, all normal
conversions that don't change the mode, and all view conversions
except those that need to "step up" the alignment. */
else if (TREE_CODE (exp) != NON_LVALUE_EXPR
&& ! (TREE_CODE (exp) == VIEW_CONVERT_EXPR
&& ! ((TYPE_ALIGN (TREE_TYPE (exp))
> TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0))))
&& STRICT_ALIGNMENT
&& (TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0)))
< BIGGEST_ALIGNMENT)
&& (TYPE_ALIGN_OK (TREE_TYPE (exp))
|| TYPE_ALIGN_OK (TREE_TYPE
(TREE_OPERAND (exp, 0))))))
&& ! ((TREE_CODE (exp) == NOP_EXPR
|| TREE_CODE (exp) == CONVERT_EXPR)
&& (TYPE_MODE (TREE_TYPE (exp))
== TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))))))
break;
The key is of course STRICT_ALIGNMENT here.
The proposed fix is to teach expand_expr_addr_expr_1 to look itself through
the VIEW_CONVERT_EXPR nodes that "step up" the alignment, but only if they
carry the TYPE_ALIGN_OK flag. The rationale is that these VIEW_CONVERT_EXPR
nodes will not cause any temporary to be generated so they are noop when it
comes to take the address.
Bootstrapped/regtested on sparc64-sun-solaris2.9 and sparc-sun-solaris2.8,
with upcoming patch for PR middle-end/17793.
2004-10-19 ?Eric Botcazou ?<ebotcazou@libertysurf.fr>
PR middle-end/17746
* expr.c (expand_expr_addr_expr_1): Look through VIEW_CONVERT_EXPR
nodes that "step up" the alignment if the object is already sufficiently
aligned.
--
Eric Botcazou
Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.726
diff -u -p -r1.726 expr.c
--- expr.c 3 Oct 2004 22:50:18 -0000 1.726
+++ expr.c 14 Oct 2004 14:21:09 -0000
@@ -6107,6 +6107,18 @@ expand_expr_addr_expr_1 (tree exp, rtx t
inner = TREE_OPERAND (exp, 0);
break;
+ case VIEW_CONVERT_EXPR:
+ /* get_inner_reference refuses to look through this kind of
+ VIEW_CONVERT_EXPR if STRICT_ALIGNMENT is true. But we can
+ here since we know it will not change the address. */
+ if ((TYPE_ALIGN (TREE_TYPE (exp))
+ > TYPE_ALIGN (TREE_TYPE (TREE_OPERAND (exp, 0))))
+ && TYPE_ALIGN_OK (TREE_TYPE (exp)))
+ return expand_expr_addr_expr_1 (TREE_OPERAND (exp, 0), target,
+ tmode, modifier);
+
+ /* fall through... */
+
default:
/* If the object is a DECL, then expand it for its rtl. Don't bypass
expand_expr, as that can have various side effects; LABEL_DECLs for