1 // RUN: %clang_cc1 -no-opaque-pointers -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s
3 // RUN: %clang_cc1 -no-opaque-pointers -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-pch -o %t %s
4 // RUN: %clang_cc1 -no-opaque-pointers -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -include-pch %t -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s
9 typedef void (^BlockTy)(void);
91 StrongSmall getStrongSmall(void);
92 StrongOuter getStrongOuter(void);
93 StrongOuter2 getStrongOuter2(void);
94 void calleeStrongSmall(StrongSmall);
98 - (StrongSmall)getStrongSmall;
99 - (void)m:(StrongSmall)s;
100 + (StrongSmall)getStrongSmallClass;
106 // CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* }
107 // CHECK: %[[STRUCT_STRONGOUTER:.*]] = type { %[[STRUCT_STRONG:.*]], i8*, double }
108 // CHECK: %[[STRUCT_STRONG]] = type { %[[STRUCT_TRIVIAL:.*]], i8* }
109 // CHECK: %[[STRUCT_TRIVIAL]] = type { [4 x i32] }
110 // CHECK: %[[STRUCT_BLOCK_BYREF_T:.*]] = type { i8*, %[[STRUCT_BLOCK_BYREF_T]]*, i32, i32, i8*, i8*, i8*, %[[STRUCT_STRONGOUTER]] }
111 // CHECK: %[[STRUCT_STRONGBLOCK:.*]] = type { void ()* }
112 // CHECK: %[[STRUCT_BITFIELD1:.*]] = type { i8, i8, i8*, i32, i8*, [3 x i32], i8*, double, i8, i8 }
114 // CHECK: define{{.*}} void @test_constructor_destructor_StrongOuter()
115 // CHECK: %[[T:.*]] = alloca %[[STRUCT_STRONGOUTER]], align 8
116 // CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8**
117 // CHECK: call void @__default_constructor_8_S_s16_s24(i8** %[[V0]])
118 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8**
119 // CHECK: call void @__destructor_8_S_s16_s24(i8** %[[V1]])
122 // CHECK: define linkonce_odr hidden void @__default_constructor_8_S_s16_s24(i8** noundef %[[DST:.*]])
123 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
124 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
125 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
126 // CHECK: call void @__default_constructor_8_s16(i8** %[[V0]])
127 // CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8*
128 // CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 24
129 // CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8**
130 // CHECK: %[[V4:.*]] = bitcast i8** %[[V3]] to i8*
131 // CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %[[V4]], i8 0, i64 8, i1 false)
134 // CHECK: define linkonce_odr hidden void @__default_constructor_8_s16(i8** noundef %[[DST:.*]])
135 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
136 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
137 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
138 // CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8*
139 // CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 16
140 // CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8**
141 // CHECK: %[[V4:.*]] = bitcast i8** %[[V3]] to i8*
142 // CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %[[V4]], i8 0, i64 8, i1 false)
145 // CHECK: define linkonce_odr hidden void @__destructor_8_S_s16_s24(i8** noundef %[[DST:.*]])
146 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
147 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
148 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
149 // CHECK: call void @__destructor_8_s16(i8** %[[V0]])
150 // CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8*
151 // CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 24
152 // CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8**
153 // CHECK: call void @llvm.objc.storeStrong(i8** %[[V3]], i8* null)
156 // CHECK: define linkonce_odr hidden void @__destructor_8_s16(i8** noundef %[[DST:.*]])
157 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
158 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
159 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
160 // CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8*
161 // CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 16
162 // CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8**
163 // CHECK: call void @llvm.objc.storeStrong(i8** %[[V3]], i8* null)
166 void test_constructor_destructor_StrongOuter(void) {
170 // CHECK: define{{.*}} void @test_copy_constructor_StrongOuter(%[[STRUCT_STRONGOUTER]]* noundef %[[S:.*]])
171 // CHECK: %[[S_ADDR:.*]] = alloca %[[STRUCT_STRONGOUTER]]*, align 8
172 // CHECK: %[[T:.*]] = alloca %[[STRUCT_STRONGOUTER]], align 8
173 // CHECK: store %[[STRUCT_STRONGOUTER]]* %[[S]], %[[STRUCT_STRONGOUTER]]** %[[S_ADDR]], align 8
174 // CHECK: %[[V0:.*]] = load %[[STRUCT_STRONGOUTER]]*, %[[STRUCT_STRONGOUTER]]** %[[S_ADDR]], align 8
175 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8**
176 // CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[V0]] to i8**
177 // CHECK: call void @__copy_constructor_8_8_S_t0w16_s16_s24_t32w8(i8** %[[V1]], i8** %[[V2]])
178 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8**
179 // CHECK: call void @__destructor_8_S_s16_s24(i8** %[[V3]])
182 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_S_t0w16_s16_s24_t32w8(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
183 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
184 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
185 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
186 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
187 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
188 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
189 // CHECK: call void @__copy_constructor_8_8_t0w16_s16(i8** %[[V0]], i8** %[[V1]])
190 // CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8*
191 // CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24
192 // CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8**
193 // CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8*
194 // CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24
195 // CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8**
196 // CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8
197 // CHECK: %[[V9:.*]] = call i8* @llvm.objc.retain(i8* %[[V8]])
198 // CHECK: store i8* %[[V9]], i8** %[[V4]], align 8
199 // CHECK: %[[V10:.*]] = bitcast i8** %[[V0]] to i8*
200 // CHECK: %[[V11:.*]] = getelementptr inbounds i8, i8* %[[V10]], i64 32
201 // CHECK: %[[V12:.*]] = bitcast i8* %[[V11]] to i8**
202 // CHECK: %[[V13:.*]] = bitcast i8** %[[V1]] to i8*
203 // CHECK: %[[V14:.*]] = getelementptr inbounds i8, i8* %[[V13]], i64 32
204 // CHECK: %[[V15:.*]] = bitcast i8* %[[V14]] to i8**
205 // CHECK: %[[V16:.*]] = bitcast i8** %[[V12]] to i64*
206 // CHECK: %[[V17:.*]] = bitcast i8** %[[V15]] to i64*
207 // CHECK: %[[V18:.*]] = load i64, i64* %[[V17]], align 8
208 // CHECK: store i64 %[[V18]], i64* %[[V16]], align 8
211 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w16_s16(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
212 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
213 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
214 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
215 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
216 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
217 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
218 // CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8*
219 // CHECK: %[[V3:.*]] = bitcast i8** %[[V1]] to i8*
220 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %[[V2]], i8* align 8 %[[V3]], i64 16, i1 false)
221 // CHECK: %[[V4:.*]] = bitcast i8** %[[V0]] to i8*
222 // CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 16
223 // CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8**
224 // CHECK: %[[V7:.*]] = bitcast i8** %[[V1]] to i8*
225 // CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 16
226 // CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8**
227 // CHECK: %[[V10:.*]] = load i8*, i8** %[[V9]], align 8
228 // CHECK: %[[V11:.*]] = call i8* @llvm.objc.retain(i8* %[[V10]])
229 // CHECK: store i8* %[[V11]], i8** %[[V6]], align 8
232 void test_copy_constructor_StrongOuter(StrongOuter *s) {
236 /// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_S_t0w16_s16_s24_t32w8(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
237 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
238 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
239 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
240 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
241 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
242 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
243 // CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8*
244 // CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24
245 // CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8**
246 // CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8*
247 // CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24
248 // CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8**
249 // CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8
250 // CHECK: call void @llvm.objc.storeStrong(i8** %[[V4]], i8* %[[V8]])
252 void test_copy_assignment_StrongOuter(StrongOuter *d, StrongOuter *s) {
256 // CHECK: define{{.*}} void @test_move_constructor_StrongOuter()
257 // CHECK: %[[T1:.*]] = getelementptr inbounds %[[STRUCT_BLOCK_BYREF_T]], %[[STRUCT_BLOCK_BYREF_T]]* %{{.*}}, i32 0, i32 7
258 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T1]] to i8**
259 // CHECK: call void @__default_constructor_8_S_s16_s24(i8** %[[V1]])
260 // CHECK: %[[T2:.*]] = getelementptr inbounds %[[STRUCT_BLOCK_BYREF_T]], %[[STRUCT_BLOCK_BYREF_T]]* %{{.*}}, i32 0, i32 7
261 // CHECK: %[[V9:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T2]] to i8**
262 // CHECK: call void @__destructor_8_S_s16_s24(i8** %[[V9]])
264 // CHECK: define internal void @__Block_byref_object_copy_(i8* noundef %0, i8* noundef %1)
265 // CHECK: call void @__move_constructor_8_8_S_t0w16_s16_s24_t32w8(
267 // CHECK: define linkonce_odr hidden void @__move_constructor_8_8_S_t0w16_s16_s24_t32w8(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
268 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
269 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
270 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
271 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
272 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
273 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
274 // CHECK: call void @__move_constructor_8_8_t0w16_s16(i8** %[[V0]], i8** %[[V1]])
275 // CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8*
276 // CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24
277 // CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8**
278 // CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8*
279 // CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24
280 // CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8**
281 // CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8
282 // CHECK: store i8* null, i8** %[[V7]], align 8
283 // CHECK: store i8* %[[V8]], i8** %[[V4]], align 8
285 // CHECK: define internal void @__Block_byref_object_dispose_(i8* noundef %0)
286 // CHECK: call void @__destructor_8_S_s16_s24(
288 void test_move_constructor_StrongOuter(void) {
289 __block StrongOuter t;
290 BlockTy b = ^{ (void)t; };
293 // CHECK: define linkonce_odr hidden void @__move_assignment_8_8_S_t0w16_s16_s24_t32w8(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
294 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
295 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
296 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
297 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
298 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
299 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
300 // CHECK: call void @__move_assignment_8_8_t0w16_s16(i8** %[[V0]], i8** %[[V1]])
301 // CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8*
302 // CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24
303 // CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8**
304 // CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8*
305 // CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24
306 // CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8**
307 // CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8
308 // CHECK: store i8* null, i8** %[[V7]], align 8
309 // CHECK: %[[V9:.*]] = load i8*, i8** %[[V4]], align 8
310 // CHECK: store i8* %[[V8]], i8** %[[V4]], align 8
311 // CHECK: call void @llvm.objc.release(i8* %[[V9]])
313 void test_move_assignment_StrongOuter(StrongOuter *p) {
314 *p = getStrongOuter();
317 // CHECK: define linkonce_odr hidden void @__default_constructor_8_s0_S_s24(i8** noundef %[[DST:.*]])
318 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
319 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
320 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
321 // CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8*
322 // CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %[[V1]], i8 0, i64 8, i1 false)
323 // CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8*
324 // CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 8
325 // CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8**
326 // CHECK: call void @__default_constructor_8_s16(i8** %[[V4]])
328 // CHECK: define linkonce_odr hidden void @__destructor_8_s0_S_s24(i8** noundef %[[DST:.*]])
329 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
330 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
331 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
332 // CHECK: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* null)
333 // CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8*
334 // CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 8
335 // CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8**
336 // CHECK: call void @__destructor_8_s16(i8** %[[V3]])
338 void test_constructor_destructor_StrongOuter2(void) {
342 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_s0_S_t8w16_s24(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
343 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
344 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
345 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
346 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
347 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
348 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
349 // CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8
350 // CHECK: %[[V3:.*]] = call i8* @llvm.objc.retain(i8* %[[V2]])
351 // CHECK: store i8* %[[V3]], i8** %[[V0]], align 8
352 // CHECK: %[[V4:.*]] = bitcast i8** %[[V0]] to i8*
353 // CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 8
354 // CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8**
355 // CHECK: %[[V7:.*]] = bitcast i8** %[[V1]] to i8*
356 // CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 8
357 // CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8**
358 // CHECK: call void @__copy_constructor_8_8_t0w16_s16(i8** %[[V6]], i8** %[[V9]])
360 void test_copy_constructor_StrongOuter2(StrongOuter2 *s) {
364 // CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_s0_S_t8w16_s24(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
365 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
366 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
367 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
368 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
369 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
370 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
371 // CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8
372 // CHECK: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* %[[V2]])
373 // CHECK: %[[V3:.*]] = bitcast i8** %[[V0]] to i8*
374 // CHECK: %[[V4:.*]] = getelementptr inbounds i8, i8* %[[V3]], i64 8
375 // CHECK: %[[V5:.*]] = bitcast i8* %[[V4]] to i8**
376 // CHECK: %[[V6:.*]] = bitcast i8** %[[V1]] to i8*
377 // CHECK: %[[V7:.*]] = getelementptr inbounds i8, i8* %[[V6]], i64 8
378 // CHECK: %[[V8:.*]] = bitcast i8* %[[V7]] to i8**
379 // CHECK: call void @__copy_assignment_8_8_t0w16_s16(i8** %[[V5]], i8** %[[V8]])
381 void test_copy_assignment_StrongOuter2(StrongOuter2 *d, StrongOuter2 *s) {
385 // CHECK: define linkonce_odr hidden void @__move_constructor_8_8_s0_S_t8w16_s24(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
386 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
387 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
388 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
389 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
390 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
391 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
392 // CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8
393 // CHECK: store i8* null, i8** %[[V1]], align 8
394 // CHECK: store i8* %[[V2]], i8** %[[V0]], align 8
395 // CHECK: %[[V3:.*]] = bitcast i8** %[[V0]] to i8*
396 // CHECK: %[[V4:.*]] = getelementptr inbounds i8, i8* %[[V3]], i64 8
397 // CHECK: %[[V5:.*]] = bitcast i8* %[[V4]] to i8**
398 // CHECK: %[[V6:.*]] = bitcast i8** %[[V1]] to i8*
399 // CHECK: %[[V7:.*]] = getelementptr inbounds i8, i8* %[[V6]], i64 8
400 // CHECK: %[[V8:.*]] = bitcast i8* %[[V7]] to i8**
401 // CHECK: call void @__move_constructor_8_8_t0w16_s16(i8** %[[V5]], i8** %[[V8]])
403 void test_move_constructor_StrongOuter2(void) {
404 __block StrongOuter2 t;
405 BlockTy b = ^{ (void)t; };
408 // CHECK: define linkonce_odr hidden void @__move_assignment_8_8_s0_S_t8w16_s24(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
409 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
410 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
411 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
412 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
413 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
414 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
415 // CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8
416 // CHECK: store i8* null, i8** %[[V1]], align 8
417 // CHECK: %[[V3:.*]] = load i8*, i8** %[[V0]], align 8
418 // CHECK: store i8* %[[V2]], i8** %[[V0]], align 8
419 // CHECK: call void @llvm.objc.release(i8* %[[V3]])
420 // CHECK: %[[V4:.*]] = bitcast i8** %[[V0]] to i8*
421 // CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 8
422 // CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8**
423 // CHECK: %[[V7:.*]] = bitcast i8** %[[V1]] to i8*
424 // CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 8
425 // CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8**
426 // CHECK: call void @__move_assignment_8_8_t0w16_s16(i8** %[[V6]], i8** %[[V9]])
428 void test_move_assignment_StrongOuter2(StrongOuter2 *p) {
429 *p = getStrongOuter2();
432 // CHECK: define{{.*}} void @test_parameter_StrongSmall([2 x i64] %[[A_COERCE:.*]])
433 // CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
434 // CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to [2 x i64]*
435 // CHECK: store [2 x i64] %[[A_COERCE]], [2 x i64]* %[[V0]], align 8
436 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8**
437 // CHECK: call void @__destructor_8_s8(i8** %[[V1]])
440 void test_parameter_StrongSmall(StrongSmall a) {
443 // CHECK: define{{.*}} void @test_argument_StrongSmall([2 x i64] %[[A_COERCE:.*]])
444 // CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
445 // CHECK: %[[TEMP_LVALUE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
446 // CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to [2 x i64]*
447 // CHECK: store [2 x i64] %[[A_COERCE]], [2 x i64]* %[[V0]], align 8
448 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TEMP_LVALUE]] to i8**
449 // CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8**
450 // CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** %[[V2]])
451 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TEMP_LVALUE]] to [2 x i64]*
452 // CHECK: %[[V4:.*]] = load [2 x i64], [2 x i64]* %[[V3]], align 8
453 // CHECK: call void @calleeStrongSmall([2 x i64] %[[V4]])
454 // CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8**
455 // CHECK: call void @__destructor_8_s8(i8** %[[V5]])
458 void test_argument_StrongSmall(StrongSmall a) {
459 calleeStrongSmall(a);
462 // CHECK: define{{.*}} [2 x i64] @test_return_StrongSmall([2 x i64] %[[A_COERCE:.*]])
463 // CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
464 // CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
465 // CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to [2 x i64]*
466 // CHECK: store [2 x i64] %[[A_COERCE]], [2 x i64]* %[[V0]], align 8
467 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[RETVAL]] to i8**
468 // CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8**
469 // CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** %[[V2]])
470 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8**
471 // CHECK: call void @__destructor_8_s8(i8** %[[V3]])
472 // CHECK: %[[V4:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[RETVAL]] to [2 x i64]*
473 // CHECK: %[[V5:.*]] = load [2 x i64], [2 x i64]* %[[V4]], align 8
474 // CHECK: ret [2 x i64] %[[V5]]
476 StrongSmall test_return_StrongSmall(StrongSmall a) {
480 // CHECK: define{{.*}} void @test_destructor_ignored_result()
481 // CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
482 // CHECK: %[[CALL:.*]] = call [2 x i64] @getStrongSmall()
483 // CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to [2 x i64]*
484 // CHECK: store [2 x i64] %[[CALL]], [2 x i64]* %[[V0]], align 8
485 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
486 // CHECK: call void @__destructor_8_s8(i8** %[[V1]])
489 void test_destructor_ignored_result(void) {
493 // CHECK: define{{.*}} void @test_destructor_ignored_result2(%{{.*}}* noundef %[[C:.*]])
494 // CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
495 // CHECK: %[[CALL:.*]] = call [2 x i64]{{.*}}@objc_msgSend
496 // CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to [2 x i64]*
497 // CHECK: store [2 x i64] %[[CALL]], [2 x i64]* %[[V5]], align 8
498 // CHECK: %[[V6:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
499 // CHECK: call void @__destructor_8_s8(i8** %[[V6]])
501 void test_destructor_ignored_result2(C *c) {
505 // CHECK: define{{.*}} void @test_copy_constructor_StrongBlock(
506 // CHECK: call void @__copy_constructor_8_8_sb0(
507 // CHECK: call void @__destructor_8_sb0(
510 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_sb0(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
511 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
512 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
513 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
514 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
515 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
516 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
517 // CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8
518 // CHECK: %[[V3:.*]] = call i8* @llvm.objc.retainBlock(i8* %[[V2]])
519 // CHECK: store i8* %[[V3]], i8** %[[V0]], align 8
522 void test_copy_constructor_StrongBlock(StrongBlock *s) {
526 // CHECK: define{{.*}} void @test_copy_assignment_StrongBlock(%[[STRUCT_STRONGBLOCK]]* noundef %[[D:.*]], %[[STRUCT_STRONGBLOCK]]* noundef %[[S:.*]])
527 // CHECK: call void @__copy_assignment_8_8_sb0(
529 // CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_sb0(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
530 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
531 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
532 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
533 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
534 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
535 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
536 // CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8
537 // CHECK: %[[V3:.*]] = call i8* @llvm.objc.retainBlock(i8* %[[V2]])
538 // CHECK: %[[V4:.*]] = load i8*, i8** %[[V0]], align 8
539 // CHECK: store i8* %[[V3]], i8** %[[V0]], align 8
540 // CHECK: call void @llvm.objc.release(i8* %[[V4]])
543 void test_copy_assignment_StrongBlock(StrongBlock *d, StrongBlock *s) {
547 // CHECK-LABEL: define{{.*}} void @test_copy_assignment_StructWithBool(
548 // CHECK: call void @__copy_assignment_8_8_AB0s1n2_tv0w8_AE_S_sv8_AB16s4n16_tv128w32_AE(
550 // CHECK-LABEL: define linkonce_odr hidden void @__copy_assignment_8_8_AB0s1n2_tv0w8_AE_S_sv8_AB16s4n16_tv128w32_AE(
551 // CHECK: %[[ADDR_CUR:.*]] = phi i8**
552 // CHECK: %[[ADDR_CUR1:.*]] = phi i8**
554 // CHECK: %[[V4:.*]] = bitcast i8** %[[ADDR_CUR]] to i8*
555 // CHECK: %[[V5:.*]] = bitcast i8** %[[ADDR_CUR1]] to i8*
556 // CHECK: %[[V6:.*]] = load volatile i8, i8* %[[V5]], align 1
557 // CHECK: %[[TOBOOL:.*]] = trunc i8 %[[V6]] to i1
558 // CHECK: %[[FROMBOOL:.*]] = zext i1 %[[TOBOOL]] to i8
559 // CHECK: store volatile i8 %[[FROMBOOL]], i8* %[[V4]], align 1
561 void test_copy_assignment_StructWithBool(StructWithBool *d, StructWithBool *s) {
565 // CHECK: define{{.*}} void @test_copy_constructor_StrongVolatile0(
566 // CHECK: call void @__copy_constructor_8_8_t0w4_sv8(
568 // CHECK: call void @__destructor_8_sv8(
571 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w4_sv8(
572 // CHECK: %[[V8:.*]] = load volatile i8*, i8** %{{.*}}, align 8
573 // CHECK: %[[V9:.*]] = call i8* @llvm.objc.retain(i8* %[[V8]])
574 // CHECK: store volatile i8* %[[V9]], i8** %{{.*}}, align 8
576 void test_copy_constructor_StrongVolatile0(StrongVolatile *s) {
577 StrongVolatile t = *s;
580 // CHECK: define{{.*}} void @test_copy_constructor_StrongVolatile1(
581 // CHECK: call void @__copy_constructor_8_8_tv0w128_sv16(
583 void test_copy_constructor_StrongVolatile1(Strong *s) {
584 volatile Strong t = *s;
587 // CHECK: define{{.*}} void @test_block_capture_Strong()
588 // CHECK: call void @__default_constructor_8_s16(
589 // CHECK: call void @__copy_constructor_8_8_t0w16_s16(
590 // CHECK: call void @__destructor_8_s16(
591 // CHECK: call void @__destructor_8_s16(
594 // CHECK: define linkonce_odr hidden void @__copy_helper_block_8_32n13_8_8_t0w16_s16(i8* noundef %0, i8* noundef %1)
595 // CHECK: call void @__copy_constructor_8_8_t0w16_s16(
598 // CHECK: define linkonce_odr hidden void @__destroy_helper_block_8_32n5_8_s16(
599 // CHECK: call void @__destructor_8_s16(
602 void test_block_capture_Strong(void) {
604 BlockTy b = ^(void){ (void)t; };
607 // CHECK: define{{.*}} void @test_variable_length_array(i32 noundef %[[N:.*]])
608 // CHECK: %[[N_ADDR:.*]] = alloca i32, align 4
609 // CHECK: store i32 %[[N]], i32* %[[N_ADDR]], align 4
610 // CHECK: %[[V0:.*]] = load i32, i32* %[[N_ADDR]], align 4
611 // CHECK: %[[V1:.*]] = zext i32 %[[V0]] to i64
612 // CHECK: %[[VLA:.*]] = alloca %[[STRUCT_STRONG]], i64 %[[V1]], align 8
613 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONG]]* %[[VLA]] to i8**
614 // CHECK: %[[V4:.*]] = mul nuw i64 24, %[[V1]]
615 // CHECK: %[[V5:.*]] = bitcast i8** %[[V3]] to i8*
616 // CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 %[[V4]]
617 // CHECK: %[[DSTARRAY_END:.*]] = bitcast i8* %[[V6]] to i8**
620 // CHECK: %[[DSTADDR_CUR:.*]] = phi i8** [ %[[V3]], {{.*}} ], [ %[[V7:.*]], {{.*}} ]
621 // CHECK: %[[DONE:.*]] = icmp eq i8** %[[DSTADDR_CUR]], %[[DSTARRAY_END]]
622 // CHECK: br i1 %[[DONE]], label
624 // CHECK: call void @__default_constructor_8_s16(i8** %[[DSTADDR_CUR]])
625 // CHECK: %[[V8:.*]] = bitcast i8** %[[DSTADDR_CUR]] to i8*
626 // CHECK: %[[V9:.*]] = getelementptr inbounds i8, i8* %[[V8]], i64 24
627 // CHECK: %[[V7]] = bitcast i8* %[[V9]] to i8**
630 // CHECK: call void @func(%[[STRUCT_STRONG]]* noundef %[[VLA]])
631 // CHECK: %[[V10:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[VLA]], i64 %[[V1]]
632 // CHECK: %[[ARRAYDESTROY_ISEMPTY:.*]] = icmp eq %[[STRUCT_STRONG]]* %[[VLA]], %[[V10]]
633 // CHECK: br i1 %[[ARRAYDESTROY_ISEMPTY]], label
635 // CHECK: %[[ARRAYDESTROY_ELEMENTPAST:.*]] = phi %[[STRUCT_STRONG]]* [ %[[V10]], {{.*}} ], [ %[[ARRAYDESTROY_ELEMENT:.*]], {{.*}} ]
636 // CHECK: %[[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[ARRAYDESTROY_ELEMENTPAST]], i64 -1
637 // CHECK: %[[V11:.*]] = bitcast %[[STRUCT_STRONG]]* %[[ARRAYDESTROY_ELEMENT]] to i8**
638 // CHECK: call void @__destructor_8_s16(i8** %[[V11]])
639 // CHECK: %[[ARRAYDESTROY_DONE:.*]] = icmp eq %[[STRUCT_STRONG]]* %[[ARRAYDESTROY_ELEMENT]], %[[VLA]]
640 // CHECK: br i1 %[[ARRAYDESTROY_DONE]], label
644 void test_variable_length_array(int n) {
649 // CHECK: define linkonce_odr hidden void @__default_constructor_8_AB8s8n4_s8_AE(
650 // CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %{{.*}}, i8 0, i64 32, i1 false)
651 void test_constructor_destructor_IDArray(void) {
655 // CHECK: define linkonce_odr hidden void @__default_constructor_8_AB8s24n4_S_s24_AE(
656 void test_constructor_destructor_StructArray(void) {
660 // Test that StructArray's field 'd' is copied before entering the loop.
662 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w8_AB8s24n4_S_t8w16_s24_AE(i8** noundef %[[DST:.*]], i8** noundef %[[SRC:.*]])
664 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
665 // CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8
666 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
667 // CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8
668 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
669 // CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8
670 // CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i64*
671 // CHECK: %[[V3:.*]] = bitcast i8** %[[V1]] to i64*
672 // CHECK: %[[V4:.*]] = load i64, i64* %[[V3]], align 8
673 // CHECK: store i64 %[[V4]], i64* %[[V2]], align 8
681 // CHECK-NOT: load i64, i64* %
682 // CHECK-NOT: store i64 %
683 // CHECK: call void @__copy_constructor_8_8_t0w16_s16(
685 void test_copy_constructor_StructArray(StructArray a) {
689 // Check that IRGen copies the 9-bit bitfield emitting i16 load and store.
691 // CHECK: define{{.*}} void @test_copy_constructor_Bitfield0(
693 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_s0_t8w2(
694 // CHECK: %[[V4:.*]] = bitcast i8** %{{.*}} to i8*
695 // CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 8
696 // CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8**
697 // CHECK: %[[V7:.*]] = bitcast i8** %{{.*}} to i8*
698 // CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 8
699 // CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8**
700 // CHECK: %[[V10:.*]] = bitcast i8** %[[V6]] to i16*
701 // CHECK: %[[V11:.*]] = bitcast i8** %[[V9]] to i16*
702 // CHECK: %[[V12:.*]] = load i16, i16* %[[V11]], align 8
703 // CHECK: store i16 %[[V12]], i16* %[[V10]], align 8
706 void test_copy_constructor_Bitfield0(Bitfield0 *a) {
710 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w2_s8_t16w4_s24_t32w12_s48_t56w9_tv513w2_tv520w8
711 // CHECK: %[[V4:.*]] = load i16, i16* %{{.*}}, align 8
712 // CHECK: store i16 %[[V4]], i16* %{{.*}}, align 8
713 // CHECK: %[[V21:.*]] = load i32, i32* %{{.*}}, align 8
714 // CHECK: store i32 %[[V21]], i32* %{{.*}}, align 8
715 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %{{.*}}, i8* align 8 %{{.*}}, i64 12, i1 false)
716 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %{{.*}}, i8* align 8 %{{.*}}, i64 9, i1 false)
717 // CHECK: %[[V54:.*]] = bitcast i8** %[[V0:.*]] to %[[STRUCT_BITFIELD1]]*
718 // CHECK: %[[I5:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V54]], i32 0, i32 8
719 // CHECK: %[[V55:.*]] = bitcast i8** %[[V1:.*]] to %[[STRUCT_BITFIELD1]]*
720 // CHECK: %[[I51:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V55]], i32 0, i32 8
721 // CHECK: %[[BF_LOAD:.*]] = load volatile i8, i8* %[[I51]], align 8
722 // CHECK: %[[BF_SHL:.*]] = shl i8 %[[BF_LOAD]], 5
723 // CHECK: %[[BF_ASHR:.*]] = ashr i8 %[[BF_SHL]], 6
724 // CHECK: %[[BF_CAST:.*]] = sext i8 %[[BF_ASHR]] to i32
725 // CHECK: %[[V56:.*]] = trunc i32 %[[BF_CAST]] to i8
726 // CHECK: %[[BF_LOAD2:.*]] = load volatile i8, i8* %[[I5]], align 8
727 // CHECK: %[[BF_VALUE:.*]] = and i8 %[[V56]], 3
728 // CHECK: %[[BF_SHL3:.*]] = shl i8 %[[BF_VALUE]], 1
729 // CHECK: %[[BF_CLEAR:.*]] = and i8 %[[BF_LOAD2]], -7
730 // CHECK: %[[BF_SET:.*]] = or i8 %[[BF_CLEAR]], %[[BF_SHL3]]
731 // CHECK: store volatile i8 %[[BF_SET]], i8* %[[I5]], align 8
732 // CHECK: %[[V57:.*]] = bitcast i8** %[[V0]] to %[[STRUCT_BITFIELD1]]*
733 // CHECK: %[[I6:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V57]], i32 0, i32 9
734 // CHECK: %[[V58:.*]] = bitcast i8** %[[V1]] to %[[STRUCT_BITFIELD1]]*
735 // CHECK: %[[I64:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V58]], i32 0, i32 9
736 // CHECK: %[[V59:.*]] = load volatile i8, i8* %[[I64]], align 1
737 // CHECK: store volatile i8 %[[V59]], i8* %[[I6]], align 1
739 void test_copy_constructor_Bitfield1(Bitfield1 *a) {
743 // CHECK: define{{.*}} void @test_copy_constructor_VolatileArray(
744 // CHECK: call void @__copy_constructor_8_8_s0_AB8s4n16_tv64w32_AE(
746 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_s0_AB8s4n16_tv64w32_AE(
747 // CHECK: %[[ADDR_CUR:.*]] = phi i8**
748 // CHECK: %[[ADDR_CUR1:.*]] = phi i8**
749 // CHECK: %[[V12:.*]] = bitcast i8** %[[ADDR_CUR]] to i32*
750 // CHECK: %[[V13:.*]] = bitcast i8** %[[ADDR_CUR1]] to i32*
751 // CHECK: %[[V14:.*]] = load volatile i32, i32* %[[V13]], align 4
752 // CHECK: store volatile i32 %[[V14]], i32* %[[V12]], align 4
754 void test_copy_constructor_VolatileArray(VolatileArray *a) {
755 VolatileArray t = *a;
758 // CHECK: define{{.*}} void @test_compound_literal0(
759 // CHECK: %[[P:.*]] = alloca %[[STRUCT_STRONGSMALL]]*, align 8
760 // CHECK: %[[_COMPOUNDLITERAL:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
761 // CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1
762 // CHECK: %[[_COMPOUNDLITERAL1:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
763 // CHECK: %[[CLEANUP_COND4:.*]] = alloca i1, align 1
765 // CHECK: %[[I:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 0
766 // CHECK: store i32 1, i32* %[[I]], align 8
767 // CHECK: %[[F1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 1
768 // CHECK: store i8* null, i8** %[[F1]], align 8
769 // CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1
771 // CHECK: %[[I2:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 0
772 // CHECK: store i32 2, i32* %[[I2]], align 8
773 // CHECK: %[[F13:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 1
774 // CHECK: store i8* null, i8** %[[F13]], align 8
775 // CHECK: store i1 true, i1* %[[CLEANUP_COND4]], align 1
777 // CHECK: %[[COND:.*]] = phi %[[STRUCT_STRONGSMALL]]* [ %[[_COMPOUNDLITERAL]], %{{.*}} ], [ %[[_COMPOUNDLITERAL1]], %{{.*}} ]
778 // CHECK: store %[[STRUCT_STRONGSMALL]]* %[[COND]], %[[STRUCT_STRONGSMALL]]** %[[P]], align 8
779 // CHECK: call void @func(
781 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]] to i8**
782 // CHECK: call void @__destructor_8_s8(i8** %[[V1]])
784 // CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]] to i8**
785 // CHECK: call void @__destructor_8_s8(i8** %[[V2]])
787 void test_compound_literal0(int c) {
788 StrongSmall *p = c ? &(StrongSmall){ 1, 0 } : &(StrongSmall){ 2, 0 };
792 // Check that there is only one destructor call, which destructs 't'.
794 // CHECK: define{{.*}} void @test_compound_literal1(
795 // CHECK: %[[T:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
797 // CHECK: %[[I:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 0
798 // CHECK: store i32 1, i32* %[[I]], align 8
799 // CHECK: %[[F1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 1
800 // CHECK: store i8* null, i8** %[[F1]], align 8
802 // CHECK: %[[I1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 0
803 // CHECK: store i32 2, i32* %[[I1]], align 8
804 // CHECK: %[[F12:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 1
805 // CHECK: store i8* null, i8** %[[F12]], align 8
807 // CHECK: call void @func(
808 // CHECK-NOT: call void
809 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[T]] to i8**
810 // CHECK: call void @__destructor_8_s8(i8** %[[V1]])
811 // CHECK-NOT: call void
813 void test_compound_literal1(int c) {
814 StrongSmall t = c ? (StrongSmall){ 1, 0 } : (StrongSmall){ 2, 0 };
818 // CHECK: define{{.*}} void @test_compound_literal2(
819 // CHECK: %[[P_ADDR:.*]] = alloca %[[STRUCT_STRONGSMALL]]*, align 8
820 // CHECK: %[[_COMPOUNDLITERAL:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
821 // CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1
822 // CHECK: %[[_COMPOUNDLITERAL1:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
823 // CHECK: %[[CLEANUP_COND4:.*]] = alloca i1, align 1
824 // CHECK: %[[V0:.*]] = load %[[STRUCT_STRONGSMALL]]*, %[[STRUCT_STRONGSMALL]]** %[[P_ADDR]], align 8
826 // CHECK: %[[I:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 0
827 // CHECK: store i32 1, i32* %[[I]], align 8
828 // CHECK: %[[F1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 1
829 // CHECK: store i8* null, i8** %[[F1]], align 8
830 // CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1
831 // CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[V0]] to i8**
832 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]] to i8**
833 // CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** %[[V2]], i8** %[[V3]])
835 // CHECK: %[[I2:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 0
836 // CHECK: store i32 2, i32* %[[I2]], align 8
837 // CHECK: %[[F13:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 1
838 // CHECK: store i8* null, i8** %[[F13]], align 8
839 // CHECK: store i1 true, i1* %[[CLEANUP_COND4]], align 1
840 // CHECK: %[[V4:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[V0]] to i8**
841 // CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]] to i8**
842 // CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** %[[V4]], i8** %[[V5]])
844 // CHECK: call void @func(
846 // CHECK: %[[V6:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]] to i8**
847 // CHECK: call void @__destructor_8_s8(i8** %[[V6]])
849 // CHECK: %[[V7:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]] to i8**
850 // CHECK: call void @__destructor_8_s8(i8** %[[V7]])
852 void test_compound_literal2(int c, StrongSmall *p) {
853 *p = c ? (StrongSmall){ 1, 0 } : (StrongSmall){ 2, 0 };
857 // CHECK: define{{.*}} void @test_member_access(
858 // CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]],
859 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
860 // CHECK: call void @__destructor_8_s8(i8** %[[V3]])
861 // CHECK: call void @func(
863 void test_member_access(void) {
864 g0 = getStrongSmall().f1;
868 // CHECK: define{{.*}} void @test_member_access2(%{{.*}}* noundef %[[C:.*]])
869 // CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
870 // CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
871 // CHECK: call void @__destructor_8_s8(i8** %[[V8]])
872 // CHECK: call void @func(
874 void test_member_access2(C *c) {
875 g0 = [c getStrongSmall].f1;
879 // CHECK: define{{.*}} void @test_member_access3(
880 // CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
881 // CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
882 // CHECK: call void @__destructor_8_s8(i8** %[[V8]])
883 // CHECK: call void @func(
885 void test_member_access3(void) {
886 g0 = [C getStrongSmallClass].f1;
890 // CHECK: define{{.*}} void @test_member_access4()
891 // CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
892 // CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
893 // CHECK: call void @__destructor_8_s8(i8** %[[V5]])
894 // CHECK: call void @func(
896 void test_member_access4(void) {
897 g0 = ^{ StrongSmall s; return s; }().f1;
901 // CHECK: define{{.*}} void @test_volatile_variable_reference(
902 // CHECK: %[[AGG_TMP_ENSURED:.*]] = alloca %[[STRUCT_STRONGSMALL]],
903 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8**
904 // CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %{{.*}} to i8**
905 // CHECK: call void @__copy_constructor_8_8_tv0w32_sv8(i8** %[[V1]], i8** %[[V2]])
906 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8**
907 // CHECK: call void @__destructor_8_s8(i8** %[[V3]])
908 // CHECK: call void @func(
910 void test_volatile_variable_reference(volatile StrongSmall *a) {
915 struct ZeroBitfield {
921 // CHECK: define linkonce_odr hidden void @__default_constructor_8_sv0
922 // CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_sv0
923 void test_zero_bitfield(void) {
924 struct ZeroBitfield volatile a, b;
928 // CHECK-LABEL: define{{.*}} i8* @test_conditional0(
929 // CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
931 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
932 // CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
934 // CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
935 // CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V2]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g1 to i8**))
937 // CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
938 // CHECK: call void @__destructor_8_s8(i8** %[[V5]])
939 // CHECK: @llvm.objc.autoreleaseReturnValue
941 id test_conditional0(int c) {
942 return (c ? g2 : g1).f1;
945 // CHECK-LABEL: define{{.*}} i8* @test_conditional1(
946 // CHECK-NOT: call void @__destructor
948 id test_conditional1(int c) {
949 calleeStrongSmall(c ? g2 : g1);
952 // CHECK-LABEL: define{{.*}} i8* @test_assignment0(
953 // CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
954 // CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**), i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g1 to i8**))
955 // CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
956 // CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V0]], i8** bitcast (%[[STRUCT_STRONGSMALL]]* @g2 to i8**))
957 // CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
958 // CHECK: call void @__destructor_8_s8(i8** %[[V3]])
960 id test_assignment0(void) {
964 // CHECK-LABEL: define{{.*}} i8* @test_assignment1(
965 // CHECK-NOT: call void @__destructor
967 id test_assignment1(void) {
968 calleeStrongSmall(g2 = g1);
971 // CHECK-LABEL: define{{.*}} void @test_null_reveiver(
972 // CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
975 // CHECK: %[[V7:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP]] to [2 x i64]*
976 // CHECK: %[[V8:.*]] = load [2 x i64], [2 x i64]* %[[V7]], align 8
977 // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void ({{.*}}, [2 x i64] %[[V8]])
980 // CHECK: %[[V9:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP]] to i8**
981 // CHECK: call void @__destructor_8_s8(i8** %[[V9]]) #4
984 void test_null_reveiver(C *c) {
985 [c m:getStrongSmall()];
988 #endif /* USESTRUCT */