[ELF] Add makeThreadLocal/makeThreadLocalN and remove InputFile::localSymStorage
authorFangrui Song <i@maskray.me>
Thu, 4 Aug 2022 18:09:40 +0000 (11:09 -0700)
committerFangrui Song <i@maskray.me>
Thu, 4 Aug 2022 18:09:40 +0000 (11:09 -0700)
commitf6bd0a8f2bc4b62f7f7800a7dd1de6ba764b56c6
tree08772d4c73254ddc864077237f8a7f67cacc0d95
parentcf08452e918e04c5a95b6dce11a977b317ac4476
[ELF] Add makeThreadLocal/makeThreadLocalN and remove InputFile::localSymStorage

makeThreadLocal/makeThreadLocalN are moved from D130810 ([ELF] Parallelize input
section initialization) here to make D130810 more focused on the refactor:

* COFF has some needs for multiple linker contexts. 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/D123879 are too expensive and will not
  really benefit ELF.

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