[lld][MachO] Avoid redundant work in Writer::scanRelocations() (#246903) During relocation scanning, `Writer::scanRelocations()` looks up `target->getRelocAttrs(r.type)` up to three times per symbol relocation (in `scanRelocations()`, `validateSymbolRelocation()`, and `prepareSymbolRelocation()`), tests `r.referent` twice for symbol referents, and makes an out-of-line call to `validateSymbolRelocation()` on every symbol relocation even though it only rejects two rare thread-local-variable cases. Move `validateSymbolRelocation()` (whose only caller is `Writer::scanRelocations()`) into `Writer.cpp`, split the rare TLV validation logic into a `LLVM_ATTRIBUTE_NOINLINE` helper, and mark `DylibSymbol` `final` so `dysym->isTlv()` avoids a virtual call on the fast path. Fetch `RelocAttrs` once per relocation, pass it to `validateSymbolRelocation()` and `prepareSymbolRelocation()`, hoist loop-invariant `target->relocAttrs` and `config->emitChainedFixups`, and dispatch on `r.referent` once for non-subtractor relocations. Assisted by Gemini + Claude. GitOrigin-RevId: d4c06073fd83d8ff993851e875634ae5ecc4d51b
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.
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.