]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-sra: Do not refresh readonly decls (PR 100453)
authorMartin Jambor <mjambor@suse.cz>
Wed, 16 Jun 2021 11:18:46 +0000 (13:18 +0200)
committerMartin Jambor <mjambor@suse.cz>
Wed, 16 Jun 2021 11:23:14 +0000 (13:23 +0200)
commitd7deee423f993bee8ee440f6fe0c9126c316c64b
tree5a3bb7aaab48cc4b86f7677ed7963243a817f760
parenta490b1dc0b3c26bff2ee00ac0da2d606d2009e3a
tree-sra: Do not refresh readonly decls (PR 100453)

When SRA transforms an assignment where the RHS is an aggregate decl
that it creates replacements for, the (least efficient) fallback
method of dealing with them is to store all the replacements back into
the original decl and then let the original assignment takes its
course.

That of course should not need to be done for TREE_READONLY bases
which cannot change contents.  The SRA code handled this situation
only for DECL_IN_CONSTANT_POOL const decls, this patch modifies the
check so that it tests for TREE_READONLY and I also looked at all
other callers of generate_subtree_copies and added checks to another
one dealing with the same exact situation and one which deals with it
in a non-assignment context.

gcc/ChangeLog:

2021-06-11  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/100453
* tree-sra.c (create_access): Disqualify any const candidates
which are written to.
(sra_modify_expr): Do not store sub-replacements back to a const base.
(handle_unscalarized_data_in_subtree): Likewise.
(sra_modify_assign): Likewise.  Earlier, use TREE_READONLy test
instead of constant_decl_p.

gcc/testsuite/ChangeLog:

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

PR tree-optimization/100453
* gcc.dg/tree-ssa/pr100453.c: New test.
gcc/testsuite/gcc.dg/tree-ssa/pr100453.c [new file with mode: 0644]
gcc/tree-sra.c