]> gcc.gnu.org Git - gcc.git/commit
ipa: Fix C++ member ptr indirect inlining (PR 114254, PR 108802)
authorMartin Jambor <mjambor@suse.cz>
Tue, 19 Mar 2024 21:33:27 +0000 (22:33 +0100)
committerMartin Jambor <mjambor@suse.cz>
Tue, 19 Mar 2024 21:37:42 +0000 (22:37 +0100)
commitbf838884fac573b4902a21bb82d9b6f777e32cb9
treec0d5c83e1c071a66db285dc1c2340381071c287d
parent7a6261332de58fd47283d694d8cd61ea7cdb324c
ipa: Fix C++ member ptr indirect inlining (PR 114254, PR 108802)

Even though we have had code to handle creation of indirect call graph
edges (so that these calls can than be made direct as part of IPA-CP
and inlining and eventually also inlined) for C++ member pointers for
many years, it turns out that it does not work for lambdas and that it
has been severely broken since GCC 10 when the base class has virtual
functions.

Lambdas don't work because the code cannot work with structures
representing member function pointers because they are passed by
reference instead by value and the code was not ready for that.

The presence of virtual methods broke thinks because at some point C++
FE got clever and stopped emitting the check for virtual methods when
the base class does not have any and that in turn made our existing
testcases not test the necessary pattern matching code.  The pattern
matcher had a small bug which did not matter before
r10-917-g3b47da42de621c but did afterwards.

This patch changes the pattern matcher to match both of these cases.

gcc/ChangeLog:

2024-03-06  Martin Jambor  <mjambor@suse.cz>

PR ipa/108802
PR ipa/114254
* ipa-prop.cc (ipa_get_stmt_member_ptr_load_param): Fix case looking
at COMPONENT_REFs directly from a PARM_DECL, also recognize loads from
a pointer parameter.
(ipa_analyze_indirect_call_uses): Also recognize loads from a pointer
parameter, also recognize the case when pfn pointer is loaded in its
own BB.

gcc/testsuite/ChangeLog:

2024-03-06  Martin Jambor  <mjambor@suse.cz>

PR ipa/108802
PR ipa/114254
* g++.dg/ipa/iinline-4.C: New test.
* g++.dg/ipa/pr108802.C: Likewise.
gcc/ipa-prop.cc
gcc/testsuite/g++.dg/ipa/iinline-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ipa/pr108802.C [new file with mode: 0644]
This page took 0.064528 seconds and 6 git commands to generate.