r226549 - [OPENMP] Fixed DSA processing for predetermined shared variables.

Alexey Bataev a.bataev at hotmail.com
Mon Jan 19 23:03:46 PST 2015


Author: abataev
Date: Tue Jan 20 01:03:46 2015
New Revision: 226549

URL: http://llvm.org/viewvc/llvm-project?rev=226549&view=rev
Log:
[OPENMP] Fixed DSA processing for predetermined shared variables.
This patch allows to use predetermined shared variables in private clauses in
parallel or tasks regions.

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=226549&r1=226548&r2=226549&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Jan 20 01:03:46 2015
@@ -425,16 +425,16 @@ DSAStackTy::DSAVarData DSAStackTy::getTo
     // OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
     // in a Construct, C/C++, predetermined, p.4]
     //  Static data members are shared.
-    if (D->isStaticDataMember()) {
-      DVar.CKind = OMPC_shared;
-      return DVar;
-    }
-
     // OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
     // in a Construct, C/C++, predetermined, p.7]
     //  Variables with static storage duration that are declared in a scope
     //  inside the construct are shared.
-    if (D->isStaticLocal()) {
+    if (D->isStaticDataMember() || D->isStaticLocal()) {
+      DSAVarData DVarTemp =
+          hasDSA(D, isOpenMPPrivate, MatchesAlways(), FromParent);
+      if (DVarTemp.CKind != OMPC_unknown && DVarTemp.RefExpr)
+        return DVar;
+
       DVar.CKind = OMPC_shared;
       return DVar;
     }

Modified: cfe/trunk/test/OpenMP/single_copyprivate_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/single_copyprivate_messages.cpp?rev=226549&r1=226548&r2=226549&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/single_copyprivate_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/single_copyprivate_messages.cpp Tue Jan 20 01:03:46 2015
@@ -44,6 +44,7 @@ S5 m(4); // expected-note 2 {{'m' define
 template <class T, class C>
 T tmain(T argc, C **argv) {
   T i;
+  static T TA;
 #pragma omp parallel
 #pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
 #pragma omp parallel
@@ -95,12 +96,18 @@ T tmain(T argc, C **argv) {
 #pragma omp parallel
 #pragma omp single firstprivate(i) copyprivate(i) // expected-error {{firstprivate variable cannot be copyprivate}} expected-note {{defined as firstprivate}}
   foo();
+#pragma omp parallel private(TA)
+  {
+#pragma omp single copyprivate(TA)
+    TA = 99;
+  }
 
   return T();
 }
 
 int main(int argc, char **argv) {
   int i;
+  static int intA;
 #pragma omp parallel
 #pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
 #pragma omp parallel
@@ -154,6 +161,11 @@ int main(int argc, char **argv) {
   foo();
 #pragma omp single copyprivate(i) nowait // expected-error {{the 'copyprivate' clause must not be used with the 'nowait' clause}} expected-note {{'nowait' clause is here}}
   foo();
+#pragma omp parallel private(intA)
+  {
+#pragma omp single copyprivate(intA)
+    intA = 99;
+  }
 
   return tmain(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char>' requested here}}
 }





More information about the cfe-commits mailing list