[PATCH] D130810: [ELF] Parallelize input section initialization

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 17:18:47 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: aganea, int3, peter.smith.
Herald added subscribers: StephenFan, arichardson, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This implements the last step of
https://discourse.llvm.org/t/parallel-input-file-parsing/60164 for the ELF port.

For an ELF object file, we previously did: parse, (parallel) initializeLocalSymbols, postParseObjectFile.
Now we do: parse, (parallel) initSectionsAndLocalSyms, postParseObjectFile.

With --threads=8,

- ld.lld is 1.03x as fast linking release builds of clang and chrome
- ld.lld is 1.05x as fast linking an internal search program

---

- COFF has some needs for multiple linker contexts. D108850 <https://reviews.llvm.org/D108850> partially removed global states from lldCommon but left the global variable `lctx`.
- To the best of my knowledge, all multiple-linker-context feature requests to ELF are more from user convenience, with no very strong argument.
- In practice, ELF port is very difficult to remove global states without introducing significant performance regression/hurting code readability.
- Per-thread allocators from D122922 <https://reviews.llvm.org/D122922>/D123879 <https://reviews.llvm.org/D123879> are too expensive and will not really benefit ELF.

This patch adds a simple thread_local based makeTL to lld/Common/Memory.h. It
will enable further optimization in ELF.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130810

Files:
  lld/ELF/Driver.cpp
  lld/ELF/InputFiles.cpp
  lld/ELF/InputFiles.h
  lld/ELF/InputSection.cpp
  lld/include/lld/Common/Memory.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130810.448750.patch
Type: text/x-patch
Size: 13163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220730/65192dc7/attachment.bin>


More information about the llvm-commits mailing list