This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Add data to code relocations postprocessing
AbandonedPublic

Authored by Amir on Aug 18 2022, 6:46 PM.

Details

Reviewers
rafauler
maksfb
Summary

BOLT's assumption regarding data to code relocations is that
they will be "consumed", or accounted for, as jump table entries.
For jump tables that we failed to recognize, the relocation would
still be created and later attempted to be emitted, but if the
symbol was removed, this leads to undefined symbol error.

Add a post-processing step that accounts for such unclaimed
relocations and creates secondary entry points.

Diff Detail

Event Timeline

Amir created this revision.Aug 18 2022, 6:46 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ayermolo. · View Herald Transcript
Amir requested review of this revision.Aug 18 2022, 6:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2022, 6:46 PM
Amir updated this revision to Diff 453894.Aug 18 2022, 11:19 PM

Add printing stats about created entry points

tschuett added inline comments.
bolt/lib/Core/BinaryContext.cpp
998

Are you tied to unordered_set ? There are more memory-efficient data structures:
https://llvm.org/docs/ProgrammersManual.html#set-like-containers-std-set-smallset-setvector-etc

Amir added inline comments.Aug 18 2022, 11:41 PM
bolt/lib/Core/BinaryContext.cpp
998

Thanks for a tip! No, a SmallPtrSet is probably a better data structure here.

Amir updated this revision to Diff 454090.Aug 19 2022, 1:10 PM

Fix jump table entry check; SmallPtrSet

Amir planned changes to this revision.Aug 22 2022, 10:01 AM

The issue should be handled via postProcessIndirectBranches ExternallyReferencedOffsets mechanism.