Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-13 Thread Carlo Bertolli via cfe-commits
carlo.bertolli closed this revision.
carlo.bertolli added a comment.

Committed revision 275271.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-13 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-12 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 63689.
carlo.bertolli added a comment.

[OpenMP] Add regression test to check correctness of ast building, remove 
'brief's, and rebase.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_ast_print.cpp
  test/OpenMP/target_data_use_device_ptr_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2275,6 +2275,9 @@
 void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(const OMPUseDevicePtrClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_data_use_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
+struct ST {
+  int *a;
+};
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  void func(int arg) {
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+{}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr() // expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+{}
+#pragma omp target data map(i) use_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(i) // expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(j) // expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(z) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(aa) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(e) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(g) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k,i,j) // expected-error2 {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(d) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(da) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+  return;
+ }
+};
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return [0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef int from;
+
+template 
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T i;
+  T  = i;
+  T *k = 
+  T * = k;
+  T aa[10];
+#pragma omp target 

Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-12 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked 3 inline comments as done.


Comment at: lib/Sema/SemaOpenMP.cpp:11648
@@ +11647,3 @@
+// item should be a pointer or reference to pointer
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

ABataev wrote:
> What if Type is dependent?
In that case at line 8084 (function getPrivateItem) will return the pair 
(nullptr, true) and at line 11640 I will push nullptr for later analysis.
If this is not enough, can you please explain what needs to be done? Thanks!!


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

I don't see successful test for the clause, which prints AST and checks 
serialization/deserialization. Also it should include a template test to check 
that dependent objects are handled correctly



Comment at: include/clang/AST/OpenMPClause.h:4236
@@ +4235,3 @@
+  friend class OMPClauseReader;
+  /// \brief Build clause with number of variables \a N.
+  ///

\brief


Comment at: include/clang/AST/OpenMPClause.h:4258
@@ +4257,3 @@
+public:
+  /// \brief Creates clause with a list of variables \a VL.
+  ///

\brief


Comment at: include/clang/AST/OpenMPClause.h:4269
@@ +4268,3 @@
+ SourceLocation EndLoc, ArrayRef VL);
+  /// \brief Creates an empty clause with the place for \a N variables.
+  ///

\brief


Comment at: lib/Sema/SemaOpenMP.cpp:11648
@@ +11647,3 @@
+// item should be a pointer or reference to pointer
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

What if Type is dependent?


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 63527.
carlo.bertolli added a comment.

[OpenMP] Apply comments: remove creation of private variable and update 
regression tests to include references to pointers.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2275,6 +2275,9 @@
 void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(const OMPUseDevicePtrClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_data_use_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
+struct ST {
+  int *a;
+};
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  void func(int arg) {
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+{}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr() // expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+{}
+#pragma omp target data map(i) use_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(i) // expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(j) // expected-error {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(z) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(aa) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(e) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(g) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k,i,j) // expected-error2 {{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(d) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(da) // expected-error{{expected pointer or reference to pointer in 'use_device_ptr' clause}}
+{}
+  return;
+ }
+};
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return [0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef int from;
+
+template 
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T i;
+  T  = i;
+  T *k = 
+  T * = k;
+  T aa[10];
+#pragma omp target data map(i) use_device_ptr 

Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked an inline comment as done.
carlo.bertolli added a comment.

> No positive tests for the construct


Do you mean in the regression test? I thought I covered all negative and 
positive cases, but please let me know if I missed anything.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8333
@@ -8332,1 +8332,3 @@
   "expected at least one 'to' clause or 'from' clause specified to '#pragma 
omp target update'">;
+def  err_omp_usedeviceptr_not_a_pointer : Error<
+  "expected pointer in 'use_device_ptr' clause">;

ABataev wrote:
> Shall we accept refs to pointers and arrays?
I think that people of the OpenMP committee agreed that we can accept 
references to pointers. There is no indication in the specifications about 
arrays, so I will leave them out for the time being.
I will add a mention of references here.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-11 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

No positive tests for the construct



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8333
@@ -8332,1 +8332,3 @@
   "expected at least one 'to' clause or 'from' clause specified to '#pragma 
omp target update'">;
+def  err_omp_usedeviceptr_not_a_pointer : Error<
+  "expected pointer in 'use_device_ptr' clause">;

Shall we accept refs to pointers and arrays?


Comment at: lib/Sema/SemaOpenMP.cpp:11644-11646
@@ +11643,5 @@
+Type = Type.getUnqualifiedType();
+DeclRefExpr *Ref = nullptr;
+if (!VD)
+  Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/false);
+Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);

