diff --git a/flang/include/flang/Support/Flags.h b/flang/include/flang/Support/Flags.h index 979699131ad8f..bcbb72f8e50d0 100644 --- a/flang/include/flang/Support/Flags.h +++ b/flang/include/flang/Support/Flags.h @@ -12,5 +12,6 @@ #include "llvm/Support/CommandLine.h" extern llvm::cl::opt enableDelayedPrivatization; +extern llvm::cl::opt enableDelayedPrivatizationStaging; #endif // FORTRAN_SUPPORT_FLAGS_H_ diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index cd06bd5d33ca3..ea8c279962508 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -2227,6 +2227,11 @@ genTargetClauses(lower::AbstractConverter &converter, cp.processThreadLimit(stmtCtx, clauseOps); cp.processTODO( loc, llvm::omp::Directive::OMPD_target); + + // `target private(..)` is only supported in delayed privatization mode. + if (!enableDelayedPrivatization) + cp.processTODO( + loc, llvm::omp::Directive::OMPD_target); } static void genTargetDataClauses( diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index f3865cfb877dc..1c59996d7bd93 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -25,6 +25,7 @@ #include "flang/Semantics/openmp-utils.h" #include "flang/Semantics/symbol.h" #include "flang/Semantics/tools.h" +#include "flang/Support/Flags.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/Frontend/OpenMP/OMP.h.inc" @@ -2735,7 +2736,8 @@ void OmpAttributeVisitor::CreateImplicitSymbols( // 4) not mapped target variable -> firstprivate // - i.e. implicit, but meets OpenMP specification rules for // firstprivate "promotion" - if (IsTargetCaptureImplicitlyFirstprivatizeable(*symbol, prevDSA, + if (enableDelayedPrivatizationStaging && + IsTargetCaptureImplicitlyFirstprivatizeable(*symbol, prevDSA, dataSharingAttributeFlags, dataMappingAttributeFlags, dirContext.defaultMap)) { prevDSA.set(Symbol::Flag::OmpImplicit); diff --git a/flang/lib/Support/Flags.cpp b/flang/lib/Support/Flags.cpp index 3bc8d4685b7dc..02f64981618dd 100644 --- a/flang/lib/Support/Flags.cpp +++ b/flang/lib/Support/Flags.cpp @@ -12,3 +12,9 @@ llvm::cl::opt enableDelayedPrivatization("enable-delayed-privatization", llvm::cl::desc( "Emit private/local variables as clauses/specifiers on MLIR ops."), llvm::cl::init(true)); + +llvm::cl::opt enableDelayedPrivatizationStaging( + "enable-delayed-privatization-staging", + llvm::cl::desc("For partially supported constructs, emit private/local " + "variables as clauses/specifiers on MLIR ops."), + llvm::cl::init(false)); diff --git a/flang/test/Integration/OpenMP/map-types-and-sizes.f90 b/flang/test/Integration/OpenMP/map-types-and-sizes.f90 index 1a266dfff68d0..93f28a7525e19 100644 --- a/flang/test/Integration/OpenMP/map-types-and-sizes.f90 +++ b/flang/test/Integration/OpenMP/map-types-and-sizes.f90 @@ -6,7 +6,8 @@ ! added to this directory and sub-directories. !===----------------------------------------------------------------------===! -!RUN: %flang_fc1 -emit-llvm -fopenmp -fopenmp-version=51 -fopenmp-targets=amdgcn-amd-amdhsa %s -o - | FileCheck %s +!RUN: %flang_fc1 -emit-llvm -fopenmp -mmlir --enable-delayed-privatization-staging=false -fopenmp-version=51 -fopenmp-targets=amdgcn-amd-amdhsa %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NO-FPRIV +!RUN: %flang_fc1 -emit-llvm -fopenmp -mmlir --enable-delayed-privatization-staging=true -fopenmp-version=51 -fopenmp-targets=amdgcn-amd-amdhsa %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV !=============================================================================== @@ -14,7 +15,8 @@ !=============================================================================== !CHECK: @.offload_sizes = private unnamed_addr constant [2 x i64] [i64 4, i64 0] -!CHECK: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 289, i64 288] +!CHECK-FPRIV: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 289, i64 288] +!CHECK-NO-FPRIV: @.offload_maptypes = private unnamed_addr constant [2 x i64] [i64 800, i64 288] subroutine mapType_scalar integer :: a !$omp target @@ -382,7 +384,8 @@ subroutine mapType_nested_derived_type_member_idx() end subroutine !CHECK: @.offload_sizes{{.*}} = private unnamed_addr constant [3 x i64] [i64 8, i64 4, i64 0] -!CHECK: @.offload_maptypes{{.*}} = private unnamed_addr constant [3 x i64] [i64 544, i64 289, i64 288] +!CHECK-FPRIV: @.offload_maptypes{{.*}} = private unnamed_addr constant [3 x i64] [i64 544, i64 289, i64 288] +!CHECK-NO-FPRIV: @.offload_maptypes{{.*}} = private unnamed_addr constant [3 x i64] [i64 544, i64 800, i64 288] subroutine mapType_c_ptr use iso_c_binding, only : c_ptr, c_loc type(c_ptr) :: a @@ -393,7 +396,8 @@ subroutine mapType_c_ptr end subroutine mapType_c_ptr !CHECK: @.offload_sizes{{.*}} = private unnamed_addr constant [2 x i64] [i64 1, i64 0] -!CHECK: @.offload_maptypes{{.*}} = private unnamed_addr constant [2 x i64] [i64 289, i64 288] +!CHECK-FPRIV: @.offload_maptypes{{.*}} = private unnamed_addr constant [2 x i64] [i64 289, i64 288] +!CHECK-NO-FPRIV: @.offload_maptypes{{.*}} = private unnamed_addr constant [2 x i64] [i64 800, i64 288] subroutine mapType_char character :: a !$omp target diff --git a/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map-2.f90 b/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map-2.f90 index 50cff4547bf2a..da13ac157a5c8 100644 --- a/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map-2.f90 +++ b/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map-2.f90 @@ -2,8 +2,8 @@ ! module boundaries. ! RUN: split-file %s %t -! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 %t/imp_scalar_map_module.f90 -o - | FileCheck %s --check-prefix=CHECK-MOD -! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 %t/imp_scalar_map_target.f90 -o - | FileCheck %s --check-prefix=CHECK-PROG +! RUN: bbc -emit-hlfir -fopenmp --enable-delayed-privatization-staging -fopenmp-version=50 %t/imp_scalar_map_module.f90 -o - | FileCheck %s --check-prefix=CHECK-MOD +! RUN: bbc -emit-hlfir -fopenmp --enable-delayed-privatization-staging -fopenmp-version=50 %t/imp_scalar_map_target.f90 -o - | FileCheck %s --check-prefix=CHECK-PROG !--- imp_scalar_map_module.f90 module test_data diff --git a/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map.f90 b/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map.f90 index 1a861ec7d1a68..8ce17671d0221 100644 --- a/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map.f90 +++ b/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-implicit-scalar-map.f90 @@ -1,7 +1,7 @@ ! Tests delayed privatization works for implicit capture of scalars similarly to ! the way it works for explicitly firstprivitized scalars. -! RUN: %flang_fc1 -emit-mlir -fopenmp \ +! RUN: %flang_fc1 -emit-mlir -fopenmp -mmlir --enable-delayed-privatization-staging \ ! RUN: -o - %s 2>&1 | FileCheck %s ! CHECK-LABEL: omp.private {type = firstprivate} @_QFExdgfx_firstprivate_i32 : i32 copy { diff --git a/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90 b/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90 index b6fc246799d32..3cc50129dfab6 100644 --- a/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90 +++ b/flang/test/Lower/OpenMP/DelayedPrivatization/target-private-multiple-variables.f90 @@ -1,7 +1,9 @@ ! Tests delayed privatization for `targets ... private(..)` for allocatables. -! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s -! RUN: bbc -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s +! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization-staging \ +! RUN: -o - %s 2>&1 | FileCheck %s +! RUN: bbc -emit-hlfir -fopenmp --enable-delayed-privatization-staging -o - %s 2>&1 \ +! RUN: | FileCheck %s subroutine target_allocatable(lb, ub, l) implicit none diff --git a/flang/test/Lower/OpenMP/DelayedPrivatization/target-teams-private-implicit-scalar-map.f90 b/flang/test/Lower/OpenMP/DelayedPrivatization/target-teams-private-implicit-scalar-map.f90 index cb3e4919a5e4c..002b0da48af13 100644 --- a/flang/test/Lower/OpenMP/DelayedPrivatization/target-teams-private-implicit-scalar-map.f90 +++ b/flang/test/Lower/OpenMP/DelayedPrivatization/target-teams-private-implicit-scalar-map.f90 @@ -1,7 +1,7 @@ ! Tests delayed privatization works for implicit capture of scalars similarly to ! the way it works for explicitly firstprivitized scalars. -! RUN: %flang_fc1 -emit-mlir -fopenmp \ +! RUN: %flang_fc1 -emit-mlir -fopenmp -mmlir --enable-delayed-privatization-staging \ ! RUN: -o - %s 2>&1 | FileCheck %s !CHECK: omp.private {type = private} @[[SYM_K:.*]] : i32 diff --git a/flang/test/Lower/OpenMP/defaultmap.f90 b/flang/test/Lower/OpenMP/defaultmap.f90 index 4a05e3e62aa7f..345c18bda465f 100644 --- a/flang/test/Lower/OpenMP/defaultmap.f90 +++ b/flang/test/Lower/OpenMP/defaultmap.f90 @@ -1,4 +1,5 @@ -!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV +!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -mmlir --enable-delayed-privatization-staging=false %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NO-FPRIV +!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -mmlir --enable-delayed-privatization-staging=true %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV subroutine defaultmap_allocatable_present() implicit none @@ -49,9 +50,11 @@ subroutine defaultmap_pointer_to() integer, dimension(:), pointer :: arr_ptr(:) integer :: scalar_int +! CHECK-NO-FPRIV: %[[MAP_1:.*]] = omp.map.info var_ptr({{.*}} : !fir.ref>>>, !fir.box>>) map_clauses(implicit, to) capture(ByRef) var_ptr_ptr({{.*}}) bounds({{.*}}) -> !fir.llvm_ptr>> {name = ""} ! CHECK-FPRIV: %[[MAP_1:.*]] = omp.map.info var_ptr({{.*}} : !fir.ref>>>, !fir.box>>) map_clauses(implicit, to) capture(ByRef) var_ptr_ptr({{.*}}) bounds({{.*}}) -> !fir.llvm_ptr>> {name = ""} ! CHECK: %[[MAP_2:.*]] = omp.map.info var_ptr({{.*}} : !fir.ref>>>, !fir.box>>) map_clauses(always, implicit, to) capture(ByRef) members({{.*}}) -> !fir.ref>>> {name = "arr_ptr"} ! CHECK-FPRIV: %[[MAP_3:.*]] = omp.map.info var_ptr({{.*}} : !fir.ref, i32) map_clauses(to) capture(ByCopy) -> !fir.ref +! CHECK-NO-FPRIV: %[[MAP_3:.*]] = omp.map.info var_ptr({{.*}} : !fir.ref, i32) map_clauses(implicit) capture(ByCopy) -> !fir.ref {name = "scalar_int"} !$omp target defaultmap(to: pointer) arr_ptr(1) = scalar_int + 20 !$omp end target diff --git a/flang/test/Lower/OpenMP/optional-argument-map-2.f90 b/flang/test/Lower/OpenMP/optional-argument-map-2.f90 index f2eaa71e3fa1a..58a3654bf7f94 100644 --- a/flang/test/Lower/OpenMP/optional-argument-map-2.f90 +++ b/flang/test/Lower/OpenMP/optional-argument-map-2.f90 @@ -1,4 +1,5 @@ -!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV +!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization-staging=false %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NO-FPRIV +!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization-staging=true %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV module mod implicit none @@ -82,3 +83,36 @@ end module mod ! CHECK-FPRIV: hlfir.assign %[[VAL_28]]#0 to %[[VAL_26]]#0 : !fir.boxchar<1>, !fir.ref> ! CHECK-FPRIV: return ! CHECK-FPRIV: } +! CHECK-NO-FPRIV: %[[VAL_8:.*]] = fir.is_present %[[VAL_3]]#1 : (!fir.ref>) -> i1 +! CHECK-NO-FPRIV: %[[VAL_9:.*]] = arith.constant 0 : index +! CHECK-NO-FPRIV: %[[VAL_10:.*]] = arith.constant 1 : index +! CHECK-NO-FPRIV: %[[VAL_11:.*]]:2 = fir.if %[[VAL_8]] -> (index, index) { +! CHECK-NO-FPRIV: %[[VAL_12:.*]]:2 = fir.unboxchar %[[VAL_3]]#0 : (!fir.boxchar<1>) -> (!fir.ref>, index) +! CHECK-NO-FPRIV: fir.result %[[VAL_12]]#1, %[[VAL_10]] : index, index +! CHECK-NO-FPRIV: } else { +! CHECK-NO-FPRIV: fir.result %[[VAL_9]], %[[VAL_9]] : index, index +! CHECK-NO-FPRIV: } +! CHECK-NO-FPRIV: %[[VAL_13:.*]] = arith.subi %[[VAL_14:.*]]#0, %[[VAL_10]] : index +! CHECK-NO-FPRIV: %[[VAL_15:.*]] = omp.map.bounds lower_bound(%[[VAL_9]] : index) upper_bound(%[[VAL_13]] : index) extent(%[[VAL_14]]#0 : index) stride(%[[VAL_14]]#1 : index) start_idx(%[[VAL_9]] : index) {stride_in_bytes = true} +! CHECK-NO-FPRIV: %[[VAL_16:.*]] = omp.map.info var_ptr(%[[VAL_3]]#1 : !fir.ref>, !fir.char<1,?>) map_clauses(implicit) capture(ByCopy) bounds(%[[VAL_15]]) -> !fir.ref> {name = "a"} +! CHECK-NO-FPRIV: fir.store %[[ARG0]] to %[[VAL_0]] : !fir.ref> +! CHECK-NO-FPRIV: %[[VAL_17:.*]] = arith.constant 0 : index +! CHECK-NO-FPRIV: %[[VAL_18:.*]] = arith.constant 1 : index +! CHECK-NO-FPRIV: %[[VAL_19:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref>, index) +! CHECK-NO-FPRIV: %[[VAL_20:.*]] = arith.subi %[[VAL_19]]#1, %[[VAL_18]] : index +! CHECK-NO-FPRIV: %[[VAL_21:.*]] = omp.map.bounds lower_bound(%[[VAL_17]] : index) upper_bound(%[[VAL_20]] : index) extent(%[[VAL_19]]#1 : index) stride(%[[VAL_18]] : index) start_idx(%[[VAL_17]] : index) {stride_in_bytes = true} +! CHECK-NO-FPRIV: %[[VAL_22:.*]] = fir.box_offset %[[VAL_0]] base_addr : (!fir.ref>) -> !fir.llvm_ptr>> +! CHECK-NO-FPRIV: %[[VAL_23:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref>, !fir.boxchar<1>) map_clauses(implicit, to) capture(ByRef) var_ptr_ptr(%[[VAL_22]] : !fir.llvm_ptr>>, !fir.char<1,?>) bounds(%14) -> !fir.llvm_ptr>> {name = ""} +! CHECK-NO-FPRIV: %[[VAL_24:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref>, !fir.boxchar<1>) map_clauses(always, implicit, to) capture(ByRef) members(%[[VAL_23]] : [0] : !fir.llvm_ptr>>) -> !fir.ref> {name = ""} +! CHECK-NO-FPRIV: %[[VAL_26:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref>, !fir.boxchar<1>) map_clauses(attach, ref_ptr, ref_ptee) capture(ByRef) var_ptr_ptr(%[[VAL_22]] : !fir.llvm_ptr>>, !fir.char<1,?>) bounds(%[[VAL_21]]) -> !fir.ref> +! CHECK-NO-FPRIV: omp.target kernel_type(generic) map_entries(%[[VAL_7]] -> %[[VAL_27:.*]], %[[VAL_16]] -> %[[VAL_28:.*]], %[[VAL_24]] -> %[[VAL_29:.*]], %[[VAL_26]] -> %[[VAL_30:.*]], %[[VAL_23]] -> %[[VAL_30:.*]] : !fir.ref>, !fir.ref>, !fir.ref>, !fir.ref>, !fir.llvm_ptr>>) { +! CHECK-NO-FPRIV: %[[VAL_31:.*]] = fir.load %[[VAL_29]] : !fir.ref> +! CHECK-NO-FPRIV: %[[VAL_32:.*]]:2 = fir.unboxchar %[[VAL_31]] : (!fir.boxchar<1>) -> (!fir.ref>, index) +! CHECK-NO-FPRIV: %[[VAL_33:.*]] = arith.constant 4 : index +! CHECK-NO-FPRIV: %[[VAL_34:.*]]:2 = hlfir.declare %[[VAL_27]] typeparams %[[VAL_33]] {uniq_name = "_QMmodFroutine_boxcharEb"} : (!fir.ref>, index) -> (!fir.ref>, !fir.ref>) +! CHECK-NO-FPRIV: %[[VAL_35:.*]]:2 = hlfir.declare %[[VAL_28]] typeparams %[[VAL_32]]#1 {fortran_attrs = #fir.var_attrs, uniq_name = "_QMmodFroutine_boxcharEa"} : (!fir.ref>, index) -> (!fir.boxchar<1>, !fir.ref>) +! CHECK-NO-FPRIV: hlfir.assign %[[VAL_35]]#0 to %[[VAL_34]]#0 : !fir.boxchar<1>, !fir.ref> +! CHECK-NO-FPRIV: omp.terminator +! CHECK-NO-FPRIV: } +! CHECK-NO-FPRIV: return +! CHECK-NO-FPRIV:} diff --git a/flang/test/Lower/OpenMP/target-map-complex.f90 b/flang/test/Lower/OpenMP/target-map-complex.f90 index 06a891b9a230c..34ddb9e79e10e 100644 --- a/flang/test/Lower/OpenMP/target-map-complex.f90 +++ b/flang/test/Lower/OpenMP/target-map-complex.f90 @@ -1,17 +1,21 @@ -!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s +!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization-staging=false %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NO-FPRIV +!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization-staging=true %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV ! Check that the complex*4 is passed by value. but complex*8 is passed by ! reference -!CHECK: omp.private {type = firstprivate} @[[PRIV_64:.*]] : complex copy { -!CHECK: omp.private {type = firstprivate} @[[PRIV_32:.*]] : complex copy { +!CHECK-FPRIV: omp.private {type = firstprivate} @[[PRIV_64:.*]] : complex copy { +!CHECK-FPRIV: omp.private {type = firstprivate} @[[PRIV_32:.*]] : complex copy { !CHECK-LABEL: func.func @_QMmPbar() !CHECK: %[[V1:[0-9]+]]:2 = hlfir.declare {{.*}} (!fir.ref>) -> (!fir.ref>, !fir.ref>) !CHECK: %[[V0:[0-9]+]]:2 = hlfir.declare {{.*}} (!fir.ref>) -> (!fir.ref>, !fir.ref>) -!CHECK: %[[V2:[0-9]+]] = omp.map.info var_ptr(%[[V1]]#0 : !fir.ref>, complex) {{.*}} capture(ByCopy) -!CHECK: %[[V3:[0-9]+]] = omp.map.info var_ptr(%[[V0]]#0 : !fir.ref>, complex) {{.*}} capture(ByRef) -!CHECK: omp.target kernel_type(generic) map_entries(%[[V2]] -> {{.*}}, %[[V3]] -> {{.*}} : !fir.ref>, !fir.ref>) private(@[[PRIV_32]] %[[V1]]#0 -> %{{.*}} [map_idx=0], @[[PRIV_64]] %[[V0]]#0 -> %{{.*}} [map_idx=1] : !fir.ref>, !fir.ref>) { +!CHECK-FPRIV: %[[V2:[0-9]+]] = omp.map.info var_ptr(%[[V1]]#0 : !fir.ref>, complex) {{.*}} capture(ByCopy) +!CHECK-FPRIV: %[[V3:[0-9]+]] = omp.map.info var_ptr(%[[V0]]#0 : !fir.ref>, complex) {{.*}} capture(ByRef) +!CHECK-FPRIV: omp.target kernel_type(generic) map_entries(%[[V2]] -> {{.*}}, %[[V3]] -> {{.*}} : !fir.ref>, !fir.ref>) private(@[[PRIV_32]] %[[V1]]#0 -> %{{.*}} [map_idx=0], @[[PRIV_64]] %[[V0]]#0 -> %{{.*}} [map_idx=1] : !fir.ref>, !fir.ref>) { +!CHECK-NO-FPRIV: %[[V2:[0-9]+]] = omp.map.info var_ptr(%[[V1]]#1 : !fir.ref>, complex) {{.*}} capture(ByCopy) +!CHECK-NO-FPRIV: %[[V3:[0-9]+]] = omp.map.info var_ptr(%[[V0]]#1 : !fir.ref>, complex) {{.*}} capture(ByRef) +!CHECK-NO-FPRIV: omp.target kernel_type(generic) map_entries(%[[V2]] -> {{.*}}, %[[V3]] -> {{.*}} : !fir.ref>, !fir.ref>) module m implicit none diff --git a/flang/test/Lower/OpenMP/target-scope.f90 b/flang/test/Lower/OpenMP/target-scope.f90 index 394b2d869edb2..de3bee3bdcacb 100644 --- a/flang/test/Lower/OpenMP/target-scope.f90 +++ b/flang/test/Lower/OpenMP/target-scope.f90 @@ -28,7 +28,7 @@ subroutine target_scope_basic() !$omp target ! CHECK: omp.map.info var_ptr(%{{.*}} : !fir.ref, i32) - ! CHECK: omp.target kernel_type(generic) map_entries(%{{.*}} -> %{{.*}} : !fir.ref) private({{.*}} -> %[[XARG:.*]] [map_idx=0] : !fir.ref) { + ! CHECK: omp.target kernel_type(generic) map_entries(%{{.*}} -> %[[XARG:.*]] : !fir.ref) { ! CHECK: hlfir.declare %[[XARG]] {uniq_name = "_QFtarget_scope_basicEx"} ! CHECK: omp.scope { !$omp scope @@ -45,7 +45,7 @@ subroutine target_scope_nowait() x = 10 !$omp target - ! CHECK: omp.target kernel_type(generic) map_entries(%{{.*}} -> %{{.*}} : !fir.ref) private({{.*}} -> %[[XARG:.*]] [map_idx=0] : !fir.ref) { + ! CHECK: omp.target kernel_type(generic) map_entries(%{{.*}} -> %[[XARG:.*]] : !fir.ref) { ! CHECK: hlfir.declare %[[XARG]] {uniq_name = "_QFtarget_scope_nowaitEx"} ! CHECK: omp.scope nowait { !$omp scope diff --git a/flang/test/Lower/OpenMP/target.f90 b/flang/test/Lower/OpenMP/target.f90 index 1dd09322e9826..3f36759da2a55 100644 --- a/flang/test/Lower/OpenMP/target.f90 +++ b/flang/test/Lower/OpenMP/target.f90 @@ -1,5 +1,6 @@ ! The "thread_limit" clause was added to the "target" construct in OpenMP 5.1. -!RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=51 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV +!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization-staging=false -fopenmp-version=51 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-NO-FPRIV +!RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --enable-delayed-privatization-staging=true -fopenmp-version=51 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-FPRIV !=============================================================================== ! Target_Enter Simple @@ -433,8 +434,11 @@ end subroutine omp_target_implicit subroutine omp_target_implicit_nested integer::a, b + !CHECK-NO-FPRIV: omp.target kernel_type(generic) map_entries(%{{.*}} -> %[[ARG0:.*]], %{{.*}} -> %[[ARG1:.*]] : !fir.ref, !fir.ref) { !CHECK-FPRIV: omp.target kernel_type(generic) map_entries(%{{.*}} -> %[[ARG0:.*]], %{{.*}} -> %[[ARG1:.*]] : !fir.ref, !fir.ref) private(@{{.*}} %{{.*}} -> %[[ARG2:.*]] [map_idx=0], @{{.*}} %{{.*}} -> %[[ARG3:.*]] [map_idx=1] : !fir.ref, !fir.ref) { !$omp target + !CHECK-NO-FPRIV: %[[VAL_8:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFomp_target_implicit_nestedEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) + !CHECK-NO-FPRIV: %[[VAL_9:.*]]:2 = hlfir.declare %[[ARG1]] {uniq_name = "_QFomp_target_implicit_nestedEb"} : (!fir.ref) -> (!fir.ref, !fir.ref) !CHECK-FPRIV: %[[VAL_8:.*]]:2 = hlfir.declare %[[ARG2]] {uniq_name = "_QFomp_target_implicit_nestedEa"} : (!fir.ref) -> (!fir.ref, !fir.ref) !CHECK-FPRIV: %[[VAL_9:.*]]:2 = hlfir.declare %[[ARG3]] {uniq_name = "_QFomp_target_implicit_nestedEb"} : (!fir.ref) -> (!fir.ref, !fir.ref) @@ -670,12 +674,17 @@ subroutine target_unstructured integer :: i = 1 !CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFtarget_unstructuredEj"} : (!fir.ref) -> (!fir.ref, !fir.ref) integer :: j = 11 + !CHECK-NO-FPRIV: %[[VAL_4:.*]] = omp.map.info var_ptr(%[[VAL_1]]#1 : !fir.ref, i32) map_clauses(implicit) capture(ByCopy) -> !fir.ref {name = "i"} + !CHECK-NO-FPRIV: %[[VAL_5:.*]] = omp.map.info var_ptr(%[[VAL_3]]#1 : !fir.ref, i32) map_clauses(implicit) capture(ByCopy) -> !fir.ref {name = "j"} + !CHECK-NO-FPRIV: omp.target kernel_type(generic) map_entries(%[[VAL_4]] -> %[[VAL_6:.*]], %[[VAL_5]] -> %[[VAL_7:.*]] : !fir.ref, !fir.ref) { !CHECK-FPRIV: %[[VAL_4:.*]] = omp.map.info var_ptr(%[[VAL_1]]#0 : !fir.ref, i32) map_clauses(to) capture(ByCopy) -> !fir.ref !CHECK-FPRIV: %[[VAL_5:.*]] = omp.map.info var_ptr(%[[VAL_3]]#0 : !fir.ref, i32) map_clauses(to) capture(ByCopy) -> !fir.ref !CHECK-FPRIV: omp.target kernel_type(generic) map_entries(%[[VAL_4]] -> %[[ARG_0:.*]], %[[VAL_5]] -> %[[ARG_1:.*]] : !fir.ref, !fir.ref) private(@{{.*}} %[[VAL_1]]#0 -> %[[ARG_2:.*]] [map_idx=0], @{{.*}} %[[VAL_3]]#0 -> %[[ARG_3:.*]] [map_idx=1] : !fir.ref, !fir.ref) { !$omp target !CHECK-FPRIV: %[[VAL_8:.*]]:2 = hlfir.declare %[[ARG_2]] {uniq_name = "_QFtarget_unstructuredEi"} : (!fir.ref) -> (!fir.ref, !fir.ref) !CHECK-FPRIV: %[[VAL_9:.*]]:2 = hlfir.declare %[[ARG_3]] {uniq_name = "_QFtarget_unstructuredEj"} : (!fir.ref) -> (!fir.ref, !fir.ref) + !CHECK-NO-FPRIV: %[[VAL_8:.*]]:2 = hlfir.declare %[[VAL_6]] {uniq_name = "_QFtarget_unstructuredEi"} : (!fir.ref) -> (!fir.ref, !fir.ref) + !CHECK-NO-FPRIV: %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_7]] {uniq_name = "_QFtarget_unstructuredEj"} : (!fir.ref) -> (!fir.ref, !fir.ref) !CHECK: ^bb1: do while (i <= j) diff --git a/flang/test/Semantics/OpenMP/symbol08.f90 b/flang/test/Semantics/OpenMP/symbol08.f90 index c803ec5ad8ab9..bf0f724669fa2 100644 --- a/flang/test/Semantics/OpenMP/symbol08.f90 +++ b/flang/test/Semantics/OpenMP/symbol08.f90 @@ -133,8 +133,8 @@ subroutine dotprod (b, c, n, block_size, num_teams, block_threads) !$omp teams num_teams(num_teams) thread_limit(block_threads) reduction(+: sum) !$omp distribute !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/i0 (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4) - !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/n HostAssoc INTEGER(4) - !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/block_size HostAssoc INTEGER(4) + !REF: /dotprod/n + !REF: /dotprod/block_size do i0=1,n,block_size !$omp parallel do reduction(+: sum) !DEF: /dotprod/OtherConstruct1/OtherConstruct1/OtherConstruct1/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)