[llvm] [LoongArch] Allow delayed decision for ADD/SUB relocations (PR #72960)

Jinyang He via llvm-commits llvm-commits at lists.llvm.org
Mon May 26 03:24:56 PDT 2025


================
@@ -190,6 +218,56 @@ bool LoongArchAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
   return true;
 }
 
+bool LoongArchAsmBackend::handleAddSubRelocations(const MCAsmLayout &Layout,
+                                                  const MCFragment &F,
+                                                  const MCFixup &Fixup,
+                                                  const MCValue &Target,
+                                                  uint64_t &FixedValue) const {
+  std::pair<MCFixupKind, MCFixupKind> FK;
+  uint64_t FixedValueA, FixedValueB;
+  const MCSection &SecA = Target.getSymA()->getSymbol().getSection();
+  const MCSection &SecB = Target.getSymB()->getSymbol().getSection();
+
+  // 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)
----------------
MQ-mengqing wrote:

Thanks for reminder, this feature should be supported. I made a simple patch,
https://github.com/MQ-mengqing/llvm-project/commit/a8d69db409307f32bc6267b4705537703ef6e339
Is that you expected?


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


More information about the llvm-commits mailing list