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?
2011-12-30 Eric Botcazou <[email protected]>
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
Index: tree-sra.c
===================================================================
--- tree-sra.c (revision 182691)
+++ tree-sra.c (working copy)
@@ -1478,7 +1478,8 @@ build_ref_for_model (location_t loc, tre
expr = TREE_OPERAND (expr, 0);
type = TREE_TYPE (expr);
- } while (TREE_CODE (expr) == COMPONENT_REF);
+ } while (TREE_CODE (expr) == COMPONENT_REF
+ && !types_compatible_p (TREE_TYPE (expr), TREE_TYPE (base)));
}
t = build_ref_for_offset (loc, base, offset, type, gsi, insert_after);