From 3c356eef31ab309466c198de3915037b068d8861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Clement=20=28=E3=83=90=E3=83=AC=E3=83=B3?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=B3=20=E3=82=AF=E3=83=AC=E3=83=A1?= =?UTF-8?q?=E3=83=B3=29?= Date: Mon, 6 Nov 2023 15:49:40 -0800 Subject: [PATCH] [flang][openacc] Support variable from equivalence in data clauses (#71434) The value for a var in an equivalence is represented by a `fir.ptr`. Support this type in the recipe creation. --- flang/lib/Lower/OpenACC.cpp | 2 +- flang/test/Lower/OpenACC/acc-private.f90 | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index 27b262f9535675..2337beb80dc979 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -724,7 +724,7 @@ mlir::Type getTypeFromBounds(llvm::SmallVector &bounds, if (shape.empty() || shape.size() != bounds.size()) return ty; auto newSeqTy = fir::SequenceType::get(shape, seqTy.getEleTy()); - if (mlir::isa(ty)) + if (mlir::isa(ty)) return fir::ReferenceType::get(newSeqTy); return newSeqTy; } diff --git a/flang/test/Lower/OpenACC/acc-private.f90 b/flang/test/Lower/OpenACC/acc-private.f90 index 80b474b348c1c2..7ec8e345fd3af3 100644 --- a/flang/test/Lower/OpenACC/acc-private.f90 +++ b/flang/test/Lower/OpenACC/acc-private.f90 @@ -3,6 +3,15 @@ ! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s --check-prefixes=CHECK,FIR ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK,HLFIR +! CHECK-LABEL: acc.private.recipe @privatization_ref_10xf32 : !fir.ref> init { +! HLFIR: ^bb0(%[[ARG0:.*]]: !fir.ref>): +! HLFIR: %[[C10:.*]] = arith.constant 10 : index +! HLFIR: %[[SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1> +! HLFIR: %[[ALLOCA:.*]] = fir.alloca !fir.array<10xf32> +! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.private.init"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref> +! CHECK: } + ! CHECK-LABEL: acc.firstprivate.recipe @firstprivatization_ref_UxUx2xi32 : !fir.ref> init { ! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref>, %[[ARG1:.*]]: index, %[[ARG2:.*]]: index, %[[ARG3:.*]]: index): ! HLFIR: %[[SHAPE:.*]] = fir.shape %[[ARG1]], %[[ARG2]], %[[ARG3]] : (index, index, index) -> !fir.shape<3> @@ -363,3 +372,17 @@ subroutine acc_firstprivate_dynamic_extent(a, n) end subroutine ! CHECK: acc.parallel firstprivate(@firstprivatization_ref_UxUx2xi32 -> %{{.*}} : !fir.ref>) + +module acc_declare_equivalent + integer, parameter :: n = 10 + real :: v1(n) + real :: v2(n) + equivalence(v1(1), v2(1)) +contains + subroutine sub1() + !$acc parallel private(v2) + !$acc end parallel + end subroutine +end module + +! CHECK: acc.parallel private(@privatization_ref_10xf32 -> %{{.*}} : !fir.ref>)