sra: Avoid verification failure (PR 93516)
get_ref_base_and_extent can return different sizes for COMPONENT_REFs
and DECLs of the same type, with the latter including (more?) padding.
When in the IL there is an assignment between such a COMPONENT_REF and a
DECL, SRA will try to propagate the access from the former as a child of
the latter, creating an artificial reference that does not match the
access's declared size, which triggers a verifier assert.
Fixed by teaching the propagation functions about this special situation
so that they don't do it. The condition is the same that
build_user_friendly_ref_for_offset uses so the artificial reference
causing the verifier is guaranteed not to be created.
2020-02-14 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/93516
* tree-sra.c (propagate_subaccesses_from_rhs): Do not create
access of the same type as the parent.
(propagate_subaccesses_from_lhs): Likewise.
gcc/testsuite/
* g++.dg/tree-ssa/pr93516.C: New test.