Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Feb 13, 2025

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

Blind fix for llvm#116982 failing on big-endian buildbots.
@llvmbot
Copy link
Member

llvmbot commented Feb 13, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Jay Foad (jayfoad)

Changes

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

@jayfoad
Copy link
Contributor Author

jayfoad commented Feb 13, 2025

This is an alternative to #127064

@jayfoad jayfoad merged commit ba45592 into llvm:main Feb 13, 2025
8 of 9 checks passed
@jayfoad jayfoad deleted the fix-dumpcode-endianness branch February 13, 2025 16:44
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants