[flang-commits] [flang] 0000030 - Revert "[Flang][OpenMP] Add semantic check for OpenMP Private, Firstprivate and Lastprivate clauses."

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Sun Apr 3 08:54:33 PDT 2022


Author: Kiran Chandramohan
Date: 2022-04-03T15:54:02Z
New Revision: 0000030b18c1e60e5e4f7444e30694bac9ffc14e

URL: https://github.com/llvm/llvm-project/commit/0000030b18c1e60e5e4f7444e30694bac9ffc14e
DIFF: https://github.com/llvm/llvm-project/commit/0000030b18c1e60e5e4f7444e30694bac9ffc14e.diff

LOG: Revert "[Flang][OpenMP] Add semantic check for OpenMP Private, Firstprivate and Lastprivate clauses."

This reverts commit a2ca6bbda6160c1b474fffd6204bcac9456c7eb1.

D93213 performs some checks to ensure that variables that appear in
statement functions are not in privatisation clauses. The point at
which this check is currently performed, there can be misparses that
cause more constructs to be identified as statement functions. This
can lead to various kinds of errors, hence reverting.

This revert hopefully fixes:
https://github.com/llvm/llvm-project/issues/54477
https://github.com/llvm/llvm-project/issues/54161
https://github.com/llvm/llvm-project/issues/54163

Reviewed By: shraiysh

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

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-directives.cpp

Removed: 
    flang/test/Semantics/omp-private03.f90


################################################################################
diff  --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index f6e9ae9f2c5ec..068f944962eb6 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -279,18 +279,6 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
     return true;
   }
 
-  bool Pre(const parser::StmtFunctionStmt &x) {
-    const auto &parsedExpr{std::get<parser::Scalar<parser::Expr>>(x.t)};
-    if (const auto *expr{GetExpr(parsedExpr)}) {
-      for (const Symbol &symbol : evaluate::CollectSymbols(*expr)) {
-        if (!IsStmtFunctionDummy(symbol)) {
-          stmtFunctionExprSymbols_.insert(symbol.GetUltimate());
-        }
-      }
-    }
-    return true;
-  }
-
   bool Pre(const parser::OpenMPBlockConstruct &);
   void Post(const parser::OpenMPBlockConstruct &);
 
@@ -530,7 +518,7 @@ class OmpAttributeVisitor : DirectiveAttributeVisitor<llvm::omp::Directive> {
   void CheckDataCopyingClause(
       const parser::Name &, const Symbol &, Symbol::Flag);
   void CheckAssocLoopLevel(std::int64_t level, const parser::OmpClause *clause);
-  void CheckPrivateDSAObject(
+  void CheckObjectInNamelist(
       const parser::Name &, const Symbol &, Symbol::Flag);
   void CheckSourceLabel(const parser::Label &);
   void CheckLabelContext(const parser::CharBlock, const parser::CharBlock,
@@ -1585,7 +1573,7 @@ void OmpAttributeVisitor::ResolveOmpObject(
                     CheckMultipleAppearances(*name, *symbol, ompFlag);
                   }
                   if (privateDataSharingAttributeFlags.test(ompFlag)) {
-                    CheckPrivateDSAObject(*name, *symbol, ompFlag);
+                    CheckObjectInNamelist(*name, *symbol, ompFlag);
                   }
 
                   if (ompFlag == Symbol::Flag::OmpAllocate) {
@@ -1779,7 +1767,7 @@ void OmpAttributeVisitor::CheckDataCopyingClause(
   }
 }
 
-void OmpAttributeVisitor::CheckPrivateDSAObject(
+void OmpAttributeVisitor::CheckObjectInNamelist(
     const parser::Name &name, const Symbol &symbol, Symbol::Flag ompFlag) {
   const auto &ultimateSymbol{symbol.GetUltimate()};
   llvm::StringRef clauseName{"PRIVATE"};
@@ -1794,14 +1782,6 @@ void OmpAttributeVisitor::CheckPrivateDSAObject(
         "Variable '%s' in NAMELIST cannot be in a %s clause"_err_en_US,
         name.ToString(), clauseName.str());
   }
-
-  if (stmtFunctionExprSymbols_.find(ultimateSymbol) !=
-      stmtFunctionExprSymbols_.end()) {
-    context_.Say(name.source,
-        "Variable '%s' in STATEMENT FUNCTION expression cannot be in a "
-        "%s clause"_err_en_US,
-        name.ToString(), clauseName.str());
-  }
 }
 
 void OmpAttributeVisitor::CheckSourceLabel(const parser::Label &label) {

diff  --git a/flang/test/Semantics/omp-private03.f90 b/flang/test/Semantics/omp-private03.f90
deleted file mode 100644
index a0cf829bd5d26..0000000000000
--- a/flang/test/Semantics/omp-private03.f90
+++ /dev/null
@@ -1,39 +0,0 @@
-! RUN: %python %S/test_errors.py %s %flang -fopenmp
-! OpenMP Version 4.5
-! Variables that appear in expressions for statement function definitions
-! may not appear in private, firstprivate or lastprivate clauses.
-
-subroutine stmt_function(temp)
-
-  integer :: i, p, q, r
-  real :: c, f, s, v, t(10)
-  real, intent(in) :: temp
-
-  c(temp) = p * (temp - q) / r
-  f(temp) = q + (temp * r/p)
-  v(temp) = c(temp) + f(temp)/2 - s
-
-  p = 5
-  q = 32
-  r = 9
-
-  !ERROR: Variable 'p' in STATEMENT FUNCTION expression cannot be in a PRIVATE clause
-  !$omp parallel private(p)
-  s = c(temp)
-  !$omp end parallel
-
-  !ERROR: Variable 's' in STATEMENT FUNCTION expression cannot be in a FIRSTPRIVATE clause
-  !$omp parallel firstprivate(s)
-  s = s + f(temp)
-  !$omp end parallel
-
-  !ERROR: Variable 's' in STATEMENT FUNCTION expression cannot be in a LASTPRIVATE clause
-  !$omp parallel do lastprivate(s, t)
-  do i = 1, 10
-    t(i) = v(temp) + i - s
-  end do
-  !$omp end parallel do
-
-  print *, t
-
-end subroutine stmt_function


        


More information about the flang-commits mailing list