Skip to content

Commit ba45592

Browse files
authored
[AMDGPU] Try to fix -mattr=dumpcode on big-endian hosts (#127073)
Blind fix for #116982 failing on big-endian buildbots.
1 parent 88015d1 commit ba45592

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/MC/MCInst.h"
3030
#include "llvm/MC/MCObjectStreamer.h"
3131
#include "llvm/MC/MCStreamer.h"
32+
#include "llvm/Support/Endian.h"
3233
#include "llvm/Support/ErrorHandling.h"
3334
#include "llvm/Support/Format.h"
3435
#include <algorithm>
@@ -316,7 +317,8 @@ void AMDGPUAsmPrinter::emitInstruction(const MachineInstr *MI) {
316317
raw_string_ostream HexStream(HexLine);
317318

318319
for (size_t i = 0; i < CodeBytes.size(); i += 4) {
319-
unsigned int CodeDWord = *(unsigned int *)&CodeBytes[i];
320+
unsigned int CodeDWord =
321+
support::endian::read32le(CodeBytes.data() + i);
320322
HexStream << format("%s%08X", (i > 0 ? " " : ""), CodeDWord);
321323
}
322324

0 commit comments

Comments
 (0)