[lld] [lld][MachO] Key branch-extension thunks on (referent, addend) (PR #191808)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 17:01:37 PDT 2026


================
@@ -351,19 +351,34 @@ void TextOutputSection::finalize() {
       uint64_t highVA = callVA + forwardBranchRange;
       // Calculate our call referent address
       auto *funcSym = cast<Symbol *>(r.referent);
-      ThunkInfo &thunkInfo = thunkMap[funcSym];
-      // The referent is not reachable, so we need to use a thunk ...
-      if ((funcSym->isInStubs() ||
+      ThunkInfo &thunkInfo = thunkMap[ThunkKey{funcSym, r.addend}];
+      // The referent is not reachable, so we need to use a thunk... unless we
----------------
ellishg wrote:

The original comment was wrong. Line 383 is where we actually check to see if the referent is reachable by the original branch.

https://github.com/llvm/llvm-project/pull/191808


More information about the llvm-commits mailing list