1 // RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -emit-llvm -o - %s | FileCheck %s
10 @property(nonatomic) S0 nonatomic;
26 // CHECK: %[[STRUCT_S0:.*]] = type { ptr }
28 // Check that parameters of user-defined setters are destructed.
30 // CHECK-LABEL: define internal void @"\01-[C setP1:]"(
31 // CHECK: %[[S0:.*]] = alloca %[[STRUCT_S0]], align 8
32 // CHECK: call void @__copy_assignment_8_8_s0(ptr %{{.*}}, ptr %[[S0]])
33 // CHECK: call void @__destructor_8_s0(ptr %[[S0]])
35 // CHECK: define internal i64 @"\01-[C nonatomic]"(ptr noundef %[[SELF:.*]], {{.*}})
36 // CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_S0]], align 8
37 // CHECK: %[[SELF_ADDR:.*]] = alloca ptr, align 8
38 // CHECK: store ptr %[[SELF]], ptr %[[SELF_ADDR]], align 8
39 // CHECK: %[[V0:.*]] = load ptr, ptr %[[SELF_ADDR]], align 8
40 // CHECK: %[[IVAR:.*]] = load i32, ptr @"OBJC_IVAR_$_C._nonatomic", align 8
41 // CHECK: %[[IVAR_CONV:.*]] = sext i32 %[[IVAR]] to i64
42 // CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[IVAR_CONV]]
43 // CHECK: call void @__copy_constructor_8_8_s0(ptr %[[RETVAL]], ptr %[[ADD_PTR]])
47 // CHECK: define internal void @"\01-[C setNonatomic:]"(ptr noundef %[[SELF:.*]], {{.*}}, i64 %[[NONATOMIC_COERCE:.*]])
48 // CHECK: %[[NONATOMIC:.*]] = alloca %[[STRUCT_S0]], align 8
49 // CHECK: %[[SELF_ADDR:.*]] = alloca ptr, align 8
50 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds nuw %[[STRUCT_S0]], ptr %[[NONATOMIC]], i32 0, i32 0
51 // CHECK: %[[COERCE_VAL_IP:.*]] = inttoptr i64 %[[NONATOMIC_COERCE]] to ptr
52 // CHECK: store ptr %[[COERCE_VAL_IP]], ptr %[[COERCE_DIVE]], align 8
53 // CHECK: store ptr %[[SELF]], ptr %[[SELF_ADDR]], align 8
54 // CHECK: %[[V0:.*]] = load ptr, ptr %[[SELF_ADDR]], align 8
55 // CHECK: %[[IVAR:.*]] = load i32, ptr @"OBJC_IVAR_$_C._nonatomic", align 8
56 // CHECK: %[[IVAR_CONV:.*]] = sext i32 %[[IVAR]] to i64
57 // CHECK: %[[ADD_PTR:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 %[[IVAR_CONV]]
58 // CHECK: call void @__move_assignment_8_8_s0(ptr %[[ADD_PTR]], ptr %[[NONATOMIC]])
62 // CHECK-LABEL: define internal i64 @"\01-[C atomic0]"(
63 // CHECK: call void @objc_copyCppObjectAtomic({{.*}}, {{.*}}, ptr noundef @__copy_constructor_8_8_s0)
67 // CHECK-LABEL: define internal void @"\01-[C setAtomic0:]"(
68 // CHECK: call void @objc_copyCppObjectAtomic({{.*}}, {{.*}}, ptr noundef @__move_assignment_8_8_s0)
72 // CHECK: define void @test0(ptr noundef %[[C:.*]], ptr noundef %[[A:.*]])
73 // CHECK: %[[C_ADDR:.*]] = alloca ptr, align 8
74 // CHECK: %[[A_ADDR:.*]] = alloca ptr, align 8
75 // CHECK: %[[AGG_TMP_ENSURED:.*]] = alloca %[[STRUCT_S0]], align 8
76 // CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_S0]], align 8
77 // CHECK: store ptr null, ptr %[[C_ADDR]], align 8
78 // CHECK: call void @llvm.objc.storeStrong(ptr %[[C_ADDR]], ptr %[[C]])
79 // CHECK: store ptr %[[A]], ptr %[[A_ADDR]], align 8
80 // CHECK: %[[V0:.*]] = load ptr, ptr %[[A_ADDR]], align 8
81 // CHECK: call void @__copy_constructor_8_8_s0(ptr %[[AGG_TMP_ENSURED]], ptr %[[V0]])
82 // CHECK: %[[V1:.*]] = load ptr, ptr %[[C_ADDR]], align 8
83 // CHECK: call void @__copy_constructor_8_8_s0(ptr %[[AGG_TMP]], ptr %[[AGG_TMP_ENSURED]])
84 // CHECK: %[[V2:.*]] = icmp eq ptr %[[V1]], null
85 // CHECK: br i1 %[[V2]], label %[[MSGSEND_NULL:.*]], label %[[MSGSEND_CALL:.*]]
87 // CHECK: [[MSGSEND_CALL]]:
88 // CHECK: %[[V3:.*]] = load ptr, ptr @OBJC_SELECTOR_REFERENCES_, align 8
89 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds nuw %[[STRUCT_S0]], ptr %[[AGG_TMP]], i32 0, i32 0
90 // CHECK: %[[V4:.*]] = load ptr, ptr %[[COERCE_DIVE]], align 8
91 // CHECK: %[[COERCE_VAL_PI:.*]] = ptrtoint ptr %[[V4]] to i64
92 // CHECK: call void @objc_msgSend(ptr noundef %[[V1]], ptr noundef %[[V3]], i64 %[[COERCE_VAL_PI]])
93 // CHECK: br label %[[MSGSEND_CONT:.*]]
95 // CHECK: [[MSGSEND_NULL]]:
96 // CHECK: call void @__destructor_8_s0(ptr %[[AGG_TMP]])
97 // CHECK: br label %[[MSGSEND_CONT]]
99 // CHECK: [[MSGSEND_CONT]]:
100 // CHECK: call void @__destructor_8_s0(ptr %[[AGG_TMP_ENSURED]]
101 // CHECK: call void @llvm.objc.storeStrong(ptr %[[C_ADDR]], ptr null)
104 void test0(C *c, S0 *a) {