[PATCH] D97550: [LLD][ELF][ARM] Refactor inBranchRange to use addend for PC Bias
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 27 00:30:19 PST 2021
MaskRay added inline comments.
================
Comment at: lld/ELF/Arch/ARM.cpp:301
uint64_t dst = (expr == R_PLT_PC) ? s.getPltVA() : s.getVA();
- return !inBranchRange(type, branchAddr, dst);
+ return !inBranchRange(type, branchAddr, dst + a);
}
----------------
IIUC a is usually -8, so `dst+a-branchAddr` is the value to be encoded. So this simplifies understanding. `inBranchRange` can just use the regular `[-2**n, 2**n)` range instead of doing some compensation.
================
Comment at: lld/ELF/Relocations.cpp:1937
+ // Compensate for the different ARM/Thumb PC bias so we can reuse more thunks.
+ int64_t keyAddend = rel.addend + getPCBias(rel.type);
----------------
MaskRay wrote:
> This probably needs a test (similar to D70637) to test sharing, even if it is difficult to construct a test exercising the range limit.
Perhaps the comment can say that `keyAddend` is usually 0, even on ARM.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97550/new/
https://reviews.llvm.org/D97550
More information about the llvm-commits
mailing list