1 // RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s
4 // RUN: %clang_cc1 -fopenmp -x c++ %s -verify -Wno-vla -debug-info-kind=limited -emit-llvm -o - -triple x86_64-apple-darwin10 | FileCheck %s --check-prefix=CHECK --check-prefix=DEBUG
6 // RUN: %clang_cc1 -verify -Wno-vla -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
7 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
8 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
9 // RUN: %clang_cc1 -fopenmp-simd -x c++ %s -verify -Wno-vla -debug-info-kind=limited -emit-llvm -o - -triple x86_64-apple-darwin10 | FileCheck --check-prefix SIMD-ONLY0 %s
10 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
11 // expected-no-diagnostics
15 typedef void **omp_allocator_handle_t
;
16 extern const omp_allocator_handle_t omp_null_allocator
;
17 extern const omp_allocator_handle_t omp_default_mem_alloc
;
18 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
19 extern const omp_allocator_handle_t omp_const_mem_alloc
;
20 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
21 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
22 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
23 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
24 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
26 // CHECK-DAG: @reduction_size.[[ID:.+]]_[[CID:[0-9]+]].artificial.
27 // CHECK-DAG: @reduction_size.[[ID]]_[[CID]].artificial..cache.
33 S
& operator=(const S
&) {return *this;}
35 friend S
operator+(const S
&a
, const S
&b
) {return a
;}
38 int main(int argc
, char **argv
) {
43 #pragma omp taskgroup allocate(omp_pteam_mem_alloc: a) task_reduction(+: a, b, argc)
45 #pragma omp taskgroup task_reduction(-:c, d)
52 // CHECK: [[ARGC_ADDR:%.+]] = alloca i32,
53 // CHECK: [[ARGV_ADDR:%.+]] = alloca ptr,
54 // CHECK: [[A:%.+]] = alloca i32,
55 // CHECK: [[B:%.+]] = alloca float,
56 // CHECK: [[C:%.+]] = alloca [5 x %struct.S],
57 // CHECK: [[RD_IN1:%.+]] = alloca [3 x [[T1:%[^,]+]]],
58 // CHECK: [[TD1:%.+]] = alloca ptr,
59 // CHECK: [[RD_IN2:%.+]] = alloca [2 x [[T2:%[^,]+]]],
60 // CHECK: [[TD2:%.+]] = alloca ptr,
62 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(ptr
63 // CHECK: [[VLA:%.+]] = alloca i16, i64 [[VLA_SIZE:%[^,]+]],
65 // CHECK: call void @__kmpc_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])
66 // CHECK-DAG: store ptr [[A]], ptr [[A_REF:[^,]+]],
67 // CHECK-DAG: [[A_REF]] = getelementptr inbounds [[T1]], ptr [[GEPA:%[^,]+]], i32 0, i32 0
68 // CHECK-DAG: store ptr [[A]], ptr [[A_REF:[^,]+]],
69 // CHECK-DAG: [[A_REF]] = getelementptr inbounds [[T1]], ptr [[GEPA]], i32 0, i32 1
70 // CHECK-DAG: [[GEPA]] = getelementptr inbounds [3 x [[T1]]], ptr [[RD_IN1]], i64 0, i64
71 // CHECK-DAG: [[TMP6:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPA]], i32 0, i32 2
72 // CHECK-DAG: store i64 4, ptr [[TMP6]],
73 // CHECK-DAG: [[TMP7:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPA]], i32 0, i32 3
74 // CHECK-DAG: store ptr @[[AINIT:.+]], ptr [[TMP7]],
75 // CHECK-DAG: [[TMP8:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPA]], i32 0, i32 4
76 // CHECK-DAG: store ptr null, ptr [[TMP8]],
77 // CHECK-DAG: [[TMP9:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPA]], i32 0, i32 5
78 // CHECK-DAG: store ptr @[[ACOMB:.+]], ptr [[TMP9]],
79 // CHECK-DAG: [[TMP10:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPA]], i32 0, i32 6
80 // CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP10]], i8 0, i64 4, i1 false)
81 // CHECK-DAG: store ptr [[B]], ptr [[TMP12:%[^,]+]],
82 // CHECK-DAG: [[TMP12]] = getelementptr inbounds [[T1]], ptr [[GEPB:%[^,]+]], i32 0, i32 0
83 // CHECK-DAG: store ptr [[B]], ptr [[TMP12:%[^,]+]],
84 // CHECK-DAG: [[TMP12]] = getelementptr inbounds [[T1]], ptr [[GEPB]], i32 0, i32 1
85 // CHECK-DAG: [[GEPB]] = getelementptr inbounds [3 x [[T1]]], ptr [[RD_IN1]], i64 0, i64
86 // CHECK-DAG: [[TMP14:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPB]], i32 0, i32 2
87 // CHECK-DAG: store i64 4, ptr [[TMP14]],
88 // CHECK-DAG: [[TMP15:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPB]], i32 0, i32 3
89 // CHECK-DAG: store ptr @[[BINIT:.+]], ptr [[TMP15]],
90 // CHECK-DAG: [[TMP16:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPB]], i32 0, i32 4
91 // CHECK-DAG: store ptr null, ptr [[TMP16]],
92 // CHECK-DAG: [[TMP17:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPB]], i32 0, i32 5
93 // CHECK-DAG: store ptr @[[BCOMB:.+]], ptr [[TMP17]],
94 // CHECK-DAG: [[TMP18:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPB]], i32 0, i32 6
95 // CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP18]], i8 0, i64 4, i1 false)
96 // CHECK-DAG: store ptr [[ARGC_ADDR]], ptr [[TMP20:%[^,]+]],
97 // CHECK-DAG: [[TMP20]] = getelementptr inbounds [[T1]], ptr [[GEPARGC:%[^,]+]], i32 0, i32 0
98 // CHECK-DAG: store ptr [[ARGC_ADDR]], ptr [[TMP20:%[^,]+]],
99 // CHECK-DAG: [[TMP20]] = getelementptr inbounds [[T1]], ptr [[GEPARGC]], i32 0, i32 1
100 // CHECK-DAG: [[GEPARGC]] = getelementptr inbounds [3 x [[T1]]], ptr [[RD_IN1]], i64 0, i64
101 // CHECK-DAG: [[TMP22:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPARGC]], i32 0, i32 2
102 // CHECK-DAG: store i64 4, ptr [[TMP22]],
103 // CHECK-DAG: [[TMP23:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPARGC]], i32 0, i32 3
104 // CHECK-DAG: store ptr @[[ARGCINIT:.+]], ptr [[TMP23]],
105 // CHECK-DAG: [[TMP24:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPARGC]], i32 0, i32 4
106 // CHECK-DAG: store ptr null, ptr [[TMP24]],
107 // CHECK-DAG: [[TMP25:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPARGC]], i32 0, i32 5
108 // CHECK-DAG: store ptr @[[ARGCCOMB:.+]], ptr [[TMP25]],
109 // CHECK-DAG: [[TMP26:%.+]] = getelementptr inbounds [[T1]], ptr [[GEPARGC]], i32 0, i32 6
110 // CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP26]], i8 0, i64 4, i1 false)
111 // CHECK-DAG: [[TMP29:%.+]] = call ptr @__kmpc_taskred_init(i32 [[GTID]], i32 3, ptr [[RD_IN1]])
112 // DEBUG-DAG: call void @llvm.dbg.declare(metadata ptr [[TD1]],
113 // CHECK-DAG: store ptr [[TMP29]], ptr [[TD1]],
114 // CHECK-DAG: call void @__kmpc_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])
115 // CHECK-DAG: store ptr [[C]], ptr [[TMP30:%[^,]+]],
116 // CHECK-DAG: [[TMP30]] = getelementptr inbounds [[T2]], ptr [[GEPC:%[^,]+]], i32 0, i32 0
117 // CHECK-DAG: store ptr [[C]], ptr [[TMP30:%[^,]+]],
118 // CHECK-DAG: [[TMP30]] = getelementptr inbounds [[T2]], ptr [[GEPC]], i32 0, i32 1
119 // CHECK-DAG: [[GEPC]] = getelementptr inbounds [2 x [[T2]]], ptr [[RD_IN2]], i64 0, i64
120 // CHECK-DAG: [[TMP32:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPC]], i32 0, i32 2
121 // CHECK-DAG: store i64 20, ptr [[TMP32]],
122 // CHECK-DAG: [[TMP33:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPC]], i32 0, i32 3
123 // CHECK-DAG: store ptr @[[CINIT:.+]], ptr [[TMP33]],
124 // CHECK-DAG: [[TMP34:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPC]], i32 0, i32 4
125 // CHECK-DAG: store ptr @[[CFINI:.+]], ptr [[TMP34]],
126 // CHECK-DAG: [[TMP35:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPC]], i32 0, i32 5
127 // CHECK-DAG: store ptr @[[CCOMB:.+]], ptr [[TMP35]],
128 // CHECK-DAG: [[TMP36:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPC]], i32 0, i32 6
129 // CHECK-DAG: call void @llvm.memset.p0.i64(ptr align 8 [[TMP36]], i8 0, i64 4, i1 false)
130 // CHECK-DAG: store ptr [[VLA]], ptr [[TMP38:%[^,]+]],
131 // CHECK-DAG: [[TMP38]] = getelementptr inbounds [[T2]], ptr [[GEPVLA:%[^,]+]], i32 0, i32 0
132 // CHECK-DAG: store ptr [[VLA]], ptr [[TMP38:%[^,]+]],
133 // CHECK-DAG: [[TMP38]] = getelementptr inbounds [[T2]], ptr [[GEPVLA]], i32 0, i32 1
134 // CHECK-DAG: [[GEPVLA]] = getelementptr inbounds [2 x [[T2]]], ptr [[RD_IN2]], i64 0, i64
135 // CHECK-DAG: [[TMP40:%.+]] = mul nuw i64 [[VLA_SIZE]], 2
136 // CHECK-DAG: [[TMP41:%.+]] = udiv exact i64 [[TMP40]], ptrtoint (ptr getelementptr (i16, ptr null, i32 1) to i64)
137 // CHECK-DAG: [[TMP42:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPVLA]], i32 0, i32 2
138 // CHECK-DAG: store i64 [[TMP40]], ptr [[TMP42]],
139 // CHECK-DAG: [[TMP43:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPVLA]], i32 0, i32 3
140 // CHECK-DAG: store ptr @[[VLAINIT:.+]], ptr [[TMP43]],
141 // CHECK-DAG: [[TMP44:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPVLA]], i32 0, i32 4
142 // CHECK-DAG: store ptr null, ptr [[TMP44]],
143 // CHECK-DAG: [[TMP45:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPVLA]], i32 0, i32 5
144 // CHECK-DAG: store ptr @[[VLACOMB:.+]], ptr [[TMP45]],
145 // CHECK-DAG: [[TMP46:%.+]] = getelementptr inbounds [[T2]], ptr [[GEPVLA]], i32 0, i32 6
146 // CHECK-DAG: store i32 1, ptr [[TMP46]],
147 // CHECK: [[TMP48:%.+]] = call ptr @__kmpc_taskred_init(i32 [[GTID]], i32 2, ptr [[RD_IN2]])
148 // CHECK: store ptr [[TMP48]], ptr [[TD2]],
149 // CHECK: call void @__kmpc_end_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])
150 // CHECK: call void @__kmpc_end_taskgroup(ptr {{[^,]+}}, i32 [[GTID]])
152 // CHECK-DAG: define internal void @[[AINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})
153 // CHECK-DAG: store i32 0, ptr %
154 // CHECK-DAG: ret void
157 // CHECK-DAG: define internal void @[[ACOMB]](ptr noundef %0, ptr noundef %1)
158 // CHECK-DAG: add nsw i32 %
159 // CHECK-DAG: store i32 %
160 // CHECK-DAG: ret void
163 // CHECK-DAG: define internal void @[[BINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})
164 // CHECK-DAG: store float 0.000000e+00, ptr %
165 // CHECK-DAG: ret void
168 // CHECK-DAG: define internal void @[[BCOMB]](ptr noundef %0, ptr noundef %1)
169 // CHECK-DAG: fadd float %
170 // CHECK-DAG: store float %
171 // CHECK-DAG: ret void
174 // CHECK-DAG: define internal void @[[ARGCINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})
175 // CHECK-DAG: store i32 0, ptr %
176 // CHECK-DAG: ret void
179 // CHECK-DAG: define internal void @[[ARGCCOMB]](ptr noundef %0, ptr noundef %1)
180 // CHECK-DAG: add nsw i32 %
181 // CHECK-DAG: store i32 %
182 // CHECK-DAG: ret void
185 // CHECK-DAG: define internal void @[[CINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})
186 // CHECK-DAG: phi ptr [
187 // CHECK-DAG: call {{.+}}(ptr {{.+}})
188 // CHECK-DAG: br i1 %
189 // CHECK-DAG: ret void
192 // CHECK-DAG: define internal void @[[CFINI]](ptr noundef %0)
193 // CHECK-DAG: phi ptr [
194 // CHECK-DAG: call {{.+}}(ptr {{.+}})
195 // CHECK-DAG: br i1 %
196 // CHECK-DAG: ret void
199 // CHECK-DAG: define internal void @[[CCOMB]](ptr noundef %0, ptr noundef %1)
200 // CHECK-DAG: phi ptr [
201 // CHECK-DAG: phi ptr [
202 // CHECK-DAG: call {{.+}}(ptr {{.+}}, ptr {{.+}}, ptr {{.+}})
203 // CHECK-DAG: call {{.+}}(ptr {{.+}}, ptr {{.+}})
204 // CHECK-DAG: call {{.+}}(ptr {{.+}})
205 // CHECK-DAG: br i1 %
206 // CHECK-DAG: ret void
209 // CHECK-DAG: define internal void @[[VLAINIT]](ptr noalias noundef %{{.+}}, ptr noalias noundef %{{.+}})
210 // CHECK-DAG: call i32 @__kmpc_global_thread_num(ptr {{[^,]+}})
211 // CHECK-DAG: call ptr @__kmpc_threadprivate_cached(ptr
212 // CHECK-DAG: phi ptr [
213 // CHECK-DAG: store i16 0, ptr %
214 // CHECK-DAG: br i1 %
215 // CHECK-DAG: ret void
218 // CHECK-DAG: define internal void @[[VLACOMB]](ptr noundef %0, ptr noundef %1)
219 // CHECK-DAG: call i32 @__kmpc_global_thread_num(ptr {{[^,]+}})
220 // CHECK-DAG: call ptr @__kmpc_threadprivate_cached(ptr
221 // CHECK-DAG: phi ptr [
222 // CHECK-DAG: phi ptr [
223 // CHECK-DAG: sext i16 %{{.+}} to i32
224 // CHECK-DAG: add nsw i32 %
225 // CHECK-DAG: trunc i32 %{{.+}} to i16
226 // CHECK-DAG: store i16 %
227 // CHECK-DAG: br i1 %
228 // CHECK-DAG: ret void
232 // DEBUG-LABEL: distinct !DICompileUnit
233 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[AINIT]]",
234 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ACOMB]]",
235 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[BINIT]]",
236 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[BCOMB]]",
237 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ARGCINIT]]",
238 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[ARGCCOMB]]",
239 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CINIT]]",
240 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CFINI]]",
241 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[CCOMB]]",
242 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[VLAINIT]]",
243 // DEBUG-DAG: distinct !DISubprogram(linkageName: "[[VLACOMB]]",