[PATCH] D81082: [PowerPC] Do not add the relocation addend to the instruction encoding
Stefan Pintilie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 18:16:58 PDT 2020
stefanp updated this revision to Diff 269386.
stefanp added a comment.
I've put the return instructions back in place.
The test in this patch already prints out the addend. The CHECK-O section prints out the relocation and then it has `symbol+<addend>`. Is that what you are looking for?
For example:
; CHECK-O-NEXT: 0000000000000000: R_PPC64_PCREL34 array2+0x1c
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81082/new/
https://reviews.llvm.org/D81082
Files:
llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
llvm/test/CodeGen/PowerPC/pcrel-relocation-plus-offset.ll
Index: llvm/test/CodeGen/PowerPC/pcrel-relocation-plus-offset.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/pcrel-relocation-plus-offset.ll
+++ llvm/test/CodeGen/PowerPC/pcrel-relocation-plus-offset.ll
@@ -16,7 +16,7 @@
; CHECK-S-NEXT: plwa r3, array2 at PCREL+28(0), 1
; CHECK-S-NEXT: blr
; CHECK-O-LABEL: <getElementLocal7>:
-; CHECK-O: 00 00 10 04 1c 00 60 a4 plwa 3, 28(0), 1
+; CHECK-O: 00 00 10 04 00 00 60 a4 plwa 3, 0(0), 1
; CHECK-O-NEXT: 0000000000000000: R_PPC64_PCREL34 array2+0x1c
; CHECK-O-NEXT: 20 00 80 4e blr
entry:
@@ -30,7 +30,7 @@
; CHECK-S-NEXT: plwa r3, array2 at PCREL-8(0), 1
; CHECK-S-NEXT: blr
; CHECK-O-LABEL: <getElementLocalNegative>:
-; CHECK-O: ff ff 13 04 f8 ff 60 a4 plwa 3, -8(0), 1
+; CHECK-O: 00 00 10 04 00 00 60 a4 plwa 3, 0(0), 1
; CHECK-O-NEXT: 0000000000000020: R_PPC64_PCREL34 array2-0x8
; CHECK-O-NEXT: 20 00 80 4e blr
entry:
Index: llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
+++ llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCCodeEmitter.cpp
@@ -219,7 +219,8 @@
Fixups.push_back(
MCFixup::create(IsLittleEndian ? 0 : 1, Expr,
static_cast<MCFixupKind>(PPC::fixup_ppc_pcrel34)));
- // There is no offset to return so just return 0.
+ // Put zero in the location of the immediate. The linker will fill in the
+ // correct value based on the relocation.
return 0;
}
case MCExpr::Binary: {
@@ -242,6 +243,7 @@
const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(LHS);
(void)SRE;
const MCConstantExpr *CE = cast<MCConstantExpr>(RHS);
+ assert(isInt<34>(CE->getValue()) && "Value must fit in 34 bits.");
// Currently these are the only valid PCRelative Relocations.
assert((SRE->getKind() == MCSymbolRefExpr::VK_PCREL ||
@@ -251,9 +253,9 @@
Fixups.push_back(
MCFixup::create(IsLittleEndian ? 0 : 1, Expr,
static_cast<MCFixupKind>(PPC::fixup_ppc_pcrel34)));
- assert(isInt<34>(CE->getValue()) && "Value must fit in 34 bits.");
- // Return the offset that should be added to the relocation by the linker.
- return (CE->getValue() & 0x3FFFFFFFFUL) | RegBits;
+ // Put zero in the location of the immediate. The linker will fill in the
+ // correct value based on the relocation.
+ return 0;
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81082.269386.patch
Type: text/x-patch
Size: 2614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200609/d804fbda/attachment.bin>
More information about the llvm-commits
mailing list