Skip to content

Commit 356c718

Browse files
committed
[AMDGPU] Fix big endian bots after 7c327c2
The pass that this test case is testing has host-endianness dependencies. This fixes the pertinent one causing failures on BE bots.
1 parent 4682039 commit 356c718

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,19 +411,31 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
411411
DataExtractor Extractor(S, /*IsLittleEndian=*/true, 8);
412412
DataExtractor::Cursor Offset(0);
413413
while (Offset && Offset.tell() < S.size()) {
414-
StringRef ReadBytes = Extractor.getBytes(
415-
Offset, std::min(ReadSize, S.size() - Offset.tell()));
414+
uint64_t ReadNow = std::min(ReadSize, S.size() - Offset.tell());
415+
uint64_t ReadBytes = 0;
416+
switch (ReadNow) {
417+
default: llvm_unreachable("min(4, X) > 4?");
418+
case 1:
419+
ReadBytes = Extractor.getU8(Offset);
420+
break;
421+
case 2:
422+
ReadBytes = Extractor.getU16(Offset);
423+
break;
424+
case 3:
425+
ReadBytes = Extractor.getU24(Offset);
426+
break;
427+
case 4:
428+
ReadBytes = Extractor.getU32(Offset);
429+
break;
430+
}
416431

417432
cantFail(Offset.takeError(),
418433
"failed to read bytes from constant array");
419434

420-
APInt IntVal(8 * ReadBytes.size(), 0);
421-
LoadIntFromMemory(
422-
IntVal, reinterpret_cast<const uint8_t *>(ReadBytes.data()),
423-
ReadBytes.size());
435+
APInt IntVal(8 * ReadSize, ReadBytes);
424436

425437
// TODO: Should not bothering aligning up.
426-
if (ReadBytes.size() < ReadSize)
438+
if (ReadNow < ReadSize)
427439
IntVal = IntVal.zext(8 * ReadSize);
428440

429441
Type *IntTy = Type::getIntNTy(Ctx, IntVal.getBitWidth());

0 commit comments

Comments
 (0)