[llvm] [LoongArch] Use section-relaxable check instead of relax feature from STI (PR #153792)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 15 04:49:28 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-loongarch
Author: ZhaoQi (zhaoqi5)
<details>
<summary>Changes</summary>
In some cases, such as using `lto` or `llc`, relax feature is not available from this `SubtargetInfo` (`LoongArchAsmBackend` is instantiated too early), causing loss of relocations.
This commit modifiy the condition to check whether the section which contains the two symbols is relaxable. If not relaxable, no need to record relocations.
---
Full diff: https://github.com/llvm/llvm-project/pull/153792.diff
1 Files Affected:
- (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
index ca5d27d54bb81..34a5d802daed6 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchAsmBackend.cpp
@@ -448,10 +448,10 @@ bool LoongArchAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
isPCRelFixupResolved(Target.getSubSym(), F))
return Fallback();
- // In SecA == SecB case. If the linker relaxation is disabled, the
+ // In SecA == SecB case. If the section is not linker-relaxable, the
// FixedValue has already been calculated out in evaluateFixup,
// return true and avoid record relocations.
- if (&SecA == &SecB && !STI.hasFeature(LoongArch::FeatureRelax))
+ if (&SecA == &SecB && !SecA.isLinkerRelaxable())
return true;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/153792
More information about the llvm-commits
mailing list