[PATCH] D116881: [ELF] Add Resolver class to relocation scan pass. NFC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 9 00:43:04 PST 2022


MaskRay created this revision.
MaskRay added reviewers: alexander-shaposhnikov, ikudrin, peter.smith.
Herald added subscribers: steven.zhang, atanasyan, arichardson, sdardis, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently the way some relocation-related static functions pass around
states is clumsy. Add a Resolver class to store some states as member
variables.

Advantages:

- Avoid the parameter `InputSectionBase &sec` (this offsets the cost passing around `this` paramemter)
- Avoid the parameter `OffsetGetter &getOffset`. Its state is absorbed into Resolver.
- Avoid the parameter `end` (Mips and PowerPC hacks)
- `config` and `target` can be cached as member variables to reduce global state accesses. (potential speedup because the compiler didn't know `config`/`target` were not changed across function calls)
- If we ever want to reduce if-else costs (e.g. `config->emachine==EM_MIPS` for non-Mips) or introduce parallel relocation scan not handling some tricky arches (PPC/Mips)[1], we can templatize Resolver

`target` isn't used as much as `config`, so I change it to a const reference
during the migration.

There is a minor performance inprovement for elf::scanRelocations.

[1]: https://maskray.me/blog/2021-12-19-why-isnt-ld.lld-faster "Scan relocations"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116881

Files:
  lld/ELF/Relocations.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116881.398399.patch
Type: text/x-patch
Size: 14266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220109/fb6f33a7/attachment-0001.bin>


More information about the llvm-commits mailing list