Skip to content

Commit 8a79448

Browse files
committed
Merging r243660:
------------------------------------------------------------------------ r243660 | Matthew.Arsenault | 2015-07-30 13:03:08 -0400 (Thu, 30 Jul 2015) | 9 lines AMDGPU: Fix unreachable when emitting binary debug info Copy implementation of applyFixup from AArch64 with AArch64 bits ripped out. Tests will be included with a later commit. Several other problems must be fixed before binary debug info emission will work. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@253229 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 074105b commit 8a79448

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,26 @@ void AMDGPUMCObjectWriter::writeObject(MCAssembler &Asm,
7171
}
7272
}
7373

74+
static unsigned getFixupKindNumBytes(unsigned Kind) {
75+
switch (Kind) {
76+
case FK_Data_1:
77+
return 1;
78+
case FK_Data_2:
79+
return 2;
80+
case FK_Data_4:
81+
return 4;
82+
case FK_Data_8:
83+
return 8;
84+
default:
85+
llvm_unreachable("Unknown fixup kind!");
86+
}
87+
}
88+
7489
void AMDGPUAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
7590
unsigned DataSize, uint64_t Value,
7691
bool IsPCRel) const {
7792

7893
switch ((unsigned)Fixup.getKind()) {
79-
default: llvm_unreachable("Unknown fixup kind");
8094
case AMDGPU::fixup_si_sopp_br: {
8195
uint16_t *Dst = (uint16_t*)(Data + Fixup.getOffset());
8296
*Dst = (Value - 4) / 4;
@@ -96,6 +110,24 @@ void AMDGPUAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
96110
*Dst = Value + 4;
97111
break;
98112
}
113+
default: {
114+
// FIXME: Copied from AArch64
115+
unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
116+
if (!Value)
117+
return; // Doesn't change encoding.
118+
MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind());
119+
120+
// Shift the value into position.
121+
Value <<= Info.TargetOffset;
122+
123+
unsigned Offset = Fixup.getOffset();
124+
assert(Offset + NumBytes <= DataSize && "Invalid fixup offset!");
125+
126+
// For each byte of the fragment that the fixup touches, mask in the
127+
// bits from the fixup value.
128+
for (unsigned i = 0; i != NumBytes; ++i)
129+
Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
130+
}
99131
}
100132
}
101133

0 commit comments

Comments
 (0)