[PATCH] Fix PR middle-end/17746
Eric Botcazou
ebotcazou@libertysurf.fr
Tue Oct 19 21:46:00 GMT 2004
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr17746.diff
Type: text/x-diff
Size: 1004 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20041019/526f4710/attachment.bin>
More information about the Gcc-patches
mailing list