r364650 - [OPENMP]Fix DSA for loop iteration variables in simd loops.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 28 08:16:37 PDT 2019


Author: abataev
Date: Fri Jun 28 08:16:37 2019
New Revision: 364650

URL: http://llvm.org/viewvc/llvm-project?rev=364650&view=rev
Log:
[OPENMP]Fix DSA for loop iteration variables in simd loops.

According to the OpenMP 5.0 standard, the loop iteration variable in the associated
for-loop of a simd construct with just one associated for-loop may be
listed in a private, lastprivate, or linear clause with a linear-step
that is the increment of the associated for-loop. Also, the loop
teration variables in the associated for-loops of a simd construct with
multiple associated for-loops may be listed in a private or lastprivate
clause.

Modified:
    cfe/trunk/lib/Sema/SemaOpenMP.cpp
    cfe/trunk/test/OpenMP/simd_loop_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=364650&r1=364649&r2=364650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Jun 28 08:16:37 2019
@@ -5697,7 +5697,9 @@ static bool checkOpenMPIterationSpace(
             ? ((NestedLoopCount == 1) ? OMPC_linear : OMPC_lastprivate)
             : OMPC_private;
     if (((isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&
-          DVar.CKind != PredeterminedCKind && DVar.RefExpr) ||
+          DVar.CKind != PredeterminedCKind && DVar.RefExpr &&
+          (SemaRef.getLangOpts().OpenMP <= 45 ||
+           (DVar.CKind != OMPC_lastprivate && DVar.CKind != OMPC_private))) ||
          ((isOpenMPWorksharingDirective(DKind) || DKind == OMPD_taskloop ||
            isOpenMPDistributeDirective(DKind)) &&
           !isOpenMPSimdDirective(DKind) && DVar.CKind != OMPC_unknown &&

Modified: cfe/trunk/test/OpenMP/simd_loop_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/simd_loop_messages.cpp?rev=364650&r1=364649&r2=364650&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/simd_loop_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/simd_loop_messages.cpp Fri Jun 28 08:16:37 2019
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s -fopenmp-version=50 -DOMP50
+// RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify %s -fopenmp-version=50 -DOMP50
 
 static int sii;
 // expected-note at +1 {{defined as threadprivate or thread local}}
@@ -239,12 +241,22 @@ int test_iteration_spaces() {
   for (ii = 0; (ii < 10); (ii-=0))
     c[ii] = a[ii];
 
-  // expected-note at +2  {{defined as private}}
-  // expected-error at +2 {{loop iteration variable in the associated loop of 'omp simd' directive may not be private, predetermined as linear}}
+#ifndef OMP50
+  // expected-note at +3  {{defined as private}}
+  // expected-error at +3 {{loop iteration variable in the associated loop of 'omp simd' directive may not be private, predetermined as linear}}
+#endif // OMP50
   #pragma omp simd private(ii)
   for (ii = 0; ii < 10; ii++)
     c[ii] = a[ii];
 
+#ifndef OMP50
+  // expected-note at +3  {{defined as lastprivate}}
+  // expected-error at +3 {{loop iteration variable in the associated loop of 'omp simd' directive may not be lastprivate, predetermined as linear}}
+#endif // OMP50
+  #pragma omp simd lastprivate(ii)
+  for (ii = 0; ii < 10; ii++)
+    c[ii] = a[ii];
+
   // expected-error at +1 {{unexpected OpenMP clause 'shared' in directive '#pragma omp simd'}}
   #pragma omp simd shared(ii)
   for (ii = 0; ii < 10; ii++)




More information about the cfe-commits mailing list