1 // RUN: mlir-translate -mlir-to-llvmir %s -split-input-file -verify-diagnostics
3 // Checking translation when the update is carried out by using more than one op
5 llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr, %expr: i32) {
6 omp.atomic.update %x : !llvm.ptr {
8 %t1 = llvm.mul %xval, %expr : i32
9 %t2 = llvm.sdiv %t1, %expr : i32
10 %newval = llvm.add %xval, %t2 : i32
11 omp.yield(%newval : i32)
18 // Checking translation when the captured variable is not used in the inner
20 llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr, %expr: i32) {
21 // expected-error @+2 {{no atomic update operation with region argument as operand found inside atomic.update region}}
22 // expected-error @+1 {{LLVM Translation failed for operation: omp.atomic.update}}
23 omp.atomic.update %x : !llvm.ptr {
25 %newval = llvm.mul %expr, %expr : i32
26 omp.yield(%newval : i32)
33 // Checking translation when the update is carried out by using more than one
34 // operations in the atomic capture region.
35 llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr, %v: !llvm.ptr, %expr: i32) {
36 // expected-error @+1 {{LLVM Translation failed for operation: omp.atomic.capture}}
37 omp.atomic.capture memory_order(seq_cst) {
38 omp.atomic.read %v = %x : !llvm.ptr, !llvm.ptr, i32
39 // expected-error @+1 {{no atomic update operation with region argument as operand found inside atomic.update region}}
40 omp.atomic.update %x : !llvm.ptr {
42 %newval = llvm.mul %expr, %expr : i32
43 omp.yield(%newval : i32)
51 // Checking translation when the captured variable is not used in the inner
53 llvm.func @omp_atomic_update_multiple_step_update(%x: !llvm.ptr, %v: !llvm.ptr, %expr: i32) {
54 omp.atomic.capture memory_order(seq_cst) {
55 omp.atomic.read %v = %x : !llvm.ptr, !llvm.ptr, i32
56 omp.atomic.update %x : !llvm.ptr {
58 %t1 = llvm.mul %xval, %expr : i32
59 %t2 = llvm.sdiv %t1, %expr : i32
60 %newval = llvm.add %xval, %t2 : i32
61 omp.yield(%newval : i32)
69 llvm.func @omp_threadprivate() {
70 %0 = llvm.mlir.constant(1 : i64) : i64
71 %1 = llvm.mlir.constant(1 : i32) : i32
72 %2 = llvm.mlir.constant(2 : i32) : i32
73 %3 = llvm.mlir.constant(3 : i32) : i32
75 %4 = llvm.alloca %0 x i32 {in_type = i32, name = "a"} : (i64) -> !llvm.ptr
77 // expected-error @below {{Addressing symbol not found}}
78 // expected-error @below {{LLVM Translation failed for operation: omp.threadprivate}}
79 %5 = omp.threadprivate %4 : !llvm.ptr -> !llvm.ptr
81 llvm.store %1, %5 : i32, !llvm.ptr
84 %6 = omp.threadprivate %4 : !llvm.ptr -> !llvm.ptr
85 llvm.store %2, %6 : i32, !llvm.ptr
89 llvm.store %3, %5 : i32, !llvm.ptr