[flang] [llvm] [flang][openacc] Allow finalize clause on exit data more than once (PR #135415)
Valentin Clement バレンタイン クレメン via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 11 11:10:06 PDT 2025
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/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.
>From a0d3d9aaa81da2327b2410a1b4360dec04ff83d0 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Fri, 11 Apr 2025 11:07:36 -0700
Subject: [PATCH] [flang][openacc] Allow finalize clause on exit data more than
once
---
flang/test/Lower/OpenACC/acc-exit-data.f90 | 5 +++++
flang/test/Semantics/OpenACC/acc-data.f90 | 2 +-
llvm/include/llvm/Frontend/OpenACC/ACC.td | 12 ++++--------
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/flang/test/Lower/OpenACC/acc-exit-data.f90 b/flang/test/Lower/OpenACC/acc-exit-data.f90
index fbd1edfb6afe4..bf5f7094913a1 100644
--- a/flang/test/Lower/OpenACC/acc-exit-data.f90
+++ b/flang/test/Lower/OpenACC/acc-exit-data.f90
@@ -102,4 +102,9 @@ subroutine acc_exit_data
!CHECK: acc.exit_data wait_devnum(%[[WAIT6]] : i32) wait(%[[WAIT4]], %[[WAIT5]] : i32, i32) dataOperands(%[[DEVPTR]] : !fir.ref<!fir.array<10x10xf32>>)
!CHECK: acc.delete accPtr(%[[DEVPTR]] : !fir.ref<!fir.array<10x10xf32>>) {name = "a", structured = false}
+ !$acc exit data delete(a) finalize
+!CHECK: acc.exit_data dataOperands(%{{.*}} : !fir.ref<!fir.array<10x10xf32>>) attributes {finalize}
+
+ !$acc exit data delete(a) finalize finalize
+!CHECK: acc.exit_data dataOperands(%{{.*}} : !fir.ref<!fir.array<10x10xf32>>) attributes {finalize}
end subroutine acc_exit_data
diff --git a/flang/test/Semantics/OpenACC/acc-data.f90 b/flang/test/Semantics/OpenACC/acc-data.f90
index 84eb72825b34c..ac49532c495d5 100644
--- a/flang/test/Semantics/OpenACC/acc-data.f90
+++ b/flang/test/Semantics/OpenACC/acc-data.f90
@@ -86,7 +86,7 @@ program openacc_data_validity
!$acc exit data delete(aa) finalize
- !ERROR: At most one FINALIZE clause can appear on the EXIT DATA directive
+ ! OK
!$acc exit data delete(aa) finalize finalize
!ERROR: Argument `cc` on the DETACH clause must be a variable or array with the POINTER or ALLOCATABLE attribute
diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td
index 8729d4505205b..cee0d53458a08 100644
--- a/llvm/include/llvm/Frontend/OpenACC/ACC.td
+++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td
@@ -535,14 +535,10 @@ def ACC_EnterData : Directive<"enter data"> {
// 2.14.7
def ACC_ExitData : Directive<"exit data"> {
- let allowedClauses = [
- VersionedClause<ACCC_Wait>
- ];
- let allowedOnceClauses = [
- VersionedClause<ACCC_Async>,
- VersionedClause<ACCC_If>,
- VersionedClause<ACCC_Finalize>
- ];
+ let allowedClauses = [VersionedClause<ACCC_Finalize>,
+ VersionedClause<ACCC_Wait>];
+ let allowedOnceClauses = [VersionedClause<ACCC_Async>,
+ VersionedClause<ACCC_If>];
let requiredClauses = [
VersionedClause<ACCC_Copyout>,
VersionedClause<ACCC_Delete>,
More information about the llvm-commits
mailing list