Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / nvptx_target_cuda_mode_messages.cpp
blobb70136bcdc2d978dd6b1e2634977ea569fd7aedb
1 // RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-target-device -fopenmp-cuda-mode -fopenmp-host-ir-file-path %t-ppc-host.bc -o -
4 template <typename tx, typename ty>
5 struct TT {
6 tx X;
7 ty Y;
8 };
10 int foo(int n, double *ptr) {
11 int a = 0;
12 short aa = 0;
13 float b[10];
14 double c[5][10];
15 TT<long long, char> d;
17 #pragma omp target firstprivate(a) map(tofrom: b) // expected-note 2 {{defined as threadprivate or thread local}}
19 int c; // expected-note {{defined as threadprivate or thread local}}
20 #pragma omp parallel shared(a, b, c, aa) // expected-error 3 {{threadprivate or thread local variable cannot be shared}}
21 b[a] = a;
22 #pragma omp parallel for
23 for (int i = 0; i < 10; ++i) // expected-note {{defined as threadprivate or thread local}}
24 #pragma omp parallel shared(i) // expected-error {{threadprivate or thread local variable cannot be shared}}
25 ++i;
28 #pragma omp target map(aa, b, c, d)
30 int e; // expected-note {{defined as threadprivate or thread local}}
31 #pragma omp parallel private(b, e) // expected-error {{threadprivate or thread local variable cannot be private}}
33 aa += 1;
34 b[2] = 1.0;
35 c[1][2] = 1.0;
36 d.X = 1;
37 d.Y = 1;
41 #pragma omp target private(ptr)
43 ptr[0]++;
46 return a;
49 template <typename tx>
50 tx ftemplate(int n) {
51 tx a = 0;
52 tx b[10];
54 #pragma omp target reduction(+ \
55 : a, b) // expected-note {{defined as threadprivate or thread local}}
57 int e; // expected-note {{defined as threadprivate or thread local}}
58 #pragma omp parallel shared(a, e) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
59 a += 1;
60 b[2] += 1;
63 return a;
66 static int fstatic(int n) {
67 int a = 0;
68 char aaa = 0;
69 int b[10];
71 #pragma omp target firstprivate(a, aaa, b)
73 a += 1;
74 aaa += 1;
75 b[2] += 1;
78 return a;
81 struct S1 {
82 double a;
84 int r1(int n) {
85 int b = n + 1;
87 #pragma omp target firstprivate(b) // expected-note {{defined as threadprivate or thread local}}
89 int c; // expected-note {{defined as threadprivate or thread local}}
90 #pragma omp parallel shared(b, c) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
91 this->a = (double)b + 1.5;
94 return (int)b;
98 int bar(int n, double *ptr) {
99 int a = 0;
100 a += foo(n, ptr);
101 S1 S;
102 a += S.r1(n);
103 a += fstatic(n);
104 a += ftemplate<int>(n); // expected-note {{in instantiation of function template specialization 'ftemplate<int>' requested here}}
106 return a;