Skip to content

[flang][openacc] Support single array element in data clause #70065

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
Oct 24, 2023
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
14 changes: 11 additions & 3 deletions flang/lib/Lower/DirectivesCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,9 +898,17 @@ mlir::Value gatherDataOperandAddrAndBounds(
builder, operandLocation, converter, compExv, baseAddr);
}
} else {
// Scalar or full array.
if (const auto *dataRef{
std::get_if<Fortran::parser::DataRef>(&designator.u)}) {
if (Fortran::parser::Unwrap<Fortran::parser::ArrayElement>(
designator)) {
// Single array element.
fir::ExtendedValue compExv =
converter.genExprAddr(operandLocation, *expr, stmtCtx);
baseAddr = fir::getBase(compExv);
asFortran << (*expr).AsFortran();
} else if (const auto *dataRef{
std::get_if<Fortran::parser::DataRef>(
&designator.u)}) {
// Scalar or full array.
const Fortran::parser::Name &name =
Fortran::parser::GetLastName(*dataRef);
fir::ExtendedValue dataExv =
Expand Down
14 changes: 14 additions & 0 deletions flang/test/Lower/OpenACC/acc-enter-data.f90
Original file line number Diff line number Diff line change
Expand Up @@ -803,3 +803,17 @@ subroutine acc_enter_data_derived_type()
!CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.ref<!fir.array<10xf32>>)

end subroutine

subroutine acc_enter_data_single_array_element()
type t1
real, allocatable :: a(:, :)
end type t1
type(t1), allocatable :: e(:)
allocate(e(10)%a(5,5))

!$acc enter data create(e(2)%a(1,2))

!CHECK: %[[CREATE:.*]] = acc.create varPtr(%{{.*}} : !fir.ref<f32>) -> !fir.ref<f32> {name = "e(2_8)%a(1_8,2_8)", structured = false}
!CHECK: acc.enter_data dataOperands(%[[CREATE]] : !fir.ref<f32>)

end subroutine