Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 21fcdfd

Browse files
committed
[AMDGPU] Fix s_branch with -1 offset
Summary: In case s_branch instruction target is itself backend should emit offset -1 but instead it emit 0. ''' label: s_branch label // should emit [0xff,0xff,0x82,0xbf] ''' Tom, Matt: why are we adjusting fixup values in applyFixup() method instead of processFixup()? processFixup() is calling adjustFixupValue() but does nothing with its result. Reviewers: vpykhtin, artem.tamazov, tstellarAMD Subscribers: arsenm, kzhuravl, wdng, nhaehnle, yaxunl Differential Revision: https://reviews.llvm.org/D24671 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281896 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 383922d commit 21fcdfd

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,21 @@ void AMDGPUAsmBackend::processFixupValue(const MCAssembler &Asm,
133133
const MCValue &Target, uint64_t &Value,
134134
bool &IsResolved) {
135135
if (IsResolved)
136-
(void)adjustFixupValue(Fixup, Value, &Asm.getContext());
137-
136+
Value = adjustFixupValue(Fixup, Value, &Asm.getContext());
138137
}
139138

140139
void AMDGPUAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
141140
unsigned DataSize, uint64_t Value,
142141
bool IsPCRel) const {
143-
unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
144142
if (!Value)
145143
return; // Doesn't change encoding.
146144

147-
Value = adjustFixupValue(Fixup, Value, nullptr);
148-
149145
MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
150146

151147
// Shift the value into position.
152148
Value <<= Info.TargetOffset;
153149

150+
unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
154151
uint32_t Offset = Fixup.getOffset();
155152
assert(Offset + NumBytes <= DataSize && "Invalid fixup offset!");
156153

test/MC/AMDGPU/labels-branch.s

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
// RUN: llvm-mc -arch=amdgcn -mcpu=fiji -show-encoding %s | FileCheck %s --check-prefix=VI
2+
// RUN: llvm-mc -arch=amdgcn -mcpu=fiji -filetype=obj %s | llvm-objdump -disassemble -mcpu=fiji - | FileCheck %s --check-prefix=BIN
23

34
loop_start:
45
s_branch loop_start
56
// VI: s_branch loop_start ; encoding: [A,A,0x82,0xbf]
67
// VI-NEXT: ; fixup A - offset: 0, value: loop_start, kind: fixup_si_sopp_br
8+
// BIN: loop_start:
9+
// BIN-NEXT: BF82FFFF
710

811
s_branch loop_end
912
// VI: s_branch loop_end ; encoding: [A,A,0x82,0xbf]
1013
// VI-NEXT: ; fixup A - offset: 0, value: loop_end, kind: fixup_si_sopp_br
14+
// BIN: BF820000
15+
// BIN: loop_end:
1116
loop_end:
1217

1318
s_branch gds
1419
// VI: s_branch gds ; encoding: [A,A,0x82,0xbf]
1520
// VI-NEXT: ; fixup A - offset: 0, value: gds, kind: fixup_si_sopp_br
21+
// BIN: BF820000
22+
// BIN: gds:
1623
gds:
1724
s_nop 0

0 commit comments

Comments
 (0)