[MLIR][Bytecode] Ensure dataIt is aligned coming out of EncodingReader::alignTo.

This addresses the TODO in the code previously and checks that the address of `dataIt` is properly aligned to the requested alignment.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D137855
This commit is contained in:
bzcheeseman
2022-11-11 11:22:06 -08:00
parent d9bff27024
commit ae461d8b99

View File

@@ -103,8 +103,13 @@ public:
}
}
// 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();
}