Skip to content

Commit 3c356ee

Browse files
authored
[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.
1 parent 03529b9 commit 3c356ee

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

flang/lib/Lower/OpenACC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ mlir::Type getTypeFromBounds(llvm::SmallVector<mlir::Value> &bounds,
724724
if (shape.empty() || shape.size() != bounds.size())
725725
return ty;
726726
auto newSeqTy = fir::SequenceType::get(shape, seqTy.getEleTy());
727-
if (mlir::isa<fir::ReferenceType>(ty))
727+
if (mlir::isa<fir::ReferenceType, fir::PointerType>(ty))
728728
return fir::ReferenceType::get(newSeqTy);
729729
return newSeqTy;
730730
}

flang/test/Lower/OpenACC/acc-private.f90

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s --check-prefixes=CHECK,FIR
44
! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK,HLFIR
55

6+
! CHECK-LABEL: acc.private.recipe @privatization_ref_10xf32 : !fir.ref<!fir.array<10xf32>> init {
7+
! HLFIR: ^bb0(%[[ARG0:.*]]: !fir.ref<!fir.array<10xf32>>):
8+
! HLFIR: %[[C10:.*]] = arith.constant 10 : index
9+
! HLFIR: %[[SHAPE:.*]] = fir.shape %[[C10]] : (index) -> !fir.shape<1>
10+
! HLFIR: %[[ALLOCA:.*]] = fir.alloca !fir.array<10xf32>
11+
! HLFIR: %[[DECLARE:.*]]:2 = hlfir.declare %[[ALLOCA]](%[[SHAPE]]) {uniq_name = "acc.private.init"} : (!fir.ref<!fir.array<10xf32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
12+
! HLFIR: acc.yield %[[DECLARE]]#0 : !fir.ref<!fir.array<10xf32>>
13+
! CHECK: }
14+
615
! CHECK-LABEL: acc.firstprivate.recipe @firstprivatization_ref_UxUx2xi32 : !fir.ref<!fir.array<?x?x2xi32>> init {
716
! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref<!fir.array<?x?x2xi32>>, %[[ARG1:.*]]: index, %[[ARG2:.*]]: index, %[[ARG3:.*]]: index):
817
! HLFIR: %[[SHAPE:.*]] = fir.shape %[[ARG1]], %[[ARG2]], %[[ARG3]] : (index, index, index) -> !fir.shape<3>
@@ -363,3 +372,17 @@ subroutine acc_firstprivate_dynamic_extent(a, n)
363372
end subroutine
364373

365374
! CHECK: acc.parallel firstprivate(@firstprivatization_ref_UxUx2xi32 -> %{{.*}} : !fir.ref<!fir.array<?x?x2xi32>>)
375+
376+
module acc_declare_equivalent
377+
integer, parameter :: n = 10
378+
real :: v1(n)
379+
real :: v2(n)
380+
equivalence(v1(1), v2(1))
381+
contains
382+
subroutine sub1()
383+
!$acc parallel private(v2)
384+
!$acc end parallel
385+
end subroutine
386+
end module
387+
388+
! CHECK: acc.parallel private(@privatization_ref_10xf32 -> %{{.*}} : !fir.ref<!fir.array<10xf32>>)

0 commit comments

Comments
 (0)