[flang-commits] [flang] 887b69c - [flang][openacc] Disallow the zero modifier on the create clause with the declare directive

Valentin Clement via flang-commits flang-commits at lists.llvm.org
Mon Jul 31 14:30:02 PDT 2023


Author: Valentin Clement
Date: 2023-07-31T14:29:56-07:00
New Revision: 887b69c1f18264ddfbacf6fcdb848d896b503955

URL: https://github.com/llvm/llvm-project/commit/887b69c1f18264ddfbacf6fcdb848d896b503955
DIFF: https://github.com/llvm/llvm-project/commit/887b69c1f18264ddfbacf6fcdb848d896b503955.diff

LOG: [flang][openacc] Disallow the zero modifier on the create clause with the declare directive

The OpenACC 3.3 specification does not allow the `zero` modifier
on the `create` clause used with the declare directive.

Reviewed By: razvanlupusoru

Differential Revision: https://reviews.llvm.org/D156703

Added: 
    

Modified: 
    flang/lib/Lower/OpenACC.cpp
    flang/lib/Semantics/check-acc-structure.cpp
    flang/test/Lower/OpenACC/acc-declare.f90
    flang/test/Semantics/OpenACC/acc-declare-validity.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 705446cbc6a39a..50ea53bea87a3d 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -2399,12 +2399,13 @@ genDeclareInModule(Fortran::lower::AbstractConverter &converter,
   for (const Fortran::parser::AccClause &clause : accClauseList.v) {
     if (const auto *createClause =
             std::get_if<Fortran::parser::AccClause::Create>(&clause.u)) {
-      genGlobalCtorsWithModifier<Fortran::parser::AccClause::Create,
-                                 mlir::acc::CreateOp, mlir::acc::DeleteOp>(
-          converter, modBuilder, createClause,
-          Fortran::parser::AccDataModifier::Modifier::Zero,
-          mlir::acc::DataClause::acc_create,
-          mlir::acc::DataClause::acc_create_zero);
+      const Fortran::parser::AccObjectListWithModifier &listWithModifier =
+          createClause->v;
+      const auto &accObjectList =
+          std::get<Fortran::parser::AccObjectList>(listWithModifier.t);
+      genGlobalCtors<mlir::acc::CreateOp, mlir::acc::DeleteOp>(
+          converter, modBuilder, accObjectList,
+          mlir::acc::DataClause::acc_create);
     } else if (const auto *copyinClause =
                    std::get_if<Fortran::parser::AccClause::Copyin>(&clause.u)) {
       genGlobalCtorsWithModifier<Fortran::parser::AccClause::Copyin,

diff  --git a/flang/lib/Semantics/check-acc-structure.cpp b/flang/lib/Semantics/check-acc-structure.cpp
index aeb34b8d5cb9eb..4ed3b32eec5c3a 100644
--- a/flang/lib/Semantics/check-acc-structure.cpp
+++ b/flang/lib/Semantics/check-acc-structure.cpp
@@ -389,6 +389,15 @@ void AccStructureChecker::Enter(const parser::AccClause::Create &c) {
                   .str()),
           ContextDirectiveAsFortran());
     }
+    if (GetContext().directive == llvm::acc::Directive::ACCD_declare) {
+      context_.Say(GetContext().clauseSource,
+          "The ZERO modifier is not allowed for the %s clause "
+          "on the %s directive"_err_en_US,
+          parser::ToUpperCaseLetters(
+              llvm::acc::getOpenACCClauseName(llvm::acc::Clause::ACCC_create)
+                  .str()),
+          ContextDirectiveAsFortran());
+    }
   }
 }
 

diff  --git a/flang/test/Lower/OpenACC/acc-declare.f90 b/flang/test/Lower/OpenACC/acc-declare.f90
index 325f152c392044..d5b0a48d7a90a9 100644
--- a/flang/test/Lower/OpenACC/acc-declare.f90
+++ b/flang/test/Lower/OpenACC/acc-declare.f90
@@ -4,8 +4,8 @@
 
 module acc_declare_test
  integer, parameter :: n = 100000
- real, dimension(n) :: data1, data2
- !$acc declare create(data1) create(zero: data2)
+ real, dimension(n) :: data1
+ !$acc declare create(data1)
 end module
 
 ! CHECK-LABEL: fir.global @_QMacc_declare_testEdata1 {acc.declare = #acc.declare<dataClause = acc_create>} : !fir.array<100000xf32>
@@ -25,23 +25,6 @@ module acc_declare_test
 ! CHECK:         acc.terminator
 ! CHECK:       }
 
-! CHECK-LABEL: fir.global @_QMacc_declare_testEdata2 {acc.declare = #acc.declare<dataClause =  acc_create_zero>} : !fir.array<100000xf32>
-
-! CHECK-LABEL: acc.global_ctor @_QMacc_declare_testEdata2_acc_ctor {
-! CHECK:         %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata2) {acc.declare = #acc.declare<dataClause =  acc_create_zero>} : !fir.ref<!fir.array<100000xf32>>
-! CHECK:         %[[CREATE:.*]] = acc.create varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {dataClause = #acc<data_clause acc_create_zero>, name = "data2", structured = false}
-! CHECK:         acc.declare_enter dataOperands(%[[CREATE]] : !fir.ref<!fir.array<100000xf32>>)
-! CHECK:         acc.terminator
-! CHECK:       }
-
-! CHECK-LABEL: acc.global_dtor @_QMacc_declare_testEdata2_acc_dtor {
-! CHECK:         %[[GLOBAL_ADDR:.*]] = fir.address_of(@_QMacc_declare_testEdata2) {acc.declare = #acc.declare<dataClause =  acc_create_zero>} : !fir.ref<!fir.array<100000xf32>>
-! CHECK:         %[[DEVICEPTR:.*]] = acc.getdeviceptr varPtr(%[[GLOBAL_ADDR]] : !fir.ref<!fir.array<100000xf32>>) -> !fir.ref<!fir.array<100000xf32>> {dataClause = #acc<data_clause acc_create_zero>, name = "data2", structured = false}
-! CHECK:         acc.declare_exit dataOperands(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>)
-! CHECK:         acc.delete accPtr(%[[DEVICEPTR]] : !fir.ref<!fir.array<100000xf32>>) {dataClause = #acc<data_clause acc_create_zero>, name = "data2", structured = false}
-! CHECK:         acc.terminator
-! CHECK:       }
-
 module acc_declare_copyin_test
  integer, parameter :: n = 100000
  real, dimension(n) :: data1

diff  --git a/flang/test/Semantics/OpenACC/acc-declare-validity.f90 b/flang/test/Semantics/OpenACC/acc-declare-validity.f90
index 5578d9afbc0d2d..5a5a5407f77aa8 100644
--- a/flang/test/Semantics/OpenACC/acc-declare-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-declare-validity.f90
@@ -30,6 +30,9 @@ module openacc_declare_validity
   !ERROR: DEVICEPTR clause is not allowed on the DECLARE directive in module declaration section
   !$acc declare deviceptr(ab)
 
+  !ERROR: The ZERO modifier is not allowed for the CREATE clause on the DECLARE directive
+  !$acc declare create(zero: aa)
+
 contains
 
   subroutine sub1(cc, dd)


        


More information about the flang-commits mailing list