2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -O2 -disable-llvm-passes -o - %s | FileCheck %s
|
2011-06-16 07:02:42 +08:00
|
|
|
|
2011-07-27 09:07:15 +08:00
|
|
|
struct NSFastEnumerationState;
|
|
|
|
@interface NSArray
|
|
|
|
- (unsigned long) countByEnumeratingWithState: (struct NSFastEnumerationState*) state
|
|
|
|
objects: (id*) buffer
|
|
|
|
count: (unsigned long) bufferSize;
|
|
|
|
@end;
|
|
|
|
NSArray *nsarray() { return 0; }
|
|
|
|
// CHECK: define [[NSARRAY:%.*]]* @_Z7nsarrayv()
|
|
|
|
|
|
|
|
void use(id);
|
|
|
|
|
2011-06-16 07:02:42 +08:00
|
|
|
// rdar://problem/9315552
|
|
|
|
// The analogous ObjC testcase test46 in arr.m.
|
|
|
|
void test0(__weak id *wp, __weak volatile id *wvp) {
|
|
|
|
extern id test0_helper(void);
|
|
|
|
|
|
|
|
// TODO: this is sub-optimal, we should retain at the actual call site.
|
|
|
|
// TODO: in the non-volatile case, we do not need to be reloading.
|
|
|
|
|
|
|
|
// CHECK: [[T0:%.*]] = call i8* @_Z12test0_helperv()
|
2019-03-22 03:59:49 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** {{%.*}}, align 8
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
|
|
|
|
// CHECK-NEXT: [[T4:%.*]] = call i8* @llvm.objc.retain(i8* [[T3]])
|
2011-07-07 14:58:02 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T4]], i8**
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
|
2011-06-16 07:02:42 +08:00
|
|
|
id x = *wp = test0_helper();
|
|
|
|
|
|
|
|
// CHECK: [[T0:%.*]] = call i8* @_Z12test0_helperv()
|
2019-03-22 03:59:49 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T0]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = load i8**, i8*** {{%.*}}, align 8
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = call i8* @llvm.objc.storeWeak(i8** [[T2]], i8* [[T1]])
|
|
|
|
// CHECK-NEXT: [[T4:%.*]] = call i8* @llvm.objc.loadWeakRetained(i8** [[T2]])
|
2011-07-07 14:58:02 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T4]], i8**
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]])
|
2011-06-16 07:02:42 +08:00
|
|
|
id y = *wvp = test0_helper();
|
|
|
|
}
|
|
|
|
|
|
|
|
// rdar://problem/9320648
|
|
|
|
struct Test1_helper { Test1_helper(); };
|
|
|
|
@interface Test1 @end
|
|
|
|
@implementation Test1 { Test1_helper x; } @end
|
|
|
|
// CHECK: define internal i8* @"\01-[Test1 .cxx_construct]"(
|
|
|
|
// CHECK: call void @_ZN12Test1_helperC1Ev(
|
|
|
|
// CHECK-NEXT: load
|
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: ret i8*
|
|
|
|
|
|
|
|
void test34(int cond) {
|
|
|
|
__strong id strong;
|
|
|
|
__weak id weak;
|
|
|
|
extern void test34_sink(id *);
|
|
|
|
test34_sink(cond ? &strong : 0);
|
|
|
|
test34_sink(cond ? &weak : 0);
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z6test34i(
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: [[COND:%.*]] = alloca i32
|
|
|
|
// CHECK-NEXT: [[STRONG:%.*]] = alloca i8*
|
|
|
|
// CHECK-NEXT: [[WEAK:%.*]] = alloca i8*
|
|
|
|
// CHECK-NEXT: [[TEMP1:%.*]] = alloca i8*
|
|
|
|
// CHECK-NEXT: [[TEMP2:%.*]] = alloca i8*
|
2012-11-28 07:02:53 +08:00
|
|
|
// CHECK-NEXT: [[CONDCLEANUPSAVE:%.*]] = alloca i8*
|
|
|
|
// CHECK-NEXT: [[CONDCLEANUP:%.*]] = alloca i1
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: store i32
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[STRONGP:%.*]] = bitcast i8** [[STRONG]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[STRONGP]])
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: store i8* null, i8** [[STRONG]]
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[WEAKP:%.*]] = bitcast i8** [[WEAK]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[WEAKP]])
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call i8* @llvm.objc.initWeak(i8** [[WEAK]], i8* null)
|
2011-06-16 07:02:42 +08:00
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load i32, i32* [[COND]]
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
|
|
|
|
// CHECK: [[ARG:%.*]] = phi i8**
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i8** null, i8** [[TEMP1]]
|
|
|
|
// CHECK-NEXT: br i1 [[T0]],
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[T0:%.*]] = load i8*, i8** [[ARG]]
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T0]], i8** [[TEMP1]]
|
|
|
|
// CHECK-NEXT: br label
|
2013-03-23 10:35:54 +08:00
|
|
|
// CHECK: [[W0:%.*]] = phi i8* [ [[T0]], {{%.*}} ], [ undef, {{%.*}} ]
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call void @_Z11test34_sinkPU15__autoreleasingP11objc_object(i8** [[T1]])
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
|
|
|
|
// CHECK-NEXT: br i1 [[T0]],
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[T0:%.*]] = load i8*, i8** [[TEMP1]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retain(i8* [[T0]])
|
2018-12-21 02:05:41 +08:00
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.use(i8* [[W0]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = load i8*, i8** [[ARG]]
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T1]], i8** [[ARG]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T2]])
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: br label
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[T0:%.*]] = load i32, i32* [[COND]]
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = icmp ne i32 [[T0]], 0
|
|
|
|
// CHECK: [[ARG:%.*]] = phi i8**
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = select i1 [[T0]], i8** null, i8** [[TEMP2]]
|
2012-11-28 07:02:53 +08:00
|
|
|
// CHECK-NEXT: store i1 false, i1* [[CONDCLEANUP]]
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: br i1 [[T0]],
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call i8* @llvm.objc.loadWeakRetained(i8** [[ARG]])
|
2012-11-28 07:02:53 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T0]], i8** [[CONDCLEANUPSAVE]]
|
|
|
|
// CHECK-NEXT: store i1 true, i1* [[CONDCLEANUP]]
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T0]], i8** [[TEMP2]]
|
|
|
|
// CHECK-NEXT: br label
|
|
|
|
// CHECK: call void @_Z11test34_sinkPU15__autoreleasingP11objc_object(i8** [[T1]])
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = icmp eq i8** [[ARG]], null
|
|
|
|
// CHECK-NEXT: br i1 [[T0]],
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[T0:%.*]] = load i8*, i8** [[TEMP2]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call i8* @llvm.objc.storeWeak(i8** [[ARG]], i8* [[T0]])
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: br label
|
|
|
|
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.destroyWeak(i8** [[WEAK]])
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Test35_Helper {
|
|
|
|
static id makeObject1() __attribute__((ns_returns_retained));
|
|
|
|
id makeObject2() __attribute__((ns_returns_retained));
|
|
|
|
static id makeObject3();
|
|
|
|
id makeObject4();
|
|
|
|
};
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z6test3513Test35_HelperPS_
|
2011-06-16 07:02:42 +08:00
|
|
|
void test35(Test35_Helper x0, Test35_Helper *x0p) {
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* @_ZN13Test35_Helper11makeObject1Ev
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NOT: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj1 = Test35_Helper::makeObject1();
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* @_ZN13Test35_Helper11makeObject2Ev
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NOT: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj2 = x0.makeObject2();
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* @_ZN13Test35_Helper11makeObject2Ev
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NOT: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj3 = x0p->makeObject2();
|
|
|
|
id (Test35_Helper::*pmf)() __attribute__((ns_returns_retained))
|
|
|
|
= &Test35_Helper::makeObject2;
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* %
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NOT: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj4 = (x0.*pmf)();
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* %
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NOT: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj5 = (x0p->*pmf)();
|
|
|
|
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @_Z7test35b13Test35_HelperPS_
|
2011-06-16 07:02:42 +08:00
|
|
|
void test35b(Test35_Helper x0, Test35_Helper *x0p) {
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* @_ZN13Test35_Helper11makeObject3Ev
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj1 = Test35_Helper::makeObject3();
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* @_ZN13Test35_Helper11makeObject4Ev
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj2 = x0.makeObject4();
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* @_ZN13Test35_Helper11makeObject4Ev
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj3 = x0p->makeObject4();
|
|
|
|
id (Test35_Helper::*pmf)() = &Test35_Helper::makeObject4;
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* %
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj4 = (x0.*pmf)();
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK: call i8* %
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain
|
2011-06-16 07:02:42 +08:00
|
|
|
id obj5 = (x0p->*pmf)();
|
|
|
|
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.end
|
2011-06-16 07:02:42 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
2011-06-17 07:24:51 +08:00
|
|
|
|
|
|
|
// rdar://problem/9603128
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i8* @_Z6test36P11objc_object(
|
2011-06-17 07:24:51 +08:00
|
|
|
id test36(id z) {
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: llvm.objc.retain
|
|
|
|
// CHECK: llvm.objc.retain
|
|
|
|
// CHECK: llvm.objc.release
|
|
|
|
// CHECK: llvm.objc.autoreleaseReturnValue
|
2011-06-17 07:24:51 +08:00
|
|
|
return z;
|
|
|
|
}
|
2011-07-27 09:07:15 +08:00
|
|
|
|
|
|
|
// Template instantiation side of rdar://problem/9817306
|
|
|
|
@interface Test37
|
2011-12-10 09:22:52 +08:00
|
|
|
+ alloc;
|
|
|
|
- init;
|
2011-07-27 09:07:15 +08:00
|
|
|
- (NSArray *) array;
|
|
|
|
@end
|
|
|
|
template <class T> void test37(T *a) {
|
|
|
|
for (id x in a.array) {
|
|
|
|
use(x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extern template void test37<Test37>(Test37 *a);
|
|
|
|
template void test37<Test37>(Test37 *a);
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z6test37I6Test37EvPT_(
|
2011-12-10 08:28:18 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[NSARRAY]]* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to [[NSARRAY]]* (i8*, i8*)*)(
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[NSARRAY]]* [[T0]] to i8*
|
2019-03-22 03:59:49 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = notail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* [[T1]])
|
2011-12-10 08:28:18 +08:00
|
|
|
// CHECK-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[NSARRAY]]*
|
2011-07-27 09:07:15 +08:00
|
|
|
|
|
|
|
// Make sure it's not immediately released before starting the iteration.
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
2011-12-10 08:28:18 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
|
|
|
|
// CHECK-NEXT: @objc_msgSend
|
2011-07-27 09:07:15 +08:00
|
|
|
|
|
|
|
// This bitcast is for the mutation check.
|
2011-12-10 08:28:18 +08:00
|
|
|
// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
|
|
|
|
// CHECK-NEXT: @objc_enumerationMutation
|
2011-07-27 09:07:15 +08:00
|
|
|
|
|
|
|
// This bitcast is for the 'next' message send.
|
2011-12-10 08:28:18 +08:00
|
|
|
// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
|
|
|
|
// CHECK-NEXT: @objc_msgSend
|
2011-07-27 09:07:15 +08:00
|
|
|
|
|
|
|
// This bitcast is for the final release.
|
2011-12-10 08:28:18 +08:00
|
|
|
// CHECK: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]])
|
2011-12-10 08:23:21 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void send_release() {
|
|
|
|
[Test37 array];
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z12send_releaseIiEvv(
|
2011-12-10 08:23:21 +08:00
|
|
|
// CHECK: call %0* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
|
|
|
|
// CHECK-NEXT: bitcast
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call i8* @llvm.objc.retainAutoreleasedReturnValue
|
2011-12-10 08:23:21 +08:00
|
|
|
// CHECK-NEXT: bitcast
|
|
|
|
// CHECK-NEXT: bitcast
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release
|
2011-12-10 08:23:21 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
template void send_release<int>();
|
2011-12-10 09:22:52 +08:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
Test37 *instantiate_init() {
|
|
|
|
Test37 *result = [[Test37 alloc] init];
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr %2* @_Z16instantiate_initIiEP6Test37v
|
2011-12-10 09:22:52 +08:00
|
|
|
// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
|
|
|
|
// CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call i8* @llvm.objc.retain
|
|
|
|
// CHECK: call void @llvm.objc.release
|
|
|
|
// CHECK: call i8* @llvm.objc.autoreleaseReturnValue
|
2011-12-10 09:22:52 +08:00
|
|
|
template Test37* instantiate_init<int>();
|
|
|
|
|
2012-04-07 02:20:53 +08:00
|
|
|
// Just make sure that the AST invariants hold properly here,
|
|
|
|
// i.e. that we don't crash.
|
|
|
|
// The block should get bound in the full-expression outside
|
|
|
|
// the statement-expression.
|
|
|
|
template <class T> class Test38 {
|
|
|
|
void test(T x) {
|
|
|
|
^{ (void) x; }, ({ x; });
|
|
|
|
}
|
|
|
|
};
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_ZN6Test38IiE4testEi(
|
2012-04-07 02:20:53 +08:00
|
|
|
template class Test38<int>;
|
2012-07-31 08:33:55 +08:00
|
|
|
|
|
|
|
// rdar://problem/11964832
|
|
|
|
class Test39_base1 {
|
|
|
|
virtual void foo();
|
|
|
|
};
|
|
|
|
class Test39_base2 {
|
|
|
|
virtual id bar();
|
|
|
|
};
|
|
|
|
class Test39 : Test39_base1, Test39_base2 { // base2 is at non-zero offset
|
|
|
|
virtual id bar();
|
|
|
|
};
|
|
|
|
id Test39::bar() { return 0; }
|
|
|
|
// Note lack of autorelease.
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i8* @_ZThn8_N6Test393barEv(
|
2012-07-31 08:33:55 +08:00
|
|
|
// CHECK: call i8* @_ZN6Test393barEv(
|
|
|
|
// CHECK-NEXT: ret i8*
|
2013-04-11 10:14:26 +08:00
|
|
|
|
|
|
|
// rdar://13617051
|
|
|
|
// Just a basic sanity-check that IR-gen still works after instantiating
|
|
|
|
// a non-dependent message send that requires writeback.
|
|
|
|
@interface Test40
|
|
|
|
+ (void) foo:(id *)errorPtr;
|
|
|
|
@end
|
|
|
|
template <class T> void test40_helper() {
|
|
|
|
id x;
|
|
|
|
[Test40 foo: &x];
|
|
|
|
};
|
|
|
|
template void test40_helper<int>();
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z13test40_helperIiEvv()
|
2013-04-11 10:14:26 +08:00
|
|
|
// CHECK: [[X:%.*]] = alloca i8*
|
|
|
|
// CHECK-NEXT: [[TEMP:%.*]] = alloca i8*
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[XP:%.*]] = bitcast i8** [[X]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XP]])
|
2013-04-11 10:14:26 +08:00
|
|
|
// CHECK-NEXT: store i8* null, i8** [[X]]
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[T0:%.*]] = load i8*, i8** [[X]]
|
2013-04-11 10:14:26 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T0]], i8** [[TEMP]]
|
|
|
|
// CHECK: @objc_msgSend
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[TEMP]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call i8* @llvm.objc.retain(i8* [[T0]])
|
2013-04-11 10:14:26 +08:00
|
|
|
|
2015-10-22 02:06:31 +08:00
|
|
|
// Check that moves out of __weak variables are compiled to use objc_moveWeak.
|
|
|
|
void test41(__weak id &&x) {
|
|
|
|
__weak id y = static_cast<__weak id &&>(x);
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: define void @_Z6test41OU6__weakP11objc_object
|
|
|
|
// CHECK: [[X:%.*]] = alloca i8**
|
|
|
|
// CHECK: [[Y:%.*]] = alloca i8*
|
|
|
|
// CHECK: [[T0:%.*]] = load i8**, i8*** [[X]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.moveWeak(i8** [[Y]], i8** [[T0]])
|
|
|
|
// CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[Y]])
|