Skip to content

[flang][openacc] Allow polymorphic entity in data clauses #141856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions flang/include/flang/Optimizer/Builder/DirectivesCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ inline AddrAndBoundsInfo getDataOperandBaseAddr(fir::FirOpBuilder &builder,

if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(
fir::unwrapRefType(symAddr.getType()))) {
if (mlir::isa<fir::RecordType>(boxTy.getEleTy()))
TODO(loc, "derived type");

// In case of a box reference, load it here to get the box value.
// This is preferrable because then the same box value can then be used for
// all address/dimension retrievals. For Fortran optional though, leave
Expand Down
2 changes: 2 additions & 0 deletions flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ void registerOpenACCExtensions(mlir::DialectRegistry &registry) {
fir::SequenceType::attachInterface<OpenACCMappableModel<fir::SequenceType>>(
*ctx);
fir::BoxType::attachInterface<OpenACCMappableModel<fir::BaseBoxType>>(*ctx);
fir::ClassType::attachInterface<OpenACCMappableModel<fir::BaseBoxType>>(
*ctx);

fir::ReferenceType::attachInterface<
OpenACCPointerLikeModel<fir::ReferenceType>>(*ctx);
Expand Down
20 changes: 20 additions & 0 deletions flang/test/Lower/OpenACC/acc-enter-data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s

module mod1
implicit none
type :: derived
real :: m
contains
end type derived
end module mod1

subroutine acc_enter_data
integer :: async = 1
real, dimension(10, 10) :: a, b, c
Expand Down Expand Up @@ -651,3 +659,15 @@ subroutine acc_enter_data_single_array_element()
!CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.heap<!fir.array<?x?xf32>>)

end subroutine

subroutine test_class(a)
use mod1
class(derived) :: a
!$acc enter data copyin(a)
end subroutine

! CHECK-LABEL: func.func @_QPtest_class(
! CHECK-SAME: %[[ARG0:.*]]: !fir.class<!fir.type<_QMmod1Tderived{m:f32}>> {fir.bindc_name = "a"}) {
! CHECK: %[[DECL_ARG0:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope %0 {uniq_name = "_QFtest_classEa"} : (!fir.class<!fir.type<_QMmod1Tderived{m:f32}>>, !fir.dscope) -> (!fir.class<!fir.type<_QMmod1Tderived{m:f32}>>, !fir.class<!fir.type<_QMmod1Tderived{m:f32}>>)
! CHECK: %[[COPYIN:.*]] = acc.copyin var(%[[DECL_ARG0]]#0 : !fir.class<!fir.type<_QMmod1Tderived{m:f32}>>) -> !fir.class<!fir.type<_QMmod1Tderived{m:f32}>> {name = "a", structured = false}
! CHECK: acc.enter_data dataOperands(%[[COPYIN]] : !fir.class<!fir.type<_QMmod1Tderived{m:f32}>>)
Loading