[ELF] Add target-specific relocation scanning for x86 (#178846)

Implement scanSection/scanSectionImpl for i386 and x86-64 to

* enable devirtualization of getRelExpr calls
* eliminate abstraction overhead for PLT-to-PCRel optimization, TLS
relocations
* optimize for R_X86_64_PC32 and R_X86_64_PLT32: they consist of 95%
  relocations in `lld/ELF/**/*.o` files.

at the cost of more code.

TLS relocation handling is inlined into scanSectionImpl. Also,

- Remove getTlsGdRelaxSkip
- Replace TLS-optimization-specific expressions:
- R_RELAX_TLS_GD_TO_LE, R_RELAX_TLS_LD_TO_LE, R_RELAX_TLS_IE_TO_LE →
R_TPREL
  - R_RELAX_TLS_GD_TO_IE → R_GOT_PC

This follows the pattern established for MIPS and PPC64 in `#163138`.

getRelExpr is simplified to only handle relocations needed for
relocateNonAlloc and relocateEH.

Average "Scan relocations" time (measured by --time-trace) decreases
from 110078 to 101585.

(
```
ruby -rjson -e 't=[]; 50.times { system("numactl -C 0-7 /t/lld1 -flavor gnu --threads=8 @response.txt -o a.out --time-trace"); t << JSON.parse(File.read("a.out.time-trace"))["traceEvents"].find { |e| e["name"] == "Scan relocations" }["dur"] }; puts "Average: #{t.sum / t.size}"'
```
)

GitOrigin-RevId: 8a3b830c94575a97c40c8b8f4a23f910fab5f0f5
4 files changed
tree: ffd04da469677b2f4c8148cd8c401ff386e4623f
  1. cmake/
  2. COFF/
  3. Common/
  4. docs/
  5. ELF/
  6. include/
  7. MachO/
  8. MinGW/
  9. test/
  10. tools/
  11. unittests/
  12. utils/
  13. wasm/
  14. .clang-format
  15. .clang-tidy
  16. .gitignore
  17. CMakeLists.txt
  18. LICENSE.TXT
  19. Maintainers.md
  20. README.md
README.md

LLVM Linker (lld)

This directory and its subdirectories contain source code for the LLVM Linker, a modular cross platform linker which is built as part of the LLVM compiler infrastructure project.

lld is open source software. You may freely distribute it under the terms of the license agreement found in LICENSE.txt.

Benchmarking

In order to make sure various developers can evaluate patches over the same tests, we create a collection of self contained programs.

It is hosted at https://s3-us-west-2.amazonaws.com/linker-tests/lld-speed-test.tar.xz

The current sha256 is 10eec685463d5a8bbf08d77f4ca96282161d396c65bd97dc99dbde644a31610f.