diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp --- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp +++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp @@ -103,8 +103,13 @@ } } - // TODO: Check that the current data pointer is actually at the expected - // alignment. + // Ensure the data iterator is now aligned. This case is unlikely because we + // *just* went through the effort to align the data iterator. + if (LLVM_UNLIKELY(!llvm::isAddrAligned(llvm::Align(alignment), dataIt))) { + return emitError("expected data iterator aligned to ", alignment, + ", but got pointer: '0x" + + llvm::utohexstr((uintptr_t)dataIt) + "'"); + } return success(); }