Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / single_private_codegen.cpp
blob5d90103c0f2e95139fc9e0379270df55b907eda0
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK1
3 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
4 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK1
5 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK3
6 // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK4
8 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
9 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
10 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
11 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DLAMBDA -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
12 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -fblocks -DBLOCKS -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
13 // expected-no-diagnostics
14 #ifndef HEADER
15 #define HEADER
17 template <class T>
18 struct S {
19 T f;
20 S(T a) : f(a) {}
21 S() : f() {}
22 operator T() { return T(); }
23 ~S() {}
26 volatile double g;
28 template <typename T>
29 T tmain() {
30 S<T> test;
31 T t_var = T();
32 T vec[] = {1, 2};
33 S<T> s_arr[] = {1, 2};
34 S<T> var(3);
35 #pragma omp parallel
36 #pragma omp single private(t_var, vec, s_arr, s_arr, var, var)
38 vec[0] = t_var;
39 s_arr[0] = var;
41 return T();
44 int main() {
45 static int sivar;
46 #ifdef LAMBDA
47 [&]() {
48 #pragma omp parallel
49 #pragma omp single private(g, sivar)
51 g = 1;
52 sivar = 101;
53 [&]() {
54 g = 2;
55 sivar = 211;
56 }();
58 }();
59 return 0;
60 #elif defined(BLOCKS)
62 #pragma omp parallel
63 #pragma omp single private(g, sivar)
65 g = 1;
66 sivar = 101;
68 g = 2;
69 sivar = 203;
70 }();
72 }();
73 return 0;
74 #else
75 S<float> test;
76 int t_var = 0;
77 int vec[] = {1, 2};
78 S<float> s_arr[] = {1, 2};
79 S<float> var(3);
80 #pragma omp parallel
81 #pragma omp single private(t_var, vec, s_arr, s_arr, var, var, sivar)
83 vec[0] = t_var;
84 s_arr[0] = var;
85 sivar = 303;
87 return tmain<int>();
88 #endif
92 #endif
94 // CHECK1-LABEL: define {{[^@]+}}@main
95 // CHECK1-SAME: () #[[ATTR0:[0-9]+]] {
96 // CHECK1-NEXT: entry:
97 // CHECK1-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
98 // CHECK1-NEXT: [[TEST:%.*]] = alloca [[STRUCT_S:%.*]], align 4
99 // CHECK1-NEXT: [[T_VAR:%.*]] = alloca i32, align 4
100 // CHECK1-NEXT: [[VEC:%.*]] = alloca [2 x i32], align 4
101 // CHECK1-NEXT: [[S_ARR:%.*]] = alloca [2 x %struct.S], align 4
102 // CHECK1-NEXT: [[VAR:%.*]] = alloca [[STRUCT_S]], align 4
103 // CHECK1-NEXT: store i32 0, ptr [[RETVAL]], align 4
104 // CHECK1-NEXT: call void @_ZN1SIfEC1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[TEST]])
105 // CHECK1-NEXT: store i32 0, ptr [[T_VAR]], align 4
106 // CHECK1-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[VEC]], ptr align 4 @__const.main.vec, i64 8, i1 false)
107 // CHECK1-NEXT: [[ARRAYINIT_BEGIN:%.*]] = getelementptr inbounds [2 x %struct.S], ptr [[S_ARR]], i64 0, i64 0
108 // CHECK1-NEXT: call void @_ZN1SIfEC1Ef(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYINIT_BEGIN]], float noundef 1.000000e+00)
109 // CHECK1-NEXT: [[ARRAYINIT_ELEMENT:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARRAYINIT_BEGIN]], i64 1
110 // CHECK1-NEXT: call void @_ZN1SIfEC1Ef(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYINIT_ELEMENT]], float noundef 2.000000e+00)
111 // CHECK1-NEXT: call void @_ZN1SIfEC1Ef(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]], float noundef 3.000000e+00)
112 // CHECK1-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1:[0-9]+]], i32 0, ptr @main.omp_outlined)
113 // CHECK1-NEXT: [[CALL:%.*]] = call noundef i32 @_Z5tmainIiET_v()
114 // CHECK1-NEXT: store i32 [[CALL]], ptr [[RETVAL]], align 4
115 // CHECK1-NEXT: call void @_ZN1SIfED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]]) #[[ATTR5:[0-9]+]]
116 // CHECK1-NEXT: [[ARRAY_BEGIN:%.*]] = getelementptr inbounds [2 x %struct.S], ptr [[S_ARR]], i32 0, i32 0
117 // CHECK1-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARRAY_BEGIN]], i64 2
118 // CHECK1-NEXT: br label [[ARRAYDESTROY_BODY:%.*]]
119 // CHECK1: arraydestroy.body:
120 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENTPAST:%.*]] = phi ptr [ [[TMP0]], [[ENTRY:%.*]] ], [ [[ARRAYDESTROY_ELEMENT:%.*]], [[ARRAYDESTROY_BODY]] ]
121 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARRAYDESTROY_ELEMENTPAST]], i64 -1
122 // CHECK1-NEXT: call void @_ZN1SIfED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYDESTROY_ELEMENT]]) #[[ATTR5]]
123 // CHECK1-NEXT: [[ARRAYDESTROY_DONE:%.*]] = icmp eq ptr [[ARRAYDESTROY_ELEMENT]], [[ARRAY_BEGIN]]
124 // CHECK1-NEXT: br i1 [[ARRAYDESTROY_DONE]], label [[ARRAYDESTROY_DONE1:%.*]], label [[ARRAYDESTROY_BODY]]
125 // CHECK1: arraydestroy.done1:
126 // CHECK1-NEXT: call void @_ZN1SIfED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[TEST]]) #[[ATTR5]]
127 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, ptr [[RETVAL]], align 4
128 // CHECK1-NEXT: ret i32 [[TMP1]]
131 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIfEC1Ev
132 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1:[0-9]+]] comdat align 2 {
133 // CHECK1-NEXT: entry:
134 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
135 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
136 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
137 // CHECK1-NEXT: call void @_ZN1SIfEC2Ev(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]])
138 // CHECK1-NEXT: ret void
141 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIfEC1Ef
142 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], float noundef [[A:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
143 // CHECK1-NEXT: entry:
144 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
145 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca float, align 4
146 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
147 // CHECK1-NEXT: store float [[A]], ptr [[A_ADDR]], align 4
148 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
149 // CHECK1-NEXT: [[TMP0:%.*]] = load float, ptr [[A_ADDR]], align 4
150 // CHECK1-NEXT: call void @_ZN1SIfEC2Ef(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]], float noundef [[TMP0]])
151 // CHECK1-NEXT: ret void
154 // CHECK1-LABEL: define {{[^@]+}}@main.omp_outlined
155 // CHECK1-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]]) #[[ATTR3:[0-9]+]] {
156 // CHECK1-NEXT: entry:
157 // CHECK1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
158 // CHECK1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
159 // CHECK1-NEXT: [[T_VAR:%.*]] = alloca i32, align 4
160 // CHECK1-NEXT: [[VEC:%.*]] = alloca [2 x i32], align 4
161 // CHECK1-NEXT: [[S_ARR:%.*]] = alloca [2 x %struct.S], align 4
162 // CHECK1-NEXT: [[VAR:%.*]] = alloca [[STRUCT_S:%.*]], align 4
163 // CHECK1-NEXT: [[SIVAR:%.*]] = alloca i32, align 4
164 // CHECK1-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
165 // CHECK1-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
166 // CHECK1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
167 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
168 // CHECK1-NEXT: [[TMP2:%.*]] = call i32 @__kmpc_single(ptr @[[GLOB1]], i32 [[TMP1]])
169 // CHECK1-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0
170 // CHECK1-NEXT: br i1 [[TMP3]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_END:%.*]]
171 // CHECK1: omp_if.then:
172 // CHECK1-NEXT: [[ARRAY_BEGIN:%.*]] = getelementptr inbounds [2 x %struct.S], ptr [[S_ARR]], i32 0, i32 0
173 // CHECK1-NEXT: [[ARRAYCTOR_END:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARRAY_BEGIN]], i64 2
174 // CHECK1-NEXT: br label [[ARRAYCTOR_LOOP:%.*]]
175 // CHECK1: arrayctor.loop:
176 // CHECK1-NEXT: [[ARRAYCTOR_CUR:%.*]] = phi ptr [ [[ARRAY_BEGIN]], [[OMP_IF_THEN]] ], [ [[ARRAYCTOR_NEXT:%.*]], [[ARRAYCTOR_LOOP]] ]
177 // CHECK1-NEXT: call void @_ZN1SIfEC1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYCTOR_CUR]])
178 // CHECK1-NEXT: [[ARRAYCTOR_NEXT]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARRAYCTOR_CUR]], i64 1
179 // CHECK1-NEXT: [[ARRAYCTOR_DONE:%.*]] = icmp eq ptr [[ARRAYCTOR_NEXT]], [[ARRAYCTOR_END]]
180 // CHECK1-NEXT: br i1 [[ARRAYCTOR_DONE]], label [[ARRAYCTOR_CONT:%.*]], label [[ARRAYCTOR_LOOP]]
181 // CHECK1: arrayctor.cont:
182 // CHECK1-NEXT: call void @_ZN1SIfEC1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]])
183 // CHECK1-NEXT: [[TMP4:%.*]] = load i32, ptr [[T_VAR]], align 4
184 // CHECK1-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x i32], ptr [[VEC]], i64 0, i64 0
185 // CHECK1-NEXT: store i32 [[TMP4]], ptr [[ARRAYIDX]], align 4
186 // CHECK1-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds [2 x %struct.S], ptr [[S_ARR]], i64 0, i64 0
187 // CHECK1-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[ARRAYIDX1]], ptr align 4 [[VAR]], i64 4, i1 false)
188 // CHECK1-NEXT: store i32 303, ptr [[SIVAR]], align 4
189 // CHECK1-NEXT: call void @_ZN1SIfED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]]) #[[ATTR5]]
190 // CHECK1-NEXT: [[ARRAY_BEGIN2:%.*]] = getelementptr inbounds [2 x %struct.S], ptr [[S_ARR]], i32 0, i32 0
191 // CHECK1-NEXT: [[TMP5:%.*]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARRAY_BEGIN2]], i64 2
192 // CHECK1-NEXT: br label [[ARRAYDESTROY_BODY:%.*]]
193 // CHECK1: arraydestroy.body:
194 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENTPAST:%.*]] = phi ptr [ [[TMP5]], [[ARRAYCTOR_CONT]] ], [ [[ARRAYDESTROY_ELEMENT:%.*]], [[ARRAYDESTROY_BODY]] ]
195 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds [[STRUCT_S]], ptr [[ARRAYDESTROY_ELEMENTPAST]], i64 -1
196 // CHECK1-NEXT: call void @_ZN1SIfED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYDESTROY_ELEMENT]]) #[[ATTR5]]
197 // CHECK1-NEXT: [[ARRAYDESTROY_DONE:%.*]] = icmp eq ptr [[ARRAYDESTROY_ELEMENT]], [[ARRAY_BEGIN2]]
198 // CHECK1-NEXT: br i1 [[ARRAYDESTROY_DONE]], label [[ARRAYDESTROY_DONE3:%.*]], label [[ARRAYDESTROY_BODY]]
199 // CHECK1: arraydestroy.done3:
200 // CHECK1-NEXT: call void @__kmpc_end_single(ptr @[[GLOB1]], i32 [[TMP1]])
201 // CHECK1-NEXT: br label [[OMP_IF_END]]
202 // CHECK1: omp_if.end:
203 // CHECK1-NEXT: call void @__kmpc_barrier(ptr @[[GLOB2:[0-9]+]], i32 [[TMP1]])
204 // CHECK1-NEXT: ret void
207 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIfED1Ev
208 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
209 // CHECK1-NEXT: entry:
210 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
211 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
212 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
213 // CHECK1-NEXT: call void @_ZN1SIfED2Ev(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]]) #[[ATTR5]]
214 // CHECK1-NEXT: ret void
217 // CHECK1-LABEL: define {{[^@]+}}@_Z5tmainIiET_v
218 // CHECK1-SAME: () #[[ATTR6:[0-9]+]] comdat {
219 // CHECK1-NEXT: entry:
220 // CHECK1-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
221 // CHECK1-NEXT: [[TEST:%.*]] = alloca [[STRUCT_S_0:%.*]], align 4
222 // CHECK1-NEXT: [[T_VAR:%.*]] = alloca i32, align 4
223 // CHECK1-NEXT: [[VEC:%.*]] = alloca [2 x i32], align 4
224 // CHECK1-NEXT: [[S_ARR:%.*]] = alloca [2 x %struct.S.0], align 4
225 // CHECK1-NEXT: [[VAR:%.*]] = alloca [[STRUCT_S_0]], align 4
226 // CHECK1-NEXT: call void @_ZN1SIiEC1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[TEST]])
227 // CHECK1-NEXT: store i32 0, ptr [[T_VAR]], align 4
228 // CHECK1-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[VEC]], ptr align 4 @__const._Z5tmainIiET_v.vec, i64 8, i1 false)
229 // CHECK1-NEXT: [[ARRAYINIT_BEGIN:%.*]] = getelementptr inbounds [2 x %struct.S.0], ptr [[S_ARR]], i64 0, i64 0
230 // CHECK1-NEXT: call void @_ZN1SIiEC1Ei(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYINIT_BEGIN]], i32 noundef 1)
231 // CHECK1-NEXT: [[ARRAYINIT_ELEMENT:%.*]] = getelementptr inbounds [[STRUCT_S_0]], ptr [[ARRAYINIT_BEGIN]], i64 1
232 // CHECK1-NEXT: call void @_ZN1SIiEC1Ei(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYINIT_ELEMENT]], i32 noundef 2)
233 // CHECK1-NEXT: call void @_ZN1SIiEC1Ei(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]], i32 noundef 3)
234 // CHECK1-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1]], i32 0, ptr @_Z5tmainIiET_v.omp_outlined)
235 // CHECK1-NEXT: store i32 0, ptr [[RETVAL]], align 4
236 // CHECK1-NEXT: call void @_ZN1SIiED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]]) #[[ATTR5]]
237 // CHECK1-NEXT: [[ARRAY_BEGIN:%.*]] = getelementptr inbounds [2 x %struct.S.0], ptr [[S_ARR]], i32 0, i32 0
238 // CHECK1-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[STRUCT_S_0]], ptr [[ARRAY_BEGIN]], i64 2
239 // CHECK1-NEXT: br label [[ARRAYDESTROY_BODY:%.*]]
240 // CHECK1: arraydestroy.body:
241 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENTPAST:%.*]] = phi ptr [ [[TMP0]], [[ENTRY:%.*]] ], [ [[ARRAYDESTROY_ELEMENT:%.*]], [[ARRAYDESTROY_BODY]] ]
242 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds [[STRUCT_S_0]], ptr [[ARRAYDESTROY_ELEMENTPAST]], i64 -1
243 // CHECK1-NEXT: call void @_ZN1SIiED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYDESTROY_ELEMENT]]) #[[ATTR5]]
244 // CHECK1-NEXT: [[ARRAYDESTROY_DONE:%.*]] = icmp eq ptr [[ARRAYDESTROY_ELEMENT]], [[ARRAY_BEGIN]]
245 // CHECK1-NEXT: br i1 [[ARRAYDESTROY_DONE]], label [[ARRAYDESTROY_DONE1:%.*]], label [[ARRAYDESTROY_BODY]]
246 // CHECK1: arraydestroy.done1:
247 // CHECK1-NEXT: call void @_ZN1SIiED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[TEST]]) #[[ATTR5]]
248 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, ptr [[RETVAL]], align 4
249 // CHECK1-NEXT: ret i32 [[TMP1]]
252 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIfEC2Ev
253 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
254 // CHECK1-NEXT: entry:
255 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
256 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
257 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
258 // CHECK1-NEXT: [[F:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[THIS1]], i32 0, i32 0
259 // CHECK1-NEXT: store float 0.000000e+00, ptr [[F]], align 4
260 // CHECK1-NEXT: ret void
263 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIfEC2Ef
264 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], float noundef [[A:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
265 // CHECK1-NEXT: entry:
266 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
267 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca float, align 4
268 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
269 // CHECK1-NEXT: store float [[A]], ptr [[A_ADDR]], align 4
270 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
271 // CHECK1-NEXT: [[F:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], ptr [[THIS1]], i32 0, i32 0
272 // CHECK1-NEXT: [[TMP0:%.*]] = load float, ptr [[A_ADDR]], align 4
273 // CHECK1-NEXT: store float [[TMP0]], ptr [[F]], align 4
274 // CHECK1-NEXT: ret void
277 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIfED2Ev
278 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
279 // CHECK1-NEXT: entry:
280 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
281 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
282 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
283 // CHECK1-NEXT: ret void
286 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIiEC1Ev
287 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
288 // CHECK1-NEXT: entry:
289 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
290 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
291 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
292 // CHECK1-NEXT: call void @_ZN1SIiEC2Ev(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]])
293 // CHECK1-NEXT: ret void
296 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIiEC1Ei
297 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[A:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
298 // CHECK1-NEXT: entry:
299 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
300 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
301 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
302 // CHECK1-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
303 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
304 // CHECK1-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
305 // CHECK1-NEXT: call void @_ZN1SIiEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]], i32 noundef [[TMP0]])
306 // CHECK1-NEXT: ret void
309 // CHECK1-LABEL: define {{[^@]+}}@_Z5tmainIiET_v.omp_outlined
310 // CHECK1-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]]) #[[ATTR3]] {
311 // CHECK1-NEXT: entry:
312 // CHECK1-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
313 // CHECK1-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
314 // CHECK1-NEXT: [[T_VAR:%.*]] = alloca i32, align 4
315 // CHECK1-NEXT: [[VEC:%.*]] = alloca [2 x i32], align 4
316 // CHECK1-NEXT: [[S_ARR:%.*]] = alloca [2 x %struct.S.0], align 4
317 // CHECK1-NEXT: [[VAR:%.*]] = alloca [[STRUCT_S_0:%.*]], align 4
318 // CHECK1-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
319 // CHECK1-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
320 // CHECK1-NEXT: [[TMP0:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
321 // CHECK1-NEXT: [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
322 // CHECK1-NEXT: [[TMP2:%.*]] = call i32 @__kmpc_single(ptr @[[GLOB1]], i32 [[TMP1]])
323 // CHECK1-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0
324 // CHECK1-NEXT: br i1 [[TMP3]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_END:%.*]]
325 // CHECK1: omp_if.then:
326 // CHECK1-NEXT: [[ARRAY_BEGIN:%.*]] = getelementptr inbounds [2 x %struct.S.0], ptr [[S_ARR]], i32 0, i32 0
327 // CHECK1-NEXT: [[ARRAYCTOR_END:%.*]] = getelementptr inbounds [[STRUCT_S_0]], ptr [[ARRAY_BEGIN]], i64 2
328 // CHECK1-NEXT: br label [[ARRAYCTOR_LOOP:%.*]]
329 // CHECK1: arrayctor.loop:
330 // CHECK1-NEXT: [[ARRAYCTOR_CUR:%.*]] = phi ptr [ [[ARRAY_BEGIN]], [[OMP_IF_THEN]] ], [ [[ARRAYCTOR_NEXT:%.*]], [[ARRAYCTOR_LOOP]] ]
331 // CHECK1-NEXT: call void @_ZN1SIiEC1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYCTOR_CUR]])
332 // CHECK1-NEXT: [[ARRAYCTOR_NEXT]] = getelementptr inbounds [[STRUCT_S_0]], ptr [[ARRAYCTOR_CUR]], i64 1
333 // CHECK1-NEXT: [[ARRAYCTOR_DONE:%.*]] = icmp eq ptr [[ARRAYCTOR_NEXT]], [[ARRAYCTOR_END]]
334 // CHECK1-NEXT: br i1 [[ARRAYCTOR_DONE]], label [[ARRAYCTOR_CONT:%.*]], label [[ARRAYCTOR_LOOP]]
335 // CHECK1: arrayctor.cont:
336 // CHECK1-NEXT: call void @_ZN1SIiEC1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]])
337 // CHECK1-NEXT: [[TMP4:%.*]] = load i32, ptr [[T_VAR]], align 4
338 // CHECK1-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x i32], ptr [[VEC]], i64 0, i64 0
339 // CHECK1-NEXT: store i32 [[TMP4]], ptr [[ARRAYIDX]], align 4
340 // CHECK1-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds [2 x %struct.S.0], ptr [[S_ARR]], i64 0, i64 0
341 // CHECK1-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 4 [[ARRAYIDX1]], ptr align 4 [[VAR]], i64 4, i1 false)
342 // CHECK1-NEXT: call void @_ZN1SIiED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[VAR]]) #[[ATTR5]]
343 // CHECK1-NEXT: [[ARRAY_BEGIN2:%.*]] = getelementptr inbounds [2 x %struct.S.0], ptr [[S_ARR]], i32 0, i32 0
344 // CHECK1-NEXT: [[TMP5:%.*]] = getelementptr inbounds [[STRUCT_S_0]], ptr [[ARRAY_BEGIN2]], i64 2
345 // CHECK1-NEXT: br label [[ARRAYDESTROY_BODY:%.*]]
346 // CHECK1: arraydestroy.body:
347 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENTPAST:%.*]] = phi ptr [ [[TMP5]], [[ARRAYCTOR_CONT]] ], [ [[ARRAYDESTROY_ELEMENT:%.*]], [[ARRAYDESTROY_BODY]] ]
348 // CHECK1-NEXT: [[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds [[STRUCT_S_0]], ptr [[ARRAYDESTROY_ELEMENTPAST]], i64 -1
349 // CHECK1-NEXT: call void @_ZN1SIiED1Ev(ptr noundef nonnull align 4 dereferenceable(4) [[ARRAYDESTROY_ELEMENT]]) #[[ATTR5]]
350 // CHECK1-NEXT: [[ARRAYDESTROY_DONE:%.*]] = icmp eq ptr [[ARRAYDESTROY_ELEMENT]], [[ARRAY_BEGIN2]]
351 // CHECK1-NEXT: br i1 [[ARRAYDESTROY_DONE]], label [[ARRAYDESTROY_DONE3:%.*]], label [[ARRAYDESTROY_BODY]]
352 // CHECK1: arraydestroy.done3:
353 // CHECK1-NEXT: call void @__kmpc_end_single(ptr @[[GLOB1]], i32 [[TMP1]])
354 // CHECK1-NEXT: br label [[OMP_IF_END]]
355 // CHECK1: omp_if.end:
356 // CHECK1-NEXT: call void @__kmpc_barrier(ptr @[[GLOB2]], i32 [[TMP1]])
357 // CHECK1-NEXT: ret void
360 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIiED1Ev
361 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
362 // CHECK1-NEXT: entry:
363 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
364 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
365 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
366 // CHECK1-NEXT: call void @_ZN1SIiED2Ev(ptr noundef nonnull align 4 dereferenceable(4) [[THIS1]]) #[[ATTR5]]
367 // CHECK1-NEXT: ret void
370 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIiEC2Ev
371 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
372 // CHECK1-NEXT: entry:
373 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
374 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
375 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
376 // CHECK1-NEXT: [[F:%.*]] = getelementptr inbounds [[STRUCT_S_0:%.*]], ptr [[THIS1]], i32 0, i32 0
377 // CHECK1-NEXT: store i32 0, ptr [[F]], align 4
378 // CHECK1-NEXT: ret void
381 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIiEC2Ei
382 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]], i32 noundef [[A:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
383 // CHECK1-NEXT: entry:
384 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
385 // CHECK1-NEXT: [[A_ADDR:%.*]] = alloca i32, align 4
386 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
387 // CHECK1-NEXT: store i32 [[A]], ptr [[A_ADDR]], align 4
388 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
389 // CHECK1-NEXT: [[F:%.*]] = getelementptr inbounds [[STRUCT_S_0:%.*]], ptr [[THIS1]], i32 0, i32 0
390 // CHECK1-NEXT: [[TMP0:%.*]] = load i32, ptr [[A_ADDR]], align 4
391 // CHECK1-NEXT: store i32 [[TMP0]], ptr [[F]], align 4
392 // CHECK1-NEXT: ret void
395 // CHECK1-LABEL: define {{[^@]+}}@_ZN1SIiED2Ev
396 // CHECK1-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[THIS:%.*]]) unnamed_addr #[[ATTR1]] comdat align 2 {
397 // CHECK1-NEXT: entry:
398 // CHECK1-NEXT: [[THIS_ADDR:%.*]] = alloca ptr, align 8
399 // CHECK1-NEXT: store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
400 // CHECK1-NEXT: [[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
401 // CHECK1-NEXT: ret void
404 // CHECK3-LABEL: define {{[^@]+}}@main
405 // CHECK3-SAME: () #[[ATTR0:[0-9]+]] {
406 // CHECK3-NEXT: entry:
407 // CHECK3-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
408 // CHECK3-NEXT: [[REF_TMP:%.*]] = alloca [[CLASS_ANON:%.*]], align 1
409 // CHECK3-NEXT: store i32 0, ptr [[RETVAL]], align 4
410 // CHECK3-NEXT: call void @"_ZZ4mainENK3$_0clEv"(ptr noundef nonnull align 1 dereferenceable(1) [[REF_TMP]])
411 // CHECK3-NEXT: ret i32 0
414 // CHECK4-LABEL: define {{[^@]+}}@main
415 // CHECK4-SAME: () #[[ATTR1:[0-9]+]] {
416 // CHECK4-NEXT: entry:
417 // CHECK4-NEXT: [[RETVAL:%.*]] = alloca i32, align 4
418 // CHECK4-NEXT: store i32 0, ptr [[RETVAL]], align 4
419 // CHECK4-NEXT: [[TMP0:%.*]] = load ptr, ptr getelementptr inbounds ([[STRUCT___BLOCK_LITERAL_GENERIC:%.*]], ptr @__block_literal_global, i32 0, i32 3), align 8
420 // CHECK4-NEXT: call void [[TMP0]](ptr noundef @__block_literal_global)
421 // CHECK4-NEXT: ret i32 0
424 // CHECK4-LABEL: define {{[^@]+}}@__main_block_invoke
425 // CHECK4-SAME: (ptr noundef [[DOTBLOCK_DESCRIPTOR:%.*]]) #[[ATTR2:[0-9]+]] {
426 // CHECK4-NEXT: entry:
427 // CHECK4-NEXT: [[DOTBLOCK_DESCRIPTOR_ADDR:%.*]] = alloca ptr, align 8
428 // CHECK4-NEXT: [[BLOCK_ADDR:%.*]] = alloca ptr, align 8
429 // CHECK4-NEXT: store ptr [[DOTBLOCK_DESCRIPTOR]], ptr [[DOTBLOCK_DESCRIPTOR_ADDR]], align 8
430 // CHECK4-NEXT: store ptr [[DOTBLOCK_DESCRIPTOR]], ptr [[BLOCK_ADDR]], align 8
431 // CHECK4-NEXT: call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @[[GLOB1:[0-9]+]], i32 0, ptr @__main_block_invoke.omp_outlined)
432 // CHECK4-NEXT: ret void
435 // CHECK4-LABEL: define {{[^@]+}}@__main_block_invoke.omp_outlined
436 // CHECK4-SAME: (ptr noalias noundef [[DOTGLOBAL_TID_:%.*]], ptr noalias noundef [[DOTBOUND_TID_:%.*]]) #[[ATTR3:[0-9]+]] {
437 // CHECK4-NEXT: entry:
438 // CHECK4-NEXT: [[DOTGLOBAL_TID__ADDR:%.*]] = alloca ptr, align 8
439 // CHECK4-NEXT: [[DOTBOUND_TID__ADDR:%.*]] = alloca ptr, align 8
440 // CHECK4-NEXT: [[G:%.*]] = alloca double, align 8
441 // CHECK4-NEXT: [[SIVAR:%.*]] = alloca i32, align 4
442 // CHECK4-NEXT: [[BLOCK:%.*]] = alloca <{ ptr, i32, i32, ptr, ptr, double, i32 }>, align 8
443 // CHECK4-NEXT: store ptr [[DOTGLOBAL_TID_]], ptr [[DOTGLOBAL_TID__ADDR]], align 8
444 // CHECK4-NEXT: store ptr [[DOTBOUND_TID_]], ptr [[DOTBOUND_TID__ADDR]], align 8
445 // CHECK4-NEXT: [[TMP0:%.*]] = load ptr, ptr [[DOTGLOBAL_TID__ADDR]], align 8
446 // CHECK4-NEXT: [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
447 // CHECK4-NEXT: [[TMP2:%.*]] = call i32 @__kmpc_single(ptr @[[GLOB1]], i32 [[TMP1]])
448 // CHECK4-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP2]], 0
449 // CHECK4-NEXT: br i1 [[TMP3]], label [[OMP_IF_THEN:%.*]], label [[OMP_IF_END:%.*]]
450 // CHECK4: omp_if.then:
451 // CHECK4-NEXT: store double 1.000000e+00, ptr [[G]], align 8
452 // CHECK4-NEXT: store i32 101, ptr [[SIVAR]], align 4
453 // CHECK4-NEXT: [[BLOCK_ISA:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[BLOCK]], i32 0, i32 0
454 // CHECK4-NEXT: store ptr @_NSConcreteStackBlock, ptr [[BLOCK_ISA]], align 8
455 // CHECK4-NEXT: [[BLOCK_FLAGS:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[BLOCK]], i32 0, i32 1
456 // CHECK4-NEXT: store i32 1073741824, ptr [[BLOCK_FLAGS]], align 8
457 // CHECK4-NEXT: [[BLOCK_RESERVED:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[BLOCK]], i32 0, i32 2
458 // CHECK4-NEXT: store i32 0, ptr [[BLOCK_RESERVED]], align 4
459 // CHECK4-NEXT: [[BLOCK_INVOKE:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[BLOCK]], i32 0, i32 3
460 // CHECK4-NEXT: store ptr @_block_invoke, ptr [[BLOCK_INVOKE]], align 8
461 // CHECK4-NEXT: [[BLOCK_DESCRIPTOR:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[BLOCK]], i32 0, i32 4
462 // CHECK4-NEXT: store ptr @__block_descriptor_tmp.1, ptr [[BLOCK_DESCRIPTOR]], align 8
463 // CHECK4-NEXT: [[BLOCK_CAPTURED:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[BLOCK]], i32 0, i32 5
464 // CHECK4-NEXT: [[TMP4:%.*]] = load volatile double, ptr [[G]], align 8
465 // CHECK4-NEXT: store volatile double [[TMP4]], ptr [[BLOCK_CAPTURED]], align 8
466 // CHECK4-NEXT: [[BLOCK_CAPTURED1:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[BLOCK]], i32 0, i32 6
467 // CHECK4-NEXT: [[TMP5:%.*]] = load i32, ptr [[SIVAR]], align 4
468 // CHECK4-NEXT: store i32 [[TMP5]], ptr [[BLOCK_CAPTURED1]], align 8
469 // CHECK4-NEXT: [[TMP6:%.*]] = getelementptr inbounds [[STRUCT___BLOCK_LITERAL_GENERIC:%.*]], ptr [[BLOCK]], i32 0, i32 3
470 // CHECK4-NEXT: [[TMP7:%.*]] = load ptr, ptr [[TMP6]], align 8
471 // CHECK4-NEXT: call void [[TMP7]](ptr noundef [[BLOCK]])
472 // CHECK4-NEXT: call void @__kmpc_end_single(ptr @[[GLOB1]], i32 [[TMP1]])
473 // CHECK4-NEXT: br label [[OMP_IF_END]]
474 // CHECK4: omp_if.end:
475 // CHECK4-NEXT: call void @__kmpc_barrier(ptr @[[GLOB2:[0-9]+]], i32 [[TMP1]])
476 // CHECK4-NEXT: ret void
479 // CHECK4-LABEL: define {{[^@]+}}@_block_invoke
480 // CHECK4-SAME: (ptr noundef [[DOTBLOCK_DESCRIPTOR:%.*]]) #[[ATTR2]] {
481 // CHECK4-NEXT: entry:
482 // CHECK4-NEXT: [[DOTBLOCK_DESCRIPTOR_ADDR:%.*]] = alloca ptr, align 8
483 // CHECK4-NEXT: [[BLOCK_ADDR:%.*]] = alloca ptr, align 8
484 // CHECK4-NEXT: store ptr [[DOTBLOCK_DESCRIPTOR]], ptr [[DOTBLOCK_DESCRIPTOR_ADDR]], align 8
485 // CHECK4-NEXT: store ptr [[DOTBLOCK_DESCRIPTOR]], ptr [[BLOCK_ADDR]], align 8
486 // CHECK4-NEXT: [[BLOCK_CAPTURE_ADDR:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[DOTBLOCK_DESCRIPTOR]], i32 0, i32 5
487 // CHECK4-NEXT: store double 2.000000e+00, ptr [[BLOCK_CAPTURE_ADDR]], align 8
488 // CHECK4-NEXT: [[BLOCK_CAPTURE_ADDR1:%.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, double, i32 }>, ptr [[DOTBLOCK_DESCRIPTOR]], i32 0, i32 6
489 // CHECK4-NEXT: store i32 203, ptr [[BLOCK_CAPTURE_ADDR1]], align 8
490 // CHECK4-NEXT: ret void