[mlir][openmp] Add check for types of operands in omp.atomic.write

This patch makes sure that the address dereferences to value in
omp.atomic.write operation.

Reviewed By: kiranchandramohan, peixin

Differential Revision: https://reviews.llvm.org/D126272
This commit is contained in:
Shraiysh Vaishay 2022-05-25 17:19:09 +05:30
parent c85688a22b
commit 512d06b045
2 changed files with 11 additions and 0 deletions

View File

@ -838,6 +838,9 @@ LogicalResult AtomicWriteOp::verify() {
"memory-order must not be acq_rel or acquire for atomic writes");
}
}
if (address().getType().cast<PointerLikeType>().getElementType() !=
value().getType())
return emitError("address must dereference to value type");
return verifySynchronizationHint(*this, hint_val());
}

View File

@ -600,6 +600,14 @@ func.func @omp_atomic_write6(%addr : memref<i32>, %val : i32) {
// -----
func.func @omp_atomic_write(%addr : memref<memref<i32>>, %val : i32) {
// expected-error @below {{address must dereference to value type}}
omp.atomic.write %addr = %val : memref<memref<i32>>, i32
return
}
// -----
func.func @omp_atomic_update1(%x: memref<i32>, %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<i32> {