[llvm] [LoongArch] Allow difference across sections (PR #141722)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat May 31 16:52:57 PDT 2025


================
@@ -447,19 +447,16 @@ bool LoongArchAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
     if (!force) {
       const MCSection &SecA = SA.getSection();
       const MCSection &SecB = SB.getSection();
+      const MCSection &SecCur = *F.getParent();
 
-      // We need record relocation if SecA != SecB. Usually SecB is same as the
-      // section of Fixup, which will be record the relocation as PCRel. If SecB
-      // is not same as the section of Fixup, it will report error. Just return
-      // false and then this work can be finished by handleFixup.
-      if (&SecA != &SecB)
+      // Fallback for PCRel relocations.
----------------
MaskRay wrote:

It seems that we fallback because the generic case may generate R_LARCH_32_PCREL, which is better than ADD/SUB relocation pair here? The comment should be clarified

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


More information about the llvm-commits mailing list