On Sat, Sep 20, 2025 at 9:32 PM Jan Hubicka <[email protected]> wrote:
>
> Hi,
> Currently we speculatively devirtualize using static analysis (with no profile
> feedback) only when there is one possible target found.  With profile feedback
> we support multiple targets which seems useful in some scenarios.
>
> This patch adds --param max-devirt-targets which enables devirtualization up 
> to
> given number of targets and defaults it to 3.  This happens i.e. in spec2017
> omnetpp, though the devirtualizaton is later undone by inliner since it is not
> considered useful.  The patch still seems to improve omnetpp by 2% in some
> setups.
>
> Other advantage of the patch is that the multi-target devirtualizatoin gets
> tested without profile feedback so we more likely notice problems with it.
>
> The patch disables devirtualization in 3 ipa-cp testcases.  This is a
> broken cost model of ipa-cp that is too conservative about cloning and
> also does not account code size savings for devirutalization, so the
> small increase of code size caused by adding extra call edges disables
> it.  I will fill PR for that.
>
> Bootstrapped/regtested x86_64-linux, comitted.
>
> gcc/ChangeLog:
>
>         * doc/invoke.texi (--param max-devirt-targets) Document.
>         * ipa-devirt.cc (ipa_devirt): Implement muti-target
>         devirtualization.
>         * params.opt (max-devirt-targets): New parameter.
>
> gcc/testsuite/ChangeLog:
>
>         * g++.dg/ipa/devirt-2.C: Update template.
>         * g++.dg/ipa/devirt-42.C: Update template.
>         * g++.dg/lto/devirt-2_0.C: Update template.

I got

FAIL: g++.dg/ipa/devirt-2.C  -std=gnu++17  scan-ipa-dump cp
"Discovered a virtual call to a known target.*B::foo"
FAIL: g++.dg/ipa/devirt-2.C  -std=gnu++17  scan-ipa-dump cp
"Discovered a virtual call to a known target.*B::foo"
FAIL: g++.dg/ipa/devirt-2.C  -std=gnu++26  scan-ipa-dump cp
"Discovered a virtual call to a known target.*B::foo"
FAIL: g++.dg/ipa/devirt-2.C  -std=gnu++26  scan-ipa-dump cp
"Discovered a virtual call to a known target.*B::foo"
FAIL: g++.dg/ipa/devirt-2.C  -std=gnu++98  scan-ipa-dump cp
"Discovered a virtual call to a known target.*B::foo"
FAIL: g++.dg/ipa/devirt-2.C  -std=gnu++98  scan-ipa-dump cp
"Discovered a virtual call to a known target.*B::foo"
FAIL: g++-dg-lto-devirt-2-01.exe scan-wpa-ipa-dump cp "Discovered a
virtual call to a known target.*foo"
FAIL: g++-dg-lto-devirt-2-01.exe scan-wpa-ipa-dump cp "Discovered a
virtual call to a known target.*foo"

on Linux/x86-64.

-- 
H.J.

Reply via email to