Skip to content

Commit f14a4ac

Browse files
committed
Sparc: Suppress applyFixup when a relocation is generated
The computed R_SPARC_HIX22/R_SPARC_LOX10 value is non-zero even when the input is 0. We should suppress applyFixup when a relocation is generated.
1 parent d0096e8 commit f14a4ac

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

llvm/lib/Target/Sparc/MCTargetDesc/SparcAsmBackend.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,9 @@ namespace {
231231
const MCValue &Target, MutableArrayRef<char> Data,
232232
uint64_t Value, bool IsResolved,
233233
const MCSubtargetInfo *STI) const override {
234-
if (mc::isRelocRelocation(Fixup.getKind()))
234+
if (!IsResolved)
235235
return;
236236
Value = adjustFixupValue(Fixup.getKind(), Value);
237-
if (!Value) return; // Doesn't change encoding.
238237

239238
unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
240239
unsigned Offset = Fixup.getOffset();

llvm/test/MC/Sparc/Relocations/relocation-specifier.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ sethi %lm(sym), %l0
7979
# ASM-NEXT: ldx [%l7+%l1], %l2, %gdop(sym)
8080
# OBJDUMP: sethi 0x3fffff, %g0
8181
# OBJDUMP-NEXT: xor %g0, -0x400, %g0
82-
# OBJDUMP-NEXT: sethi 0x3fffff, %g1
82+
# OBJDUMP-NEXT: sethi 0x0, %g1
8383
# OBJDUMP-NEXT: R_SPARC_HIX22 sym
84-
# OBJDUMP-NEXT: xor %g1, -0x400, %g1
84+
# OBJDUMP-NEXT: xor %g1, 0x0, %g1
8585
# OBJDUMP-NEXT: R_SPARC_LOX10 sym
8686
# OBJDUMP-NEXT: sethi 0x0, %l1
8787
# OBJDUMP-NEXT: R_SPARC_GOTDATA_OP_HIX22 sym

0 commit comments

Comments
 (0)