1 // expected-no-diagnostics
2 #ifndef HEADER
3 #define HEADER
4
5 // Test host codegen.
6 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
7 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
8 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-64
9 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
10 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
11 // RUN: %clang_cc1 -DCK1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK1 --check-prefix CK1-32
12
13 // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
14 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
15 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
16 // RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
17 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
18 // RUN: %clang_cc1 -DCK1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
19 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
20 #ifdef CK1
21
22 template <typename T, int X, long long Y>
23 struct SS{
24 T a[X];
25 float b;
26 // CK1: define {{.*}}i32 @{{.+}}foo{{.+}}(
fooSS27 int foo(void) {
28
29 // CK1: call i32 @__tgt_target_teams(
30 // CK1: call void @[[OFFL1:.+]](
31 #pragma omp target
32 #pragma omp teams distribute parallel for
33 for(int i = 0; i < X; i++) {
34 a[i] = (T)0;
35 }
36 // CK1: call i32 @__tgt_target_teams(
37 // CK1: call void @[[OFFL2:.+]](
38 #pragma omp target
39 #pragma omp teams distribute parallel for dist_schedule(static)
40 for(int i = 0; i < X; i++) {
41 a[i] = (T)0;
42 }
43 // CK1: call i32 @__tgt_target_teams(
44 // CK1: call void @[[OFFL3:.+]](
45 #pragma omp target
46 #pragma omp teams distribute parallel for dist_schedule(static, X/2)
47 for(int i = 0; i < X; i++) {
48 a[i] = (T)0;
49 }
50 // CK1: define internal void @[[OFFL1]](
51 // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL1:.+]] to {{.+}},
52 // CK1: ret void
53
54 // CK1: define internal void @[[OUTL1]]({{.+}})
55 // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92
56 // CK1: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL1:.+]] to
57 // CK1: call void @__kmpc_for_static_fini(
58 // CK1: ret void
59
60 // CK1: define internal void @[[PAR_OUTL1]]({{.+}})
61 // CK1: call void @__kmpc_for_static_init_4(
62 // CK1: call void @__kmpc_for_static_fini(
63 // CK1: ret void
64
65 // CK1: define internal void @[[OFFL2]](
66 // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL2:.+]] to {{.+}},
67 // CK1: ret void
68
69 // CK1: define internal void @[[OUTL2]]({{.+}})
70 // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92
71 // CK1: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL2:.+]] to
72 // CK1: call void @__kmpc_for_static_fini(
73 // CK1: ret void
74
75 // CK1: define internal void @[[PAR_OUTL2]]({{.+}})
76 // CK1: call void @__kmpc_for_static_init_4(
77 // CK1: call void @__kmpc_for_static_fini(
78 // CK1: ret void
79
80
81 // CK1: define internal void @[[OFFL3]](
82 // CK1: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTL3:.+]] to {{.+}},
83 // CK1: ret void
84
85 // CK1: define internal void @[[OUTL3]]({{.+}})
86 // CK1: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91
87 // CK1: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL3:.+]] to
88 // CK1: call void @__kmpc_for_static_fini(
89 // CK1: ret void
90
91 // CK1: define internal void @[[PAR_OUTL3]]({{.+}})
92 // CK1: call void @__kmpc_for_static_init_4(
93 // CK1: call void @__kmpc_for_static_fini(
94 // CK1: ret void
95
96 return a[0];
97 }
98 };
99
teams_template_struct(void)100 int teams_template_struct(void) {
101 SS<int, 123, 456> V;
102 return V.foo();
103
104 }
105 #endif // CK1
106
107 // Test host codegen.
108 // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64
109 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
110 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-64
111 // RUN: %clang_cc1 -DCK2 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32
112 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
113 // RUN: %clang_cc1 -DCK2 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CK2 --check-prefix CK2-32
114
115 // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
116 // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
117 // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
118 // RUN: %clang_cc1 -DCK2 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s
119 // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
120 // RUN: %clang_cc1 -DCK2 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s
121 // SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
122 #ifdef CK2
123
124 template <typename T, int n>
tmain(T argc)125 int tmain(T argc) {
126 T a[n];
127 int m = 10;
128 #pragma omp target
129 #pragma omp teams distribute parallel for
130 for(int i = 0; i < n; i++) {
131 a[i] = (T)0;
132 }
133 #pragma omp target
134 #pragma omp teams distribute parallel for dist_schedule(static)
135 for(int i = 0; i < n; i++) {
136 a[i] = (T)0;
137 }
138 #pragma omp target
139 #pragma omp teams distribute parallel for dist_schedule(static, m)
140 for(int i = 0; i < n; i++) {
141 a[i] = (T)0;
142 }
143 return 0;
144 }
145
main(int argc,char ** argv)146 int main (int argc, char **argv) {
147 int n = 100;
148 int a[n];
149 int m = 10;
150 #pragma omp target
151 #pragma omp teams distribute parallel for
152 for(int i = 0; i < n; i++) {
153 a[i] = 0;
154 }
155 #pragma omp target
156 #pragma omp teams distribute parallel for dist_schedule(static)
157 for(int i = 0; i < n; i++) {
158 a[i] = 0;
159 }
160 #pragma omp target
161 #pragma omp teams distribute parallel for dist_schedule(static, m)
162 for(int i = 0; i < n; i++) {
163 a[i] = 0;
164 }
165 return tmain<int, 10>(argc);
166 }
167
168 // CK2: define {{.*}}i32 @{{[^,]+}}(i{{.+}}{{.+}} %[[ARGC:.+]], {{.+}})
169 // CK2: call i32 @__tgt_target_teams(
170 // CK2: call void @[[OFFL1:.+]]({{.+}})
171 // CK2: call i32 @__tgt_target_teams(
172 // CK2: call void @[[OFFL2:.+]]({{.+}})
173 // CK2: call i32 @__tgt_target_teams(
174 // CK2: call void @[[OFFL3:.+]]({{.+}})
175 // CK2: {{%.+}} = call{{.*}} i32 @[[TMAIN:.+]]({{.+}})
176 // CK2: ret
177
178 // CK2: define {{.*}}void @[[OFFL1]]({{.+}})
179 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL1:.+]] to {{.+}},
180 // CK2: ret void
181
182 // CK2: define internal void @[[OUTL1]]({{.+}})
183 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92
184 // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL1:.+]] to
185 // CK2: call void @__kmpc_for_static_fini(
186 // CK2: ret void
187
188 // CK2: define internal void @[[PAR_OUTL1]]({{.+}})
189 // CK2: call void @__kmpc_for_static_init_4(
190 // CK2: call void @__kmpc_for_static_fini(
191 // CK2: ret void
192
193 // CK2: define {{.*}}void @[[OFFL2]]({{.+}})
194 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 3, {{.+}} @[[OUTL2:.+]] to {{.+}},
195 // CK2: ret void
196
197 // CK2: define internal void @[[OUTL2]]({{.+}})
198 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92
199 // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL2:.+]] to
200 // CK2: call void @__kmpc_for_static_fini(
201 // CK2: ret void
202
203 // CK2: define internal void @[[PAR_OUTL2]]({{.+}})
204 // CK2: call void @__kmpc_for_static_init_4(
205 // CK2: call void @__kmpc_for_static_fini(
206 // CK2: ret void
207
208 // CK2: define {{.*}}void @[[OFFL3]]({{.+}})
209 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 4, {{.+}} @[[OUTL3:.+]] to {{.+}},
210 // CK2: ret void
211
212 // CK2: define internal void @[[OUTL3]]({{.+}})
213 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91
214 // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTL3:.+]] to
215 // CK2: call void @__kmpc_for_static_fini(
216 // CK2: ret void
217
218 // CK2: define internal void @[[PAR_OUTL3]]({{.+}})
219 // CK2: call void @__kmpc_for_static_init_4(
220 // CK2: call void @__kmpc_for_static_fini(
221 // CK2: ret void
222
223 // CK2: define {{.*}}i32 @[[TMAIN]]({{.+}})
224 // CK2: call i32 @__tgt_target_teams(
225 // CK2: call void @[[OFFLT1:.+]]({{.+}})
226 // CK2: call i32 @__tgt_target_teams(
227 // CK2: call void @[[OFFLT2:.+]]({{.+}})
228 // CK2: call i32 @__tgt_target_teams(
229 // CK2: call void @[[OFFLT3:.+]]({{.+}})
230 // CK2: ret
231 // CK2-NEXT: }
232
233 // CK2: define {{.*}}void @[[OFFLT1]]({{.+}})
234 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT1:.+]] to {{.+}},
235 // CK2: ret void
236
237 // CK2: define internal void @[[OUTLT1]]({{.+}})
238 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92
239 // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTLT1:.+]] to
240 // CK2: call void @__kmpc_for_static_fini(
241 // CK2: ret void
242
243 // CK2: define internal void @[[PAR_OUTLT1]]({{.+}})
244 // CK2: call void @__kmpc_for_static_init_4(
245 // CK2: call void @__kmpc_for_static_fini(
246 // CK2: ret void
247
248 // CK2: define {{.*}}void @[[OFFLT2]]({{.+}})
249 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}} @[[OUTLT2:.+]] to {{.+}},
250 // CK2: ret void
251
252 // CK2: define internal void @[[OUTLT2]]({{.+}})
253 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 92
254 // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTLT2:.+]] to
255 // CK2: call void @__kmpc_for_static_fini(
256 // CK2: ret void
257
258 // CK2: define internal void @[[PAR_OUTLT2]]({{.+}})
259 // CK2: call void @__kmpc_for_static_init_4(
260 // CK2: call void @__kmpc_for_static_fini(
261 // CK2: ret void
262
263 // CK2: define {{.*}}void @[[OFFLT3]]({{.+}})
264 // CK2: call void {{.+}} @__kmpc_fork_teams({{.+}}, i32 {{.+}}, {{.+}} @[[OUTLT3:.+]] to {{.+}},
265 // CK2: ret void
266
267 // CK2: define internal void @[[OUTLT3]]({{.+}})
268 // CK2: call void @__kmpc_for_static_init_4({{.+}}, {{.+}}, i32 91
269 // CK2: call void {{.*}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} @[[PAR_OUTLT3:.+]] to
270 // CK2: call void @__kmpc_for_static_fini(
271 // CK2: ret void
272
273 // CK2: define internal void @[[PAR_OUTLT3]]({{.+}})
274 // CK2: call void @__kmpc_for_static_init_4(
275 // CK2: call void @__kmpc_for_static_fini(
276 // CK2: ret void
277
278 #endif // CK2
279 #endif // #ifndef HEADER
280