[flang-commits] [flang] 29cdc8f - [flang][OpenMP] Fix nested privatization of allocatable (#96968)
via flang-commits
flang-commits at lists.llvm.org
Mon Jul 1 10:10:38 PDT 2024
Author: Leandro Lupori
Date: 2024-07-01T14:10:35-03:00
New Revision: 29cdc8f9ca58411992d3fa5afd89e0628df24679
URL: https://github.com/llvm/llvm-project/commit/29cdc8f9ca58411992d3fa5afd89e0628df24679
DIFF: https://github.com/llvm/llvm-project/commit/29cdc8f9ca58411992d3fa5afd89e0628df24679.diff
LOG: [flang][OpenMP] Fix nested privatization of allocatable (#96968)
In nested constructs where a given variable is privatized more than
once, using the default clause, the innermost host association symbol
will point to the previous host association symbol.
Such symbol lacks the allocatable attribute and can't be used to
generate the type of the symbol to be cloned. Use the ultimate
symbol instead.
Fixes #85594, #80398
Added:
flang/test/Lower/OpenMP/task2.f90
Modified:
flang/lib/Lower/Bridge.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 50f58843ec70b..d4c5053927539 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -625,7 +625,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
const auto *details = sym.detailsIf<Fortran::semantics::HostAssocDetails>();
assert(details && "No host-association found");
const Fortran::semantics::Symbol &hsym = details->symbol();
- mlir::Type hSymType = genType(hsym);
+ mlir::Type hSymType = genType(hsym.GetUltimate());
Fortran::lower::SymbolBox hsb =
lookupSymbol(hsym, /*symMap=*/nullptr, /*forceHlfirBase=*/true);
diff --git a/flang/test/Lower/OpenMP/task2.f90 b/flang/test/Lower/OpenMP/task2.f90
new file mode 100644
index 0000000000000..ce491d95e9397
--- /dev/null
+++ b/flang/test/Lower/OpenMP/task2.f90
@@ -0,0 +1,33 @@
+!RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
+
+!CHECK-LABEL: func @_QPomp_task_nested_allocatable_firstprivate
+subroutine omp_task_nested_allocatable_firstprivate
+ integer, allocatable :: a(:)
+
+ allocate(a(7))
+ a = 10
+
+!CHECK: %[[A:.*]]:2 = hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs<allocatable>,
+!CHECK-SAME: uniq_name = "_QFomp_task_nested_allocatable_firstprivateEa"} :
+!CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) ->
+!CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
+!CHECK: omp.task {
+ !$omp task default(firstprivate)
+!CHECK: omp.task {
+!CHECK: %[[PRIV_A:.*]]:2 = hlfir.declare %{{.*}} {fortran_attrs = #fir.var_attrs<allocatable>,
+!CHECK-SAME: uniq_name = "_QFomp_task_nested_allocatable_firstprivateEa"} :
+!CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) ->
+!CHECK-SAME: (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
+!CHECK: %[[PRIV_A_BOX:.*]] = fir.load %[[PRIV_A]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+!CHECK: fir.if %{{.*}} {
+!CHECK: %[[TEMP:.*]] = fir.load %[[A]]#0 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
+!CHECK: hlfir.assign %[[TEMP]] to %[[PRIV_A_BOX]] temporary_lhs :
+!CHECK-SAME: !fir.box<!fir.heap<!fir.array<?xi32>>>, !fir.box<!fir.heap<!fir.array<?xi32>>>
+!CHECK: }
+ !$omp task default(firstprivate)
+ a = 2
+!CHECK: }
+ !$omp end task
+!CHECK: }
+ !$omp end task
+end subroutine
More information about the flang-commits
mailing list