diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp --- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp +++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -838,6 +838,9 @@ "memory-order must not be acq_rel or acquire for atomic writes"); } } + if (address().getType().cast().getElementType() != + value().getType()) + return emitError("address must dereference to value type"); return verifySynchronizationHint(*this, hint_val()); } diff --git a/mlir/test/Dialect/OpenMP/invalid.mlir b/mlir/test/Dialect/OpenMP/invalid.mlir --- a/mlir/test/Dialect/OpenMP/invalid.mlir +++ b/mlir/test/Dialect/OpenMP/invalid.mlir @@ -600,6 +600,14 @@ // ----- +func.func @omp_atomic_write(%addr : memref>, %val : i32) { + // expected-error @below {{address must dereference to value type}} + omp.atomic.write %addr = %val : memref>, i32 + return +} + +// ----- + func.func @omp_atomic_update1(%x: memref, %expr: f32) { // expected-error @below {{the type of the operand must be a pointer type whose element type is the same as that of the region argument}} omp.atomic.update %x : memref {