Skip to content

Commit 04a811b

Browse files
committed
[mlir] Ensure memref's alignment is within SPIRV's alignment bounds.
1 parent 526787f commit 04a811b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mlir/lib/Conversion/MemRefToSPIRV/MemRefToSPIRV.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "mlir/IR/MLIRContext.h"
2323
#include "mlir/IR/Visitors.h"
2424
#include <cassert>
25+
#include <limits>
2526
#include <optional>
2627

2728
#define DEBUG_TYPE "memref-to-spirv-pattern"
@@ -467,6 +468,11 @@ struct MemoryRequirements {
467468
static FailureOr<MemoryRequirements>
468469
calculateMemoryRequirements(Value accessedPtr, bool isNontemporal,
469470
uint64_t preferredAlignment) {
471+
472+
if (std::numeric_limits<uint32_t>::max() < preferredAlignment) {
473+
return failure();
474+
}
475+
470476
MLIRContext *ctx = accessedPtr.getContext();
471477

472478
auto memoryAccess = spirv::MemoryAccess::None;

0 commit comments

Comments
 (0)