It is better to add this code in codegen part


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-06 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 62878.
carlo.bertolli added a comment.

[OpenMP] Remove 'brief' comment tags and change error report to standard 
'expected' form.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2275,6 +2275,9 @@
 void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(const OMPUseDevicePtrClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_data_use_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
+struct ST {
+  int *a;
+};
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  void func(int arg) {
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+{}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr() // expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+{}
+#pragma omp target data map(i) use_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(i) // expected-error {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(j) // expected-error {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(z) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(aa) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(e) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(g) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(k,i,j) // expected-error2 {{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(d) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+#pragma omp target data map(i) use_device_ptr(da) // expected-error{{expected pointer in 'use_device_ptr' clause}}
+{}
+  return;
+ }
+};
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return [0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef int from;
+
+template 
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T i;
+  T  = i;
+  T *k = 
+  T * = k;
+  T aa[10];
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+  {}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+  {}
+#pragma omp target 

Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-06 Thread Carlo Bertolli via cfe-commits
carlo.bertolli marked 4 inline comments as done.
carlo.bertolli added a comment.

Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-05 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/AST/OpenMPClause.h:4221
@@ +4220,3 @@
+
+/// \brief This represents clause 'use_device_ptr' in the '#pragma omp ...'
+/// directives.

No \brief's


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8333
@@ -8332,1 +8332,3 @@
   "expected at least one 'to' clause or 'from' clause specified to '#pragma 
omp target update'">;
+def  err_omp_usedeviceptr_not_a_pointer : Error<
+  "item used in 'use_device_pointer' clause is not a pointer">;

I think it 's better to use 'expected ...' form as in other errors/warnings


Comment at: include/clang/Sema/Sema.h:8466
@@ -8465,1 +8465,3 @@
SourceLocation EndLoc);
+  /// \brief Called on well-formed 'use_device_ptr' clause.
+  OMPClause *ActOnOpenMPUseDevicePtrClause(ArrayRef VarList,

No \brief


Comment at: lib/Sema/TreeTransform.h:1784
@@ -1783,1 +1783,3 @@
 
+  /// \brief Build a new OpenMP 'use_device_ptr' clause.
+  ///

Remove \brief tag


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-07-05 Thread Carlo Bertolli via cfe-commits
carlo.bertolli updated this revision to Diff 62817.
carlo.bertolli added a comment.

[OpenMP] Remove private variable creation from this patch as requested by 
comments and rebase.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_data_use_device_ptr_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2274,6 +2274,9 @@
 void OMPClauseEnqueue::VisitOMPFromClause(const OMPFromClause *C) {
   VisitOMPClauseList(C);
 }
+void OMPClauseEnqueue::VisitOMPUseDevicePtrClause(const OMPUseDevicePtrClause *C) {
+  VisitOMPClauseList(C);
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_data_use_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_data_use_device_ptr_messages.cpp
@@ -0,0 +1,206 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
+struct ST {
+  int *a;
+};
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  void func(int arg) {
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+{}
+#pragma omp target data map(i) use_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr() // expected-error {{expected expression}}
+{}
+#pragma omp target data map(i) use_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+{}
+#pragma omp target data map(i) use_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(i) // expected-error {{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(j) // expected-error {{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(k) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(z) // OK
+{}
+#pragma omp target data map(i) use_device_ptr(aa) // expected-error{{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(e) // expected-error{{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(g) // expected-error{{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(k,i,j) // expected-error2 {{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(d) // expected-error{{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+#pragma omp target data map(i) use_device_ptr(da) // expected-error{{item used in 'use_device_pointer' clause is not a pointer}}
+{}
+  return;
+ }
+};
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return [0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef int from;
+
+template 
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  T i;
+  T  = i;
+  T *k = 
+  T * = k;
+  T aa[10];
+#pragma omp target data map(i) use_device_ptr // expected-error {{expected '(' after 'use_device_ptr'}}
+  {}
+#pragma omp target data map(i) use_device_ptr( // 

Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-06-30 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

In http://reviews.llvm.org/D21904#472074, @carlo.bertolli wrote:

> I think that Kelvin is right. This is what that sentence refers to:
>  int * bla = ..;
>  #pragma omp target data use_device_ptr(bla)
>  {
>
>   .. bla .. // <-- this is the 'reference' that sentence is about
>
> }
>
> What puzzles me about that sentence is that it seems it is asking us to use 
> bla as following:
>  int addr_bla = 
>  // now can use addr_bla
>
> I am specifically referring to this part of the sentence: "must be to the 
> address of the list item"
>
> Anyway, as Kelvin says, this has nothing to do with what we expect sema for 
> use_device_ptr to accept. Samuel point, but I may be mistaken, is that a 
> reference to a pointer should be considered as a pointer itself.
>  Alexey: if you do not think this is right, I can add a test that excludes 
> references.
>
> Finally, thanks for the very quick review and for all your comments
>
> - Carlo


Carlo, I'm not sure about this sentence at all. If you think that this 
construct may accept references to pointers, then go ahead and ignore my 
previous comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-06-30 Thread Carlo Bertolli via cfe-commits
carlo.bertolli added a comment.

I think that Kelvin is right. This is what that sentence refers to:
int * bla = ..;
#pragma omp target data use_device_ptr(bla)
{

  .. bla .. // <-- this is the 'reference' that sentence is about

}

What puzzles me about that sentence is that it seems it is asking us to use bla 
as following:
int addr_bla = 
// now can use addr_bla

I am specifically referring to this part of the sentence: "must be to the 
address of the list item"

Anyway, as Kelvin says, this has nothing to do with what we expect sema for 
use_device_ptr to accept. Samuel point, but I may be mistaken, is that a 
reference to a pointer should be considered as a pointer itself.
Alexey: if you do not think this is right, I can add a test that excludes 
references.

Finally, thanks for the very quick review and for all your comments

- Carlo




Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-06-30 Thread Kelvin Li via cfe-commits
kkwli0 added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:11377
@@ +11376,3 @@
+// item should be a pointer or array
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

sfantao wrote:
> ABataev wrote:
> > sfantao wrote:
> > > ABataev wrote:
> > > > You should not skip the reference from the type, references are not 
> > > > allowed also
> > > Hi Alexey, I think the item can be a reference to a pointer. I couldn't 
> > > find that restriction in the spec,  can you point me to what you are 
> > > referring to? We should probably refer to that in the preceding comment. 
> > > 
> > > Thanks!
> > Here is the restriction:
> > "2.10.1 target data Construct, restrictions. References in the construct to 
> > a list item that appears in a use_device_ptr clause must be to the address 
> > of the list item."
> > Does it mean that references are allowed?
> Ok, thanks. My interpretation is that that restriction refers to references 
> used in clauses (in the same construct) other than use_device_ptr to 
> declarations used in use_device_ptr. I think the motivation is to restrict 
> the use of the value of the pointer  by other clauses given that value is 
> going to change for that data environment because of the behavior implemented 
> by use_device_ptr. Carlo, what is your interpretation?
I interpret the rule to the list item being used inside the construct instead 
of being used in the other clauses on the same construct.


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-06-30 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:11377
@@ +11376,3 @@
+// item should be a pointer or array
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

ABataev wrote:
> sfantao wrote:
> > ABataev wrote:
> > > You should not skip the reference from the type, references are not 
> > > allowed also
> > Hi Alexey, I think the item can be a reference to a pointer. I couldn't 
> > find that restriction in the spec,  can you point me to what you are 
> > referring to? We should probably refer to that in the preceding comment. 
> > 
> > Thanks!
> Here is the restriction:
> "2.10.1 target data Construct, restrictions. References in the construct to a 
> list item that appears in a use_device_ptr clause must be to the address of 
> the list item."
> Does it mean that references are allowed?
Ok, thanks. My interpretation is that that restriction refers to references 
used in clauses (in the same construct) other than use_device_ptr to 
declarations used in use_device_ptr. I think the motivation is to restrict the 
use of the value of the pointer  by other clauses given that value is going to 
change for that data environment because of the behavior implemented by 
use_device_ptr. Carlo, what is your interpretation?


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-06-30 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:11377
@@ +11376,3 @@
+// item should be a pointer or array
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

sfantao wrote:
> ABataev wrote:
> > You should not skip the reference from the type, references are not allowed 
> > also
> Hi Alexey, I think the item can be a reference to a pointer. I couldn't find 
> that restriction in the spec,  can you point me to what you are referring to? 
> We should probably refer to that in the preceding comment. 
> 
> Thanks!
Here is the restriction:
"2.10.1 target data Construct, restrictions. References in the construct to a 
list item that appears in a use_device_ptr clause must be to the address of the 
list item."
Does it mean that references are allowed?


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-06-30 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/Sema/SemaOpenMP.cpp:11377
@@ +11376,3 @@
+// item should be a pointer or array
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

ABataev wrote:
> You should not skip the reference from the type, references are not allowed 
> also
Hi Alexey, I think the item can be a reference to a pointer. I couldn't find 
that restriction in the spec,  can you point me to what you are referring to? 
We should probably refer to that in the preceding comment. 

Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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


Re: [PATCH] D21904: [OpenMP] Initial implementation of parse+sema for clause use_device_ptr of 'target data'

2016-06-30 Thread Alexey Bataev via cfe-commits
ABataev added inline comments.


Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8318
@@ -8317,1 +8317,3 @@
+def  err_omp_usedeviceptr_not_a_pointer : Error<
+  "item used in 'use_device_pointer' clause is not a pointer">;
 } // end of OpenMP category

It's better to rephrase this message: "expected a variable of pointer type" or 
something like this. Also, it would be good to have a corresponding note, 
describing the provided item.


Comment at: lib/Sema/SemaOpenMP.cpp:11377
@@ +11376,3 @@
+// item should be a pointer or array
+if (!Type.getNonReferenceType()->isPointerType()) {
+  Diag(ELoc, diag::err_omp_usedeviceptr_not_a_pointer)

You should not skip the reference from the type, references are not allowed also


Comment at: lib/Sema/SemaOpenMP.cpp:11382-11394
@@ +11381,15 @@
+}
+Type = Type.getUnqualifiedType();
+auto VDPrivate = buildVarDecl(*this, ELoc, Type, D->getName(),
+  D->hasAttrs() ? >getAttrs() : nullptr);
+if (VDPrivate->isInvalidDecl())
+  continue;
+auto VDPrivateRefExpr = buildDeclRefExpr(
+*this, VDPrivate, RefExpr->getType().getUnqualifiedType(), ELoc);
+
+DeclRefExpr *Ref = nullptr;
+if (!VD)
+  Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/false);
+Vars.push_back(VD ? RefExpr->IgnoreParens() : Ref);
+PrivateCopies.push_back(VDPrivateRefExpr);
+  }

I don't think that this patch requires some private copies right now. They will 
be required only during codegen. I think the private copies must be excluded 
from parsing/sema patch


Repository:
  rL LLVM

http://reviews.llvm.org/D21904



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