1 ! This test checks lowering of OpenMP Threadprivate Directive.
2 ! Test for variables with different kind.
5 !RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
9 integer(kind
=1), save :: i1
10 integer(kind
=2), save :: i2
11 integer(kind
=4), save :: i4
12 integer(kind
=8), save :: i8
13 integer(kind
=16), save :: i16
15 !CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@_QFEi) : !fir.ref<i32>
16 !CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<i32> -> !fir.ref<i32>
17 !CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@_QFEi1) : !fir.ref<i8>
18 !CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<i8> -> !fir.ref<i8>
19 !CHECK-DAG: [[ADDR2:%.*]] = fir.address_of(@_QFEi16) : !fir.ref<i128>
20 !CHECK-DAG: [[NEWADDR2:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref<i128> -> !fir.ref<i128>
21 !CHECK-DAG: [[ADDR3:%.*]] = fir.address_of(@_QFEi2) : !fir.ref<i16>
22 !CHECK-DAG: [[NEWADDR3:%.*]] = omp.threadprivate [[ADDR3]] : !fir.ref<i16> -> !fir.ref<i16>
23 !CHECK-DAG: [[ADDR4:%.*]] = fir.address_of(@_QFEi4) : !fir.ref<i32>
24 !CHECK-DAG: [[NEWADDR4:%.*]] = omp.threadprivate [[ADDR4]] : !fir.ref<i32> -> !fir.ref<i32>
25 !CHECK-DAG: [[ADDR5:%.*]] = fir.address_of(@_QFEi8) : !fir.ref<i64>
26 !CHECK-DAG: [[NEWADDR5:%.*]] = omp.threadprivate [[ADDR5]] : !fir.ref<i64> -> !fir.ref<i64>
27 !$omp threadprivate(i, i1, i2, i4, i8, i16)
29 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR0]] : !fir.ref<i32>
30 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR1]] : !fir.ref<i8>
31 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR2]] : !fir.ref<i128>
32 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR3]] : !fir.ref<i16>
33 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR4]] : !fir.ref<i32>
34 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR5]] : !fir.ref<i64>
35 print *, i
, i1
, i2
, i4
, i8
, i16
38 !CHECK-DAG: [[ADDR39:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<i32> -> !fir.ref<i32>
39 !CHECK-DAG: [[ADDR40:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<i8> -> !fir.ref<i8>
40 !CHECK-DAG: [[ADDR41:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref<i128> -> !fir.ref<i128>
41 !CHECK-DAG: [[ADDR42:%.*]] = omp.threadprivate [[ADDR3]] : !fir.ref<i16> -> !fir.ref<i16>
42 !CHECK-DAG: [[ADDR43:%.*]] = omp.threadprivate [[ADDR4]] : !fir.ref<i32> -> !fir.ref<i32>
43 !CHECK-DAG: [[ADDR44:%.*]] = omp.threadprivate [[ADDR5]] : !fir.ref<i64> -> !fir.ref<i64>
44 !CHECK-DAG: %{{.*}} = fir.load [[ADDR39]] : !fir.ref<i32>
45 !CHECK-DAG: %{{.*}} = fir.load [[ADDR40]] : !fir.ref<i8>
46 !CHECK-DAG: %{{.*}} = fir.load [[ADDR41]] : !fir.ref<i128>
47 !CHECK-DAG: %{{.*}} = fir.load [[ADDR42]] : !fir.ref<i16>
48 !CHECK-DAG: %{{.*}} = fir.load [[ADDR43]] : !fir.ref<i32>
49 !CHECK-DAG: %{{.*}} = fir.load [[ADDR44]] : !fir.ref<i64>
50 print *, i
, i1
, i2
, i4
, i8
, i16
53 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR0]] : !fir.ref<i32>
54 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR1]] : !fir.ref<i8>
55 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR2]] : !fir.ref<i128>
56 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR3]] : !fir.ref<i16>
57 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR4]] : !fir.ref<i32>
58 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR5]] : !fir.ref<i64>
59 print *, i
, i1
, i2
, i4
, i8
, i16
61 !CHECK-DAG: fir.global internal @_QFEi : i32 {
62 !CHECK-DAG: fir.global internal @_QFEi1 : i8 {
63 !CHECK-DAG: fir.global internal @_QFEi16 : i128 {
64 !CHECK-DAG: fir.global internal @_QFEi2 : i16 {
65 !CHECK-DAG: fir.global internal @_QFEi4 : i32 {
66 !CHECK-DAG: fir.global internal @_QFEi8 : i64 {