1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks -fobjc-runtime=ios-11.0 -emit-llvm -o - %s | FileCheck -check-prefix=ARM64 -check-prefix=COMMON %s
// RUN: %clang_cc1 -triple thumbv7-apple-ios10 -fobjc-arc -fblocks -fobjc-runtime=ios-10.0 -emit-llvm -o - %s | FileCheck -check-prefix=COMMON %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13 -fobjc-arc -fblocks -fobjc-runtime=macosx-10.13.0 -emit-llvm -o - %s | FileCheck -check-prefix=COMMON %s
// RUN: %clang_cc1 -triple i386-apple-macosx10.13.0 -fobjc-arc -fblocks -fobjc-runtime=macosx-fragile-10.13.0 -emit-llvm -o - %s | FileCheck -check-prefix=COMMON %s
typedef void (^BlockTy)(void);
// COMMON: %[[STRUCT_WEAK:.*]] = type { i32, ptr }
typedef struct {
int f0;
__weak id f1;
} Weak;
Weak getWeak(void);
void calleeWeak(Weak);
// ARM64: define{{.*}} void @test_constructor_destructor_Weak()
// ARM64: %[[T:.*]] = alloca %[[STRUCT_WEAK]], align 8
// ARM64: call void @__default_constructor_8_w8(ptr %[[T]])
// ARM64: call void @__destructor_8_w8(ptr %[[T]])
// ARM64: ret void
// ARM64: define linkonce_odr hidden void @__default_constructor_8_w8(ptr noundef %[[DST:.*]])
// ARM64: %[[DST_ADDR:.*]] = alloca ptr, align 8
// ARM64: store ptr %[[DST]], ptr %[[DST_ADDR]], align 8
// ARM64: %[[V0:.*]] = load ptr, ptr %[[DST_ADDR]], align 8
// ARM64: %[[V2:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 8
// ARM64: call void @llvm.memset.p0.i64(ptr align 8 %[[V2]], i8 0, i64 8, i1 false)
// ARM64: define linkonce_odr hidden void @__destructor_8_w8(ptr noundef %[[DST:.*]])
// ARM64: %[[DST_ADDR:.*]] = alloca ptr, align 8
// ARM64: store ptr %[[DST]], ptr %[[DST_ADDR]], align 8
// ARM64: %[[V0:.*]] = load ptr, ptr %[[DST_ADDR]], align 8
// ARM64: %[[V2:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 8
// ARM64: call void @llvm.objc.destroyWeak(ptr %[[V2]])
@interface C
- (void)m:(Weak)a;
@end
void test_constructor_destructor_Weak(void) {
Weak t;
}
// ARM64: define{{.*}} void @test_copy_constructor_Weak(ptr noundef %{{.*}})
// ARM64: call void @__copy_constructor_8_8_t0w4_w8(ptr %{{.*}}, ptr %{{.*}})
// ARM64: call void @__destructor_8_w8(ptr %{{.*}})
// ARM64: define linkonce_odr hidden void @__copy_constructor_8_8_t0w4_w8(ptr noundef %[[DST:.*]], ptr noundef %[[SRC:.*]])
// ARM64: %[[DST_ADDR:.*]] = alloca ptr, align 8
// ARM64: %[[SRC_ADDR:.*]] = alloca ptr, align 8
// ARM64: store ptr %[[DST]], ptr %[[DST_ADDR]], align 8
// ARM64: store ptr %[[SRC]], ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V0:.*]] = load ptr, ptr %[[DST_ADDR]], align 8
// ARM64: %[[V1:.*]] = load ptr, ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V4:.*]] = load i32, ptr %[[V1]], align 8
// ARM64: store i32 %[[V4]], ptr %[[V0]], align 8
// ARM64: %[[V6:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 8
// ARM64: %[[V9:.*]] = getelementptr inbounds i8, ptr %[[V1]], i64 8
// ARM64: call void @llvm.objc.copyWeak(ptr %[[V6]], ptr %[[V9]])
void test_copy_constructor_Weak(Weak *s) {
Weak t = *s;
}
// ARM64: define{{.*}} void @test_copy_assignment_Weak(ptr noundef %{{.*}}, ptr noundef %{{.*}})
// ARM64: call void @__copy_assignment_8_8_t0w4_w8(ptr %{{.*}}, ptr %{{.*}})
// ARM64: define linkonce_odr hidden void @__copy_assignment_8_8_t0w4_w8(ptr noundef %[[DST:.*]], ptr noundef %[[SRC:.*]])
// ARM64: %[[DST_ADDR:.*]] = alloca ptr, align 8
// ARM64: %[[SRC_ADDR:.*]] = alloca ptr, align 8
// ARM64: store ptr %[[DST]], ptr %[[DST_ADDR]], align 8
// ARM64: store ptr %[[SRC]], ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V0:.*]] = load ptr, ptr %[[DST_ADDR]], align 8
// ARM64: %[[V1:.*]] = load ptr, ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V4:.*]] = load i32, ptr %[[V1]], align 8
// ARM64: store i32 %[[V4]], ptr %[[V0]], align 8
// ARM64: %[[V6:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 8
// ARM64: %[[V9:.*]] = getelementptr inbounds i8, ptr %[[V1]], i64 8
// ARM64: %[[V11:.*]] = call ptr @llvm.objc.loadWeakRetained(ptr %[[V9]])
// ARM64: %[[V12:.*]] = call ptr @llvm.objc.storeWeak(ptr %[[V6]], ptr %[[V11]])
// ARM64: call void @llvm.objc.release(ptr %[[V11]])
void test_copy_assignment_Weak(Weak *d, Weak *s) {
*d = *s;
}
// ARM64: define internal void @__Block_byref_object_copy_(ptr noundef %0, ptr noundef %1)
// ARM64: call void @__move_constructor_8_8_t0w4_w8(ptr %{{.*}}, ptr %{{.*}})
// ARM64: define linkonce_odr hidden void @__move_constructor_8_8_t0w4_w8(ptr noundef %[[DST:.*]], ptr noundef %[[SRC:.*]])
// ARM64: %[[DST_ADDR:.*]] = alloca ptr, align 8
// ARM64: %[[SRC_ADDR:.*]] = alloca ptr, align 8
// ARM64: store ptr %[[DST]], ptr %[[DST_ADDR]], align 8
// ARM64: store ptr %[[SRC]], ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V0:.*]] = load ptr, ptr %[[DST_ADDR]], align 8
// ARM64: %[[V1:.*]] = load ptr, ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V4:.*]] = load i32, ptr %[[V1]], align 8
// ARM64: store i32 %[[V4]], ptr %[[V0]], align 8
// ARM64: %[[V6:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 8
// ARM64: %[[V9:.*]] = getelementptr inbounds i8, ptr %[[V1]], i64 8
// ARM64: call void @llvm.objc.moveWeak(ptr %[[V6]], ptr %[[V9]])
void test_move_constructor_Weak(void) {
__block Weak t;
BlockTy b = ^{ (void)t; };
}
// ARM64: define{{.*}} void @test_move_assignment_Weak(ptr noundef %{{.*}})
// ARM64: call void @__move_assignment_8_8_t0w4_w8(ptr %{{.*}}, ptr %{{.*}})
// ARM64: define linkonce_odr hidden void @__move_assignment_8_8_t0w4_w8(ptr noundef %[[DST:.*]], ptr noundef %[[SRC:.*]])
// ARM64: %[[DST_ADDR:.*]] = alloca ptr, align 8
// ARM64: %[[SRC_ADDR:.*]] = alloca ptr, align 8
// ARM64: store ptr %[[DST]], ptr %[[DST_ADDR]], align 8
// ARM64: store ptr %[[SRC]], ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V0:.*]] = load ptr, ptr %[[DST_ADDR]], align 8
// ARM64: %[[V1:.*]] = load ptr, ptr %[[SRC_ADDR]], align 8
// ARM64: %[[V4:.*]] = load i32, ptr %[[V1]], align 8
// ARM64: store i32 %[[V4]], ptr %[[V0]], align 8
// ARM64: %[[V6:.*]] = getelementptr inbounds i8, ptr %[[V0]], i64 8
// ARM64: %[[V9:.*]] = getelementptr inbounds i8, ptr %[[V1]], i64 8
// ARM64: %[[V11:.*]] = call ptr @llvm.objc.loadWeakRetained(ptr %[[V9]])
// ARM64: %[[V12:.*]] = call ptr @llvm.objc.storeWeak(ptr %[[V6]], ptr %[[V11]])
// ARM64: call void @llvm.objc.destroyWeak(ptr %[[V9]])
// ARM64: call void @llvm.objc.release(ptr %[[V11]])
void test_move_assignment_Weak(Weak *p) {
*p = getWeak();
}
// COMMON: define{{.*}} void @test_parameter_Weak(ptr noundef %[[A:.*]])
// COMMON: call void @__destructor_{{.*}}(ptr %[[A]])
void test_parameter_Weak(Weak a) {
}
// COMMON: define{{.*}} void @test_argument_Weak(ptr noundef %[[A:.*]])
// COMMON: %[[A_ADDR:.*]] = alloca ptr
// COMMON: %[[AGG_TMP:.*]] = alloca %[[STRUCT_WEAK]]
// COMMON: store ptr %[[A]], ptr %[[A_ADDR]]
// COMMON: %[[V0:.*]] = load ptr, ptr %[[A_ADDR]]
// COMMON: call void @__copy_constructor_{{.*}}(ptr %[[AGG_TMP]], ptr %[[V0]])
// COMMON: call void @calleeWeak(ptr noundef %[[AGG_TMP]])
// COMMON-NEXT: ret
void test_argument_Weak(Weak *a) {
calleeWeak(*a);
}
// COMMON: define{{.*}} void @test_return_Weak(ptr dead_on_unwind noalias writable sret(%[[STRUCT_WEAK]]) align {{.*}} %[[AGG_RESULT:.*]], ptr noundef %[[A:.*]])
// COMMON: %[[A_ADDR:.*]] = alloca ptr
// COMMON: store ptr %[[A]], ptr %[[A_ADDR]]
// COMMON: %[[V0:.*]] = load ptr, ptr %[[A_ADDR]]
// COMMON: call void @__copy_constructor_{{.*}}(ptr %[[AGG_RESULT]], ptr %[[V0]])
// COMMON: ret void
Weak test_return_Weak(Weak *a) {
return *a;
}
// COMMON-LABEL: define{{.*}} void @test_null_receiver(
// COMMON: %[[AGG_TMP:.*]] = alloca %[[STRUCT_WEAK]]
// COMMON: br i1
// COMMON: call void @objc_msgSend({{.*}}, ptr noundef %[[AGG_TMP]])
// COMMON: br
// COMMON: call void @__destructor_{{.*}}(ptr %[[AGG_TMP]])
// COMMON: br
void test_null_receiver(C *c) {
[c m:getWeak()];
}
|