This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][NFC] Move addRelocation{X86,AArch64} into MCPlusBuilder
ClosedPublic

Authored by Amir on Aug 12 2022, 2:50 PM.

Details

Summary

The two methods don't belong in BinaryFunction methods.
Move the dispatch tables into target-specific MCPlusBuilder methods.

Diff Detail

Event Timeline

Amir created this revision.Aug 12 2022, 2:50 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Amir requested review of this revision.Aug 12 2022, 2:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2022, 2:50 PM
Amir retitled this revision from [BOLT][NFC] Move addRelocation{X86,AArch64} out of RI methods to [BOLT][NFC] Move addRelocation{X86,AArch64} out of BF methods.Aug 12 2022, 2:52 PM
Amir edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Aug 12 2022, 6:37 PM
Amir planned changes to this revision.Aug 23 2022, 3:45 PM

Plan to break addRelocation into the target-specific check in MCPlusBuilder and actually adding the relocation to the container in BinaryFunction.

Amir edited the summary of this revision. (Show Details)Jan 24 2023, 12:41 PM
Amir retitled this revision from [BOLT][NFC] Move addRelocation{X86,AArch64} out of BF methods to [BOLT][NFC] Move addRelocation{X86,AArch64} into MCPlusBuilder.Jan 24 2023, 1:11 PM
Amir edited the summary of this revision. (Show Details)
Amir updated this revision to Diff 491890.Jan 24 2023, 1:17 PM

Move the switch tables into MCPlusBuilder

This revision is now accepted and ready to land.Jan 24 2023, 1:17 PM
Amir requested review of this revision.Jan 24 2023, 1:18 PM
rafauler added inline comments.Jan 25 2023, 10:49 AM
bolt/include/bolt/Core/MCPlusBuilder.h
399

I'm a bit confused with the name, for example, what does it mean to have a supported relocation? Why is ELF::R_AARCH64_CALL26 unsupported? I think either the comments here need to be expanded a bit or the function get a better name, because this "support" is very specific to the needs of BinaryFunction.

Amir added inline comments.Jan 25 2023, 5:09 PM
bolt/include/bolt/Core/MCPlusBuilder.h
399

What name and comment would you suggest? These are relocations we store for function splitting and reordering.

rafauler added inline comments.Jan 27 2023, 2:39 PM
bolt/include/bolt/Core/MCPlusBuilder.h
399

I don't have good names that give the necessary context. I guess something like "shouldRecordCodeReloc/shouldStoreReloc" or "shouldRetainCodeReloc". The context might go in a comment maybe... the context is that these relocations are essentially used by our disassembly step to better understand code (by using these code relocs). For ARM, they help us decode instruction operands unambiguously, but sometimes we might discard them because we already have the necessary information in the instruction itself (for example, we don't need to record CALL relocs in ARM because we can fully decode the target from the call operand). For X86, they might be used in scanExternalRefs when we want to skip a function but still patch references inside it.

Amir updated this revision to Diff 504855.Mar 13 2023, 2:55 PM

Rename isSupportedRelocation to shouldRecordCodeRelocation, add comment.

Amir marked 2 inline comments as done.Mar 13 2023, 2:56 PM
This revision is now accepted and ready to land.Mar 14 2023, 2:40 PM