[lld-macho] Simplify linker optimization hint processing
authorDaniel Bertalan <dani@danielbertalan.dev>
Sat, 3 Sep 2022 13:29:00 +0000 (15:29 +0200)
committerDaniel Bertalan <dani@danielbertalan.dev>
Tue, 6 Sep 2022 06:19:08 +0000 (08:19 +0200)
commita8ec90ad9cfd5f3d4fda1272490a92c5b295c46f
tree536d1ed82416f689d039029110b14dfe142de520
parentd2a6e165e8980ed35fb4e5c7d468bfdc797b28c3
[lld-macho] Simplify linker optimization hint processing

This commit removes the `relocTargets` vector, and instead makes the
code reconstruct the referent addresses from the relocated instructions.
This will allow us to move `applyOptimizationHints` from
`ConcatInputSection::writeTo` to a separate pass that parses and applies
LOHs in one step, on a per-file basis. This will improve performance, as
parsing is currently done serially in `ObjFile::parse`.

I opted to remove the sanity check that ensures that all relocations
within a LOH point to the same symbol. This completely eliminates the
need to search through relocations. It is my understanding that
mismatched relocation targets should not be present in valid object
files, so it's unlikely that the removal will lead to mislinks.

Differential Revision: https://reviews.llvm.org/D133274
lld/MachO/Arch/ARM64.cpp
lld/MachO/InputSection.cpp
lld/MachO/Target.h
lld/test/MachO/loh-adrp-add.s
lld/test/MachO/loh-adrp-ldr.s