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

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 07:35:02 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Jay Foad (jayfoad)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/127073.diff


1 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp (+3-1) 


``````````diff
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);
       }
 

``````````

</details>


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


More information about the llvm-commits mailing list