1 ! REQUIRES: openmp_runtime
3 !RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s
5 !CHECK: omp.critical.declare @help2
6 !CHECK: omp.critical.declare @help1 hint(contended)
8 subroutine omp_critical()
11 !CHECK: omp.critical(@help1)
12 !$OMP CRITICAL(help1) HINT(omp_lock_hint_contended)
14 !CHECK: omp.terminator
15 !$OMP END CRITICAL(help1)
17 ! Test that the same name can be used again
18 ! Also test with the zero hint expression
19 !CHECK: omp.critical(@help2)
20 !$OMP CRITICAL(help2) HINT(omp_lock_hint_none)
22 !CHECK: omp.terminator
23 !$OMP END CRITICAL(help2)
28 !CHECK: omp.terminator
30 end subroutine omp_critical
33 ! Tests that privatization for pre-determined variables (here `i`) is properly
35 subroutine predetermined_privatization()
41 !CHECK: %[[PRIV_I_ALLOC:.*]] = fir.alloca i32 {bindc_name = "i", pinned, {{.*}}}
42 !CHECK: %[[PRIV_I_DECL:.*]]:2 = hlfir.declare %[[PRIV_I_ALLOC]]
45 !CHECK: omp.loop_nest (%[[IV:[^[:space:]]+]])
46 !CHECK: fir.store %[[IV]] to %[[PRIV_I_DECL]]#1
55 ! https://github.com/llvm/llvm-project/issues/75767
56 !CHECK-LABEL: func @_QPparallel_critical_privatization(
57 subroutine parallel_critical_privatization()
60 !CHECK: %[[I:.*]] = fir.alloca i32 {bindc_name = "i", uniq_name = "_QFparallel_critical_privatizationEi"}
61 !CHECK: %[[I_DECL:.*]]:2 = hlfir.declare %[[I]] {uniq_name = "_QFparallel_critical_privatizationEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
62 !CHECK: omp.parallel private(@{{.*}} %[[I_DECL]]#0 -> %[[PRIV_I:.*]] : !fir.ref<i32>) {
63 !CHECK: %[[PRIV_I_DECL:.*]]:2 = hlfir.declare %[[PRIV_I]] {uniq_name = "_QFparallel_critical_privatizationEi"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
64 !$omp parallel default(firstprivate)
65 !CHECK: omp.critical {
67 !CHECK: %[[C200:.*]] = arith.constant 200 : i32
68 !CHECK: hlfir.assign %[[C200]] to %[[PRIV_I_DECL]]#0 : i32, !fir.ref<i32>