2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -O2 -disable-llvm-passes -o - %s | FileCheck %s
|
2013-03-13 11:10:54 +08:00
|
|
|
|
|
|
|
#define PRECISE_LIFETIME __attribute__((objc_precise_lifetime))
|
|
|
|
|
|
|
|
id test0_helper(void) __attribute__((ns_returns_retained));
|
|
|
|
void test0() {
|
|
|
|
PRECISE_LIFETIME id x = test0_helper();
|
|
|
|
x = 0;
|
|
|
|
// CHECK: [[X:%.*]] = alloca i8*
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[XPTR1:%.*]] = bitcast i8** [[X]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[XPTR1]])
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[CALL:%.*]] = call i8* @test0_helper()
|
|
|
|
// CHECK-NEXT: store i8* [[CALL]], i8** [[X]]
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: store i8* null, i8** [[X]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW:#[0-9]+]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NOT: clang.imprecise_release
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[X]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW:#[0-9]+]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NOT: clang.imprecise_release
|
|
|
|
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[XPTR2:%.*]] = bitcast i8** [[X]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[XPTR2]])
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
2015-09-10 07:37:17 +08:00
|
|
|
// rdar://problem/9821110 - precise lifetime should suppress extension
|
|
|
|
// rdar://problem/22172983 - should work for calls via property syntax, too
|
2013-03-13 11:10:54 +08:00
|
|
|
@interface Test1
|
|
|
|
- (char*) interior __attribute__((objc_returns_inner_pointer));
|
2013-09-20 00:37:20 +08:00
|
|
|
// Should we allow this on properties? Yes! see // rdar://14990439
|
|
|
|
@property (nonatomic, readonly) char * PropertyReturnsInnerPointer __attribute__((objc_returns_inner_pointer));
|
2013-03-13 11:10:54 +08:00
|
|
|
@end
|
|
|
|
extern Test1 *test1_helper(void);
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1a_message()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1a_message(void) {
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[C:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[CPTR1:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[CPTR1]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutorelease(i8* [[T1]])
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]*
|
|
|
|
// CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[T4:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T6:%.*]] = call i8* bitcast
|
|
|
|
// CHECK-NEXT: store i8* [[T6]], i8**
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[CPTR2:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[CPTR2]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
Test1 *ptr = test1_helper();
|
|
|
|
char *c = [(ptr) interior];
|
|
|
|
}
|
|
|
|
|
2015-09-10 07:37:17 +08:00
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1a_property()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1a_property(void) {
|
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[C:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[CPTR1:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[CPTR1]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutorelease(i8* [[T1]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]*
|
|
|
|
// CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[T4:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T6:%.*]] = call i8* bitcast
|
|
|
|
// CHECK-NEXT: store i8* [[T6]], i8**
|
|
|
|
// CHECK-NEXT: [[CPTR2:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[CPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
Test1 *ptr = test1_helper();
|
|
|
|
char *c = ptr.interior;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1b_message()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1b_message(void) {
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[C:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[CPTR1:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[CPTR1]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = call i8* bitcast
|
|
|
|
// CHECK-NEXT: store i8* [[T3]], i8**
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[CPTR2:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[CPTR2]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NOT: clang.imprecise_release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: ret void
|
2015-09-10 07:37:17 +08:00
|
|
|
PRECISE_LIFETIME Test1 *ptr = test1_helper();
|
2013-03-13 11:10:54 +08:00
|
|
|
char *c = [ptr interior];
|
|
|
|
}
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1b_property()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1b_property(void) {
|
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[C:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[CPTR1:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[CPTR1]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = call i8* bitcast
|
|
|
|
// CHECK-NEXT: store i8* [[T3]], i8**
|
|
|
|
// CHECK-NEXT: [[CPTR2:%.*]] = bitcast i8** [[C]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[CPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]]
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NOT: clang.imprecise_release
|
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
PRECISE_LIFETIME Test1 *ptr = test1_helper();
|
|
|
|
char *c = ptr.interior;
|
|
|
|
}
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1c_message()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1c_message(void) {
|
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[PC:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[PCPTR1:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PCPTR1]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutorelease(i8* [[T1]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]*
|
|
|
|
// CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[T4:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T6:%.*]] = call i8* bitcast
|
|
|
|
// CHECK-NEXT: store i8* [[T6]], i8**
|
|
|
|
// CHECK-NEXT: [[PCPTR2:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PCPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
Test1 *ptr = test1_helper();
|
|
|
|
char *pc = [ptr PropertyReturnsInnerPointer];
|
|
|
|
}
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1c_property()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1c_property(void) {
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[PC:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PCPTR1:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PCPTR1]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = call i8* @llvm.objc.retainAutorelease(i8* [[T1]])
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]*
|
|
|
|
// CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[T4:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: [[T6:%.*]] = call i8* bitcast
|
|
|
|
// CHECK-NEXT: store i8* [[T6]], i8**
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PCPTR2:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PCPTR2]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
Test1 *ptr = test1_helper();
|
|
|
|
char *pc = ptr.PropertyReturnsInnerPointer;
|
|
|
|
}
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1d_message()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1d_message(void) {
|
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[PC:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[PCPTR1:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PCPTR1]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[EIGHT:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
|
|
|
// CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* noundef [[EIGHT]], i8* noundef [[SEL]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: store i8* [[CALL1]], i8**
|
|
|
|
// CHECK-NEXT: [[PCPTR2:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PCPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[NINE:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
|
|
|
// CHECK-NEXT: [[TEN:%.*]] = bitcast [[TEST1]]* [[NINE]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[TEN]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
PRECISE_LIFETIME Test1 *ptr = test1_helper();
|
|
|
|
char *pc = [ptr PropertyReturnsInnerPointer];
|
|
|
|
}
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test1d_property()
|
2015-09-10 07:37:17 +08:00
|
|
|
void test1d_property(void) {
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8
|
|
|
|
// CHECK: [[PC:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PTRPTR1]])
|
2021-11-09 10:01:48 +08:00
|
|
|
// CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
|
|
|
|
// CHECK-NEXT: call void (...) @llvm.objc.clang.arc.noop.use([[TEST1]]* [[T0]])
|
|
|
|
// CHECK-NEXT: store [[TEST1]]* [[T0]]
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PCPTR1:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[PCPTR1]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2015-09-10 07:37:17 +08:00
|
|
|
// CHECK-NEXT: [[EIGHT:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2022-01-27 09:31:26 +08:00
|
|
|
// CHECK-NEXT: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_
|
|
|
|
// CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* noundef [[EIGHT]], i8* noundef [[SEL]])
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: store i8* [[CALL1]], i8**
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PCPTR2:%.*]] = bitcast i8** [[PC]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PCPTR2]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[NINE:%.*]] = load [[TEST1]]*, [[TEST1]]**
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: [[TEN:%.*]] = bitcast [[TEST1]]* [[NINE]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[TEN]])
|
2015-04-23 05:38:15 +08:00
|
|
|
// CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8*
|
2017-04-11 04:18:45 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[PTRPTR2]])
|
2013-09-20 00:37:20 +08:00
|
|
|
// CHECK-NEXT: ret void
|
2015-09-10 07:37:17 +08:00
|
|
|
PRECISE_LIFETIME Test1 *ptr = test1_helper();
|
2013-09-20 00:37:20 +08:00
|
|
|
char *pc = ptr.PropertyReturnsInnerPointer;
|
|
|
|
}
|
|
|
|
|
2013-03-13 11:10:54 +08:00
|
|
|
@interface Test2 {
|
|
|
|
@public
|
|
|
|
id ivar;
|
|
|
|
}
|
|
|
|
@end
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test2(
|
2013-03-13 11:10:54 +08:00
|
|
|
void test2(Test2 *x) {
|
|
|
|
x->ivar = 0;
|
|
|
|
// CHECK: [[X:%.*]] = alloca [[TEST2:%.*]]*
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = bitcast [[TEST2]]* {{%.*}} to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = call i8* @llvm.objc.retain(i8* [[T0]]) [[NUW]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[TEST2]]*
|
|
|
|
// CHECK-NEXT: store [[TEST2]]* [[T2]], [[TEST2]]** [[X]],
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST2]]*, [[TEST2]]** [[X]],
|
|
|
|
// CHECK-NEXT: [[OFFSET:%.*]] = load i64, i64* @"OBJC_IVAR_$_Test2.ivar"
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST2]]* [[T0]] to i8*
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds i8, i8* [[T1]], i64 [[OFFSET]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to i8**
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T4:%.*]] = load i8*, i8** [[T3]],
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: store i8* null, i8** [[T3]],
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T4]]) [[NUW]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NOT: imprecise
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[TEST2]]*, [[TEST2]]** [[X]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST2]]* [[T0]] to i8*
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T1]]) [[NUW]], !clang.imprecise_release
|
2013-03-13 11:10:54 +08:00
|
|
|
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
2020-12-31 12:45:56 +08:00
|
|
|
// CHECK-LABEL: define{{.*}} void @test3(i8*
|
2013-03-13 11:10:54 +08:00
|
|
|
void test3(PRECISE_LIFETIME id x) {
|
|
|
|
// CHECK: [[X:%.*]] = alloca i8*,
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = call i8* @llvm.objc.retain(i8* {{%.*}}) [[NUW]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NEXT: store i8* [[T0]], i8** [[X]],
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[X]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.release(i8* [[T0]]) [[NUW]]
|
2013-03-13 11:10:54 +08:00
|
|
|
// CHECK-NOT: imprecise_release
|
|
|
|
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: attributes [[NUW]] = { nounwind }
|