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()
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK: [[FIVE:%.*]] = call i8* @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:%.*]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK: [[FN:%.*]] = load 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:%.*]]
|
2013-02-22 17:10:20 +08:00
|
|
|
// CHECK: call void @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]]
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load i8** [[OBJ]]
|
2013-02-22 17:10:20 +08:00
|
|
|
// CHECK-NEXT: call i8* @objc_initWeak(i8** [[WEAKOBJ]], i8* [[T0]]) [[NUW]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// Okay, start the message-send.
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = load [[MYOBJECT:%.*]]** @x
|
|
|
|
// CHECK-NEXT: [[ARG:%.*]] = load i8** [[OBJ]]
|
|
|
|
// CHECK-NEXT: [[ARG_RETAINED:%.*]] = call i8* @objc_retain(i8* [[ARG]])
|
|
|
|
// CHECK-NEXT: load i8** @
|
|
|
|
// 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]],
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { float, float }* [[COERCE]], i32 0, i32 0
|
|
|
|
// CHECK-NEXT: [[REALCALL:%.*]] = load float* [[T0]]
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { float, float }* [[COERCE]], i32 0, i32 1
|
|
|
|
// CHECK-NEXT: [[IMAGCALL:%.*]] = load float* [[T0]]
|
|
|
|
// CHECK-NEXT: br label [[CONT:%.*]]{{$}}
|
|
|
|
// Null path.
|
2013-02-22 17:10:20 +08:00
|
|
|
// CHECK: call void @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]] ]
|
|
|
|
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds { float, float }* [[RESULT]], i32 0, i32 0
|
|
|
|
// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds { float, float }* [[RESULT]], i32 0, i32 1
|
|
|
|
// CHECK-NEXT: store float [[REAL]], float* [[T0]]
|
|
|
|
// CHECK-NEXT: store float [[IMAG]], float* [[T1]]
|
|
|
|
// Epilogue.
|
2013-02-22 17:10:20 +08:00
|
|
|
// CHECK-NEXT: call void @objc_destroyWeak(i8** [[WEAKOBJ]]) [[NUW]]
|
|
|
|
// CHECK-NEXT: call void @objc_storeStrong(i8** [[OBJ]], i8* null) [[NUW]]
|
2013-02-12 13:53:35 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
// Cleanup.
|
|
|
|
// CHECK: landingpad
|
2013-02-22 17:10:20 +08:00
|
|
|
// CHECK: call void @objc_destroyWeak(i8** [[WEAKOBJ]]) [[NUW]]
|
|
|
|
|
|
|
|
// CHECK: attributes [[NUW]] = { nounwind }
|