This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFH] [tree-ssa] disabling lowering for &a->b causes ICE
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: "gcc at gcc dot gnu dot org List" <gcc at gcc dot gnu dot org>
- Date: Sun, 15 Feb 2004 17:00:35 -0500
- Subject: Re: [RFH] [tree-ssa] disabling lowering for &a->b causes ICE
- Organization: Red Hat Canada
- References: <7FF37753-5F8D-11D8-AC2C-000393A6D2F2@physics.uc.edu>
On Sun, 2004-02-15 at 03:03, Andrew Pinski wrote:
> When I disable the lowering of &a->b in the C or C++ front-ends, I get
> an
> ICE because for some reason a SSA_NAME made it through to expand. This
> patch should be used to solve PR 14029 when this is ICE is fixed.
>
> The test-case I get the ICE with:
> struct a
> {
> int i;
> };
> int *h(struct a *b)
> {
> return &b->i;
> }
>
> This works at -O0 because there is no rewrite into SSA.
> I need help figuring out why the variable is not rewrote out of SSA.
>
We were considering b addressable, which is not quite right. This patch
fixes this problem, but there is something else going on as we try to
get the size of 'unsigned char []' in expand_expr_real_1 while compiling
unwind-dw2.c.
I would add a check for non-null TYPE_SIZE, but I don't know that code,
and doing so causes warnings in tree-dfa.c (the compiler thinks that
we're returning the address of a local in 'return &(TREE_CHAIN (d))'.
So, there's something else going on.
HTH. Diego.
$ cvs diff -dup tree-ssa-operands.c
Index: tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-operands.c,v
retrieving revision 1.1.2.9
diff -d -u -p -r1.1.2.9 tree-ssa-operands.c
--- tree-ssa-operands.c 10 Feb 2004 18:24:17 -0000 1.1.2.9
+++ tree-ssa-operands.c 15 Feb 2004 21:46:17 -0000
@@ -1264,12 +1264,22 @@ add_stmt_operand (tree *var_p, tree stmt
static void
note_addressable (tree var, stmt_ann_t s_ann)
{
- var = get_base_decl (var);
- if (var && SSA_VAR_P (var))
+ tree sym = get_base_decl (var);
+
+ /* If VAR is a COMPONENT_REF and SYM is a pointer, then VAR is an
+ expression of the form SYM->FIELD. This means that our caller is
+ processing the expressiong &SYM->FIELD which is equivalent to
+ SYM + offsetof(FIELD). So, if this is the case, it means that we
+ are not taking the address of SYM and should just return. */
+ if (TREE_CODE (var) == COMPONENT_REF
+ && POINTER_TYPE_P (TREE_TYPE (sym)))
+ return;
+
+ if (sym && SSA_VAR_P (sym))
{
if (s_ann->addresses_taken == NULL)
s_ann->addresses_taken = BITMAP_GGC_ALLOC ();
- bitmap_set_bit (s_ann->addresses_taken, var_ann (var)->uid);
+ bitmap_set_bit (s_ann->addresses_taken, var_ann (sym)->uid);
}
}