]> git.ipfire.org Git - thirdparty/gcc.git/commit
ipa-sra: Avoid clashes with ipa-cp when pulling accesses across calls (PR 118243)
authorMartin Jambor <mjambor@suse.cz>
Fri, 28 Feb 2025 16:34:10 +0000 (17:34 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Fri, 28 Feb 2025 16:34:20 +0000 (17:34 +0100)
commit0bffcd469e68d68ba9c724f515651deff8494b82
treeacf0e4535670dab4b7d766dda955f9eb0ba1af18
parent1a150f1f688486b12cd975bdc4cd1bd52a7e0110
ipa-sra: Avoid clashes with ipa-cp when pulling accesses across calls (PR 118243)

Among other things, IPA-SRA checks whether splitting out a bit of an
aggregate or something passed by reference would lead into a clash
with an already known IPA-CP constant a way which would cause problems
later on.  Unfortunately the test is done only in
adjust_parameter_descriptions and is missing when accesses are
propagated from callees to callers, which leads to miscompilation
reported as PR 118243 (where the callee is a function created by
ipa-split).

The matter is then further complicated by the fact that we consider
complex numbers as scalars even though they can be modified piecemeal
(IPA-CP can detect and propagate the pieces separately too) which then
confuses the parameter manipulation machinery furter.

This patch simply adds the missing check to avoid the IPA-SRA
transform in these cases too, which should be suitable for backporting
to all affected release branches.  It is a bit of a shame as in the PR
testcase we do propagate both components of the complex number in
question and the transformation phase could recover.  I have some
prototype patches in this direction but that is something for (a)
stage 1.

gcc/ChangeLog:

2025-02-10  Martin Jambor  <mjambor@suse.cz>

PR ipa/118243
* ipa-sra.cc (pull_accesses_from_callee): New parameters
caller_ipcp_ts and param_idx.  Check that scalar pulled accesses would
not clash with a known IPA-CP aggregate constant.
(param_splitting_across_edge): Pass IPA-CP transformation summary and
caller parameter index to pull_accesses_from_callee.

gcc/testsuite/ChangeLog:

2025-02-10  Martin Jambor  <mjambor@suse.cz>

PR ipa/118243
* g++.dg/ipa/pr118243.C: New test.
gcc/ipa-sra.cc
gcc/testsuite/g++.dg/ipa/pr118243.C [new file with mode: 0644]