]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/ipa-prop.cc
ipa: Create LOAD references when necessary during inlining (PR 103171)
authorMartin Jambor <mjambor@suse.cz>
Thu, 31 Mar 2022 14:50:24 +0000 (16:50 +0200)
committerMartin Jambor <mjambor@suse.cz>
Thu, 31 Mar 2022 14:51:07 +0000 (16:51 +0200)
commitf6d65e803623c7ba6c8eb92ce5975fc1b90cd91e
tree5c505fe4264fc1c244428d915ddcbb45d27c3020
parent90533de067d12159b3fbc847e5397033384f7484
ipa: Create LOAD references when necessary during inlining (PR 103171)

in r12-2523-g13586172d0b70c ipa-prop tracking of jump functions during
inlining got the ability to remove ADDR references when inlining
discovered that they were not necessary or turn them into LOAD
references when we know that what was a function call argument passed
by reference will end up as a load (one or more).

Unfortunately, the code only creates the LOAD references when
replacing removed ADDR references and PR 103171 showed that with some
ordering of inlining, we need to add the LOAD reference before we know
we can remove the ADDR one - or the reference will be lost, leading to
link errors or even ICEs.

Specifically in testcase gcc.dg/lto/pr103171_1.c added in this patch,
if foo() is inlined to entry(), we need to create the LOAD reference
so that when later bar() is inlined into foo() and we discover that
the paameter is unused, we can remove the ADDR reference and still
keep the varaible around for the load.

Martin

gcc/ChangeLog:

2022-01-28  Martin Jambor  <mjambor@suse.cz>

PR ipa/103171
* ipa-prop.cc (propagate_controlled_uses): Add a LOAD reference
always when an ADDR_EXPR constant is known to reach a load because
of inlining, not just when removing an ADDR reference.

gcc/testsuite/ChangeLog:

2022-01-28  Martin Jambor  <mjambor@suse.cz>

PR ipa/103171
* gcc.dg/ipa/remref-6.c: Adjust dump scan string.
* gcc.dg/ipa/remref-7.c: New test.
* gcc.dg/lto/pr103171_0.c: New test.
* gcc.dg/lto/pr103171_1.c: Likewise.
gcc/ipa-prop.cc
gcc/testsuite/gcc.dg/ipa/remref-6.c
gcc/testsuite/gcc.dg/ipa/remref-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr103171_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/pr103171_1.c [new file with mode: 0644]