This is an archive of the discontinued LLVM Phabricator instance.

[Dwarf] Optimize getOrCreateSourceID() for repeated calls on same file (NFCI)
ClosedPublic

Authored by nikic on Jan 24 2022, 6:28 AM.

Details

Summary

DwarfCompileUnit::getOrCreateSourceID() is often called many times in sequence with the same DIFile. This is currently very expensive, because it involves creating a string from directory and file name and looking it up in a string map. This patch remembers the last DIFile and its ID and directly returns that.

This gives a geomean -1.3% compile-time improvement on O0-g: http://llvm-compile-time-tracker.com/compare.php?from=0d1308a7b77c9ed87386c22a728a6c97e2fb4887&to=0524863ab347cbb6f897844203d066869b8bee31&stat=instructions

Disclaimer: I'm not familiar with the area, but this kind of caching looks legal to me.

Diff Detail

Event Timeline

nikic created this revision.Jan 24 2022, 6:28 AM
nikic requested review of this revision.Jan 24 2022, 6:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 24 2022, 6:28 AM
dblaikie accepted this revision.Jan 24 2022, 3:07 PM

Sure, sounds alright to me, thanks!

This revision is now accepted and ready to land.Jan 24 2022, 3:07 PM
This revision was landed with ongoing or failed builds.Jan 25 2022, 12:30 AM
This revision was automatically updated to reflect the committed changes.