Index: mlir/lib/IR/AsmPrinter.cpp =================================================================== --- mlir/lib/IR/AsmPrinter.cpp +++ 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())) << "\""; }); Index: mlir/lib/Parser/Parser.cpp =================================================================== --- mlir/lib/Parser/Parser.cpp +++ 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 @@ -2320,7 +2321,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. Index: mlir/test/IR/elements-attr-interface.mlir =================================================================== --- mlir/test/IR/elements-attr-interface.mlir +++ mlir/test/IR/elements-attr-interface.mlir @@ -1,5 +1,8 @@ // RUN: mlir-opt %s -test-elements-attr-interface -verify-diagnostics +// Parsing external resources does not work on big-endian platforms currently +// XFAIL: s390x- + // This test contains various `ElementsAttr` attributes, and tests the support // for iterating the values of these attributes using various native C++ types. // This tests that the abstract iteration of ElementsAttr works properly, and