| 1 |
! This test checks lowering of OpenMP Threadprivate Directive. |
| 2 |
! Test for threadprivate variable double use in use association. |
| 3 |
|
| 4 |
!RUN: %flang_fc1 -emit-hlfir -flang-experimental-hlfir -fopenmp %s -o - | FileCheck %s |
| 5 |
!RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s |
| 6 |
|
| 7 |
! CHECK-LABEL: fir.global @_QMmEx : i32 |
| 8 |
module m |
| 9 |
integer :: x |
| 10 |
!$omp threadprivate(x) |
| 11 |
end |
| 12 |
|
| 13 |
! CHECK-LABEL: func.func @_QMm2Ptest() { |
| 14 |
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMmEx) : !fir.ref<i32> |
| 15 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QMmEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 16 |
! CHECK: %[[VAL_2:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 17 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QMmEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 18 |
! CHECK: fir.call @_QPbar(%[[VAL_3]]#1) {{.*}}: (!fir.ref<i32>) -> () |
| 19 |
! CHECK: return |
| 20 |
! CHECK: } |
| 21 |
|
| 22 |
! CHECK-LABEL: func.func private @_QMm2FtestPinternal_test() {{.*}} { |
| 23 |
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QMmEx) : !fir.ref<i32> |
| 24 |
! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QMmEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 25 |
! CHECK: %[[VAL_2:.*]] = omp.threadprivate %[[VAL_1]]#1 : !fir.ref<i32> -> !fir.ref<i32> |
| 26 |
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QMmEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>) |
| 27 |
! CHECK: fir.call @_QPbar(%[[VAL_3]]#1) {{.*}}: (!fir.ref<i32>) -> () |
| 28 |
! CHECK: return |
| 29 |
! CHECK: } |
| 30 |
|
| 31 |
module m2 |
| 32 |
use m |
| 33 |
contains |
| 34 |
subroutine test() |
| 35 |
use m |
| 36 |
call bar(x) |
| 37 |
contains |
| 38 |
subroutine internal_test() |
| 39 |
use m |
| 40 |
call bar(x) |
| 41 |
end |
| 42 |
end |
| 43 |
end |