diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -2685,8 +2685,9 @@ uint32_t dataAlignment) final { printFn(key, [&](raw_ostream &os) { // Store the blob in a hex string containing the alignment and the data. + llvm::support::ulittle32_t dataAlignmentLE(dataAlignment); os << "\"0x" - << llvm::toHex(StringRef(reinterpret_cast(&dataAlignment), + << llvm::toHex(StringRef(reinterpret_cast(&dataAlignmentLE), sizeof(dataAlignment))) << llvm::toHex(StringRef(data.data(), data.size())) << "\""; }); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -24,6 +24,7 @@ #include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/bit.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/SourceMgr.h" #include @@ -2349,7 +2350,7 @@ "expected hex string blob for key '" + key + "' to encode alignment in first 4 bytes"); } - uint32_t align = 0; + llvm::support::ulittle32_t align; memcpy(&align, blobData->data(), sizeof(uint32_t)); // Get the data portion of the blob.