[llvm] [RISC-V] Add SMLoc info for fixup. [NFCI] (PR #142054)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 15:47:46 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-risc-v

Author: Francesco Petrogalli (fpetrogalli)

<details>
<summary>Changes</summary>

This makes sure that potential error messages attached to the fixups being created are linked to the source code that triggered the split.

---
Full diff: https://github.com/llvm/llvm-project/pull/142054.diff


1 Files Affected:

- (modified) llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp (+3-2) 


``````````diff
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 963501db118e7..7b15a01dcf9ec 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -645,8 +645,9 @@ bool RISCVAsmBackend::addReloc(const MCFragment &F, const MCFixup &Fixup,
     }
     MCValue A = MCValue::get(Target.getAddSym(), nullptr, Target.getConstant());
     MCValue B = MCValue::get(Target.getSubSym());
-    auto FA = MCFixup::create(Fixup.getOffset(), nullptr, TA);
-    auto FB = MCFixup::create(Fixup.getOffset(), nullptr, TB);
+    const SMLoc Loc = Fixup.getLoc();
+    auto FA = MCFixup::create(Fixup.getOffset(), nullptr, TA, Loc);
+    auto FB = MCFixup::create(Fixup.getOffset(), nullptr, TB, Loc);
     Asm->getWriter().recordRelocation(F, FA, A, FixedValueA);
     Asm->getWriter().recordRelocation(F, FB, B, FixedValueB);
     FixedValue = FixedValueA - FixedValueB;

``````````

</details>


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


More information about the llvm-commits mailing list