sra: Avoid verification failure (PR 93516)
authorMartin Jambor <mjambor@suse.cz>
Fri, 14 Feb 2020 14:02:35 +0000 (15:02 +0100)
committerMartin Jambor <mjambor@suse.cz>
Fri, 14 Feb 2020 14:02:35 +0000 (15:02 +0100)
commit515dd04260c6049110d7624eaf1b276929dcd9af
treee62aa998fdbd5b7def31b1bcabc6970603962821
parent5a8754323d67011f7dceb5c8b82c4a5b48f0de4d
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.
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr93516.C [new file with mode: 0644]
gcc/tree-sra.c