This is an archive of the discontinued LLVM Phabricator instance.

[WPD] Add statistics
ClosedPublic

Authored by tejohnson on Apr 5 2022, 12:43 PM.

Details

Summary

Add statistics to count overall devirtualized targets as well as the
various types of devirtualizations applied at callsites.

Diff Detail

Event Timeline

tejohnson created this revision.Apr 5 2022, 12:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 12:43 PM
tejohnson requested review of this revision.Apr 5 2022, 12:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 12:43 PM
mingmingl accepted this revision.Apr 5 2022, 2:23 PM

LGTM.

Only one question regarding whether the counter is intended for DevirtModule or DevirtIndex (or both)

llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
1155

If I'm reading correctly, NumSingleImpl is incremented in DevirtModule::applySingleImplDevirt, but not for DevirtIndex::trySingleImplDevirt.

I'm wondering if this is intended for the purpose of this cl. If yes, maybe describe something like

The counter is incremented in regular LTO (or ThinLTO, etc)

This revision is now accepted and ready to land.Apr 5 2022, 2:23 PM
In D123152#3430851, @luna wrote:

LGTM.

Only one question regarding whether the counter is intended for DevirtModule or DevirtIndex (or both)

Both, see inline reply below.

llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
1155

Note that applySingleImplDevirt is called both for regular and thin LTO - for ThinLTO it is called during the backends, from importResolution(). This counter is keeping track of the number of actual single impl devirtualizations (i.e. callsites where that optimization is applied).

During the whole program portion (both regular and thin LTO) we keep track of the number of target functions that had devirtualizations in the NumDevirtTargets statistic.

In D123152#3430851, @luna wrote:

LGTM.

Only one question regarding whether the counter is intended for DevirtModule or DevirtIndex (or both)

Both, see inline reply below.

In D123152#3430851, @luna wrote:

LGTM.

Only one question regarding whether the counter is intended for DevirtModule or DevirtIndex (or both)

Both, see inline reply below.

llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
1155

Note that applySingleImplDevirt is called both for regular and thin LTO - for ThinLTO it is called during the backends, from importResolution(). This counter is keeping track of the number of actual single impl devirtualizations (i.e. callsites where that optimization is applied).

During the whole program portion (both regular and thin LTO) we keep track of the number of target functions that had devirtualizations in the NumDevirtTargets statistic.

Ah I see your point. Basically DevirtIndex::run is called within runWholeProgramDevirtOnIndex in the thin-link step, and DevirtModule::run is called for thinLTO backend compile (after thin-link step).

Thanks for pointing it out!

This revision was landed with ongoing or failed builds.Apr 5 2022, 6:48 PM
This revision was automatically updated to reflect the committed changes.