xref: /llvm-project/flang/test/Lower/OpenMP/threadprivate-commonblock-use.f90 (revision c1654c38e8b82a075613fd60f19a179b1c7df2a2)
1! This test checks lowering of OpenMP Threadprivate Directive.
2! Test for common block, defined in one module, used in a subroutine of
3! another module and privatized in a nested subroutine.
4
5!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
6
7!CHECK: fir.global common @cmn_(dense<0> : vector<4xi8>) {alignment = 4 : i64} : !fir.array<4xi8>
8module m0
9  common /cmn/ k1
10  !$omp threadprivate(/cmn/)
11end
12
13module  m1
14contains
15  subroutine ss1
16    use m0
17  contains
18!CHECK-LABEL: func private @_QMm1Fss1Pss2
19!CHECK: %[[CMN:.*]] = fir.address_of(@cmn_) : !fir.ref<!fir.array<4xi8>>
20!CHECK: omp.parallel
21!CHECK: %{{.*}} = omp.threadprivate %[[CMN]] : !fir.ref<!fir.array<4xi8>> -> !fir.ref<!fir.array<4xi8>>
22    subroutine ss2
23      !$omp parallel copyin (k1)
24      !$omp end parallel
25    end subroutine ss2
26  end subroutine ss1
27end
28
29end
30