[llvm] [AMDGPU] Try to fix -mattr=dumpcode on big-endian hosts (PR #127073)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 07:34:20 PST 2025


https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/127073

Blind fix for #116982 failing on big-endian buildbots.


>From 5adf26720a5248cb00d77cab651efc30da9d717a Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Thu, 13 Feb 2025 15:32:35 +0000
Subject: [PATCH] [AMDGPU] Try to fix -mattr=dumpcode on big-endian hosts

Blind fix for #116982 failing on big-endian buildbots.
---
 llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
index 9ddd8db1eebf2..38272b9d4840d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
@@ -29,6 +29,7 @@
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCObjectStreamer.h"
 #include "llvm/MC/MCStreamer.h"
+#include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
 #include <algorithm>
@@ -316,7 +317,8 @@ void AMDGPUAsmPrinter::emitInstruction(const MachineInstr *MI) {
       raw_string_ostream HexStream(HexLine);
 
       for (size_t i = 0; i < CodeBytes.size(); i += 4) {
-        unsigned int CodeDWord = *(unsigned int *)&CodeBytes[i];
+        unsigned int CodeDWord =
+            support::endian::read32le(CodeBytes.data() + i);
         HexStream << format("%s%08X", (i > 0 ? " " : ""), CodeDWord);
       }
 



More information about the llvm-commits mailing list