[all-commits] [llvm/llvm-project] 8a3b83: [ELF] Add target-specific relocation scanning for ...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Wed Feb 11 21:04:30 PST 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 8a3b830c94575a97c40c8b8f4a23f910fab5f0f5
https://github.com/llvm/llvm-project/commit/8a3b830c94575a97c40c8b8f4a23f910fab5f0f5
Author: Fangrui Song <i at maskray.me>
Date: 2026-02-11 (Wed, 11 Feb 2026)
Changed paths:
M lld/ELF/Arch/X86.cpp
M lld/ELF/Arch/X86_64.cpp
M lld/ELF/RelocScan.h
M lld/ELF/Relocations.cpp
Log Message:
-----------
[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}"'
```
)
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list