On Sat, Dec 31, 2011 at 12:33 AM, Eric Botcazou <ebotca...@adacore.com>
wrote:
> This is the bootstrap failure of the Ada compiler on MIPS/IRIX, a recent
> regression present on mainline and 4.6 branch.  The stage 2 compiler
> miscompiles the stage 3 compiler (sem_type.adb:Disambiguate) because of an
> oversight in the fix for PR tree-opt/50569 which changed build_ref_for_model 
> to
> replicate chains of COMPONENT_REFs instead of just the last ones.
>
> The problem is that, when build_ref_for_model is called on the RHS of an
> aggregate assignment of the form:
>
>  b1.f1 = b2
>
> with the model associated with a child of the LHS (say b1.f1.f2), it will 
> build
> something like:
>
>  MEM [&b2 + -4B].f1.f2
>
> which will wreak havoc downstream.  I think that the most straightforward way
> out is to stop going up the chain of COMPONENT_REFs as soon as the type of the
> COMPONENT_REF matches that of the base.
>
> Bootstrapped on MIPS/IRIX and regtested on x86_64-suse-linux.  OK after a full
> testing cycle?

Note that you'll get ICEs whenever TYPE_CANONICAL of some
aggregate type is NULL (thus, TYPE_STRUCTURAL_EQUALITY), so this
seems inherently fragile (similar to using TYPE_CANONICAL == TYPE_CANONICAL
here, we'd break the TYPE_STRUCTURAL_EQUALITY case again).
I think that either the original fix needs to be re-thought or we need to pass
the base FIELD_DECL to build_ref_for_model.

That is, why not stop extracting the component-refs in

      do {
        tree field = TREE_OPERAND (expr, 1);
        tree cr_offset = component_ref_field_offset (expr);
        gcc_assert (cr_offset && host_integerp (cr_offset, 1));

        offset -= TREE_INT_CST_LOW (cr_offset) * BITS_PER_UNIT;
        offset -= TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field));

        VEC_safe_push (tree, stack, cr_stack, expr);

        expr = TREE_OPERAND (expr, 0);
        type = TREE_TYPE (expr);
      } while (TREE_CODE (expr) == COMPONENT_REF);

when expr == base?

The whole point of course was to never need something like
build_ref_for_model given that we have MEM_REFs.

Thanks,
Richard.

> 2011-12-30  Eric Botcazou  <ebotca...@adacore.com>
>
>        PR tree-optimization/51624
>        * tree-sra.c (build_ref_for_model): When replicating a chain of
>        COMPONENT_REFs, stop as soon as the type of the COMPONENT_REF
>        matches that of the base.
>
>
> --
> Eric Botcazou

Reply via email to