This is an archive of the discontinued LLVM Phabricator instance.

[LegacyPM] Reduce number of calls to getName
ClosedPublic

Authored by aengelke on Apr 12 2023, 10:11 AM.

Details

Summary

Repeatedly calling getName adds some overhead, which can be easily
avoided by querying the name just once per function. The improvements
are rather small (~0.5% back-end time in a compile-time optimized
setting), but also very easy to achieve.

Note that getting the name should be entirely avoidable in the common
case, but would require more substantial changes.

Diff Detail

Event Timeline

aengelke created this revision.Apr 12 2023, 10:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 10:11 AM
aengelke requested review of this revision.Apr 12 2023, 10:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 10:11 AM
MaskRay accepted this revision.Apr 12 2023, 10:38 AM
MaskRay added inline comments.
llvm/lib/IR/LegacyPassManager.cpp
1412

Since the users are far away, consider const StringRef Name = ...

This revision is now accepted and ready to land.Apr 12 2023, 10:38 AM

LGTM, the performance overhead is likely due to hash table lookups in Value::getValueName

aengelke updated this revision to Diff 513087.Apr 13 2023, 12:42 AM

Make Name const.

This revision was landed with ongoing or failed builds.Apr 13 2023, 2:19 AM
This revision was automatically updated to reflect the committed changes.
aengelke marked an inline comment as done.