Index: flang/test/Lower/OpenMP/atomic-read.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/atomic-read.f90 @@ -0,0 +1,45 @@ +! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s + +! This test checks the lowering of atomic read + +!CHECK: func @_QQmain() { +!CHECK: %[[VAR_A:.*]] = fir.address_of(@_QFEa) : !fir.ref> +!CHECK: %[[VAR_B:.*]] = fir.address_of(@_QFEb) : !fir.ref> +!CHECK: %[[VAR_C:.*]] = fir.alloca !fir.logical<4> {bindc_name = "c", uniq_name = "_QFEc"} +!CHECK: %[[VAR_D:.*]] = fir.alloca !fir.logical<4> {bindc_name = "d", uniq_name = "_QFEd"} +!CHECK: %[[VAR_E:.*]] = fir.address_of(@_QFEe) : !fir.ref> +!CHECK: %[[VAR_F:.*]] = fir.address_of(@_QFEf) : !fir.ref> +!CHECK: %[[VAR_G:.*]] = fir.alloca f32 {bindc_name = "g", uniq_name = "_QFEg"} +!CHECK: %[[VAR_H:.*]] = fir.alloca f32 {bindc_name = "h", uniq_name = "_QFEh"} +!CHECK: %[[VAR_X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFEx"} +!CHECK: %[[VAR_Y:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFEy"} +!CHECK: omp.atomic.read %[[VAR_X]] = %[[VAR_Y]] memory_order(acquire) hint(uncontended) : !fir.ref +!CHECK: omp.atomic.read %[[VAR_A]] = %[[VAR_B]] memory_order(relaxed) hint(none) : !fir.ref> +!CHECK: omp.atomic.read %[[VAR_C]] = %[[VAR_D]] memory_order(seq_cst) hint(contended) : !fir.ref> +!CHECK: omp.atomic.read %[[VAR_E]] = %[[VAR_F]] hint(speculative) : !fir.ref> +!CHECK: omp.atomic.read %[[VAR_G]] = %[[VAR_H]] hint(nonspeculative) : !fir.ref +!CHECK: omp.atomic.read %[[VAR_G]] = %[[VAR_H]] : !fir.ref +!CHECK: return +!CHECK: } + +program OmpAtomic + + use omp_lib + integer :: x, y + character :: a, b + logical :: c, d + character(8) :: e, f + real g, h + !$omp atomic acquire read hint(omp_sync_hint_uncontended) + x = y + !$omp atomic relaxed read hint(omp_sync_hint_none) + a = b + !$omp atomic read seq_cst hint(omp_sync_hint_contended) + c = d + !$omp atomic read hint(omp_sync_hint_speculative) + e = f + !$omp atomic read hint(omp_sync_hint_nonspeculative) + g = h + !$omp atomic read + g = h +end program OmpAtomic Index: flang/test/Lower/OpenMP/atomic-write.f90 =================================================================== --- /dev/null +++ flang/test/Lower/OpenMP/atomic-write.f90 @@ -0,0 +1,37 @@ +! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s + +! This test checks the lowering of atomic write + +!CHECK: func @_QQmain() { +!CHECK: %[[VAR_X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFEx"} +!CHECK: %[[VAR_Y:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFEy"} +!CHECK: %[[VAR_Z:.*]] = fir.alloca i32 {bindc_name = "z", uniq_name = "_QFEz"} +!CHECK: %[[CONST_44:.*]] = arith.constant 44 : i32 +!CHECK: omp.atomic.write %[[VAR_X]] = %[[CONST_44]] hint(uncontended) memory_order(seq_cst) : !fir.ref, i32 +!CHECK: %[[CONST_7:.*]] = arith.constant 7 : i32 +!CHECK: {{.*}} = fir.load %[[VAR_Y]] : !fir.ref +!CHECK: %[[VAR_7y:.*]] = arith.muli %[[CONST_7]], {{.*}} : i32 +!CHECK: omp.atomic.write %[[VAR_X]] = %[[VAR_7y]] memory_order(relaxed) : !fir.ref, i32 +!CHECK: %[[CONST_10:.*]] = arith.constant 10 : i32 +!CHECK: {{.*}} = fir.load %[[VAR_X]] : !fir.ref +!CHECK: {{.*}} = arith.muli %[[CONST_10]], {{.*}} : i32 +!CHECK: {{.*}} = fir.load %[[VAR_Z]] : !fir.ref +!CHECK: %[[CONST_2:.*]] = arith.constant 2 : i32 +!CHECK: {{.*}} = arith.divsi {{.*}}, %[[CONST_2]] : i32 +!CHECK: {{.*}} = arith.addi {{.*}}, {{.*}} : i32 +!CHECK: omp.atomic.write %[[VAR_Y]] = {{.*}} hint(speculative) memory_order(release) : !fir.ref, i32 +!CHECK: return +!CHECK: } + +program OmpAtomicWrite + use omp_lib + integer :: x, y, z + !$omp atomic seq_cst write hint(omp_sync_hint_uncontended) + x = 8*4 + 12 + + !$omp atomic write relaxed + x = 7 * y + + !$omp atomic write release hint(omp_sync_hint_speculative) + y = 10*x + z/2 +end program OmpAtomicWrite Index: flang/test/Lower/OpenMP/atomic01.f90 =================================================================== --- flang/test/Lower/OpenMP/atomic01.f90 +++ /dev/null @@ -1,74 +0,0 @@ -! RUN: bbc -fopenmp -emit-fir %s -o - | \ -! RUN: FileCheck %s --check-prefix=FIRDialect -! RUN: bbc -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | \ -! RUN: FileCheck %s --check-prefix=LLVMDialect - -! This test checks the lowering of atomic read - -!FIRDialect: func @_QQmain() { -!FIRDialect: %[[VAR_A:.*]] = fir.address_of(@_QFEa) : !fir.ref> -!FIRDialect: %[[VAR_B:.*]] = fir.address_of(@_QFEb) : !fir.ref> -!FIRDialect: %[[VAR_C:.*]] = fir.alloca !fir.logical<4> {bindc_name = "c", uniq_name = "_QFEc"} -!FIRDialect: %[[VAR_D:.*]] = fir.alloca !fir.logical<4> {bindc_name = "d", uniq_name = "_QFEd"} -!FIRDialect: %[[VAR_E:.*]] = fir.address_of(@_QFEe) : !fir.ref> -!FIRDialect: %[[VAR_F:.*]] = fir.address_of(@_QFEf) : !fir.ref> -!FIRDialect: %[[VAR_G:.*]] = fir.alloca f32 {bindc_name = "g", uniq_name = "_QFEg"} -!FIRDialect: %[[VAR_H:.*]] = fir.alloca f32 {bindc_name = "h", uniq_name = "_QFEh"} -!FIRDialect: %[[VAR_X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFEx"} -!FIRDialect: %[[VAR_Y:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFEy"} -!FIRDialect: omp.atomic.read %[[VAR_X]] = %[[VAR_Y]] memory_order(acquire) hint(uncontended) : !fir.ref -!FIRDialect: omp.atomic.read %[[VAR_A]] = %[[VAR_B]] memory_order(relaxed) hint(none) : !fir.ref> -!FIRDialect: omp.atomic.read %[[VAR_C]] = %[[VAR_D]] memory_order(seq_cst) hint(contended) : !fir.ref> -!FIRDialect: omp.atomic.read %[[VAR_E]] = %[[VAR_F]] hint(speculative) : !fir.ref> -!FIRDialect: omp.atomic.read %[[VAR_G]] = %[[VAR_H]] hint(nonspeculative) : !fir.ref -!FIRDialect: omp.atomic.read %[[VAR_G]] = %[[VAR_H]] : !fir.ref -!FIRDialect: return -!FIRDialect: } - -!LLVMDialect: llvm.func @_QQmain() { -!LLVMDialect: %[[LLVM_VAR_A:.*]] = llvm.mlir.addressof @_QFEa : !llvm.ptr> -!LLVMDialect: %[[LLVM_VAR_B:.*]] = llvm.mlir.addressof @_QFEb : !llvm.ptr> -!LLVMDialect: {{.*}} = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_C:.*]] = llvm.alloca {{.*}} x i32 {bindc_name = "c", in_type = !fir.logical<4>, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEc"} : (i64) -> !llvm.ptr -!LLVMDialect: {{.*}} = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_D:.*]] = llvm.alloca {{.*}} x i32 {bindc_name = "d", in_type = !fir.logical<4>, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEd"} : (i64) -> !llvm.ptr -!LLVMDialect: %[[LLVM_VAR_E:.*]] = llvm.mlir.addressof @_QFEe : !llvm.ptr> -!LLVMDialect: %[[LLVM_VAR_F:.*]] = llvm.mlir.addressof @_QFEf : !llvm.ptr> -!LLVMDialect: {{.*}} = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_G:.*]] = llvm.alloca {{.*}} x f32 {bindc_name = "g", in_type = f32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEg"} : (i64) -> !llvm.ptr -!LLVMDialect: {{.*}} = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_H:.*]] = llvm.alloca {{.*}} x f32 {bindc_name = "h", in_type = f32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEh"} : (i64) -> !llvm.ptr -!LLVMDialect: {{.*}} = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_X:.*]] = llvm.alloca {{.*}} x i32 {bindc_name = "x", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEx"} : (i64) -> !llvm.ptr -!LLVMDialect: {{.*}} = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_Y:.*]] = llvm.alloca {{.*}} x i32 {bindc_name = "y", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEy"} : (i64) -> !llvm.ptr -!LLVMDialect: omp.atomic.read %[[LLVM_VAR_X]] = %[[LLVM_VAR_Y]] memory_order(acquire) hint(uncontended) : !llvm.ptr -!LLVMDialect: omp.atomic.read %[[LLVM_VAR_A]] = %[[LLVM_VAR_B]] memory_order(relaxed) hint(none) : !llvm.ptr> -!LLVMDialect: omp.atomic.read %[[LLVM_VAR_C]] = %[[LLVM_VAR_D]] memory_order(seq_cst) hint(contended) : !llvm.ptr -!LLVMDialect: omp.atomic.read %[[LLVM_VAR_E]] = %[[LLVM_VAR_F]] hint(speculative) : !llvm.ptr> -!LLVMDialect: omp.atomic.read %[[LLVM_VAR_G]] = %[[LLVM_VAR_H]] hint(nonspeculative) : !llvm.ptr -!LLVMDialect: omp.atomic.read %[[LLVM_VAR_G]] = %[[LLVM_VAR_H]] : !llvm.ptr -!LLVMDialect: llvm.return -!LLVMDialect: } - -program OmpAtomic - - use omp_lib - integer :: x, y - character :: a, b - logical :: c, d - character(8) :: e, f - real g, h - !$omp atomic acquire read hint(omp_sync_hint_uncontended) - x = y - !$omp atomic relaxed read hint(omp_sync_hint_none) - a = b - !$omp atomic read seq_cst hint(omp_sync_hint_contended) - c = d - !$omp atomic read hint(omp_sync_hint_speculative) - e = f - !$omp atomic read hint(omp_sync_hint_nonspeculative) - g = h - !$omp atomic read - g = h -end program OmpAtomic Index: flang/test/Lower/OpenMP/atomic02.f90 =================================================================== --- flang/test/Lower/OpenMP/atomic02.f90 +++ /dev/null @@ -1,64 +0,0 @@ -! RUN: bbc -fopenmp -emit-fir %s -o - | \ -! RUN: FileCheck %s --check-prefix=FIRDialect -! RUN: bbc -fopenmp %s -o - | fir-opt --fir-to-llvm-ir | \ -! RUN: FileCheck %s --check-prefix=LLVMDialect - -! This test checks the lowering of atomic write - -!FIRDialect: func @_QQmain() { -!FIRDialect: %[[VAR_X:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFEx"} -!FIRDialect: %[[VAR_Y:.*]] = fir.alloca i32 {bindc_name = "y", uniq_name = "_QFEy"} -!FIRDialect: %[[VAR_Z:.*]] = fir.alloca i32 {bindc_name = "z", uniq_name = "_QFEz"} -!FIRDialect: %[[CONST_44:.*]] = arith.constant 44 : i32 -!FIRDialect: omp.atomic.write %[[VAR_X]] = %[[CONST_44]] hint(uncontended) memory_order(seq_cst) : !fir.ref, i32 -!FIRDialect: %[[CONST_7:.*]] = arith.constant 7 : i32 -!FIRDialect: {{.*}} = fir.load %[[VAR_Y]] : !fir.ref -!FIRDialect: %[[VAR_7y:.*]] = arith.muli %[[CONST_7]], {{.*}} : i32 -!FIRDialect: omp.atomic.write %[[VAR_X]] = %[[VAR_7y]] memory_order(relaxed) : !fir.ref, i32 -!FIRDialect: %[[CONST_10:.*]] = arith.constant 10 : i32 -!FIRDialect: {{.*}} = fir.load %[[VAR_X]] : !fir.ref -!FIRDialect: {{.*}} = arith.muli %[[CONST_10]], {{.*}} : i32 -!FIRDialect: {{.*}} = fir.load %[[VAR_Z]] : !fir.ref -!FIRDialect: %[[CONST_2:.*]] = arith.constant 2 : i32 -!FIRDialect: {{.*}} = arith.divsi {{.*}}, %[[CONST_2]] : i32 -!FIRDialect: {{.*}} = arith.addi {{.*}}, {{.*}} : i32 -!FIRDialect: omp.atomic.write %[[VAR_Y]] = {{.*}} hint(speculative) memory_order(release) : !fir.ref, i32 -!FIRDialect: return -!FIRDialect: } - -!LLVMDialect: llvm.func @_QQmain() { -!LLVMDialect: %[[LLVM_VAR_2:.*]] = llvm.mlir.constant(2 : i32) : i32 -!LLVMDialect: %[[LLVM_VAR_10:.*]] = llvm.mlir.constant(10 : i32) : i32 -!LLVMDialect: %[[LLVM_VAR_7:.*]] = llvm.mlir.constant(7 : i32) : i32 -!LLVMDialect: %[[LLVM_VAR_44:.*]] = llvm.mlir.constant(44 : i32) : i32 -!LLVMDialect: %[[LLVM_VAR_1:.*]] = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_X:.*]] = llvm.alloca {{.*}} x i32 {bindc_name = "x", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEx"} : (i64) -> !llvm.ptr -!LLVMDialect: %[[LLVM_VAR_1_SECOND:.*]] = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_Y:.*]] = llvm.alloca {{.*}} x i32 {bindc_name = "y", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEy"} : (i64) -> !llvm.ptr -!LLVMDialect: %[[LLVM_VAR_1_THIRD:.*]] = llvm.mlir.constant(1 : i64) : i64 -!LLVMDialect: %[[LLVM_VAR_Z:.*]] = llvm.alloca {{.*}} x i32 {bindc_name = "z", in_type = i32, operand_segment_sizes = dense<0> : vector<2xi32>, uniq_name = "_QFEz"} : (i64) -> !llvm.ptr -!LLVMDialect: omp.atomic.write %[[LLVM_VAR_X]] = %[[LLVM_VAR_44]] hint(uncontended) memory_order(seq_cst) : !llvm.ptr, i32 -!LLVMDialect: {{.*}} = llvm.load %[[LLVM_VAR_Y]] : !llvm.ptr -!LLVMDialect: %[[LLVM_VAR_MUL_RESULT:.*]] = llvm.mul {{.*}}, %[[LLVM_VAR_7]] : i32 -!LLVMDialect: omp.atomic.write %[[LLVM_VAR_X]] = %[[LLVM_VAR_MUL_RESULT]] memory_order(relaxed) : !llvm.ptr, i32 -!LLVMDialect: {{.*}} = llvm.load %[[LLVM_VAR_X]] : !llvm.ptr -!LLVMDialect: {{.*}} = llvm.mul {{.*}}, %[[LLVM_VAR_10]] : i32 -!LLVMDialect: {{.*}} = llvm.load %[[LLVM_VAR_Z]] : !llvm.ptr -!LLVMDialect: {{.*}} = llvm.sdiv {{.*}}, %[[LLVM_VAR_2]] : i32 -!LLVMDialect: {{.*}} = llvm.add {{.*}} : i32 -!LLVMDialect: omp.atomic.write %[[LLVM_VAR_Y]] = {{.*}} hint(speculative) memory_order(release) : !llvm.ptr, i32 -!LLVMDialect: llvm.return -!LLVMDialect: } - -program OmpAtomicWrite - use omp_lib - integer :: x, y, z - !$omp atomic seq_cst write hint(omp_sync_hint_uncontended) - x = 8*4 + 12 - - !$omp atomic write relaxed - x = 7 * y - - !$omp atomic write release hint(omp_sync_hint_speculative) - y = 10*x + z/2 -end program OmpAtomicWrite Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td =================================================================== --- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td +++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td @@ -813,6 +813,13 @@ `:` type($x) attr-dict }]; let hasVerifier = 1; + let extraClassDeclaration = [{ + /// The number of data operands. + unsigned getNumDataOperands() { return (x() ? 1 : 0) + (v() ? 1 : 0); } + + /// The i-th data operand passed. + Value getDataOperand(unsigned i) { return i == 0 ? x() : v(); } + }]; } def AtomicWriteOp : OpenMP_Op<"atomic.write"> { @@ -847,6 +854,15 @@ attr-dict }]; let hasVerifier = 1; + let extraClassDeclaration = [{ + /// The number of data operands. + unsigned getNumDataOperands() { + return (address() ? 1 : 0) + (value() ? 1 : 0); + } + + /// The i-th data operand passed. + Value getDataOperand(unsigned i) { return i == 0 ? address() : value(); } + }]; } def AtomicUpdateOp : OpenMP_Op<"atomic.update", @@ -996,6 +1012,13 @@ let assemblyFormat = [{ $sym_addr `:` type($sym_addr) `->` type($tls_addr) attr-dict }]; + let extraClassDeclaration = [{ + /// The number of data operands. + unsigned getNumDataOperands() { return sym_addr() ? 1 : 0; } + + /// The i-th data operand passed. + Value getDataOperand(unsigned i) { return i == 0 ? sym_addr() : nullptr; } + }]; } //===----------------------------------------------------------------------===// Index: mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp =================================================================== --- mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp +++ mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp @@ -52,7 +52,23 @@ LogicalResult matchAndRewrite(T curOp, typename T::Adaptor adaptor, ConversionPatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp(curOp, TypeRange(), adaptor.getOperands(), + TypeConverter *converter = ConvertToLLVMPattern::getTypeConverter(); + SmallVector resTypes; + if (failed(converter->convertTypes(curOp->getResultTypes(), resTypes))) + return failure(); + SmallVector convertedOperands; + for (unsigned idx = 0; idx < curOp.getNumDataOperands(); ++idx) { + Value originalDataOperand = curOp.getDataOperand(idx); + if (!originalDataOperand) + return failure(); + if (originalDataOperand.getType().isa()) { + // TODO: Support memref type in data operands + rewriter.notifyMatchFailure(curOp, "memref is not supported yet"); + } else { + convertedOperands.emplace_back(adaptor.getOperands()[idx]); + } + } + rewriter.replaceOpWithNewOp(curOp, resTypes, convertedOperands, curOp->getAttrs()); return success(); } @@ -65,10 +81,10 @@ mlir::omp::MasterOp>( [&](Operation *op) { return typeConverter.isLegal(&op->getRegion(0)); }); target - .addDynamicallyLegalOp( - [&](Operation *op) { - return typeConverter.isLegal(op->getOperandTypes()); - }); + .addDynamicallyLegalOp([&](Operation *op) { + return typeConverter.isLegal(op->getOperandTypes()); + }); } void mlir::populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter, @@ -77,7 +93,8 @@ RegionOpConversion, RegionOpConversion, RegionLessOpConversion, - RegionLessOpConversion>(converter); + RegionLessOpConversion, + RegionLessOpConversion>(converter); } namespace { Index: mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir =================================================================== --- mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir +++ mlir/test/Conversion/OpenMPToLLVM/convert-to-llvmir.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -convert-openmp-to-llvm %s -split-input-file | FileCheck %s +// RUN: mlir-opt -convert-openmp-to-llvm -split-input-file %s | FileCheck %s // CHECK-LABEL: llvm.func @master_block_arg func.func @master_block_arg() { @@ -15,6 +15,8 @@ return } +// ----- + // CHECK-LABEL: llvm.func @branch_loop func.func @branch_loop() { %start = arith.constant 0 : index @@ -44,6 +46,8 @@ return } +// ----- + // CHECK-LABEL: @wsloop // CHECK: (%[[ARG0:.*]]: i64, %[[ARG1:.*]]: i64, %[[ARG2:.*]]: i64, %[[ARG3:.*]]: i64, %[[ARG4:.*]]: i64, %[[ARG5:.*]]: i64) func.func @wsloop(%arg0: index, %arg1: index, %arg2: index, %arg3: index, %arg4: index, %arg5: index) { @@ -62,3 +66,35 @@ } return } + +// ----- + +// CHECK-LABEL: @atomic_write +// CHECK: (%[[ARG0:.*]]: !llvm.ptr) +// CHECK: %[[VAL0:.*]] = llvm.mlir.constant(1 : i32) : i32 +// CHECK: omp.atomic.write %[[ARG0]] = %[[VAL0]] hint(none) memory_order(relaxed) : !llvm.ptr, i32 +func.func @atomic_write(%a: !llvm.ptr) -> () { + %1 = arith.constant 1 : i32 + omp.atomic.write %a = %1 hint(none) memory_order(relaxed) : !llvm.ptr, i32 + return +} + +// ----- + +// CHECK-LABEL: @atomic_read +// CHECK: (%[[ARG0:.*]]: !llvm.ptr, %[[ARG1:.*]]: !llvm.ptr) +// CHECK: omp.atomic.read %[[ARG1]] = %[[ARG0]] memory_order(acquire) hint(contended) : !llvm.ptr +func.func @atomic_read(%a: !llvm.ptr, %b: !llvm.ptr) -> () { + omp.atomic.read %b = %a memory_order(acquire) hint(contended) : !llvm.ptr + return +} + +// ----- + +// CHECK-LABEL: @threadprivate +// CHECK: (%[[ARG0:.*]]: !llvm.ptr) +// CHECK: %[[VAL0:.*]] = omp.threadprivate %[[ARG0]] : !llvm.ptr -> !llvm.ptr +func.func @threadprivate(%a: !llvm.ptr) -> () { + %1 = omp.threadprivate %a : !llvm.ptr -> !llvm.ptr + return +}