2013-02-12 13:53:35 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-dispatch-method=mixed -fobjc-runtime-has-weak -fexceptions -o - %s | FileCheck %s
|
2012-01-31 07:39:30 +08:00
|
|
|
|
|
|
|
@interface NSObject
|
|
|
|
- (id) new;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface MyObject : NSObject
|
|
|
|
- (char)isEqual:(id) __attribute__((ns_consumed)) object;
|
2013-02-12 13:53:35 +08:00
|
|
|
- (_Complex float) asComplexWithArg: (id) __attribute__((ns_consumed)) object;
|
2012-01-31 07:39:30 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
MyObject *x;
|
|
|
|
|
2013-02-12 13:53:35 +08:00
|
|
|
// rdar://10444476
|
|
|
|
void test0(void) {
|
|
|
|
id obj = [NSObject new];
|
|
|
|
[x isEqual : obj];
|
2012-01-31 07:39:30 +08:00
|
|
|
}
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test0()
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: [[FIVE:%.*]] = call i8* @llvm.objc.retain
|
2012-01-31 07:39:30 +08:00
|
|
|
// CHECK-NEXT: [[SIX:%.*]] = bitcast
|
|
|
|
// CHECK-NEXT: [[SEVEN:%.*]] = icmp eq i8* [[SIX]], null
|
|
|
|
// CHECK-NEXT: br i1 [[SEVEN]], label [[NULLINIT:%.*]], label [[CALL_LABEL:%.*]]
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[FN:%.*]] = load i8*, i8** getelementptr inbounds
|
2012-01-31 09:05:11 +08:00
|
|
|
// CHECK-NEXT: [[EIGHT:%.*]] = bitcast i8* [[FN]]
|
2012-01-31 07:39:30 +08:00
|
|
|
// CHECK-NEXT: [[CALL:%.*]] = call signext i8 [[EIGHT]]
|
2012-08-17 20:28:21 +08:00
|
|
|
// CHECK-NEXT: br label [[CONT:%.*]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release(i8* [[FIVE]]) [[NUW:#[0-9]+]]
|
2012-08-17 20:28:21 +08:00
|
|
|
// CHECK-NEXT: br label [[CONT]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK: phi i8 [ [[CALL]], {{%.*}} ], [ 0, {{%.*}} ]
|
|
|
|
|
|
|
|
// Ensure that we build PHIs correctly in the presence of cleanups.
|
|
|
|
// rdar://12046763
|
|
|
|
void test1(void) {
|
|
|
|
id obj = [NSObject new];
|
|
|
|
__weak id weakObj = obj;
|
|
|
|
_Complex float result = [x asComplexWithArg: obj];
|
|
|
|
}
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test1()
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK: [[OBJ:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK-NEXT: [[WEAKOBJ:%.*]] = alloca i8*, align 8
|
|
|
|
// CHECK-NEXT: [[RESULT:%.*]] = alloca { float, float }, align 4
|
|
|
|
// Various initializations.
|
|
|
|
// CHECK: [[T0:%.*]] = call i8* bitcast (
|
|
|
|
// CHECK-NEXT: store i8* [[T0]], i8** [[OBJ]]
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[OBJ]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call i8* @llvm.objc.initWeak(i8** [[WEAKOBJ]], i8* [[T0]]) [[NUW]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// Okay, start the message-send.
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[MYOBJECT:%.*]]*, [[MYOBJECT:%.*]]** @x
|
|
|
|
// CHECK-NEXT: [[ARG:%.*]] = load i8*, i8** [[OBJ]]
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: [[ARG_RETAINED:%.*]] = call i8* @llvm.objc.retain(i8* [[ARG]])
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: load i8*, i8** @
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK-NEXT: [[SELF:%.*]] = bitcast [[MYOBJECT]]* [[T0]] to i8*
|
|
|
|
// Null check.
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = icmp eq i8* [[SELF]], null
|
|
|
|
// CHECK-NEXT: br i1 [[T0]], label [[FORNULL:%.*]], label [[FORCALL:%.*]]
|
|
|
|
// Invoke and produce the return values.
|
|
|
|
// CHECK: [[CALL:%.*]] = invoke <2 x float> bitcast
|
|
|
|
// CHECK-NEXT: to label [[INVOKE_CONT:%.*]] unwind label {{%.*}}
|
|
|
|
// CHECK: [[T0:%.*]] = bitcast { float, float }* [[COERCE:%.*]] to <2 x float>*
|
|
|
|
// CHECK-NEXT: store <2 x float> [[CALL]], <2 x float>* [[T0]],
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { float, float }, { float, float }* [[COERCE]], i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[REALCALL:%.*]] = load float, float* [[T0]]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { float, float }, { float, float }* [[COERCE]], i32 0, i32 1
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[IMAGCALL:%.*]] = load float, float* [[T0]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK-NEXT: br label [[CONT:%.*]]{{$}}
|
|
|
|
// Null path.
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.release(i8* [[ARG_RETAINED]]) [[NUW]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK-NEXT: br label [[CONT]]
|
|
|
|
// Join point.
|
|
|
|
// CHECK: [[REAL:%.*]] = phi float [ [[REALCALL]], [[INVOKE_CONT]] ], [ 0.000000e+00, [[FORNULL]] ]
|
|
|
|
// CHECK-NEXT: [[IMAG:%.*]] = phi float [ [[IMAGCALL]], [[INVOKE_CONT]] ], [ 0.000000e+00, [[FORNULL]] ]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { float, float }, { float, float }* [[RESULT]], i32 0, i32 0
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds { float, float }, { float, float }* [[RESULT]], i32 0, i32 1
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK-NEXT: store float [[REAL]], float* [[T0]]
|
|
|
|
// CHECK-NEXT: store float [[IMAG]], float* [[T1]]
|
|
|
|
// Epilogue.
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK-NEXT: call void @llvm.objc.destroyWeak(i8** [[WEAKOBJ]]) [[NUW]]
|
|
|
|
// CHECK-NEXT: call void @llvm.objc.storeStrong(i8** [[OBJ]], i8* null) [[NUW]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
// Cleanup.
|
|
|
|
// CHECK: landingpad
|
2018-12-19 04:33:00 +08:00
|
|
|
// CHECK: call void @llvm.objc.destroyWeak(i8** [[WEAKOBJ]]) [[NUW]]
|
2013-02-22 17:10:20 +08:00
|
|
|
|
|
|
|
// CHECK: attributes [[NUW]] = { nounwind }
|