[lld] [lld][LoongArch] GOT indirection to PC relative optimization (PR #123743)
Lu Weining via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 26 01:53:44 PDT 2025
================
@@ -1261,6 +1314,22 @@ void LoongArch::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
tlsdescToLe(loc, rel, val);
}
continue;
+ case RE_LOONGARCH_GOT_PAGE_PC:
+ // In LoongArch, we try GOT indirection to PC relative optimization only
+ // when relaxation is enabled. This approach avoids determining whether
+ // relocation types are paired and whether the destination register of
+ // pcalau12i is only used by the immediately following instruction.
+ // Moreover, if the original code sequence can be relaxed to a single
+ // instruction `pcaddi`, the first instruction will be removed and it will
+ // not reach here.
+ if (isPairRelaxable(relocs, i) && rel.type == R_LARCH_GOT_PC_HI20 &&
----------------
SixWeining wrote:
- Check opcodes are exactly `pcalau12i + ld.{w,d}` in case the large code model (`pcalau12i + addi.d + lu32i.d + lu52i.d + ld.d`).
- Inline all these checks into `tryGotToPCRel`.
https://github.com/llvm/llvm-project/pull/123743
More information about the llvm-commits
mailing list