This is an archive of the discontinued LLVM Phabricator instance.

[LegacyPM] Call getPassName only when needed
ClosedPublic

Authored by aengelke on Apr 11 2023, 8:22 AM.

Details

Summary

Even when time tracing is disabled, getPassName is currently still
called. This adds an avoidable virtual function call for each pass.
Fetching the pass name only when required slightly improves
compile-time (particularly when LLVM is built without LTO).

Diff Detail

Event Timeline

aengelke created this revision.Apr 11 2023, 8:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 8:22 AM
aengelke requested review of this revision.Apr 11 2023, 8:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2023, 8:22 AM
aengelke updated this revision to Diff 512478.Apr 11 2023, 8:42 AM

Format changes + re-trigger CI

nikic accepted this revision.Apr 11 2023, 8:55 AM

LGTM, though the improvement here is barely measurable.

This revision is now accepted and ready to land.Apr 11 2023, 8:55 AM
MaskRay accepted this revision.Apr 11 2023, 1:28 PM

Ideally give some numbers. How costly is it? Is the cost mainly due to PassInfoMap.lookup(TI)?

Ideally give some numbers. How costly is it?

I measured an improvement between 0.5% and 1% in our (fairly compile-time optimized) setting.

Is the cost mainly due to PassInfoMap.lookup(TI)?

Mostly yes, but also the mutex in PassRegistry::getPassInfo and the virtual function call itself contribute overhead.

This revision was landed with ongoing or failed builds.Apr 12 2023, 9:36 AM
This revision was automatically updated to reflect the committed changes.