objc-weak.mm
3.48 KB
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
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-weak -fobjc-runtime-has-weak -std=c++11 -o - %s | FileCheck %s
struct A { __weak id x; };
id test0() {
A a;
A b = a;
A c(static_cast<A&&>(b));
a = c;
c = static_cast<A&&>(a);
return c.x;
}
// Copy Assignment Operator
// CHECK-LABEL: define linkonce_odr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %struct.A* @_ZN1AaSERKS_(
// CHECK: [[THISADDR:%this.*]] = alloca [[A:.*]]*
// CHECK: [[OBJECTADDR:%.*]] = alloca [[A:.*]]*
// CHECK: [[THIS:%this.*]] = load [[A]]*, [[A]]** [[THISADDR]]
// CHECK: [[OBJECT:%.*]] = load [[A]]*, [[A]]** [[OBJECTADDR]]
// CHECK: [[T0:%.*]] = getelementptr inbounds [[A]], [[A]]* [[OBJECT]], i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.loadWeak(i8** [[T0]])
// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]], [[A]]* [[THIS]], i32 0, i32 0
// CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
// Move Assignment Operator
// CHECK-LABEL: define linkonce_odr nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %struct.A* @_ZN1AaSEOS_(
// CHECK: [[THISADDR:%this.*]] = alloca [[A:.*]]*
// CHECK: [[OBJECTADDR:%.*]] = alloca [[A:.*]]*
// CHECK: [[THIS:%this.*]] = load [[A]]*, [[A]]** [[THISADDR]]
// CHECK: [[OBJECT:%.*]] = load [[A]]*, [[A]]** [[OBJECTADDR]]
// CHECK: [[T0:%.*]] = getelementptr inbounds [[A]], [[A]]* [[OBJECT]], i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.loadWeak(i8** [[T0]])
// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A]], [[A]]* [[THIS]], i32 0, i32 0
// CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
// Default Constructor
// CHECK-LABEL: define linkonce_odr void @_ZN1AC2Ev(
// CHECK: [[THISADDR:%this.*]] = alloca [[A:.*]]*
// CHECK: [[THIS:%this.*]] = load [[A]]*, [[A]]** [[THISADDR]]
// CHECK: [[T0:%.*]] = getelementptr inbounds [[A]], [[A]]* [[THIS]], i32 0, i32 0
// CHECK-NEXT: store i8* null, i8** [[T0]]
// Copy Constructor
// CHECK-LABEL: define linkonce_odr void @_ZN1AC2ERKS_(
// CHECK: [[THISADDR:%this.*]] = alloca [[A:.*]]*
// CHECK: [[OBJECTADDR:%.*]] = alloca [[A:.*]]*
// CHECK: [[THIS:%this.*]] = load [[A]]*, [[A]]** [[THISADDR]]
// CHECK: [[T0:%.*]] = getelementptr inbounds [[A]], [[A]]* [[THIS]], i32 0, i32 0
// CHECK-NEXT: [[OBJECT:%.*]] = load [[A]]*, [[A]]** [[OBJECTADDR]]
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[A]], [[A]]* [[OBJECT]], i32 0, i32 0
// CHECK-NEXT: call void @llvm.objc.copyWeak(i8** [[T0]], i8** [[T1]])
// Move Constructor
// CHECK-LABEL: define linkonce_odr void @_ZN1AC2EOS_(
// CHECK: [[THISADDR:%this.*]] = alloca [[A:.*]]*
// CHECK: [[OBJECTADDR:%.*]] = alloca [[A:.*]]*
// CHECK: [[THIS:%this.*]] = load [[A]]*, [[A]]** [[THISADDR]]
// CHECK: [[T0:%.*]] = getelementptr inbounds [[A]], [[A]]* [[THIS]], i32 0, i32 0
// CHECK-NEXT: [[OBJECT:%.*]] = load [[A]]*, [[A]]** [[OBJECTADDR]]
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[A]], [[A]]* [[OBJECT]], i32 0, i32 0
// CHECK-NEXT: call void @llvm.objc.moveWeak(i8** [[T0]], i8** [[T1]])
// Destructor
// CHECK-LABEL: define linkonce_odr void @_ZN1AD2Ev(
// CHECK: [[THISADDR:%this.*]] = alloca [[A:.*]]*
// CHECK: [[THIS:%this.*]] = load [[A]]*, [[A]]** [[THISADDR]]
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[A]], [[A]]* [[THIS]], i32 0, i32 0
// CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[T0]])