1 ! This test checks lowering of OpenMP Threadprivate Directive.
2 ! Test for real, logical, complex, and derived type.
4 !RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
16 !$omp threadprivate(x, y, z, t)
18 !CHECK-DAG: fir.global @_QMtestEt : !fir.type<_QMtestTmy_type{t_i:i32,t_arr:!fir.array<5xf32>}> {
19 !CHECK-DAG: fir.global @_QMtestEx : f32 {
20 !CHECK-DAG: fir.global @_QMtestEy : !fir.complex<4> {
21 !CHECK-DAG: fir.global @_QMtestEz : !fir.logical<4> {
25 !CHECK-DAG: [[ADDR0:%.*]] = fir.address_of(@_QMtestEt) : !fir.ref<!fir.type<_QMtestTmy_type{t_i:i32,t_arr:!fir.array<5xf32>}>>
26 !CHECK-DAG: [[NEWADDR0:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.type<_QMtestTmy_type{t_i:i32,t_arr:!fir.array<5xf32>}>> -> !fir.ref<!fir.type<_QMtestTmy_type{t_i:i32,t_arr:!fir.array<5xf32>}>>
27 !CHECK-DAG: [[ADDR1:%.*]] = fir.address_of(@_QMtestEx) : !fir.ref<f32>
28 !CHECK-DAG: [[NEWADDR1:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<f32> -> !fir.ref<f32>
29 !CHECK-DAG: [[ADDR2:%.*]] = fir.address_of(@_QMtestEy) : !fir.ref<!fir.complex<4>>
30 !CHECK-DAG: [[NEWADDR2:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref<!fir.complex<4>> -> !fir.ref<!fir.complex<4>>
31 !CHECK-DAG: [[ADDR3:%.*]] = fir.address_of(@_QMtestEz) : !fir.ref<!fir.logical<4>>
32 !CHECK-DAG: [[NEWADDR3:%.*]] = omp.threadprivate [[ADDR3]] : !fir.ref<!fir.logical<4>> -> !fir.ref<!fir.logical<4>>
33 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR1]] : !fir.ref<f32>
34 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR2]] : !fir.ref<!fir.complex<4>>
35 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR3]] : !fir.ref<!fir.logical<4>>
36 !CHECK-DAG: %{{.*}} = fir.coordinate_of [[NEWADDR0]]
37 print *, x
, y
, z
, t
%t_i
40 !CHECK-DAG: [[ADDR38:%.*]] = omp.threadprivate [[ADDR0]] : !fir.ref<!fir.type<_QMtestTmy_type{t_i:i32,t_arr:!fir.array<5xf32>}>> -> !fir.ref<!fir.type<_QMtestTmy_type{t_i:i32,t_arr:!fir.array<5xf32>}>>
41 !CHECK-DAG: [[ADDR39:%.*]] = omp.threadprivate [[ADDR1]] : !fir.ref<f32> -> !fir.ref<f32>
42 !CHECK-DAG: [[ADDR40:%.*]] = omp.threadprivate [[ADDR2]] : !fir.ref<!fir.complex<4>> -> !fir.ref<!fir.complex<4>>
43 !CHECK-DAG: [[ADDR41:%.*]] = omp.threadprivate [[ADDR3]] : !fir.ref<!fir.logical<4>> -> !fir.ref<!fir.logical<4>>
44 !CHECK-DAG: %{{.*}} = fir.load [[ADDR39]] : !fir.ref<f32>
45 !CHECK-DAG: %{{.*}} = fir.load [[ADDR40]] : !fir.ref<!fir.complex<4>>
46 !CHECK-DAG: %{{.*}} = fir.load [[ADDR41]] : !fir.ref<!fir.logical<4>>
47 !CHECK-DAG: %{{.*}} = fir.coordinate_of [[ADDR38]]
48 print *, x
, y
, z
, t
%t_i
51 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR1]] : !fir.ref<f32>
52 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR2]] : !fir.ref<!fir.complex<4>>
53 !CHECK-DAG: %{{.*}} = fir.load [[NEWADDR3]] : !fir.ref<!fir.logical<4>>
54 !CHECK-DAG: %{{.*}} = fir.coordinate_of [[NEWADDR0]]
55 print *, x
, y
, z
, t
%t_i