[ELF] Avoid referencing SectionBase::repl after ICF
authorFangrui Song <i@maskray.me>
Fri, 24 Dec 2021 20:09:48 +0000 (12:09 -0800)
committerFangrui Song <i@maskray.me>
Fri, 24 Dec 2021 20:09:48 +0000 (12:09 -0800)
commite1b6b5be462ee2f197737162fc2a7d23e9a2eab6
tree684bf8c0f2a6cf25a2c1ed1426d814079c012a90
parent8ea64d5585ec3a0a52db20c9e57ac9bed9e80fc2
[ELF] Avoid referencing SectionBase::repl after ICF

It is fairly easy to forget SectionBase::repl after ICF.
Let ICF rewrite a Defined symbol's `section` field to avoid references to
SectionBase::repl in subsequent passes. This slightly improves the --icf=none
performance due to less indirection (maybe for --icf={safe,all} as well if most
symbols are Defined).

With this change, there is only one reference to `repl` (--gdb-index D89751).
We can undo f4fb5fd7523f8e3c3b3966d43c0a28457b59d1d8 (`Move Repl to SectionBase.`)
but move `repl` to `InputSection` instead.

Reviewed By: ikudrin

Differential Revision: https://reviews.llvm.org/D116093
lld/ELF/CallGraphSort.cpp
lld/ELF/ICF.cpp
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h
lld/ELF/Relocations.cpp
lld/ELF/Symbols.cpp
lld/ELF/Symbols.h
lld/ELF/SyntheticSections.cpp
lld/ELF/Writer.cpp