1// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s 2 3// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-pch -o %t %s 4// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -include-pch %t -emit-llvm -o - -DUSESTRUCT %s | FileCheck %s 5 6#ifndef HEADER 7#define HEADER 8 9typedef void (^BlockTy)(void); 10 11typedef struct { 12 int a[4]; 13} Trivial; 14 15typedef struct { 16 Trivial f0; 17 id f1; 18} Strong; 19 20typedef struct { 21 int i; 22 id f1; 23} StrongSmall; 24 25typedef struct { 26 Strong f0; 27 id f1; 28 double d; 29} StrongOuter; 30 31typedef struct { 32 id f0; 33 Strong f1; 34} StrongOuter2; 35 36typedef struct { 37 int f0; 38 volatile id f1; 39} StrongVolatile; 40 41typedef struct { 42 BlockTy f0; 43} StrongBlock; 44 45typedef struct { 46 int i; 47 id f0[2][2]; 48} IDArray; 49 50typedef struct { 51 double d; 52 Strong f0[2][2]; 53} StructArray; 54 55typedef struct { 56 id f0; 57 int i : 9; 58} Bitfield0; 59 60typedef struct { 61 char c; 62 int i0 : 2; 63 int i1 : 4; 64 id f0; 65 int i2 : 31; 66 int i3 : 1; 67 id f1; 68 int : 0; 69 int a[3]; 70 id f2; 71 double d; 72 int i4 : 1; 73 volatile int i5 : 2; 74 volatile char i6; 75} Bitfield1; 76 77typedef struct { 78 id x; 79 volatile int a[16]; 80} VolatileArray ; 81 82#endif 83 84#ifdef USESTRUCT 85 86StrongSmall getStrongSmall(void); 87StrongOuter getStrongOuter(void); 88StrongOuter2 getStrongOuter2(void); 89void calleeStrongSmall(StrongSmall); 90void func(Strong *); 91 92@interface C 93- (StrongSmall)getStrongSmall; 94+ (StrongSmall)getStrongSmallClass; 95@end 96 97id g0; 98 99// CHECK: %[[STRUCT_STRONGOUTER:.*]] = type { %[[STRUCT_STRONG:.*]], i8*, double } 100// CHECK: %[[STRUCT_STRONG]] = type { %[[STRUCT_TRIVIAL:.*]], i8* } 101// CHECK: %[[STRUCT_TRIVIAL]] = type { [4 x i32] } 102// CHECK: %[[STRUCT_BLOCK_BYREF_T:.*]] = type { i8*, %[[STRUCT_BLOCK_BYREF_T]]*, i32, i32, i8*, i8*, i8*, %[[STRUCT_STRONGOUTER]] } 103// CHECK: %[[STRUCT_STRONGSMALL:.*]] = type { i32, i8* } 104// CHECK: %[[STRUCT_STRONGBLOCK:.*]] = type { void ()* } 105// CHECK: %[[STRUCT_BITFIELD1:.*]] = type { i8, i8, i8*, i32, i8*, [3 x i32], i8*, double, i8, i8 } 106 107// CHECK: define void @test_constructor_destructor_StrongOuter() 108// CHECK: %[[T:.*]] = alloca %[[STRUCT_STRONGOUTER]], align 8 109// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8** 110// CHECK: call void @__default_constructor_8_S_s16_s24(i8** %[[V0]]) 111// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8** 112// CHECK: call void @__destructor_8_S_s16_s24(i8** %[[V1]]) 113// CHECK: ret void 114 115// CHECK: define linkonce_odr hidden void @__default_constructor_8_S_s16_s24(i8** %[[DST:.*]]) 116// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 117// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 118// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 119// CHECK: call void @__default_constructor_8_s16(i8** %[[V0]]) 120// CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8* 121// CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 24 122// CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8** 123// CHECK: %[[V4:.*]] = bitcast i8** %[[V3]] to i8* 124// CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %[[V4]], i8 0, i64 8, i1 false) 125// CHECK: ret void 126 127// CHECK: define linkonce_odr hidden void @__default_constructor_8_s16(i8** %[[DST:.*]]) 128// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 129// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 130// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 131// CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8* 132// CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 16 133// CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8** 134// CHECK: %[[V4:.*]] = bitcast i8** %[[V3]] to i8* 135// CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %[[V4]], i8 0, i64 8, i1 false) 136// CHECK: ret void 137 138// CHECK: define linkonce_odr hidden void @__destructor_8_S_s16_s24(i8** %[[DST:.*]]) 139// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 140// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 141// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 142// CHECK: call void @__destructor_8_s16(i8** %[[V0]]) 143// CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8* 144// CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 24 145// CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8** 146// CHECK: call void @llvm.objc.storeStrong(i8** %[[V3]], i8* null) 147// CHECK: ret void 148 149// CHECK: define linkonce_odr hidden void @__destructor_8_s16(i8** %[[DST:.*]]) 150// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 151// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 152// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 153// CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8* 154// CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 16 155// CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8** 156// CHECK: call void @llvm.objc.storeStrong(i8** %[[V3]], i8* null) 157// CHECK: ret void 158 159void test_constructor_destructor_StrongOuter(void) { 160 StrongOuter t; 161} 162 163// CHECK: define void @test_copy_constructor_StrongOuter(%[[STRUCT_STRONGOUTER]]* %[[S:.*]]) 164// CHECK: %[[S_ADDR:.*]] = alloca %[[STRUCT_STRONGOUTER]]*, align 8 165// CHECK: %[[T:.*]] = alloca %[[STRUCT_STRONGOUTER]], align 8 166// CHECK: store %[[STRUCT_STRONGOUTER]]* %[[S]], %[[STRUCT_STRONGOUTER]]** %[[S_ADDR]], align 8 167// CHECK: %[[V0:.*]] = load %[[STRUCT_STRONGOUTER]]*, %[[STRUCT_STRONGOUTER]]** %[[S_ADDR]], align 8 168// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8** 169// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[V0]] to i8** 170// CHECK: call void @__copy_constructor_8_8_S_t0w16_s16_s24_t32w8(i8** %[[V1]], i8** %[[V2]]) 171// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8** 172// CHECK: call void @__destructor_8_S_s16_s24(i8** %[[V3]]) 173// CHECK: ret void 174 175// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_S_t0w16_s16_s24_t32w8(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 176// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 177// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 178// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 179// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 180// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 181// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 182// CHECK: call void @__copy_constructor_8_8_t0w16_s16(i8** %[[V0]], i8** %[[V1]]) 183// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8* 184// CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24 185// CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8** 186// CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8* 187// CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24 188// CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8** 189// CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8 190// CHECK: %[[V9:.*]] = call i8* @llvm.objc.retain(i8* %[[V8]]) 191// CHECK: store i8* %[[V9]], i8** %[[V4]], align 8 192// CHECK: %[[V10:.*]] = bitcast i8** %[[V0]] to i8* 193// CHECK: %[[V11:.*]] = getelementptr inbounds i8, i8* %[[V10]], i64 32 194// CHECK: %[[V12:.*]] = bitcast i8* %[[V11]] to i8** 195// CHECK: %[[V13:.*]] = bitcast i8** %[[V1]] to i8* 196// CHECK: %[[V14:.*]] = getelementptr inbounds i8, i8* %[[V13]], i64 32 197// CHECK: %[[V15:.*]] = bitcast i8* %[[V14]] to i8** 198// CHECK: %[[V16:.*]] = bitcast i8** %[[V12]] to i64* 199// CHECK: %[[V17:.*]] = bitcast i8** %[[V15]] to i64* 200// CHECK: %[[V18:.*]] = load i64, i64* %[[V17]], align 8 201// CHECK: store i64 %[[V18]], i64* %[[V16]], align 8 202// CHECK: ret void 203 204// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w16_s16(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 205// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 206// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 207// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 208// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 209// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 210// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 211// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8* 212// CHECK: %[[V3:.*]] = bitcast i8** %[[V1]] to i8* 213// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %[[V2]], i8* align 8 %[[V3]], i64 16, i1 false) 214// CHECK: %[[V4:.*]] = bitcast i8** %[[V0]] to i8* 215// CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 16 216// CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8** 217// CHECK: %[[V7:.*]] = bitcast i8** %[[V1]] to i8* 218// CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 16 219// CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8** 220// CHECK: %[[V10:.*]] = load i8*, i8** %[[V9]], align 8 221// CHECK: %[[V11:.*]] = call i8* @llvm.objc.retain(i8* %[[V10]]) 222// CHECK: store i8* %[[V11]], i8** %[[V6]], align 8 223// CHECK: ret void 224 225void test_copy_constructor_StrongOuter(StrongOuter *s) { 226 StrongOuter t = *s; 227} 228 229/// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_S_t0w16_s16_s24_t32w8(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 230// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 231// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 232// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 233// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 234// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 235// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 236// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8* 237// CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24 238// CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8** 239// CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8* 240// CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24 241// CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8** 242// CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8 243// CHECK: call void @llvm.objc.storeStrong(i8** %[[V4]], i8* %[[V8]]) 244 245void test_copy_assignment_StrongOuter(StrongOuter *d, StrongOuter *s) { 246 *d = *s; 247} 248 249// CHECK: define void @test_move_constructor_StrongOuter() 250// CHECK: %[[T1:.*]] = getelementptr inbounds %[[STRUCT_BLOCK_BYREF_T]], %[[STRUCT_BLOCK_BYREF_T]]* %{{.*}}, i32 0, i32 7 251// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T1]] to i8** 252// CHECK: call void @__default_constructor_8_S_s16_s24(i8** %[[V1]]) 253// CHECK: %[[T2:.*]] = getelementptr inbounds %[[STRUCT_BLOCK_BYREF_T]], %[[STRUCT_BLOCK_BYREF_T]]* %{{.*}}, i32 0, i32 7 254// CHECK: %[[V9:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T2]] to i8** 255// CHECK: call void @__destructor_8_S_s16_s24(i8** %[[V9]]) 256 257// CHECK: define internal void @__Block_byref_object_copy_(i8* %0, i8* %1) 258// CHECK: call void @__move_constructor_8_8_S_t0w16_s16_s24_t32w8( 259 260// CHECK: define linkonce_odr hidden void @__move_constructor_8_8_S_t0w16_s16_s24_t32w8(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 261// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 262// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 263// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 264// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 265// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 266// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 267// CHECK: call void @__move_constructor_8_8_t0w16_s16(i8** %[[V0]], i8** %[[V1]]) 268// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8* 269// CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24 270// CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8** 271// CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8* 272// CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24 273// CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8** 274// CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8 275// CHECK: store i8* null, i8** %[[V7]], align 8 276// CHECK: store i8* %[[V8]], i8** %[[V4]], align 8 277 278// CHECK: define internal void @__Block_byref_object_dispose_(i8* %0) 279// CHECK: call void @__destructor_8_S_s16_s24( 280 281void test_move_constructor_StrongOuter(void) { 282 __block StrongOuter t; 283 BlockTy b = ^{ (void)t; }; 284} 285 286// CHECK: define linkonce_odr hidden void @__move_assignment_8_8_S_t0w16_s16_s24_t32w8(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 287// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 288// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 289// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 290// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 291// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 292// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 293// CHECK: call void @__move_assignment_8_8_t0w16_s16(i8** %[[V0]], i8** %[[V1]]) 294// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8* 295// CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 24 296// CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8** 297// CHECK: %[[V5:.*]] = bitcast i8** %[[V1]] to i8* 298// CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 24 299// CHECK: %[[V7:.*]] = bitcast i8* %[[V6]] to i8** 300// CHECK: %[[V8:.*]] = load i8*, i8** %[[V7]], align 8 301// CHECK: store i8* null, i8** %[[V7]], align 8 302// CHECK: %[[V9:.*]] = load i8*, i8** %[[V4]], align 8 303// CHECK: store i8* %[[V8]], i8** %[[V4]], align 8 304// CHECK: call void @llvm.objc.release(i8* %[[V9]]) 305 306void test_move_assignment_StrongOuter(StrongOuter *p) { 307 *p = getStrongOuter(); 308} 309 310// CHECK: define linkonce_odr hidden void @__default_constructor_8_s0_S_s24(i8** %[[DST:.*]]) 311// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 312// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 313// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 314// CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8* 315// CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %[[V1]], i8 0, i64 8, i1 false) 316// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i8* 317// CHECK: %[[V3:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 8 318// CHECK: %[[V4:.*]] = bitcast i8* %[[V3]] to i8** 319// CHECK: call void @__default_constructor_8_s16(i8** %[[V4]]) 320 321// CHECK: define linkonce_odr hidden void @__destructor_8_s0_S_s24(i8** %[[DST:.*]]) 322// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 323// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 324// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 325// CHECK: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* null) 326// CHECK: %[[V1:.*]] = bitcast i8** %[[V0]] to i8* 327// CHECK: %[[V2:.*]] = getelementptr inbounds i8, i8* %[[V1]], i64 8 328// CHECK: %[[V3:.*]] = bitcast i8* %[[V2]] to i8** 329// CHECK: call void @__destructor_8_s16(i8** %[[V3]]) 330 331void test_constructor_destructor_StrongOuter2(void) { 332 StrongOuter2 t; 333} 334 335// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_s0_S_t8w16_s24(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 336// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 337// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 338// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 339// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 340// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 341// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 342// CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8 343// CHECK: %[[V3:.*]] = call i8* @llvm.objc.retain(i8* %[[V2]]) 344// CHECK: store i8* %[[V3]], i8** %[[V0]], align 8 345// CHECK: %[[V4:.*]] = bitcast i8** %[[V0]] to i8* 346// CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 8 347// CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8** 348// CHECK: %[[V7:.*]] = bitcast i8** %[[V1]] to i8* 349// CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 8 350// CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8** 351// CHECK: call void @__copy_constructor_8_8_t0w16_s16(i8** %[[V6]], i8** %[[V9]]) 352 353void test_copy_constructor_StrongOuter2(StrongOuter2 *s) { 354 StrongOuter2 t = *s; 355} 356 357// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_s0_S_t8w16_s24(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 358// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 359// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 360// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 361// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 362// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 363// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 364// CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8 365// CHECK: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* %[[V2]]) 366// CHECK: %[[V3:.*]] = bitcast i8** %[[V0]] to i8* 367// CHECK: %[[V4:.*]] = getelementptr inbounds i8, i8* %[[V3]], i64 8 368// CHECK: %[[V5:.*]] = bitcast i8* %[[V4]] to i8** 369// CHECK: %[[V6:.*]] = bitcast i8** %[[V1]] to i8* 370// CHECK: %[[V7:.*]] = getelementptr inbounds i8, i8* %[[V6]], i64 8 371// CHECK: %[[V8:.*]] = bitcast i8* %[[V7]] to i8** 372// CHECK: call void @__copy_assignment_8_8_t0w16_s16(i8** %[[V5]], i8** %[[V8]]) 373 374void test_copy_assignment_StrongOuter2(StrongOuter2 *d, StrongOuter2 *s) { 375 *d = *s; 376} 377 378// CHECK: define linkonce_odr hidden void @__move_constructor_8_8_s0_S_t8w16_s24(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 379// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 380// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 381// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 382// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 383// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 384// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 385// CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8 386// CHECK: store i8* null, i8** %[[V1]], align 8 387// CHECK: store i8* %[[V2]], i8** %[[V0]], align 8 388// CHECK: %[[V3:.*]] = bitcast i8** %[[V0]] to i8* 389// CHECK: %[[V4:.*]] = getelementptr inbounds i8, i8* %[[V3]], i64 8 390// CHECK: %[[V5:.*]] = bitcast i8* %[[V4]] to i8** 391// CHECK: %[[V6:.*]] = bitcast i8** %[[V1]] to i8* 392// CHECK: %[[V7:.*]] = getelementptr inbounds i8, i8* %[[V6]], i64 8 393// CHECK: %[[V8:.*]] = bitcast i8* %[[V7]] to i8** 394// CHECK: call void @__move_constructor_8_8_t0w16_s16(i8** %[[V5]], i8** %[[V8]]) 395 396void test_move_constructor_StrongOuter2(void) { 397 __block StrongOuter2 t; 398 BlockTy b = ^{ (void)t; }; 399} 400 401// CHECK: define linkonce_odr hidden void @__move_assignment_8_8_s0_S_t8w16_s24(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 402// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 403// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 404// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 405// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 406// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 407// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 408// CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8 409// CHECK: store i8* null, i8** %[[V1]], align 8 410// CHECK: %[[V3:.*]] = load i8*, i8** %[[V0]], align 8 411// CHECK: store i8* %[[V2]], i8** %[[V0]], align 8 412// CHECK: call void @llvm.objc.release(i8* %[[V3]]) 413// CHECK: %[[V4:.*]] = bitcast i8** %[[V0]] to i8* 414// CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 8 415// CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8** 416// CHECK: %[[V7:.*]] = bitcast i8** %[[V1]] to i8* 417// CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 8 418// CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8** 419// CHECK: call void @__move_assignment_8_8_t0w16_s16(i8** %[[V6]], i8** %[[V9]]) 420 421void test_move_assignment_StrongOuter2(StrongOuter2 *p) { 422 *p = getStrongOuter2(); 423} 424 425// CHECK: define void @test_parameter_StrongSmall([2 x i64] %[[A_COERCE:.*]]) 426// CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 427// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to [2 x i64]* 428// CHECK: store [2 x i64] %[[A_COERCE]], [2 x i64]* %[[V0]], align 8 429// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8** 430// CHECK: call void @__destructor_8_s8(i8** %[[V1]]) 431// CHECK: ret void 432 433void test_parameter_StrongSmall(StrongSmall a) { 434} 435 436// CHECK: define void @test_argument_StrongSmall([2 x i64] %[[A_COERCE:.*]]) 437// CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 438// CHECK: %[[TEMP_LVALUE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 439// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to [2 x i64]* 440// CHECK: store [2 x i64] %[[A_COERCE]], [2 x i64]* %[[V0]], align 8 441// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TEMP_LVALUE]] to i8** 442// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8** 443// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** %[[V2]]) 444// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TEMP_LVALUE]] to [2 x i64]* 445// CHECK: %[[V4:.*]] = load [2 x i64], [2 x i64]* %[[V3]], align 8 446// CHECK: call void @calleeStrongSmall([2 x i64] %[[V4]]) 447// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8** 448// CHECK: call void @__destructor_8_s8(i8** %[[V5]]) 449// CHECK: ret void 450 451void test_argument_StrongSmall(StrongSmall a) { 452 calleeStrongSmall(a); 453} 454 455// CHECK: define [2 x i64] @test_return_StrongSmall([2 x i64] %[[A_COERCE:.*]]) 456// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 457// CHECK: %[[A:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 458// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to [2 x i64]* 459// CHECK: store [2 x i64] %[[A_COERCE]], [2 x i64]* %[[V0]], align 8 460// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[RETVAL]] to i8** 461// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8** 462// CHECK: call void @__copy_constructor_8_8_t0w4_s8(i8** %[[V1]], i8** %[[V2]]) 463// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[A]] to i8** 464// CHECK: call void @__destructor_8_s8(i8** %[[V3]]) 465// CHECK: %[[V4:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[RETVAL]] to [2 x i64]* 466// CHECK: %[[V5:.*]] = load [2 x i64], [2 x i64]* %[[V4]], align 8 467// CHECK: ret [2 x i64] %[[V5]] 468 469StrongSmall test_return_StrongSmall(StrongSmall a) { 470 return a; 471} 472 473// CHECK: define void @test_destructor_ignored_result() 474// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 475// CHECK: %[[CALL:.*]] = call [2 x i64] @getStrongSmall() 476// CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to [2 x i64]* 477// CHECK: store [2 x i64] %[[CALL]], [2 x i64]* %[[V0]], align 8 478// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8** 479// CHECK: call void @__destructor_8_s8(i8** %[[V1]]) 480// CHECK: ret void 481 482void test_destructor_ignored_result(void) { 483 getStrongSmall(); 484} 485 486// CHECK: define void @test_destructor_ignored_result2(%{{.*}}* %[[C:.*]]) 487// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 488// CHECK: %[[CALL:.*]] = call [2 x i64]{{.*}}@objc_msgSend 489// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to [2 x i64]* 490// CHECK: store [2 x i64] %[[CALL]], [2 x i64]* %[[V5]], align 8 491// CHECK: %[[V6:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8** 492// CHECK: call void @__destructor_8_s8(i8** %[[V6]]) 493 494void test_destructor_ignored_result2(C *c) { 495 [c getStrongSmall]; 496} 497 498// CHECK: define void @test_copy_constructor_StrongBlock( 499// CHECK: call void @__copy_constructor_8_8_sb0( 500// CHECK: call void @__destructor_8_sb0( 501// CHECK: ret void 502 503// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_sb0(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 504// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 505// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 506// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 507// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 508// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 509// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 510// CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8 511// CHECK: %[[V3:.*]] = call i8* @llvm.objc.retainBlock(i8* %[[V2]]) 512// CHECK: store i8* %[[V3]], i8** %[[V0]], align 8 513// CHECK: ret void 514 515void test_copy_constructor_StrongBlock(StrongBlock *s) { 516 StrongBlock t = *s; 517} 518 519// CHECK: define void @test_copy_assignment_StrongBlock(%[[STRUCT_STRONGBLOCK]]* %[[D:.*]], %[[STRUCT_STRONGBLOCK]]* %[[S:.*]]) 520// CHECK: call void @__copy_assignment_8_8_sb0( 521 522// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_sb0(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 523// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 524// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 525// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 526// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 527// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 528// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 529// CHECK: %[[V2:.*]] = load i8*, i8** %[[V1]], align 8 530// CHECK: %[[V3:.*]] = call i8* @llvm.objc.retainBlock(i8* %[[V2]]) 531// CHECK: %[[V4:.*]] = load i8*, i8** %[[V0]], align 8 532// CHECK: store i8* %[[V3]], i8** %[[V0]], align 8 533// CHECK: call void @llvm.objc.release(i8* %[[V4]]) 534// CHECK: ret void 535 536void test_copy_assignment_StrongBlock(StrongBlock *d, StrongBlock *s) { 537 *d = *s; 538} 539 540// CHECK: define void @test_copy_constructor_StrongVolatile0( 541// CHECK: call void @__copy_constructor_8_8_t0w4_sv8( 542// CHECK-NOT: call 543// CHECK: call void @__destructor_8_sv8( 544// CHECK-NOT: call 545 546// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w4_sv8( 547// CHECK: %[[V8:.*]] = load volatile i8*, i8** %{{.*}}, align 8 548// CHECK: %[[V9:.*]] = call i8* @llvm.objc.retain(i8* %[[V8]]) 549// CHECK: store volatile i8* %[[V9]], i8** %{{.*}}, align 8 550 551void test_copy_constructor_StrongVolatile0(StrongVolatile *s) { 552 StrongVolatile t = *s; 553} 554 555// CHECK: define void @test_copy_constructor_StrongVolatile1( 556// CHECK: call void @__copy_constructor_8_8_tv0w128_sv16( 557 558void test_copy_constructor_StrongVolatile1(Strong *s) { 559 volatile Strong t = *s; 560} 561 562// CHECK: define void @test_block_capture_Strong() 563// CHECK: call void @__default_constructor_8_s16( 564// CHECK: call void @__copy_constructor_8_8_t0w16_s16( 565// CHECK: call void @__destructor_8_s16( 566// CHECK: call void @__destructor_8_s16( 567// CHECK: ret void 568 569// CHECK: define linkonce_odr hidden void @__copy_helper_block_8_32n13_8_8_t0w16_s16(i8* %0, i8* %1) 570// CHECK: call void @__copy_constructor_8_8_t0w16_s16( 571// CHECK: ret void 572 573// CHECK: define linkonce_odr hidden void @__destroy_helper_block_8_32n5_8_s16( 574// CHECK: call void @__destructor_8_s16( 575// CHECK: ret void 576 577void test_block_capture_Strong(void) { 578 Strong t; 579 BlockTy b = ^(){ (void)t; }; 580} 581 582// CHECK: define void @test_variable_length_array(i32 %[[N:.*]]) 583// CHECK: %[[N_ADDR:.*]] = alloca i32, align 4 584// CHECK: store i32 %[[N]], i32* %[[N_ADDR]], align 4 585// CHECK: %[[V0:.*]] = load i32, i32* %[[N_ADDR]], align 4 586// CHECK: %[[V1:.*]] = zext i32 %[[V0]] to i64 587// CHECK: %[[VLA:.*]] = alloca %[[STRUCT_STRONG]], i64 %[[V1]], align 8 588// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONG]]* %[[VLA]] to i8** 589// CHECK: %[[V4:.*]] = mul nuw i64 24, %[[V1]] 590// CHECK: %[[V5:.*]] = bitcast i8** %[[V3]] to i8* 591// CHECK: %[[V6:.*]] = getelementptr inbounds i8, i8* %[[V5]], i64 %[[V4]] 592// CHECK: %[[DSTARRAY_END:.*]] = bitcast i8* %[[V6]] to i8** 593// CHECK: br label 594 595// CHECK: %[[DSTADDR_CUR:.*]] = phi i8** [ %[[V3]], {{.*}} ], [ %[[V7:.*]], {{.*}} ] 596// CHECK: %[[DONE:.*]] = icmp eq i8** %[[DSTADDR_CUR]], %[[DSTARRAY_END]] 597// CHECK: br i1 %[[DONE]], label 598 599// CHECK: call void @__default_constructor_8_s16(i8** %[[DSTADDR_CUR]]) 600// CHECK: %[[V8:.*]] = bitcast i8** %[[DSTADDR_CUR]] to i8* 601// CHECK: %[[V9:.*]] = getelementptr inbounds i8, i8* %[[V8]], i64 24 602// CHECK: %[[V7]] = bitcast i8* %[[V9]] to i8** 603// CHECK: br label 604 605// CHECK: call void @func(%[[STRUCT_STRONG]]* %[[VLA]]) 606// CHECK: %[[V10:.*]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[VLA]], i64 %[[V1]] 607// CHECK: %[[ARRAYDESTROY_ISEMPTY:.*]] = icmp eq %[[STRUCT_STRONG]]* %[[VLA]], %[[V10]] 608// CHECK: br i1 %[[ARRAYDESTROY_ISEMPTY]], label 609 610// CHECK: %[[ARRAYDESTROY_ELEMENTPAST:.*]] = phi %[[STRUCT_STRONG]]* [ %[[V10]], {{.*}} ], [ %[[ARRAYDESTROY_ELEMENT:.*]], {{.*}} ] 611// CHECK: %[[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds %[[STRUCT_STRONG]], %[[STRUCT_STRONG]]* %[[ARRAYDESTROY_ELEMENTPAST]], i64 -1 612// CHECK: %[[V11:.*]] = bitcast %[[STRUCT_STRONG]]* %[[ARRAYDESTROY_ELEMENT]] to i8** 613// CHECK: call void @__destructor_8_s16(i8** %[[V11]]) 614// CHECK: %[[ARRAYDESTROY_DONE:.*]] = icmp eq %[[STRUCT_STRONG]]* %[[ARRAYDESTROY_ELEMENT]], %[[VLA]] 615// CHECK: br i1 %[[ARRAYDESTROY_DONE]], label 616 617// CHECK: ret void 618 619void test_variable_length_array(int n) { 620 Strong a[n]; 621 func(a); 622} 623 624// CHECK: define linkonce_odr hidden void @__default_constructor_8_AB8s8n4_s8_AE( 625// CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 %{{.*}}, i8 0, i64 32, i1 false) 626void test_constructor_destructor_IDArray(void) { 627 IDArray t; 628} 629 630// CHECK: define linkonce_odr hidden void @__default_constructor_8_AB8s24n4_S_s24_AE( 631void test_constructor_destructor_StructArray(void) { 632 StructArray t; 633} 634 635// Test that StructArray's field 'd' is copied before entering the loop. 636 637// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w8_AB8s24n4_S_t8w16_s24_AE(i8** %[[DST:.*]], i8** %[[SRC:.*]]) 638// CHECK: entry: 639// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8 640// CHECK: %[[SRC_ADDR:.*]] = alloca i8**, align 8 641// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8 642// CHECK: store i8** %[[SRC]], i8*** %[[SRC_ADDR]], align 8 643// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8 644// CHECK: %[[V1:.*]] = load i8**, i8*** %[[SRC_ADDR]], align 8 645// CHECK: %[[V2:.*]] = bitcast i8** %[[V0]] to i64* 646// CHECK: %[[V3:.*]] = bitcast i8** %[[V1]] to i64* 647// CHECK: %[[V4:.*]] = load i64, i64* %[[V3]], align 8 648// CHECK: store i64 %[[V4]], i64* %[[V2]], align 8 649 650// CHECK: phi i8** 651// CHECK: phi i8** 652 653// CHECK: phi i8** 654// CHECK: phi i8** 655 656// CHECK-NOT: load i64, i64* % 657// CHECK-NOT: store i64 % 658// CHECK: call void @__copy_constructor_8_8_t0w16_s16( 659 660void test_copy_constructor_StructArray(StructArray a) { 661 StructArray t = a; 662} 663 664// Check that IRGen copies the 9-bit bitfield emitting i16 load and store. 665 666// CHECK: define void @test_copy_constructor_Bitfield0( 667 668// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_s0_t8w2( 669// CHECK: %[[V4:.*]] = bitcast i8** %{{.*}} to i8* 670// CHECK: %[[V5:.*]] = getelementptr inbounds i8, i8* %[[V4]], i64 8 671// CHECK: %[[V6:.*]] = bitcast i8* %[[V5]] to i8** 672// CHECK: %[[V7:.*]] = bitcast i8** %{{.*}} to i8* 673// CHECK: %[[V8:.*]] = getelementptr inbounds i8, i8* %[[V7]], i64 8 674// CHECK: %[[V9:.*]] = bitcast i8* %[[V8]] to i8** 675// CHECK: %[[V10:.*]] = bitcast i8** %[[V6]] to i16* 676// CHECK: %[[V11:.*]] = bitcast i8** %[[V9]] to i16* 677// CHECK: %[[V12:.*]] = load i16, i16* %[[V11]], align 8 678// CHECK: store i16 %[[V12]], i16* %[[V10]], align 8 679// CHECK: ret void 680 681void test_copy_constructor_Bitfield0(Bitfield0 *a) { 682 Bitfield0 t = *a; 683} 684 685// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w2_s8_t16w4_s24_t32w12_s48_t56w9_tv513w2_tv520w8 686// CHECK: %[[V4:.*]] = load i16, i16* %{{.*}}, align 8 687// CHECK: store i16 %[[V4]], i16* %{{.*}}, align 8 688// CHECK: %[[V21:.*]] = load i32, i32* %{{.*}}, align 8 689// CHECK: store i32 %[[V21]], i32* %{{.*}}, align 8 690// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %{{.*}}, i8* align 8 %{{.*}}, i64 12, i1 false) 691// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %{{.*}}, i8* align 8 %{{.*}}, i64 9, i1 false) 692// CHECK: %[[V54:.*]] = bitcast i8** %[[V0:.*]] to %[[STRUCT_BITFIELD1]]* 693// CHECK: %[[I5:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V54]], i32 0, i32 8 694// CHECK: %[[V55:.*]] = bitcast i8** %[[V1:.*]] to %[[STRUCT_BITFIELD1]]* 695// CHECK: %[[I51:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V55]], i32 0, i32 8 696// CHECK: %[[BF_LOAD:.*]] = load volatile i8, i8* %[[I51]], align 8 697// CHECK: %[[BF_SHL:.*]] = shl i8 %[[BF_LOAD]], 5 698// CHECK: %[[BF_ASHR:.*]] = ashr i8 %[[BF_SHL]], 6 699// CHECK: %[[BF_CAST:.*]] = sext i8 %[[BF_ASHR]] to i32 700// CHECK: %[[V56:.*]] = trunc i32 %[[BF_CAST]] to i8 701// CHECK: %[[BF_LOAD2:.*]] = load volatile i8, i8* %[[I5]], align 8 702// CHECK: %[[BF_VALUE:.*]] = and i8 %[[V56]], 3 703// CHECK: %[[BF_SHL3:.*]] = shl i8 %[[BF_VALUE]], 1 704// CHECK: %[[BF_CLEAR:.*]] = and i8 %[[BF_LOAD2]], -7 705// CHECK: %[[BF_SET:.*]] = or i8 %[[BF_CLEAR]], %[[BF_SHL3]] 706// CHECK: store volatile i8 %[[BF_SET]], i8* %[[I5]], align 8 707// CHECK: %[[V57:.*]] = bitcast i8** %[[V0]] to %[[STRUCT_BITFIELD1]]* 708// CHECK: %[[I6:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V57]], i32 0, i32 9 709// CHECK: %[[V58:.*]] = bitcast i8** %[[V1]] to %[[STRUCT_BITFIELD1]]* 710// CHECK: %[[I64:.*]] = getelementptr inbounds %[[STRUCT_BITFIELD1]], %[[STRUCT_BITFIELD1]]* %[[V58]], i32 0, i32 9 711// CHECK: %[[V59:.*]] = load volatile i8, i8* %[[I64]], align 1 712// CHECK: store volatile i8 %[[V59]], i8* %[[I6]], align 1 713 714void test_copy_constructor_Bitfield1(Bitfield1 *a) { 715 Bitfield1 t = *a; 716} 717 718// CHECK: define void @test_copy_constructor_VolatileArray( 719// CHECK: call void @__copy_constructor_8_8_s0_AB8s4n16_tv64w32_AE( 720 721// CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_s0_AB8s4n16_tv64w32_AE( 722// CHECK: %[[ADDR_CUR:.*]] = phi i8** 723// CHECK: %[[ADDR_CUR1:.*]] = phi i8** 724// CHECK: %[[V12:.*]] = bitcast i8** %[[ADDR_CUR]] to i32* 725// CHECK: %[[V13:.*]] = bitcast i8** %[[ADDR_CUR1]] to i32* 726// CHECK: %[[V14:.*]] = load volatile i32, i32* %[[V13]], align 4 727// CHECK: store volatile i32 %[[V14]], i32* %[[V12]], align 4 728 729void test_copy_constructor_VolatileArray(VolatileArray *a) { 730 VolatileArray t = *a; 731} 732 733// CHECK: define void @test_compound_literal0( 734// CHECK: %[[P:.*]] = alloca %[[STRUCT_STRONGSMALL]]*, align 8 735// CHECK: %[[_COMPOUNDLITERAL:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 736// CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1 737// CHECK: %[[_COMPOUNDLITERAL1:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 738// CHECK: %[[CLEANUP_COND4:.*]] = alloca i1, align 1 739 740// CHECK: %[[I:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 0 741// CHECK: store i32 1, i32* %[[I]], align 8 742// CHECK: %[[F1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 1 743// CHECK: store i8* null, i8** %[[F1]], align 8 744// CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1 745 746// CHECK: %[[I2:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 0 747// CHECK: store i32 2, i32* %[[I2]], align 8 748// CHECK: %[[F13:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 1 749// CHECK: store i8* null, i8** %[[F13]], align 8 750// CHECK: store i1 true, i1* %[[CLEANUP_COND4]], align 1 751 752// CHECK: %[[COND:.*]] = phi %[[STRUCT_STRONGSMALL]]* [ %[[_COMPOUNDLITERAL]], %{{.*}} ], [ %[[_COMPOUNDLITERAL1]], %{{.*}} ] 753// CHECK: store %[[STRUCT_STRONGSMALL]]* %[[COND]], %[[STRUCT_STRONGSMALL]]** %[[P]], align 8 754// CHECK: call void @func( 755 756// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]] to i8** 757// CHECK: call void @__destructor_8_s8(i8** %[[V1]]) 758 759// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]] to i8** 760// CHECK: call void @__destructor_8_s8(i8** %[[V2]]) 761 762void test_compound_literal0(int c) { 763 StrongSmall *p = c ? &(StrongSmall){ 1, 0 } : &(StrongSmall){ 2, 0 }; 764 func(0); 765} 766 767// Check that there is only one destructor call, which destructs 't'. 768 769// CHECK: define void @test_compound_literal1( 770// CHECK: %[[T:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 771 772// CHECK: %[[I:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 0 773// CHECK: store i32 1, i32* %[[I]], align 8 774// CHECK: %[[F1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 1 775// CHECK: store i8* null, i8** %[[F1]], align 8 776 777// CHECK: %[[I1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 0 778// CHECK: store i32 2, i32* %[[I1]], align 8 779// CHECK: %[[F12:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[T]], i32 0, i32 1 780// CHECK: store i8* null, i8** %[[F12]], align 8 781 782// CHECK: call void @func( 783// CHECK-NOT: call void 784// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[T]] to i8** 785// CHECK: call void @__destructor_8_s8(i8** %[[V1]]) 786// CHECK-NOT: call void 787 788void test_compound_literal1(int c) { 789 StrongSmall t = c ? (StrongSmall){ 1, 0 } : (StrongSmall){ 2, 0 }; 790 func(0); 791} 792 793// CHECK: define void @test_compound_literal2( 794// CHECK: %[[P_ADDR:.*]] = alloca %[[STRUCT_STRONGSMALL]]*, align 8 795// CHECK: %[[_COMPOUNDLITERAL:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 796// CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1 797// CHECK: %[[_COMPOUNDLITERAL1:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 798// CHECK: %[[CLEANUP_COND4:.*]] = alloca i1, align 1 799// CHECK: %[[V0:.*]] = load %[[STRUCT_STRONGSMALL]]*, %[[STRUCT_STRONGSMALL]]** %[[P_ADDR]], align 8 800 801// CHECK: %[[I:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 0 802// CHECK: store i32 1, i32* %[[I]], align 8 803// CHECK: %[[F1:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]], i32 0, i32 1 804// CHECK: store i8* null, i8** %[[F1]], align 8 805// CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1 806// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[V0]] to i8** 807// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]] to i8** 808// CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** %[[V2]], i8** %[[V3]]) 809 810// CHECK: %[[I2:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 0 811// CHECK: store i32 2, i32* %[[I2]], align 8 812// CHECK: %[[F13:.*]] = getelementptr inbounds %[[STRUCT_STRONGSMALL]], %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]], i32 0, i32 1 813// CHECK: store i8* null, i8** %[[F13]], align 8 814// CHECK: store i1 true, i1* %[[CLEANUP_COND4]], align 1 815// CHECK: %[[V4:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[V0]] to i8** 816// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]] to i8** 817// CHECK: call void @__copy_assignment_8_8_t0w4_s8(i8** %[[V4]], i8** %[[V5]]) 818 819// CHECK: call void @func( 820 821// CHECK: %[[V6:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL1]] to i8** 822// CHECK: call void @__destructor_8_s8(i8** %[[V6]]) 823 824// CHECK: %[[V7:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[_COMPOUNDLITERAL]] to i8** 825// CHECK: call void @__destructor_8_s8(i8** %[[V7]]) 826 827void test_compound_literal2(int c, StrongSmall *p) { 828 *p = c ? (StrongSmall){ 1, 0 } : (StrongSmall){ 2, 0 }; 829 func(0); 830} 831 832// CHECK: define void @test_member_access( 833// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], 834// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8** 835// CHECK: call void @__destructor_8_s8(i8** %[[V3]]) 836// CHECK: call void @func( 837 838void test_member_access(void) { 839 g0 = getStrongSmall().f1; 840 func(0); 841} 842 843// CHECK: define void @test_member_access2(%{{.*}}* %[[C:.*]]) 844// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 845// CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8** 846// CHECK: call void @__destructor_8_s8(i8** %[[V8]]) 847// CHECK: call void @func( 848 849void test_member_access2(C *c) { 850 g0 = [c getStrongSmall].f1; 851 func(0); 852} 853 854// CHECK: define void @test_member_access3( 855// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 856// CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8** 857// CHECK: call void @__destructor_8_s8(i8** %[[V8]]) 858// CHECK: call void @func( 859 860void test_member_access3(void) { 861 g0 = [C getStrongSmallClass].f1; 862 func(0); 863} 864 865// CHECK: define void @test_member_access4() 866// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8 867// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8** 868// CHECK: call void @__destructor_8_s8(i8** %[[V5]]) 869// CHECK: call void @func( 870 871void test_member_access4(void) { 872 g0 = ^{ StrongSmall s; return s; }().f1; 873 func(0); 874} 875 876// CHECK: define void @test_volatile_variable_reference( 877// CHECK: %[[AGG_TMP_ENSURED:.*]] = alloca %[[STRUCT_STRONGSMALL]], 878// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8** 879// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %{{.*}} to i8** 880// CHECK: call void @__copy_constructor_8_8_tv0w32_sv8(i8** %[[V1]], i8** %[[V2]]) 881// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8** 882// CHECK: call void @__destructor_8_s8(i8** %[[V3]]) 883// CHECK: call void @func( 884 885void test_volatile_variable_reference(volatile StrongSmall *a) { 886 (void)*a; 887 func(0); 888} 889 890struct ZeroBitfield { 891 int : 0; 892 id strong; 893}; 894 895 896// CHECK: define linkonce_odr hidden void @__default_constructor_8_sv0 897// CHECK: define linkonce_odr hidden void @__copy_assignment_8_8_sv0 898void test_zero_bitfield() { 899 struct ZeroBitfield volatile a, b; 900 a = b; 901} 902 903#endif /* USESTRUCT */ 904