This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Remove module id from summary index
ClosedPublic

Authored by tejohnson on Jul 31 2023, 12:37 PM.

Details

Summary

The module paths string table mapped to both an id sequentially assigned
during LTO linking, and the module hash. The former is leftover from
before the module hash was added for caching and subsequently replaced
use of the module id when renaming promoted symbols (to avoid affects
due to link order changes). The sequentially assigned module id was not
removed, however, as it was still a convenience when serializing to/from
bitcode and assembly.

This patch removes the module id from this table, since it isn't
strictly needed and can lead to confusion on when it is appropriate to
use (e.g. see fix in D156525). It also takes a (likely not significant)
amount of overhead. Where an integer module id is needed (e.g. bitcode
writing), one is assigned on the fly.

There are a couple of test changes since the paths are now sorted
alphanumerically when assigning ids on the fly during assembly writing,
in order to ensure deterministic behavior.

Diff Detail

Event Timeline

tejohnson created this revision.Jul 31 2023, 12:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 12:37 PM
tejohnson requested review of this revision.Jul 31 2023, 12:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 12:37 PM
Herald added a subscriber: wangpc. · View Herald Transcript
MaskRay accepted this revision.Aug 31 2023, 8:02 PM

Sorry for the delay. Looks great!

llvm/lib/IR/ModuleSummaryIndex.cpp
566

There is a pitfall. ModuleIdMap[ModPath] increases the size while ModuleIdMap.size(); changes the size, so the assignment behavior is dependent on the evaluation order. Suggest try_emplace

This revision is now accepted and ready to land.Aug 31 2023, 8:02 PM
tejohnson marked an inline comment as done.Sep 1 2023, 11:52 AM
tejohnson updated this revision to Diff 555449.Sep 1 2023, 11:53 AM

address comment

MaskRay accepted this revision.Sep 1 2023, 12:05 PM
MaskRay added inline comments.
llvm/lib/IR/ModuleSummaryIndex.cpp
563

llvm::sort(ModulePaths)

tejohnson marked an inline comment as done.Sep 1 2023, 1:42 PM
tejohnson updated this revision to Diff 555500.Sep 1 2023, 1:42 PM

Address comment

This revision was landed with ongoing or failed builds.Sep 1 2023, 1:43 PM
This revision was automatically updated to reflect the committed changes.