| 1 |
! Test delayed privatization for allocatables: `firstprivate`. |
| 2 |
|
| 3 |
! RUN: split-file %s %t |
| 4 |
|
| 5 |
! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \ |
| 6 |
! RUN: -o - %t/test_ir.f90 2>&1 | FileCheck %s |
| 7 |
! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - %t/test_ir.f90 2>&1 |\ |
| 8 |
! RUN: FileCheck %s |
| 9 |
|
| 10 |
!--- test_ir.f90 |
| 11 |
subroutine delayed_privatization_allocatable |
| 12 |
implicit none |
| 13 |
integer, allocatable :: var1 |
| 14 |
|
| 15 |
!$omp parallel firstprivate(var1) |
| 16 |
var1 = 10 |
| 17 |
!$omp end parallel |
| 18 |
end subroutine |
| 19 |
|
| 20 |
! CHECK-LABEL: omp.private {type = firstprivate} |
| 21 |
! CHECK-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.ref<!fir.box<!fir.heap<i32>>>]] alloc { |
| 22 |
|
| 23 |
! CHECK-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]): |
| 24 |
|
| 25 |
! CHECK: } copy { |
| 26 |
! CHECK: ^bb0(%[[PRIV_ORIG_ARG:.*]]: [[TYPE]], %[[PRIV_PRIV_ARG:.*]]: [[TYPE]]): |
| 27 |
|
| 28 |
! CHECK-NEXT: %[[PRIV_BASE_VAL:.*]] = fir.load %[[PRIV_PRIV_ARG]] |
| 29 |
! CHECK-NEXT: %[[PRIV_BASE_BOX:.*]] = fir.box_addr %[[PRIV_BASE_VAL]] |
| 30 |
! CHECK-NEXT: %[[PRIV_BASE_ADDR:.*]] = fir.convert %[[PRIV_BASE_BOX]] |
| 31 |
! CHECK-NEXT: %[[C0:.*]] = arith.constant 0 : i64 |
| 32 |
! CHECK-NEXT: %[[COPY_COND:.*]] = arith.cmpi ne, %[[PRIV_BASE_ADDR]], %[[C0]] : i64 |
| 33 |
|
| 34 |
! CHECK-NEXT: fir.if %[[COPY_COND]] { |
| 35 |
! CHECK-NEXT: %[[ORIG_BASE_VAL:.*]] = fir.load %[[PRIV_ORIG_ARG]] |
| 36 |
! CHECK-NEXT: %[[ORIG_BASE_ADDR:.*]] = fir.box_addr %[[ORIG_BASE_VAL]] |
| 37 |
! CHECK-NEXT: %[[ORIG_BASE_LD:.*]] = fir.load %[[ORIG_BASE_ADDR]] |
| 38 |
! CHECK-NEXT: hlfir.assign %[[ORIG_BASE_LD]] to %[[PRIV_BASE_BOX]] temporary_lhs |
| 39 |
! CHECK-NEXT: } |
| 40 |
|
| 41 |
! RUN: %flang -c -emit-llvm -fopenmp -mmlir --openmp-enable-delayed-privatization \ |
| 42 |
! RUN: -o - %t/test_compilation_to_obj.f90 | \ |
| 43 |
! RUN: llvm-dis 2>&1 |\ |
| 44 |
! RUN: FileCheck %s -check-prefix=LLVM |
| 45 |
|
| 46 |
!--- test_compilation_to_obj.f90 |
| 47 |
|
| 48 |
program compilation_to_obj |
| 49 |
real, allocatable :: t(:) |
| 50 |
|
| 51 |
!$omp parallel firstprivate(t) |
| 52 |
t(1) = 3.14 |
| 53 |
!$omp end parallel |
| 54 |
|
| 55 |
end program compilation_to_obj |
| 56 |
|
| 57 |
! LLVM: @[[GLOB_VAR:[^[:space:]]+]]t = internal global |
| 58 |
|
| 59 |
! LLVM: define internal void @_QQmain..omp_par |
| 60 |
! LLVM: %[[LOCAL_VAR:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8 |
| 61 |
! LLVM-NEXT: %[[GLOB_VAL:.*]] = load { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr @[[GLOB_VAR]]t, align 8 |
| 62 |
! LLVM-NEXT: store { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] } %[[GLOB_VAL]], ptr %[[LOCAL_VAR]], align 8 |