Debian Codegraph @

flang/test/Lower/OpenMP/delayed-privatization-character-array.f90

raw
1 ! Test delayed privatization for the `CHARACTER` array type.
2
3 ! RUN: split-file %s %t
4
5 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \
6 ! RUN: -o - %t/static_len.f90 2>&1 | FileCheck %s --check-prefix=STATIC_LEN
7 ! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - %t/static_len.f90 2>&1 \
8 ! RUN: | FileCheck %s --check-prefix=STATIC_LEN
9
10 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \
11 ! RUN: -o - %t/dyn_len.f90 2>&1 | FileCheck %s --check-prefix=DYN_LEN
12 ! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - %t/dyn_len.f90 2>&1 \
13 ! RUN: | FileCheck %s --check-prefix=DYN_LEN
14
15 !--- static_len.f90
16 subroutine delayed_privatization_character_array_static_len(var1)
17 implicit none
18 character(len = 10) :: var1(5)
19
20 !$omp parallel firstprivate(var1)
21 var1(1) = "test"
22 !$omp end parallel
23 end subroutine
24
25 ! STATIC_LEN-LABEL: omp.private {type = firstprivate}
26 ! STATIC_LEN-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.ref<!fir.array<5x!fir.char<1,10>>>]] alloc {
27
28 ! STATIC_LEN-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
29 ! STATIC_LEN-DAG: %[[C5:.*]] = arith.constant 5 : index
30 ! STATIC_LEN-DAG: %[[C10:.*]] = arith.constant 10 : index
31 ! STATIC_LEN-NEXT: %[[PRIV_ALLOC:.*]] = fir.alloca !fir.array<5x!fir.char<1,10>>
32 ! STATIC_LEN-NEXT: %[[ARRAY_SHAPE:.*]] = fir.shape %[[C5]]
33 ! STATIC_LEN-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOC]](%[[ARRAY_SHAPE]]) typeparams %[[C10]]
34 ! STATIC_LEN-NEXT: omp.yield(%[[PRIV_DECL]]#0
35
36 ! STATIC_LEN-NEXT: } copy {
37 ! STATIC_LEN-NEXT: ^bb0(%[[PRIV_ORIG_ARG:.*]]: [[TYPE]], %[[PRIV_PRIV_ARG:.*]]: [[TYPE]]):
38 ! STATIC_LEN-NEXT: hlfir.assign %[[PRIV_ORIG_ARG]] to %[[PRIV_PRIV_ARG]]
39
40 ! STATIC_LEN-NEXT: omp.yield(%[[PRIV_PRIV_ARG]]
41 ! STATIC_LEN-NEXT: }
42
43 !--- dyn_len.f90
44 subroutine delayed_privatization_character_array_dynamic_len(var1, char_len, array_len)
45 implicit none
46 integer(8):: char_len
47 integer(8):: array_len
48 character(len = char_len) :: var1(array_len)
49
50 !$omp parallel private(var1)
51 var1(1) = "test"
52 !$omp end parallel
53 end subroutine
54
55 ! DYN_LEN-LABEL: omp.private {type = private}
56 ! DYN_LEN-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.box<!fir.array<\?x!fir.char<1,\?>>>]] alloc {
57
58 ! DYN_LEN-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
59
60 ! DYN_LEN: %[[C0:.*]] = arith.constant 0 : index
61 ! DYN_LEN-NEXT: %[[BOX_DIM:.*]]:3 = fir.box_dims %[[PRIV_ARG]], %[[C0]]
62 ! DYN_LEN: %[[CHAR_LEN:.*]] = fir.box_elesize %[[PRIV_ARG]]
63 ! DYN_LEN-NEXT: %[[PRIV_ALLOC:.*]] = fir.alloca !fir.array<?x!fir.char<1,?>>(%[[CHAR_LEN]] : index)
64 ! DYN_LEN-NEXT: %[[ARRAY_SHAPE:.*]] = fir.shape
65 ! DYN_LEN-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOC]](%[[ARRAY_SHAPE]]) typeparams %[[CHAR_LEN]]
66
67 ! DYN_LEN-NEXT: omp.yield(%[[PRIV_DECL]]#0