[llvm] [PowerPC][XCOFF] Handle non-zero addend in relocation to external toc-data symbol (PR #94444)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 02:00:13 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-powerpc
Author: Kai Luo (bzEq)
<details>
<summary>Changes</summary>
There are situations that the addend is not zero. We should fix it for IAS.
---
Full diff: https://github.com/llvm/llvm-project/pull/94444.diff
2 Files Affected:
- (modified) llvm/lib/MC/XCOFFObjectWriter.cpp (+2-3)
- (modified) llvm/test/CodeGen/PowerPC/tocdata-non-zero-addend.mir (+1-1)
``````````diff
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index a7c3818d598b7..061f362dd5ec8 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -729,10 +729,9 @@ void XCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
// For non toc-data external symbols, R_TOC type relocation will relocate to
// data symbols that have XCOFF::XTY_SD type csect. For toc-data external
// symbols, R_TOC type relocation will relocate to data symbols that have
- // XCOFF_ER type csect. For XCOFF_ER kind symbols, there will be no TOC
- // entry for them, so the FixedValue should always be 0.
+ // XCOFF_ER type csect.
if (SymASec->getCSectType() == XCOFF::XTY_ER) {
- FixedValue = 0;
+ FixedValue = Target.getConstant();
} else {
// The FixedValue should be the TOC entry offset from the TOC-base plus
// any constant offset value.
diff --git a/llvm/test/CodeGen/PowerPC/tocdata-non-zero-addend.mir b/llvm/test/CodeGen/PowerPC/tocdata-non-zero-addend.mir
index eff10d24a62f3..b49615ce67c43 100644
--- a/llvm/test/CodeGen/PowerPC/tocdata-non-zero-addend.mir
+++ b/llvm/test/CodeGen/PowerPC/tocdata-non-zero-addend.mir
@@ -4,7 +4,7 @@
# CHECK: lbz 3, 2(2)
# CHECK-NEXT: R_TOC x
# CHECK-LABEL: .read_y
-# CHECK: lbz 3, 0(2)
+# CHECK: lbz 3, 1(2)
# CHECK-NEXT: R_TOC y
--- |
``````````
</details>
https://github.com/llvm/llvm-project/pull/94444
More information about the llvm-commits
mailing list