[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-09-16 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4341c6618dec: [OPENMP]Do not allow threadprivates as base 
for array-like reduction. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85762/new/

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15120,6 +15120,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15120,6 +15120,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-09-08 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85762/new/

https://reviews.llvm.org/D85762

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 288701.
ABataev added a comment.
Herald added a subscriber: danielkiss.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85762/new/

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15119,6 +15119,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15119,6 +15119,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 287406.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85762/new/

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 286658.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85762/new/

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 286272.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85762/new/

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15116,6 +15116,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-08-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.

The base must be shared between the threads, threadprivates are not
allowed to be bases for array-like reductions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15068,6 +15068,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15068,6 +15068,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits