Skip to content

Commit 609361a

Browse files
authored
[flang][openacc] Allow finalize clause on exit data more than once (#135415)
The spec has not strict restriction to allow a single `finalize` clause on the `exit data` directive. Allowing this clause multiple times does not change the semantic of it. This patch relax the rules in `ACC.td` since there is no restriction in the standard. The OpenACC dialect represent the finalize clause with a UnitAttr so the attribute will be set if the is one or more `finalize` clause.
1 parent a8da483 commit 609361a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

flang/test/Lower/OpenACC/acc-exit-data.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,9 @@ subroutine acc_exit_data
102102
!CHECK: acc.exit_data wait_devnum(%[[WAIT6]] : i32) wait(%[[WAIT4]], %[[WAIT5]] : i32, i32) dataOperands(%[[DEVPTR]] : !fir.ref<!fir.array<10x10xf32>>)
103103
!CHECK: acc.delete accPtr(%[[DEVPTR]] : !fir.ref<!fir.array<10x10xf32>>) {name = "a", structured = false}
104104

105+
!$acc exit data delete(a) finalize
106+
!CHECK: acc.exit_data dataOperands(%{{.*}} : !fir.ref<!fir.array<10x10xf32>>) attributes {finalize}
107+
108+
!$acc exit data delete(a) finalize finalize
109+
!CHECK: acc.exit_data dataOperands(%{{.*}} : !fir.ref<!fir.array<10x10xf32>>) attributes {finalize}
105110
end subroutine acc_exit_data

flang/test/Semantics/OpenACC/acc-data.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ program openacc_data_validity
8686

8787
!$acc exit data delete(aa) finalize
8888

89-
!ERROR: At most one FINALIZE clause can appear on the EXIT DATA directive
89+
! OK
9090
!$acc exit data delete(aa) finalize finalize
9191

9292
!ERROR: Argument `cc` on the DETACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute

llvm/include/llvm/Frontend/OpenACC/ACC.td

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -535,14 +535,10 @@ def ACC_EnterData : Directive<"enter data"> {
535535

536536
// 2.14.7
537537
def ACC_ExitData : Directive<"exit data"> {
538-
let allowedClauses = [
539-
VersionedClause<ACCC_Wait>
540-
];
541-
let allowedOnceClauses = [
542-
VersionedClause<ACCC_Async>,
543-
VersionedClause<ACCC_If>,
544-
VersionedClause<ACCC_Finalize>
545-
];
538+
let allowedClauses = [VersionedClause<ACCC_Finalize>,
539+
VersionedClause<ACCC_Wait>];
540+
let allowedOnceClauses = [VersionedClause<ACCC_Async>,
541+
VersionedClause<ACCC_If>];
546542
let requiredClauses = [
547543
VersionedClause<ACCC_Copyout>,
548544
VersionedClause<ACCC_Delete>,

0 commit comments

Comments
 (0)