]> gcc.gnu.org Git - gcc.git/commit
sra: Fix corner case of total scalarization with virtual inheritance (PR 102505)
authorMartin Jambor <mjambor@suse.cz>
Wed, 27 Oct 2021 17:15:33 +0000 (19:15 +0200)
committerMartin Jambor <mjambor@suse.cz>
Wed, 27 Oct 2021 17:15:46 +0000 (19:15 +0200)
commit97cebda80d367737c0b25909af8063b63166e00b
tree3705f46eecc7fc28d14d902de8816aa453bb2c7c
parent2563fba71d0b67cb69b2cd2da649a50a70f2a02f
sra: Fix corner case of total scalarization with virtual inheritance (PR 102505)

PR 102505 is a situation where of SRA takes its initial top-level
access size from a get_ref_base_and_extent called on a COMPONENT_REF,
and thus derived frm the FIELD_DECL, which however does not include a
virtual base.  Total scalarization then goes on traversing the type,
which however has virtual base past the non-virtual bits, tricking SRA
to create sub-accesses outside of the supposedly encompassing
accesses, which in turn triggers the verifier within the pass.

The patch below fixes that by failing total scalarization when this
situation is detected.

This backport also has commit f217e87972a2a207e793101fc05cfc9dd095c678
squashed into it in order to avoid PR 102886 that the fix introduced
on trunk.

gcc/ChangeLog:

2021-10-20  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/102505
* tree-sra.c (totally_scalarize_subtree): Check that the
encountered field fits within the acces we would like to put it
in.

gcc/testsuite/ChangeLog:

2021-10-20  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/102505
* g++.dg/torture/pr102505.C: New test.

(cherry picked from commit 701ee067807b80957c65bd7ff94b6099a27181de)
gcc/testsuite/g++.dg/torture/pr102505.C [new file with mode: 0644]
gcc/tree-sra.c
This page took 0.060466 seconds and 6 git commands to generate.