public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/114254] New: Indirect inlining through C++ member pointers fails if the underlying class has a virtual function
@ 2024-03-06 15:40 jamborm at gcc dot gnu.org
  2024-03-07  8:08 ` [Bug ipa/114254] [11/12/13/14 regression] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-03-06 15:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114254

            Bug ID: 114254
           Summary: Indirect inlining through C++ member pointers fails if
                    the underlying class has a virtual function
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: jamborm at gcc dot gnu.org
          Reporter: jamborm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 57634
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57634&action=edit
testcase

Just adding a virtual method to the class in our test
testsuite/g++.dg/ipa/iinline-2.C and it will unfortunately stop
working.

At some point the C++ FE got clever and stopped emitting the complex
code checking if a member pointer points to a virtual method or a
normal one when the base class does not have any virtual method.  But
that meant that our testcases stopped exercising the pattern matching
code in ipa_analyze_indirect_call_uses and when that code changed with
r10-917-g3b47da42de621c (Martin Jambor: Make SRA re-construct original
memory accesses when easy) because of a small mistake, we lost the
intended ability to inline also these cases.

So this is a regression against 9.5, unfortunately.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ipa/114254] [11/12/13/14 regression] Indirect inlining through C++ member pointers fails if the underlying class has a virtual function
  2024-03-06 15:40 [Bug ipa/114254] New: Indirect inlining through C++ member pointers fails if the underlying class has a virtual function jamborm at gcc dot gnu.org
@ 2024-03-07  8:08 ` rguenth at gcc dot gnu.org
  2024-03-08 14:57 ` jamborm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-07  8:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114254

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Target Milestone|---                         |11.5
   Last reconfirmed|                            |2024-03-07
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ipa/114254] [11/12/13/14 regression] Indirect inlining through C++ member pointers fails if the underlying class has a virtual function
  2024-03-06 15:40 [Bug ipa/114254] New: Indirect inlining through C++ member pointers fails if the underlying class has a virtual function jamborm at gcc dot gnu.org
  2024-03-07  8:08 ` [Bug ipa/114254] [11/12/13/14 regression] " rguenth at gcc dot gnu.org
@ 2024-03-08 14:57 ` jamborm at gcc dot gnu.org
  2024-03-19 21:38 ` cvs-commit at gcc dot gnu.org
  2024-03-20 16:18 ` [Bug ipa/114254] [11/12/13 " jamborm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-03-08 14:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114254

--- Comment #1 from Martin Jambor <jamborm at gcc dot gnu.org> ---
I have proposed a patch on the mailing list:
https://inbox.sourceware.org/gcc-patches/ri6r0gkzvi4.fsf@virgil.suse.cz/T/#u

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ipa/114254] [11/12/13/14 regression] Indirect inlining through C++ member pointers fails if the underlying class has a virtual function
  2024-03-06 15:40 [Bug ipa/114254] New: Indirect inlining through C++ member pointers fails if the underlying class has a virtual function jamborm at gcc dot gnu.org
  2024-03-07  8:08 ` [Bug ipa/114254] [11/12/13/14 regression] " rguenth at gcc dot gnu.org
  2024-03-08 14:57 ` jamborm at gcc dot gnu.org
@ 2024-03-19 21:38 ` cvs-commit at gcc dot gnu.org
  2024-03-20 16:18 ` [Bug ipa/114254] [11/12/13 " jamborm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-19 21:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114254

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Jambor <jamborm@gcc.gnu.org>:

https://gcc.gnu.org/g:bf838884fac573b4902a21bb82d9b6f777e32cb9

commit r14-9559-gbf838884fac573b4902a21bb82d9b6f777e32cb9
Author: Martin Jambor <mjambor@suse.cz>
Date:   Tue Mar 19 22:33:27 2024 +0100

    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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug ipa/114254] [11/12/13 regression] Indirect inlining through C++ member pointers fails if the underlying class has a virtual function
  2024-03-06 15:40 [Bug ipa/114254] New: Indirect inlining through C++ member pointers fails if the underlying class has a virtual function jamborm at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2024-03-19 21:38 ` cvs-commit at gcc dot gnu.org
@ 2024-03-20 16:18 ` jamborm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jamborm at gcc dot gnu.org @ 2024-03-20 16:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114254

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13/14 regression]    |[11/12/13 regression]
                   |Indirect inlining through   |Indirect inlining through
                   |C++ member pointers fails   |C++ member pointers fails
                   |if the underlying class has |if the underlying class has
                   |a virtual function          |a virtual function

--- Comment #3 from Martin Jambor <jamborm at gcc dot gnu.org> ---
Fixed on trunk.  I may consider backporting to GCC 13 but probably not to
earlier versions.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-20 16:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-06 15:40 [Bug ipa/114254] New: Indirect inlining through C++ member pointers fails if the underlying class has a virtual function jamborm at gcc dot gnu.org
2024-03-07  8:08 ` [Bug ipa/114254] [11/12/13/14 regression] " rguenth at gcc dot gnu.org
2024-03-08 14:57 ` jamborm at gcc dot gnu.org
2024-03-19 21:38 ` cvs-commit at gcc dot gnu.org
2024-03-20 16:18 ` [Bug ipa/114254] [11/12/13 " jamborm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).