diff options
Diffstat (limited to 'test/CodeGenObjC')
81 files changed, 1031 insertions, 232 deletions
diff --git a/test/CodeGenObjC/2009-01-21-invalid-debug-info.m b/test/CodeGenObjC/2009-01-21-invalid-debug-info.m index af912e2dc54a..8278708769ae 100644 --- a/test/CodeGenObjC/2009-01-21-invalid-debug-info.m +++ b/test/CodeGenObjC/2009-01-21-invalid-debug-info.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -S -g -o %t.s %s +// RUN: %clang_cc1 -S -debug-info-kind=limited -o %t.s %s // FIXME: This test case can be removed at some point (since it will // no longer effectively test anything). The reason it was causing diff --git a/test/CodeGenObjC/2010-02-09-DbgSelf.m b/test/CodeGenObjC/2010-02-09-DbgSelf.m index a0179d9227a7..53ee35e4690a 100644 --- a/test/CodeGenObjC/2010-02-09-DbgSelf.m +++ b/test/CodeGenObjC/2010-02-09-DbgSelf.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | FileCheck %s +// RUN: %clang_cc1 -x objective-c -emit-llvm -debug-info-kind=limited < %s | FileCheck %s // Test to check that "self" argument is assigned a location. // CHECK: call void @llvm.dbg.declare(metadata %0** %{{[^,]+}}, metadata [[SELF:![0-9]*]], metadata !{{.*}}) -// CHECK: [[SELF]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "self" +// CHECK: [[SELF]] = !DILocalVariable(name: "self", arg: 1, @interface Foo -(void) Bar: (int)x ; diff --git a/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m b/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m index 1a5df30dd84c..31d4e6980ca7 100644 --- a/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m +++ b/test/CodeGenObjC/2010-02-15-Dbg-MethodStart.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c -emit-llvm -g < %s | FileCheck "%s" +// RUN: %clang_cc1 -x objective-c -emit-llvm -debug-info-kind=limited < %s | FileCheck "%s" // Test to check that subprogram start location. @interface Foo diff --git a/test/CodeGenObjC/2010-02-23-DbgInheritance.m b/test/CodeGenObjC/2010-02-23-DbgInheritance.m index 7d31b30cce5f..cb8b5f8861cb 100644 --- a/test/CodeGenObjC/2010-02-23-DbgInheritance.m +++ b/test/CodeGenObjC/2010-02-23-DbgInheritance.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -g -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm %s -debug-info-kind=limited -o - | FileCheck %s // CHECK-NOT: DW_TAG_member // Interface P should not be a member of interface I in debug info. @interface P diff --git a/test/CodeGenObjC/arc-blocks.m b/test/CodeGenObjC/arc-blocks.m index ba76c1cbc950..30f9271bd9dc 100644 --- a/test/CodeGenObjC/arc-blocks.m +++ b/test/CodeGenObjC/arc-blocks.m @@ -43,7 +43,7 @@ void test2(id x) { extern void test2_helper(id (^)(void)); test2_helper(^{ return x; }); -// CHECK-LABEL: define internal void @__copy_helper_block_ +// CHECK-LABEL: define internal void @__copy_helper_block_(i8*, i8*) #{{[0-9]+}} { // CHECK: [[T0:%.*]] = load i8*, i8** // CHECK-NEXT: [[SRC:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]* // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** @@ -53,7 +53,7 @@ void test2(id x) { // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) [[NUW]] // CHECK-NEXT: ret void -// CHECK-LABEL: define internal void @__destroy_helper_block_ +// CHECK-LABEL: define internal void @__destroy_helper_block_(i8*) #{{[0-9]+}} { // CHECK: [[T0:%.*]] = load i8*, i8** // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]* // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[T1]], i32 0, i32 5 @@ -134,7 +134,7 @@ void test4(void) { // CHECK-NEXT: call void @objc_release(i8* [[T0]]) // CHECK: ret void - // CHECK-LABEL: define internal void @__Block_byref_object_copy_ + // CHECK-LABEL: define internal void @__Block_byref_object_copy_(i8*, i8*) #{{[0-9]+}} { // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6 // CHECK-NEXT: load i8*, i8** // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]* @@ -143,7 +143,7 @@ void test4(void) { // CHECK-NEXT: store i8* [[T2]], i8** [[T0]] // CHECK-NEXT: store i8* null, i8** [[T1]] - // CHECK-LABEL: define internal void @__Block_byref_object_dispose_ + // CHECK-LABEL: define internal void @__Block_byref_object_dispose_(i8*) #{{[0-9]+}} { // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6 // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** [[T0]] // CHECK-NEXT: call void @objc_release(i8* [[T1]]) @@ -155,10 +155,10 @@ void test4(void) { // CHECK-NEXT: call void @objc_release(i8* [[T0]]) // CHECK-NEXT: ret void - // CHECK-LABEL: define internal void @__copy_helper_block_ + // CHECK-LABEL: define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} { // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8) - // CHECK-LABEL: define internal void @__destroy_helper_block_ + // CHECK-LABEL: define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} { // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8) } @@ -221,14 +221,14 @@ void test6(void) { // CHECK-NEXT: call void @llvm.lifetime.end(i64 48, i8* [[VARPTR2]]) // CHECK-NEXT: ret void - // CHECK-LABEL: define internal void @__Block_byref_object_copy_ + // CHECK-LABEL: define internal void @__Block_byref_object_copy_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} { // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6 // CHECK-NEXT: load i8*, i8** // CHECK-NEXT: bitcast i8* {{%.*}} to [[BYREF_T]]* // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6 // CHECK-NEXT: call void @objc_moveWeak(i8** [[T0]], i8** [[T1]]) - // CHECK-LABEL: define internal void @__Block_byref_object_dispose_ + // CHECK-LABEL: define internal void @__Block_byref_object_dispose_.{{[0-9]+}}(i8*) #{{[0-9]+}} { // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* {{%.*}}, i32 0, i32 6 // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) @@ -237,11 +237,11 @@ void test6(void) { // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null) // CHECK-NEXT: ret void - // CHECK-LABEL: define internal void @__copy_helper_block_ + // CHECK-LABEL: define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} { // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control) // CHECK: call void @_Block_object_assign(i8* {{%.*}}, i8* {{%.*}}, i32 8) - // CHECK-LABEL: define internal void @__destroy_helper_block_ + // CHECK-LABEL: define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} { // 0x8 - FIELD_IS_BYREF (no FIELD_IS_WEAK because clang in control) // CHECK: call void @_Block_object_dispose(i8* {{%.*}}, i32 8) } @@ -263,8 +263,7 @@ void test7(void) { // 0x42800000 - has signature, copy/dispose helpers, as well as BLOCK_HAS_EXTENDED_LAYOUT // CHECK: store i32 -1040187392, // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 - // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeakRetained(i8** [[VAR]]) - // CHECK-NEXT: call i8* @objc_initWeak(i8** [[SLOT]], i8* [[T0]]) + // CHECK-NEXT: call void @objc_copyWeak(i8** [[SLOT]], i8** [[VAR]]) // CHECK: call void @test7_helper( // CHECK-NEXT: call void @objc_destroyWeak(i8** {{%.*}}) // CHECK-NEXT: call void @objc_destroyWeak(i8** [[VAR]]) @@ -277,12 +276,12 @@ void test7(void) { // CHECK-NEXT: call void @objc_release(i8* [[T0]]) // CHECK: ret void - // CHECK-LABEL: define internal void @__copy_helper_block_ + // CHECK-LABEL: define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} { // CHECK: getelementptr // CHECK-NEXT: getelementptr // CHECK-NEXT: call void @objc_copyWeak( - // CHECK-LABEL: define internal void @__destroy_helper_block_ + // CHECK-LABEL: define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} { // CHECK: getelementptr // CHECK-NEXT: call void @objc_destroyWeak( } @@ -374,7 +373,7 @@ void test10a(void) { // We can also use _Block_object_assign/destroy with // BLOCK_FIELD_IS_BLOCK as long as we don't pass BLOCK_BYREF_CALLER. -// CHECK-LABEL: define internal void @__Block_byref_object_copy +// CHECK-LABEL: define internal void @__Block_byref_object_copy_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} { // CHECK: [[D0:%.*]] = load i8*, i8** {{%.*}} // CHECK-NEXT: [[D1:%.*]] = bitcast i8* [[D0]] to [[BYREF_T]]* // CHECK-NEXT: [[D2:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* [[D1]], i32 0, i32 6 @@ -388,7 +387,7 @@ void test10a(void) { // CHECK-NEXT: store void ()* [[T3]], void ()** [[D2]], align 8 // CHECK: ret void -// CHECK-LABEL: define internal void @__Block_byref_object_dispose +// CHECK-LABEL: define internal void @__Block_byref_object_dispose_.{{[0-9]+}}(i8*) #{{[0-9]+}} { // CHECK: [[T0:%.*]] = load i8*, i8** {{%.*}} // CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BYREF_T]]* // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[BYREF_T]], [[BYREF_T]]* [[T1]], i32 0, i32 6 @@ -648,7 +647,7 @@ void test18(id x) { extern void test18_helper(id (^)(void)); test18_helper(^{ return x; }); -// CHECK-UNOPT-LABEL: define internal void @__copy_helper_block_ +// CHECK-UNOPT-LABEL: define internal void @__copy_helper_block_.{{[0-9]+}}(i8*, i8*) #{{[0-9]+}} { // CHECK-UNOPT: [[T0:%.*]] = load i8*, i8** // CHECK-UNOPT-NEXT: [[SRC:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]* // CHECK-UNOPT-NEXT: [[T0:%.*]] = load i8*, i8** @@ -660,7 +659,7 @@ void test18(id x) { // CHECK-UNOPT-NEXT: call void @objc_storeStrong(i8** [[T1]], i8* [[T2]]) [[NUW]] // CHECK-UNOPT-NEXT: ret void -// CHECK-UNOPT-LABEL: define internal void @__destroy_helper_block_ +// CHECK-UNOPT-LABEL: define internal void @__destroy_helper_block_.{{[0-9]+}}(i8*) #{{[0-9]+}} { // CHECK-UNOPT: [[T0:%.*]] = load i8*, i8** // CHECK-UNOPT-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[BLOCK_T]]* // CHECK-UNOPT-NEXT: [[T2:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[T1]], i32 0, i32 5 diff --git a/test/CodeGenObjC/arc-captured-32bit-block-var-layout-2.m b/test/CodeGenObjC/arc-captured-32bit-block-var-layout-2.m index 6ab02a916e8b..10feda938d08 100644 --- a/test/CodeGenObjC/arc-captured-32bit-block-var-layout-2.m +++ b/test/CodeGenObjC/arc-captured-32bit-block-var-layout-2.m @@ -11,31 +11,30 @@ int main() { NSString *strong; unsigned long long eightByte = 0x8001800181818181ull; // Test1 -// CHECK: block variable layout: BL_NON_OBJECT_WORD:3, BL_STRONG:1, BL_OPERATOR:0 + // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 void (^block1)() = ^{ printf("%#llx", eightByte); NSLog(@"%@", strong); }; // Test2 int i = 1; -// CHECK: block variable layout: BL_NON_OBJECT_WORD:3, BL_STRONG:1, BL_OPERATOR:0 + // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 void (^block2)() = ^{ printf("%#llx, %d", eightByte, i); NSLog(@"%@", strong); }; // Test3 char ch = 'a'; -// CHECK: block variable layout: BL_NON_OBJECT_WORD:3, BL_STRONG:1, BL_OPERATOR:0 + // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 void (^block3)() = ^{ printf("%c %#llx", ch, eightByte); NSLog(@"%@", strong); }; // Test4 unsigned long fourByte = 0x8001ul; -// block variable layout: BL_NON_OBJECT_WORD:1, BL_STRONG:1, BL_OPERATOR:0 -// CHECK: Inline instruction for block variable layout: 0x0100 + // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 void (^block4)() = ^{ printf("%c %#lx", ch, fourByte); NSLog(@"%@", strong); }; // Test5 -// CHECK: block variable layout: BL_NON_OBJECT_WORD:3, BL_STRONG:1, BL_OPERATOR:0 + // CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 void (^block5)() = ^{ NSLog(@"%@", strong); printf("%c %#llx", ch, eightByte); }; // Test6 -// CHECK: block variable layout: BL_OPERATOR:0 + // CHECK: Block variable layout: BL_OPERATOR:0 void (^block6)() = ^{ printf("%#llx", eightByte); }; } diff --git a/test/CodeGenObjC/arc-captured-32bit-block-var-layout.m b/test/CodeGenObjC/arc-captured-32bit-block-var-layout.m index 45a894c38150..d1b578342703 100644 --- a/test/CodeGenObjC/arc-captured-32bit-block-var-layout.m +++ b/test/CodeGenObjC/arc-captured-32bit-block-var-layout.m @@ -33,7 +33,7 @@ void f() { // and a descriptor pointer). // Test 1 -// CHECK: Inline instruction for block variable layout: 0x0320 +// CHECK: Inline block variable layout: 0x0320, BL_STRONG:3, BL_BYREF:2, BL_OPERATOR:0 void (^b)() = ^{ byref_int = sh + ch+ch1+ch2 ; x(bar); @@ -44,7 +44,7 @@ void f() { b(); // Test 2 -// CHECK: Inline instruction for block variable layout: 0x0331 +// CHECK: Inline block variable layout: 0x0331, BL_STRONG:3, BL_BYREF:3, BL_WEAK:1, BL_OPERATOR:0 void (^c)() = ^{ byref_int = sh + ch+ch1+ch2 ; x(bar); @@ -65,7 +65,7 @@ void g() { unsigned int i; NSString *y; NSString *z; -// CHECK: Inline instruction for block variable layout: 0x0401 +// CHECK: Inline block variable layout: 0x0401, BL_STRONG:4, BL_WEAK:1, BL_OPERATOR:0 void (^c)() = ^{ int j = i + bletch; x(foo); @@ -110,7 +110,7 @@ void h() { block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINE:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINE:1, BL_NON_OBJECT_WORD:3, BL_BYREF:1, BL_OPERATOR:0 */ -// CHECK: block variable layout: BL_BYREF:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 +// CHECK: Block variable layout: BL_BYREF:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 void (^c)() = ^{ x(s2.ui.o1); x(u2.o1); @@ -125,7 +125,7 @@ void arr1() { __unsafe_unretained id unsafe_unretained_var[4]; } imported_s; -// CHECK: block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0 +// CHECK: Block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0 void (^c)() = ^{ x(imported_s.unsafe_unretained_var[2]); }; @@ -140,7 +140,7 @@ void arr2() { __unsafe_unretained id unsafe_unretained_var[4]; } imported_s; -// CHECK: block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0 +// CHECK: Block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0 void (^c)() = ^{ x(imported_s.unsafe_unretained_var[2]); }; @@ -155,7 +155,7 @@ void arr3() { __unsafe_unretained id unsafe_unretained_var[0]; } imported_s; -// CHECK: block variable layout: BL_OPERATOR:0 +// CHECK: Block variable layout: BL_OPERATOR:0 void (^c)() = ^{ int i = imported_s.a; }; @@ -181,7 +181,7 @@ void arr4() { } f4[2][2]; } captured_s; -// CHECK: block variable layout: BL_UNRETAINED:3, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 +// CHECK: Block variable layout: BL_UNRETAINED:3, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 void (^c)() = ^{ id i = captured_s.f0.s_f1; }; @@ -199,7 +199,7 @@ void bf1() { int flag4: 24; } s; -// CHECK: block variable layout: BL_OPERATOR:0 +// CHECK: Block variable layout: BL_OPERATOR:0 int (^c)() = ^{ return s.flag; }; @@ -212,7 +212,7 @@ void bf2() { int flag : 1; } s; -// CHECK: block variable layout: BL_OPERATOR:0 +// CHECK: Block variable layout: BL_OPERATOR:0 int (^c)() = ^{ return s.flag; }; @@ -243,7 +243,7 @@ void bf3() { unsigned int _filler : 32; } _flags; -// CHECK: block variable layout: BL_OPERATOR:0 +// CHECK: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags._draggedNodesAreDeletable; }; @@ -278,7 +278,7 @@ void bf4() { unsigned int _filler : 32; } _flags; -// CHECK: block variable layout: BL_OPERATOR:0 +// CHECK: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags._draggedNodesAreDeletable; }; @@ -296,7 +296,7 @@ void bf5() { unsigned char flag1 : 1; } _flags; -// CHECK: block variable layout: BL_OPERATOR:0 +// CHECK: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags.flag; }; @@ -313,7 +313,7 @@ void bf6() { unsigned char flag1 : 1; } _flags; -// CHECK: block variable layout: BL_OPERATOR:0 +// CHECK: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags.flag; }; @@ -329,7 +329,7 @@ void Test7() { __weak id wid9, wid10, wid11, wid12; __weak id wid13, wid14, wid15, wid16; const id bar = (id) opaque_id(); -// CHECK: block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0 +// CHECK: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0 void (^b)() = ^{ x(bar); x(wid1); @@ -364,7 +364,7 @@ __weak id wid; __weak id w9, w10, w11, w12; __weak id w13, w14, w15, w16; const id bar = (id) opaque_id(); -// CHECK: block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0 +// CHECK: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0 void (^b)() = ^{ x(bar); x(wid1); diff --git a/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m b/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m index 89e2b570b038..07b194da9435 100644 --- a/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m +++ b/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout -// RUN: FileCheck --input-file=%t-64.layout %s +// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-64 --input-file=%t-64.layout %s // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-32.layout -// RUN: FileCheck -check-prefix=CHECK-i386 --input-file=%t-32.layout %s +// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-32 --input-file=%t-32.layout %s // rdar://12184410 void x(id y) {} @@ -17,22 +17,19 @@ void f() { __block id byref_bab = (id)0; __block id bl_var1; -// CHECK: Inline instruction for block variable layout: 0x0100 -// CHECK-i386: Inline instruction for block variable layout: 0x0100 +// CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 void (^b)() = ^{ x(bar); }; -// CHECK: Inline instruction for block variable layout: 0x0210 -// CHECK-i386: Inline instruction for block variable layout: 0x0210 +// CHECK: Inline block variable layout: 0x0210, BL_STRONG:2, BL_BYREF:1, BL_OPERATOR:0 void (^c)() = ^{ x(bar); x(baz); byref_int = 1; }; -// CHECK: Inline instruction for block variable layout: 0x0230 -// CHECK-i386: Inline instruction for block variable layout: 0x0230 +// CHECK: Inline block variable layout: 0x0230, BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0 void (^d)() = ^{ x(bar); x(baz); @@ -41,8 +38,7 @@ void f() { byref_bab = 0; }; -// CHECK: Inline instruction for block variable layout: 0x0231 -// CHECK-i386: Inline instruction for block variable layout: 0x0231 +// CHECK: Inline block variable layout: 0x0231, BL_STRONG:2, BL_BYREF:3, BL_WEAK:1, BL_OPERATOR:0 __weak id wid; id (^e)() = ^{ x(bar); @@ -53,8 +49,7 @@ void f() { return wid; }; -// CHECK: Inline instruction for block variable layout: 0x0235 -// CHECK-i386: Inline instruction for block variable layout: 0x0235 +// CHECK: Inline block variable layout: 0x0235, BL_STRONG:2, BL_BYREF:3, BL_WEAK:5, BL_OPERATOR:0 __weak id wid1, wid2, wid3, wid4; id (^f)() = ^{ x(bar); @@ -69,8 +64,7 @@ void f() { return wid; }; -// CHECK: Inline instruction for block variable layout: 0x035 -// CHECK-i386: Inline instruction for block variable layout: 0x035 +// CHECK: Inline block variable layout: 0x035, BL_BYREF:3, BL_WEAK:5, BL_OPERATOR:0 id (^g)() = ^{ byref_int = 1; bl_var1 = 0; @@ -82,21 +76,18 @@ void f() { return wid; }; -// CHECK: Inline instruction for block variable layout: 0x01 -// CHECK-i386: Inline instruction for block variable layout: 0x01 +// CHECK: Inline block variable layout: 0x01, BL_WEAK:1, BL_OPERATOR:0 id (^h)() = ^{ return wid; }; -// CHECK: Inline instruction for block variable layout: 0x020 -// CHECK-i386: Inline instruction for block variable layout: 0x020 +// CHECK: Inline block variable layout: 0x020, BL_BYREF:2, BL_OPERATOR:0 void (^ii)() = ^{ byref_int = 1; byref_bab = 0; }; -// CHECK: Inline instruction for block variable layout: 0x0102 -// CHECK-i386: Inline instruction for block variable layout: 0x0102 +// CHECK: Inline block variable layout: 0x0102, BL_STRONG:1, BL_WEAK:2, BL_OPERATOR:0 void (^jj)() = ^{ x(bar); x(wid1); @@ -114,8 +105,7 @@ int main() { __weak NSString *w1 = 0; -// CHECK: Inline instruction for block variable layout: 0x0201 -// CHECK-i386: Inline instruction for block variable layout: 0x0201 +// CHECK: Inline block variable layout: 0x0201, BL_STRONG:2, BL_WEAK:1, BL_OPERATOR:0 dispatch_block_t block2 = ^{ NSLog(@"%@, %@, %@", s1, w1, s2); }; diff --git a/test/CodeGenObjC/arc-captured-block-var-layout.m b/test/CodeGenObjC/arc-captured-block-var-layout.m index 42e6060dcc25..f8518d1c44b8 100644 --- a/test/CodeGenObjC/arc-captured-block-var-layout.m +++ b/test/CodeGenObjC/arc-captured-block-var-layout.m @@ -34,7 +34,7 @@ void f() { // Test 1 // Inline instruction for block variable layout: 0x0320 (3 strong 2 byref) -// CHECK-LP64: Inline instruction for block variable layout: 0x0320 +// CHECK-LP64: Inline block variable layout: 0x0320, BL_STRONG:3, BL_BYREF:2, BL_OPERATOR:0 void (^b)() = ^{ byref_int = sh + ch+ch1+ch2 ; x(bar); @@ -46,7 +46,7 @@ void f() { // Test 2 // Inline instruction for block variable layout: 0x0331 (3 strong 3 byref 1 weak) -// CHECK-LP64: Inline instruction for block variable layout: 0x0331 +// CHECK-LP64: Inline block variable layout: 0x0331, BL_STRONG:3, BL_BYREF:3, BL_WEAK:1, BL_OPERATOR:0 void (^c)() = ^{ byref_int = sh + ch+ch1+ch2 ; x(bar); @@ -68,7 +68,7 @@ void g() { NSString *y; NSString *z; // Inline instruction for block variable layout: 0x0401 (4 strong 0 byref 1 weak) -// CHECK-LP64: Inline instruction for block variable layout: 0x0401 +// CHECK-LP64: Inline block variable layout: 0x0401, BL_STRONG:4, BL_WEAK:1, BL_OPERATOR:0 void (^c)() = ^{ int j = i + bletch; x(foo); @@ -109,7 +109,7 @@ void h() { union U u2; __block id block_id; -// CHECK-LP64: block variable layout: BL_BYREF:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_BYREF:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 void (^c)() = ^{ x(s2.ui.o1); x(u2.o1); @@ -124,7 +124,7 @@ void arr1() { __unsafe_unretained id unsafe_unretained_var[4]; } imported_s; -// CHECK-LP64: block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0 void (^c)() = ^{ x(imported_s.unsafe_unretained_var[2]); }; @@ -139,7 +139,7 @@ void arr2() { __unsafe_unretained id unsafe_unretained_var[4]; } imported_s; -// CHECK-LP64: block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0 void (^c)() = ^{ x(imported_s.unsafe_unretained_var[2]); }; @@ -154,7 +154,7 @@ void arr3() { __unsafe_unretained id unsafe_unretained_var[0]; } imported_s; -// CHECK-LP64: block variable layout: BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_OPERATOR:0 void (^c)() = ^{ int i = imported_s.a; }; @@ -180,7 +180,7 @@ void arr4() { } f4[2][2]; } captured_s; -// CHECK-LP64: block variable layout: BL_UNRETAINED:3, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_UNRETAINED:3, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_NON_OBJECT_WORD:1, BL_UNRETAINED:1, BL_OPERATOR:0 void (^c)() = ^{ id i = captured_s.f0.s_f1; }; @@ -198,7 +198,7 @@ void bf1() { int flag4: 24; } s; -// CHECK-LP64: block variable layout: BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_OPERATOR:0 int (^c)() = ^{ return s.flag; }; @@ -211,7 +211,7 @@ void bf2() { int flag : 1; } s; -// CHECK-LP64: block variable layout: BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_OPERATOR:0 int (^c)() = ^{ return s.flag; }; @@ -242,7 +242,7 @@ void bf3() { unsigned int _filler : 32; } _flags; -// CHECK-LP64: block variable layout: BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags._draggedNodesAreDeletable; }; @@ -277,7 +277,7 @@ void bf4() { unsigned int _filler : 32; } _flags; -// CHECK-LP64: block variable layout: BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags._draggedNodesAreDeletable; }; @@ -295,7 +295,7 @@ void bf5() { unsigned char flag1 : 1; } _flags; -// CHECK-LP64: block variable layout: BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags.flag; }; @@ -312,7 +312,7 @@ void bf6() { unsigned char flag1 : 1; } _flags; -// CHECK-LP64: block variable layout: BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_OPERATOR:0 unsigned char (^c)() = ^{ return _flags.flag; }; @@ -328,7 +328,7 @@ void Test7() { __weak id wid9, wid10, wid11, wid12; __weak id wid13, wid14, wid15, wid16; const id bar = (id) opaque_id(); -// CHECK-LP64: block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0 void (^b)() = ^{ x(bar); x(wid1); @@ -363,7 +363,7 @@ __weak id wid; __weak id w9, w10, w11, w12; __weak id w13, w14, w15, w16; const id bar = (id) opaque_id(); -// CHECK-LP64: block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0 +// CHECK-LP64: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0 void (^b)() = ^{ x(bar); x(wid1); diff --git a/test/CodeGenObjC/arc-foreach.m b/test/CodeGenObjC/arc-foreach.m index 17067a0a584e..90d9c1f12617 100644 --- a/test/CodeGenObjC/arc-foreach.m +++ b/test/CodeGenObjC/arc-foreach.m @@ -110,9 +110,7 @@ void test1(NSArray *array) { // CHECK-LP64: [[D0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 // CHECK-LP64: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]], [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 -// CHECK-LP64-NEXT: [[T1:%.*]] = call i8* @objc_loadWeakRetained(i8** [[X]]) -// CHECK-LP64-NEXT: call i8* @objc_initWeak(i8** [[T0]], i8* [[T1]]) -// CHECK-LP64-NEXT: call void @objc_release(i8* [[T1]]) +// CHECK-LP64-NEXT: call void @objc_copyWeak(i8** [[T0]], i8** [[X]]) // CHECK-LP64-NEXT: [[T1:%.*]] = bitcast [[BLOCK_T]]* [[BLOCK]] to // CHECK-LP64: call void @use_block // CHECK-LP64-NEXT: call void @objc_destroyWeak(i8** [[D0]]) diff --git a/test/CodeGenObjC/arc-ivar-layout.m b/test/CodeGenObjC/arc-ivar-layout.m index 086a726d806c..5e08d625e34e 100644 --- a/test/CodeGenObjC/arc-ivar-layout.m +++ b/test/CodeGenObjC/arc-ivar-layout.m @@ -1,6 +1,4 @@ -// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -S %s -o %t-64.s -// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.s %s -// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm %s -o %t-64.s | FileCheck -check-prefix CHECK-LP64 %s // rdar://8991729 @interface NSObject { @@ -17,8 +15,7 @@ @implementation AllPointers @end -// CHECK-LP64: L_OBJC_CLASS_NAME_.1: -// CHECK-LP64-NEXT: .asciz "\003" +// CHECK-LP64: strong ivar layout for class 'AllPointers': 0x03, 0x00 @class NSString, NSNumber; @interface A : NSObject { @@ -38,10 +35,12 @@ @implementation A @end +// CHECK-LP64: strong ivar layout for class 'A': 0x02, 0x00 +// CHECK-LP64: weak ivar layout for class 'A': 0x31, 0x00 + @implementation B @end -// CHECK-LP64: L_OBJC_CLASS_NAME_.15: -// CHECK-LP64-NEXT: .asciz "\022" +// CHECK-LP64: strong ivar layout for class 'B': 0x12, 0x00 @interface UnsafePerson { @public @@ -52,8 +51,8 @@ @end @implementation UnsafePerson @end -// CHECK-LP64: L_OBJC_CLASS_NAME_.20: -// CHECK-LP64-NEXT: .asciz "!" + +// CHECK-LP64: strong ivar layout for class 'UnsafePerson': 0x21, 0x00 // rdar://16136439 @interface rdar16136439 @@ -61,5 +60,20 @@ @end @implementation rdar16136439 @end -// CHECK-LP64: L_OBJC_PROP_NAME_ATTR_.29: -// CHECK-LP64-NEXT: .asciz "T@,R,W,N,V_first" + +// CHECK-LP64: weak ivar layout for class 'rdar16136439': 0x01, 0x00 + +@interface Misalign : NSObject { + char a; +} +@end + +@interface Misaligned : Misalign { + char b; + id x; +} +@end + +@implementation Misaligned @end + +// CHECK-LP64: strong ivar layout for class 'Misaligned': 0x01, 0x00 diff --git a/test/CodeGenObjC/arc-linetable-autorelease.m b/test/CodeGenObjC/arc-linetable-autorelease.m index 329206867b85..6812e8a6de83 100644 --- a/test/CodeGenObjC/arc-linetable-autorelease.m +++ b/test/CodeGenObjC/arc-linetable-autorelease.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -fobjc-arc -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fobjc-arc -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s // Ensure that the line info is making sense: // ARC cleanups should be at the closing '}'. @protocol NSObject diff --git a/test/CodeGenObjC/arc-linetable.m b/test/CodeGenObjC/arc-linetable.m index a3232ecd4e05..877dfdc12211 100644 --- a/test/CodeGenObjC/arc-linetable.m +++ b/test/CodeGenObjC/arc-linetable.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -debug-info-kind=standalone -dwarf-version=4 -disable-llvm-passes -triple x86_64-apple-darwin10 %s -o - | FileCheck %s // Legend: EXP = Return expression, RET = ret instruction @@ -35,7 +35,7 @@ // CHECK: define {{.*}}testCleanupVoid // CHECK: icmp ne {{.*}}!dbg ![[SKIP1:[0-9]+]] // CHECK: store i32 0, i32* {{.*}}, !dbg ![[RET8:[0-9]+]] -// CHECK: @objc_storeStrong{{.*}}, !dbg ![[ARC8:[0-9]+]] +// CHECK: @objc_storeStrong{{.*}}, !dbg ![[RET8]] // CHECK: ret {{.*}} !dbg ![[RET8]] typedef signed char BOOL; @@ -54,9 +54,9 @@ typedef signed char BOOL; @implementation AppDelegate : NSObject -// CHECK: ![[TESTNOSIDEEFFECT:.*]] = !DISubprogram(name: "-[AppDelegate testNoSideEffect:]" -// CHECK-SAME: line: [[@LINE+2]] -// CHECK-SAME: isLocal: true, isDefinition: true +// CHECK: ![[TESTNOSIDEEFFECT:.*]] = distinct !DISubprogram(name: "-[AppDelegate testNoSideEffect:]" +// CHECK-SAME: line: [[@LINE+2]] +// CHECK-SAME: isLocal: true, isDefinition: true - (int)testNoSideEffect:(NSString *)foo { int x = 1; return 1; // Return expression @@ -112,8 +112,7 @@ typedef signed char BOOL; [delegate testVoid :s]; } } - // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+2]], scope: - // CHECK: ![[ARC8]] = !DILocation(line: [[@LINE+1]], scope: + // CHECK: ![[RET8]] = !DILocation(line: [[@LINE+1]], scope: } diff --git a/test/CodeGenObjC/arc-literals.m b/test/CodeGenObjC/arc-literals.m index d107a28506f9..ab6c82b743fc 100644 --- a/test/CodeGenObjC/arc-literals.m +++ b/test/CodeGenObjC/arc-literals.m @@ -47,10 +47,10 @@ void test_array(id a, id b) { // CHECK: call i8* @objc_retain(i8* // Constructing the array - // CHECK: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i32 0, i32 0 + // CHECK: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i64 0, i64 0 // CHECK-NEXT: [[V0:%.*]] = load i8*, i8** [[A]], // CHECK-NEXT: store i8* [[V0]], i8** [[T0]] - // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i32 0, i32 1 + // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 1 // CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[B]], // CHECK-NEXT: store i8* [[V1]], i8** [[T0]] @@ -83,16 +83,16 @@ void test_dictionary(id k1, id o1, id k2, id o2) { // CHECK: call i8* @objc_retain(i8* // Constructing the arrays - // CHECK: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[KEYS:%[A-Za-z0-9]+]], i32 0, i32 0 + // CHECK: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[KEYS:%[A-Za-z0-9]+]], i64 0, i64 0 // CHECK-NEXT: [[V0:%.*]] = load i8*, i8** [[K1]], // CHECK-NEXT: store i8* [[V0]], i8** [[T0]] - // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i32 0, i32 0 + // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS:%[A-Za-z0-9]+]], i64 0, i64 0 // CHECK-NEXT: [[V1:%.*]] = load i8*, i8** [[O1]], // CHECK-NEXT: store i8* [[V1]], i8** [[T0]] - // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[KEYS]], i32 0, i32 1 + // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[KEYS]], i64 0, i64 1 // CHECK-NEXT: [[V2:%.*]] = load i8*, i8** [[K2]], // CHECK-NEXT: store i8* [[V2]], i8** [[T0]] - // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i32 0, i32 1 + // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [2 x i8*], [2 x i8*]* [[OBJECTS]], i64 0, i64 1 // CHECK-NEXT: [[V3:%.*]] = load i8*, i8** [[O2]], // CHECK-NEXT: store i8* [[V3]], i8** [[T0]] @@ -128,7 +128,7 @@ void test_property(B *b) { // Retain parameter // CHECK: call i8* @objc_retain - // CHECK: [[T0:%.*]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OBJECTS:%.*]], i32 0, i32 0 + // CHECK: [[T0:%.*]] = getelementptr inbounds [1 x i8*], [1 x i8*]* [[OBJECTS:%.*]], i64 0, i64 0 // Invoke 'prop' // CHECK: [[SEL:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES diff --git a/test/CodeGenObjC/arc-loadweakretained-release.m b/test/CodeGenObjC/arc-loadweakretained-release.m index 5d00ace66055..5392abdf8c5f 100644 --- a/test/CodeGenObjC/arc-loadweakretained-release.m +++ b/test/CodeGenObjC/arc-loadweakretained-release.m @@ -66,7 +66,7 @@ void test1(int cond) { // CHECK-NEXT: br i1 [[ICRISNULL1]], label [[ICRDONE:%.*]], label [[ICRWRITEBACK:%.*]] // CHECK: [[TWO:%.*]] = load i8*, i8** [[INCRTEMP]] // CHECK-NEXT: [[THREE:%.*]] = call i8* @objc_storeWeak( -// CHECK-NEXT br label [[ICRDONE]] +// CHECK-NEXT: br label [[ICRDONE]] // CHECK: [[CLEANUPISACTIVE:%.*]] = load i1, i1* [[CONDCLEANUP]] // CHECK-NEXT: br i1 [[CLEANUPISACTIVE]], label [[CLEASNUPACTION:%.*]], label [[CLEANUPDONE:%.*]] diff --git a/test/CodeGenObjC/arc-precise-lifetime.m b/test/CodeGenObjC/arc-precise-lifetime.m index 6dc3ebf54457..42a048307948 100644 --- a/test/CodeGenObjC/arc-precise-lifetime.m +++ b/test/CodeGenObjC/arc-precise-lifetime.m @@ -26,7 +26,8 @@ void test0() { // CHECK-NEXT: ret void } -// rdar://problem/9821110 +// rdar://problem/9821110 - precise lifetime should suppress extension +// rdar://problem/22172983 - should work for calls via property syntax, too @interface Test1 - (char*) interior __attribute__((objc_returns_inner_pointer)); // Should we allow this on properties? Yes! see // rdar://14990439 @@ -34,8 +35,8 @@ void test0() { @end extern Test1 *test1_helper(void); -// CHECK-LABEL: define void @test1a() -void test1a(void) { +// CHECK-LABEL: define void @test1a_message() +void test1a_message(void) { // CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8 // CHECK: [[C:%.*]] = alloca i8*, align 8 // CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* @@ -67,8 +68,43 @@ void test1a(void) { char *c = [(ptr) interior]; } -// CHECK-LABEL: define void @test1b() -void test1b(void) { + +// CHECK-LABEL: define void @test1a_property() +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* + // CHECK: call void @llvm.lifetime.start(i64 8, i8* [[PTRPTR1]]) + // CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]]) + // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]* + // CHECK-NEXT: store [[TEST1]]* [[T3]] + // CHECK-NEXT: [[CPTR1:%.*]] = bitcast i8** [[C]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.start(i64 8, i8* [[CPTR1]]) + // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutorelease(i8* [[T1]]) + // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]* + // CHECK-NEXT: [[T4:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8* + // CHECK-NEXT: [[T6:%.*]] = call i8* bitcast + // CHECK-NEXT: store i8* [[T6]], i8** + // CHECK-NEXT: [[CPTR2:%.*]] = bitcast i8** [[C]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[CPTR2]]) + // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: call void @objc_release(i8* [[T1]]) [[NUW]], !clang.imprecise_release + // CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PTRPTR2]]) + // CHECK-NEXT: ret void + Test1 *ptr = test1_helper(); + char *c = ptr.interior; +} + + +// CHECK-LABEL: define void @test1b_message() +void test1b_message(void) { // CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8 // CHECK: [[C:%.*]] = alloca i8*, align 8 // CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* @@ -94,11 +130,76 @@ void test1b(void) { // CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PTRPTR2]]) // CHECK-NEXT: ret void - __attribute__((objc_precise_lifetime)) Test1 *ptr = test1_helper(); + PRECISE_LIFETIME Test1 *ptr = test1_helper(); char *c = [ptr interior]; } -void test1c(void) { +// CHECK-LABEL: define void @test1b_property() +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* + // CHECK: call void @llvm.lifetime.start(i64 8, i8* [[PTRPTR1]]) + // CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]]) + // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]* + // CHECK-NEXT: store [[TEST1]]* [[T3]] + // CHECK-NEXT: [[CPTR1:%.*]] = bitcast i8** [[C]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.start(i64 8, i8* [[CPTR1]]) + // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[T1:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[T3:%.*]] = call i8* bitcast + // CHECK-NEXT: store i8* [[T3]], i8** + // CHECK-NEXT: [[CPTR2:%.*]] = bitcast i8** [[C]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[CPTR2]]) + // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: call void @objc_release(i8* [[T1]]) [[NUW]] + // CHECK-NOT: clang.imprecise_release + // CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PTRPTR2]]) + // CHECK-NEXT: ret void + PRECISE_LIFETIME Test1 *ptr = test1_helper(); + char *c = ptr.interior; +} + +// CHECK-LABEL: define void @test1c_message() +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* + // CHECK: call void @llvm.lifetime.start(i64 8, i8* [[PTRPTR1]]) + // CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]]) + // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]* + // CHECK-NEXT: store [[TEST1]]* [[T3]] + // CHECK-NEXT: [[PCPTR1:%.*]] = bitcast i8** [[PC]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.start(i64 8, i8* [[PCPTR1]]) + // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutorelease(i8* [[T1]]) + // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]* + // CHECK-NEXT: [[T4:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[T5:%.*]] = bitcast [[TEST1]]* [[T3]] to i8* + // CHECK-NEXT: [[T6:%.*]] = call i8* bitcast + // CHECK-NEXT: store i8* [[T6]], i8** + // CHECK-NEXT: [[PCPTR2:%.*]] = bitcast i8** [[PC]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PCPTR2]]) + // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: call void @objc_release(i8* [[T1]]) [[NUW]], !clang.imprecise_release + // CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PTRPTR2]]) + // CHECK-NEXT: ret void + Test1 *ptr = test1_helper(); + char *pc = [ptr PropertyReturnsInnerPointer]; +} + +// CHECK-LABEL: define void @test1c_property() +void test1c_property(void) { // CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8 // CHECK: [[PC:%.*]] = alloca i8*, align 8 // CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* @@ -130,7 +231,38 @@ void test1c(void) { char *pc = ptr.PropertyReturnsInnerPointer; } -void test1d(void) { +// CHECK-LABEL: define void @test1d_message() +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* + // CHECK: call void @llvm.lifetime.start(i64 8, i8* [[PTRPTR1]]) + // CHECK: [[T0:%.*]] = call [[TEST1:%.*]]* @test1_helper() + // CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]]) + // CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[TEST1]]* + // CHECK-NEXT: store [[TEST1]]* [[T3]] + // CHECK-NEXT: [[PCPTR1:%.*]] = bitcast i8** [[PC]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.start(i64 8, i8* [[PCPTR1]]) + // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[SEVEN:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_ + // CHECK-NEXT: [[EIGHT:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* + // CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[EIGHT]], i8* [[SEVEN]]) + // CHECK-NEXT: store i8* [[CALL1]], i8** + // CHECK-NEXT: [[PCPTR2:%.*]] = bitcast i8** [[PC]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PCPTR2]]) + // CHECK-NEXT: [[NINE:%.*]] = load [[TEST1]]*, [[TEST1]]** + // CHECK-NEXT: [[TEN:%.*]] = bitcast [[TEST1]]* [[NINE]] to i8* + // CHECK-NEXT: call void @objc_release(i8* [[TEN]]) + // CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* + // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PTRPTR2]]) + // CHECK-NEXT: ret void + PRECISE_LIFETIME Test1 *ptr = test1_helper(); + char *pc = [ptr PropertyReturnsInnerPointer]; +} + +// CHECK-LABEL: define void @test1d_property() +void test1d_property(void) { // CHECK: [[PTR:%.*]] = alloca [[PTR_T:%.*]]*, align 8 // CHECK: [[PC:%.*]] = alloca i8*, align 8 // CHECK: [[PTRPTR1:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* @@ -143,11 +275,8 @@ void test1d(void) { // CHECK-NEXT: [[PCPTR1:%.*]] = bitcast i8** [[PC]] to i8* // CHECK-NEXT: call void @llvm.lifetime.start(i64 8, i8* [[PCPTR1]]) // CHECK-NEXT: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** - // CHECK-NEXT: [[T2:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* - // CHECK-NEXT: [[T3:%.*]] = call i8* @objc_retainAutorelease - // CHECK-NEXT: [[SIX:%.*]] = bitcast i8* [[T3]] to [[TEST1]]* // CHECK-NEXT: [[SEVEN:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_ - // CHECK-NEXT: [[EIGHT:%.*]] = bitcast [[TEST1]]* [[SIX]] to i8* + // CHECK-NEXT: [[EIGHT:%.*]] = bitcast [[TEST1]]* [[T0]] to i8* // CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[EIGHT]], i8* [[SEVEN]]) // CHECK-NEXT: store i8* [[CALL1]], i8** // CHECK-NEXT: [[PCPTR2:%.*]] = bitcast i8** [[PC]] to i8* @@ -158,7 +287,7 @@ void test1d(void) { // CHECK-NEXT: [[PTRPTR2:%.*]] = bitcast [[PTR_T]]** [[PTR]] to i8* // CHECK-NEXT: call void @llvm.lifetime.end(i64 8, i8* [[PTRPTR2]]) // CHECK-NEXT: ret void - __attribute__((objc_precise_lifetime)) Test1 *ptr = test1_helper(); + PRECISE_LIFETIME Test1 *ptr = test1_helper(); char *pc = ptr.PropertyReturnsInnerPointer; } diff --git a/test/CodeGenObjC/arc-weak.m b/test/CodeGenObjC/arc-weak.m new file mode 100644 index 000000000000..59f8d1d69300 --- /dev/null +++ b/test/CodeGenObjC/arc-weak.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -o - %s | FileCheck %s + +__attribute((objc_root_class)) @interface A @end +@interface B : A @end + +// rdar://problem/23559789 +// Ensure that type differences don't cause an assert here. +void test0(__weak B **src) { + __weak A *dest = *src; +} +// CHECK-LABEL: define void @test0 +// CHECK: [[SRC:%.*]] = alloca [[B:%.*]]**, align 8 +// CHECK: [[DEST:%.*]] = alloca [[A:%.*]]*, align 8 +// CHECK: [[T0:%.*]] = load [[B]]**, [[B]]*** [[SRC]], align 8 +// CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]** [[T0]] to [[A]]** +// CHECK-NEXT: [[T2:%.*]] = bitcast [[A]]** [[DEST]] to i8** +// CHECK-NEXT: [[T3:%.*]] = bitcast [[A]]** [[T1]] to i8** +// CHECK-NEXT: call void @objc_copyWeak(i8** [[T2]], i8** [[T3]]) +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]** [[DEST]] to i8** +// CHECK: call void @objc_destroyWeak(i8** [[T0]]) diff --git a/test/CodeGenObjC/arc.ll b/test/CodeGenObjC/arc.ll new file mode 100644 index 000000000000..caafcff05246 --- /dev/null +++ b/test/CodeGenObjC/arc.ll @@ -0,0 +1,27 @@ +; RUN: %clang_cc1 -Os -emit-llvm -fobjc-arc -o - %s | FileCheck %s + +target triple = "x86_64-apple-darwin10" + +declare i8* @objc_retain(i8*) +declare void @objc_release(i8*) + +; CHECK-LABEL: define void @test( +; CHECK-NOT: @objc_ +; CHECK: } +define void @test(i8* %x, i1* %p) nounwind { +entry: + br label %loop + +loop: + call i8* @objc_retain(i8* %x) + %q = load i1, i1* %p + br i1 %q, label %loop.more, label %exit + +loop.more: + call void @objc_release(i8* %x) + br label %loop + +exit: + call void @objc_release(i8* %x) + ret void +} diff --git a/test/CodeGenObjC/arc.m b/test/CodeGenObjC/arc.m index 3aafefd43cdc..f756df1460f3 100644 --- a/test/CodeGenObjC/arc.m +++ b/test/CodeGenObjC/arc.m @@ -515,7 +515,7 @@ void test19() { // CHECK-NEXT: [[CALL:%.*]] = call i8* @test19_helper() // CHECK-NEXT: [[T1:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[CALL]]) [[NUW]] - // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[X]], i32 0, i64 2 + // CHECK-NEXT: [[SLOT:%.*]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[X]], i64 0, i64 2 // CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[SLOT]] // CHECK-NEXT: store i8* [[T1]], i8** [[SLOT]] // CHECK-NEXT: call void @objc_release(i8* [[T0]]) [[NUW]] @@ -556,7 +556,7 @@ void test20(unsigned n) { // Zero-initialize. // CHECK-NEXT: [[T0:%.*]] = bitcast i8** [[VLA]] to i8* // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 [[DIM]], 8 - // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 [[T1]], i32 8, i1 false) + // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 [[T1]], i32 16, i1 false) // Destroy. // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds i8*, i8** [[VLA]], i64 [[DIM]] @@ -599,7 +599,7 @@ void test21(unsigned n) { // CHECK-NEXT: [[T0:%.*]] = bitcast [3 x i8*]* [[VLA]] to i8* // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 2, [[DIM]] // CHECK-NEXT: [[T2:%.*]] = mul nuw i64 [[T1]], 24 - // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 [[T2]], i32 8, i1 false) + // CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* [[T0]], i8 0, i64 [[T2]], i32 16, i1 false) // Destroy. // CHECK-NEXT: [[T0:%.*]] = mul nuw i64 2, [[DIM]] diff --git a/test/CodeGenObjC/attr-noreturn.m b/test/CodeGenObjC/attr-noreturn.m new file mode 100644 index 000000000000..c413d0557ad2 --- /dev/null +++ b/test/CodeGenObjC/attr-noreturn.m @@ -0,0 +1,99 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-MRC +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-ARC + +__attribute__((objc_root_class)) +@interface Root +- (instancetype) init; +@end + +@interface Base : Root +@end + +@interface Middle : Base ++ (void) abort __attribute__((noreturn)); +- (void) fail __attribute__((noreturn)); +@end + +@interface Derived : Middle +@end + +// An arbitrary instance pointer may be null. +void testInstanceMethod(Derived *x) { + [x fail]; +} +// CHECK-LABEL: @testInstanceMethod +// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}){{$}} + +// A direct call of a class method will normally never have a null receiver. +void testClassMethod() { + [Derived abort]; +} +// CHECK-LABEL: @testClassMethod +// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) [[NORETURN:#[0-9]+]] + +__attribute__((weak_import)) +@interface WeakMiddle : Base +@end + +@interface WeakDerived : WeakMiddle ++ (void) abort __attribute__((noreturn)); +@end + +// The class pointer of a weakly-imported class may be null. +void testWeakImport() { + [WeakDerived abort]; +} +// CHECK-LABEL: @testWeakImport +// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}){{$}} + +@interface Derived (MyMethods) +@end + +@implementation Derived (MyMethods) + +// In general, self can be reassigned, so we can't make stronger assumptions. +// But ARC makes self const in an ordinary method. +// TODO: do the analysis to take advantage of the dominant case where +// self is not reassigned. +- (void) testSelfInstanceMethod { + [self fail]; +} +// CHECK-LABEL: [Derived(MyMethods) testSelfInstanceMethod] +// CHECK-MRC: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}){{$}} +// CHECK-ARC: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) [[NORETURN]] + +// The ARC rule doesn't apply in -init methods. +- (id) initWhileTestingSelfInstanceMethod { + self = [super init]; + [self fail]; + return self; +} +// CHECK-LABEL: [Derived(MyMethods) initWhileTestingSelfInstanceMethod] +// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}){{$}} + +// Same thing applies to class methods. ++ (void) testSelfClassMethod { + [self abort]; +} +// CHECK-LABEL: [Derived(MyMethods) testSelfClassMethod] +// CHECK-MRC: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}){{$}} +// CHECK-ARC: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) [[NORETURN]] + +// Super invocations may never be used with a null pointer; this is a +// constraint on user code when it isn't enforced by the ARC const-self +// rule. +- (void) testSuperInstanceMethod { + [super fail]; +} +// CHECK-LABEL: [Derived(MyMethods) testSuperInstanceMethod] +// CHECK: call void bitcast (i8* ([[SUPER_T:%.*]]*, i8*, ...)* @objc_msgSendSuper2 to void ([[SUPER_T]]*, i8*)*)([[SUPER_T]]* {{.*}}, i8* {{.*}}) [[NORETURN]] + ++ (void) testSuperClassMethod { + [super abort]; +} +// CHECK-LABEL: [Derived(MyMethods) testSuperClassMethod] +// CHECK: call void bitcast (i8* ([[SUPER_T]]*, i8*, ...)* @objc_msgSendSuper2 to void ([[SUPER_T]]*, i8*)*)([[SUPER_T]]* {{.*}}, i8* {{.*}}) [[NORETURN]] +@end + +// CHECK: attributes [[NORETURN]] = { noreturn } +
\ No newline at end of file diff --git a/test/CodeGenObjC/block-byref-debuginfo.m b/test/CodeGenObjC/block-byref-debuginfo.m index aa916289449e..f11566634294 100644 --- a/test/CodeGenObjC/block-byref-debuginfo.m +++ b/test/CodeGenObjC/block-byref-debuginfo.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -g -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -debug-info-kind=limited -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s // rdar://problem/14386148 // Test that the foo is aligned at an 8 byte boundary in the DWARF diff --git a/test/CodeGenObjC/block-var-layout.m b/test/CodeGenObjC/block-var-layout.m index 171df7b27489..00409f3891b9 100644 --- a/test/CodeGenObjC/block-var-layout.m +++ b/test/CodeGenObjC/block-var-layout.m @@ -159,7 +159,7 @@ void notifyBlock(id dependentBlock) { void test_empty_block() { // 01 00 -// CHECK-LP64: block variable layout for block: 0x01, 0x00 +// CHECK-LP64: block variable layout for block: 0x01, 0x30, 0x00 void (^wrapperBlock)() = ^() { }; wrapperBlock(); diff --git a/test/CodeGenObjC/blocks-ivar-debug.m b/test/CodeGenObjC/blocks-ivar-debug.m index d0cf1f10f729..4d03fef54960 100644 --- a/test/CodeGenObjC/blocks-ivar-debug.m +++ b/test/CodeGenObjC/blocks-ivar-debug.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -g %s -fblocks -S -o %t +// RUN: %clang_cc1 -debug-info-kind=limited %s -fblocks -S -o %t // Radar 7959934 @interface NSObject { diff --git a/test/CodeGenObjC/blocks.m b/test/CodeGenObjC/blocks.m index 091331e8b2bf..d485bb4053b0 100644 --- a/test/CodeGenObjC/blocks.m +++ b/test/CodeGenObjC/blocks.m @@ -84,7 +84,7 @@ void test2(Test2 *x) { // CHECK: [[T0:%.*]] = bitcast [[WEAK_T]]* [[WEAKX]] to i8* // CHECK: call void @_Block_object_dispose(i8* [[T0]], i32 8) - __weak __block Test2 *weakX = x; + __attribute__((objc_gc(weak))) __block Test2 *weakX = x; test2_helper(^{ [weakX destroy]; }); } diff --git a/test/CodeGenObjC/catch-lexical-block.m b/test/CodeGenObjC/catch-lexical-block.m index ae49405160df..a06aa83fe323 100644 --- a/test/CodeGenObjC/catch-lexical-block.m +++ b/test/CodeGenObjC/catch-lexical-block.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -g -fobjc-exceptions -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -debug-info-kind=limited -fobjc-exceptions -emit-llvm %s -o - | FileCheck %s @interface Foo @end void f0() { @try { @@ -10,6 +10,6 @@ void f0() { // We should have 3 lexical blocks here at the moment, including one // for the catch block. // CHECK: !DILexicalBlock( -// CHECK: !DILocalVariable(tag: DW_TAG_auto_variable +// CHECK: !DILocalVariable( // CHECK: !DILexicalBlock( // CHECK: !DILexicalBlock( diff --git a/test/CodeGenObjC/debug-info-block-captured-self.m b/test/CodeGenObjC/debug-info-block-captured-self.m index fb9d7c2045e6..e142a0bceb8f 100644 --- a/test/CodeGenObjC/debug-info-block-captured-self.m +++ b/test/CodeGenObjC/debug-info-block-captured-self.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -g -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s +// RUN: %clang_cc1 -fblocks -debug-info-kind=limited -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s // // Test that debug location is generated for a captured "self" inside // a block. @@ -53,19 +53,20 @@ typedef enum { // CHECK: define internal void {{.*}}_block_invoke{{.*}} // CHECK: %[[MEM1:.*]] = alloca i8*, align 8 // CHECK-NEXT: %[[MEM2:.*]] = alloca i8*, align 8 +// CHECK-NEXT: [[DBGADDR:%.*]] = alloca [[BLOCK_T:<{.*}>]]*, align 8 // CHECK: store i8* [[BLOCK_DESC:%.*]], i8** %[[MEM1]], align 8 // CHECK: %[[TMP0:.*]] = load i8*, i8** %[[MEM1]] // CHECK: call void @llvm.dbg.value(metadata i8* %[[TMP0]], i64 0, metadata ![[BDMD:[0-9]+]], metadata !{{.*}}) // CHECK: call void @llvm.dbg.declare(metadata i8* [[BLOCK_DESC]], metadata ![[BDMD:[0-9]+]], metadata !{{.*}}) -// CHECK: %[[TMP1:.*]] = bitcast -// CHECK-NEXT: store -// CHECK: call void @llvm.dbg.declare(metadata <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, %0* }>** {{[^,]*}}, metadata ![[SELF:.*]], metadata !{{.*}}) +// CHECK: store [[BLOCK_T]]* {{%.*}}, [[BLOCK_T]]** [[DBGADDR]], align 8 +// CHECK: call void @llvm.dbg.declare(metadata [[BLOCK_T]]** [[DBGADDR]], metadata ![[SELF:.*]], metadata !{{.*}}) // make sure we are still in the same function // CHECK: define {{.*}}__copy_helper_block_ // Metadata // CHECK: ![[MAIN:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Main" // CHECK-SAME: line: 23, // CHECK: ![[PMAIN:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[MAIN]], -// CHECK: ![[BDMD]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: ".block_descriptor" -// CHECK: ![[SELF]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "self" +// CHECK: ![[BDMD]] = !DILocalVariable(name: ".block_descriptor", arg: +// CHECK: ![[SELF]] = !DILocalVariable(name: "self" +// CHECK-NOT: arg: // CHECK-SAME: line: 40, diff --git a/test/CodeGenObjC/debug-info-block-helper.m b/test/CodeGenObjC/debug-info-block-helper.m index ea68cb1cf38e..107830782c3c 100644 --- a/test/CodeGenObjC/debug-info-block-helper.m +++ b/test/CodeGenObjC/debug-info-block-helper.m @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -debug-info-kind=limited -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s -o - | FileCheck %s extern void foo(void(^)(void)); // CHECK: !DISubprogram(name: "__destroy_helper_block_" diff --git a/test/CodeGenObjC/debug-info-block-line.m b/test/CodeGenObjC/debug-info-block-line.m index 9ba22bcd24fc..d4c409411c6a 100644 --- a/test/CodeGenObjC/debug-info-block-line.m +++ b/test/CodeGenObjC/debug-info-block-line.m @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -fobjc-arc -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s // rdar://11562117 typedef unsigned int NSUInteger; diff --git a/test/CodeGenObjC/debug-info-block-type.m b/test/CodeGenObjC/debug-info-block-type.m index 35c92dc64bda..1f137ed9dfc2 100644 --- a/test/CodeGenObjC/debug-info-block-type.m +++ b/test/CodeGenObjC/debug-info-block-type.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin14 -x objective-c < %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -debug-info-kind=limited -triple x86_64-apple-darwin14 -x objective-c < %s -o - | FileCheck %s #define nil ((void*) 0) typedef signed char BOOL; // CHECK: ![[BOOL:[0-9]+]] = !DIDerivedType(tag: DW_TAG_typedef, name: "BOOL" diff --git a/test/CodeGenObjC/debug-info-blocks.m b/test/CodeGenObjC/debug-info-blocks.m index 5514c5164c9b..0bf566395aa9 100644 --- a/test/CodeGenObjC/debug-info-blocks.m +++ b/test/CodeGenObjC/debug-info-blocks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-dispatch-method=mixed -x objective-c < %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -debug-info-kind=limited -triple x86_64-apple-darwin10 -fobjc-dispatch-method=mixed -x objective-c < %s -o - | FileCheck %s // rdar://problem/9279956 // Test that we generate the proper debug location for a captured self. @@ -24,9 +24,9 @@ // CHECK-DAG: [[DBG_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]]) // CHECK-DAG: [[COPY_LINE]] = !DILocation(line: 0, scope: ![[COPY_SP:[0-9]+]]) -// CHECK-DAG: [[COPY_SP]] = !DISubprogram(name: "__copy_helper_block_" +// CHECK-DAG: [[COPY_SP]] = distinct !DISubprogram(name: "__copy_helper_block_" // CHECK-DAG: [[DESTROY_LINE]] = !DILocation(line: 0, scope: ![[DESTROY_SP:[0-9]+]]) -// CHECK-DAG: [[DESTROY_SP]] = !DISubprogram(name: "__destroy_helper_block_" +// CHECK-DAG: [[DESTROY_SP]] = distinct !DISubprogram(name: "__destroy_helper_block_" typedef unsigned int NSUInteger; @protocol NSObject @@ -61,8 +61,8 @@ static void run(void (^block)(void)) { if ((self = [super init])) { run(^{ - // CHECK-DAG: ![[SELF]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "self"{{.*}}, line: [[@LINE+4]], - // CHECK-DAG: ![[D]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "d"{{.*}}, line: [[@LINE+1]], + // CHECK-DAG: ![[SELF]] = !DILocalVariable(name: "self", scope:{{.*}}, line: [[@LINE+4]], + // CHECK-DAG: ![[D]] = !DILocalVariable(name: "d", scope:{{.*}}, line: [[@LINE+1]], NSMutableDictionary *d = [[NSMutableDictionary alloc] init]; ivar = 42 + (int)[d count]; }); diff --git a/test/CodeGenObjC/debug-info-class-extension.m b/test/CodeGenObjC/debug-info-class-extension.m index 0d1b720aa677..a27810cce743 100644 --- a/test/CodeGenObjC/debug-info-class-extension.m +++ b/test/CodeGenObjC/debug-info-class-extension.m @@ -1,5 +1,5 @@ // FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -debug-info-kind=limited %s -o - | FileCheck %s // CHECK: AT_APPLE_objc_complete_type diff --git a/test/CodeGenObjC/debug-info-class-extension2.m b/test/CodeGenObjC/debug-info-class-extension2.m index 383390c4ab31..d4750c120f60 100644 --- a/test/CodeGenObjC/debug-info-class-extension2.m +++ b/test/CodeGenObjC/debug-info-class-extension2.m @@ -1,5 +1,5 @@ // FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -debug-info-kind=limited %s -o - | FileCheck %s // CHECK: AT_APPLE_objc_complete_type @interface Foo {} @end diff --git a/test/CodeGenObjC/debug-info-class-extension3.m b/test/CodeGenObjC/debug-info-class-extension3.m index f49bef82a24f..a9cf6f6a5c59 100644 --- a/test/CodeGenObjC/debug-info-class-extension3.m +++ b/test/CodeGenObjC/debug-info-class-extension3.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -masm-verbose -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -masm-verbose -S -debug-info-kind=limited %s -o - | FileCheck %s // CHECK-NOT: AT_APPLE_objc_complete_type diff --git a/test/CodeGenObjC/debug-info-crash-2.m b/test/CodeGenObjC/debug-info-crash-2.m index 9e80580796a0..e464cc730b88 100644 --- a/test/CodeGenObjC/debug-info-crash-2.m +++ b/test/CodeGenObjC/debug-info-crash-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -g -S %s -o - +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -debug-info-kind=limited -S %s -o - // REQUIRES: x86-registered-target @class Bar; diff --git a/test/CodeGenObjC/debug-info-crash.m b/test/CodeGenObjC/debug-info-crash.m index abbe2eb651c6..a8745d6d5ad3 100644 --- a/test/CodeGenObjC/debug-info-crash.m +++ b/test/CodeGenObjC/debug-info-crash.m @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -g -S %s -o - +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -debug-info-kind=limited -S %s -o - // rdar://7556129 @implementation test diff --git a/test/CodeGenObjC/debug-info-default-synth-ivar.m b/test/CodeGenObjC/debug-info-default-synth-ivar.m index e9045eca4388..fb2641265bde 100644 --- a/test/CodeGenObjC/debug-info-default-synth-ivar.m +++ b/test/CodeGenObjC/debug-info-default-synth-ivar.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -g %s -o %t +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -debug-info-kind=limited %s -o %t // RUN: grep DW_TAG_member %t | count 5 // rdar://8493239 diff --git a/test/CodeGenObjC/debug-info-getter-name.m b/test/CodeGenObjC/debug-info-getter-name.m index 1d7f545f34b6..7915a2fdd259 100644 --- a/test/CodeGenObjC/debug-info-getter-name.m +++ b/test/CodeGenObjC/debug-info-getter-name.m @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -fexceptions -fobjc-exceptions -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin10 -fexceptions -fobjc-exceptions -debug-info-kind=limited %s -o - | FileCheck %s // CHECK: !DISubprogram(name: "-[InstanceVariablesEverywhereButTheInterface someString]" diff --git a/test/CodeGenObjC/debug-info-id-with-protocol.m b/test/CodeGenObjC/debug-info-id-with-protocol.m index 836e456b2352..8974e2764783 100644 --- a/test/CodeGenObjC/debug-info-id-with-protocol.m +++ b/test/CodeGenObjC/debug-info-id-with-protocol.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s __attribute((objc_root_class)) @interface NSObject { id isa; } @@ -38,10 +38,10 @@ int main() // Verify that the debug type for both variables is 'id'. // CHECK: ![[IDTYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_typedef, name: "id" // -// CHECK: !DILocalVariable(tag: DW_TAG_arg_variable, name: "bad_carrier" +// CHECK: !DILocalVariable(name: "bad_carrier", arg: // CHECK-NOT: line: // CHECK-SAME: type: ![[IDTYPE]] // -// CHECK: !DILocalVariable(tag: DW_TAG_arg_variable, name: "good_carrier" +// CHECK: !DILocalVariable(name: "good_carrier", arg: // CHECK-NOT: line: // CHECK-SAME: type: ![[IDTYPE]] diff --git a/test/CodeGenObjC/debug-info-impl.m b/test/CodeGenObjC/debug-info-impl.m index 556bf0ee63f7..a648ea17f64f 100644 --- a/test/CodeGenObjC/debug-info-impl.m +++ b/test/CodeGenObjC/debug-info-impl.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -debug-info-kind=limited -S -emit-llvm %s -o - | FileCheck %s @interface NSObject { struct objc_object *isa; } diff --git a/test/CodeGenObjC/debug-info-instancetype.m b/test/CodeGenObjC/debug-info-instancetype.m index c96153edb9dc..be454e38c0b3 100644 --- a/test/CodeGenObjC/debug-info-instancetype.m +++ b/test/CodeGenObjC/debug-info-instancetype.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s // rdar://problem/13359718 // Substitute the actual type for a method returning instancetype. @interface NSObject diff --git a/test/CodeGenObjC/debug-info-ivars-extension.m b/test/CodeGenObjC/debug-info-ivars-extension.m index fe658f009f11..0709d2ad24d3 100644 --- a/test/CodeGenObjC/debug-info-ivars-extension.m +++ b/test/CodeGenObjC/debug-info-ivars-extension.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s // Make sure we generate debug symbols for ivars added by a class extension. diff --git a/test/CodeGenObjC/debug-info-ivars-indirect.m b/test/CodeGenObjC/debug-info-ivars-indirect.m index 0c644c7fe344..b227bc648644 100644 --- a/test/CodeGenObjC/debug-info-ivars-indirect.m +++ b/test/CodeGenObjC/debug-info-ivars-indirect.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s // Make sure we generate debug symbols for an indirectly referenced // extension to an interface. diff --git a/test/CodeGenObjC/debug-info-ivars-private.m b/test/CodeGenObjC/debug-info-ivars-private.m index d3d8cdc3e786..f533ef3adc20 100644 --- a/test/CodeGenObjC/debug-info-ivars-private.m +++ b/test/CodeGenObjC/debug-info-ivars-private.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s // Debug symbols for private ivars. This test ensures that we are // generating debug info for ivars added by the implementation. diff --git a/test/CodeGenObjC/debug-info-ivars.m b/test/CodeGenObjC/debug-info-ivars.m index aea3edaa8ae6..c6e544ae1c1c 100644 --- a/test/CodeGenObjC/debug-info-ivars.m +++ b/test/CodeGenObjC/debug-info-ivars.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s __attribute((objc_root_class)) @interface NSObject { id isa; diff --git a/test/CodeGenObjC/debug-info-lifetime-crash.m b/test/CodeGenObjC/debug-info-lifetime-crash.m index bbd7dd4ac3b1..668af631a376 100644 --- a/test/CodeGenObjC/debug-info-lifetime-crash.m +++ b/test/CodeGenObjC/debug-info-lifetime-crash.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple arm-apple-ios -emit-llvm -g -fblocks -fobjc-runtime=ios-7.0.0 -fobjc-arc %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple arm-apple-ios -emit-llvm -debug-info-kind=limited -fblocks -fobjc-runtime=ios-7.0.0 -fobjc-arc %s -o - | FileCheck %s // rdar://problem/14990656 @protocol NSObject - (id)copy; @@ -13,12 +13,12 @@ { // The debug type for these two will be identical, because we do not // actually emit the ownership qualifier. - // CHECK: !DILocalVariable(tag: DW_TAG_auto_variable, name: "weakSelf", + // CHECK: !DILocalVariable(name: "weakSelf", // CHECK-SAME: line: [[@LINE+2]] // CHECK-SAME: type: ![[SELFTY:[0-9]+]] __attribute__((objc_ownership(weak))) __typeof(self) weakSelf = self; Block = [^{ - // CHECK: !DILocalVariable(tag: DW_TAG_auto_variable, name: "strongSelf", + // CHECK: !DILocalVariable(name: "strongSelf", // CHECK-SAME: line: [[@LINE+2]] // CHECK-SAME: type: ![[SELFTY]] __attribute__((objc_ownership(strong))) __typeof(self) strongSelf = weakSelf; diff --git a/test/CodeGenObjC/debug-info-linkagename.m b/test/CodeGenObjC/debug-info-linkagename.m index b606e5d5dfca..94d438a03e2e 100644 --- a/test/CodeGenObjC/debug-info-linkagename.m +++ b/test/CodeGenObjC/debug-info-linkagename.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -g -S -o %t %s +// RUN: %clang_cc1 -debug-info-kind=limited -S -o %t %s // RUN: not grep "001-[F bar" %t // Linkage name should not use 001 prefix in debug info. diff --git a/test/CodeGenObjC/debug-info-nested-blocks.m b/test/CodeGenObjC/debug-info-nested-blocks.m index 5c5958cf3096..fe6c55bfcd6f 100644 --- a/test/CodeGenObjC/debug-info-nested-blocks.m +++ b/test/CodeGenObjC/debug-info-nested-blocks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -gdwarf-2 -fblocks -o - -x objective-c %s| FileCheck %s +// RUN: %clang_cc1 -emit-llvm -dwarf-version=2 -debug-info-kind=limited -fblocks -o - -x objective-c %s| FileCheck %s // This code triggered a bug where a dbg.declare intrinsic ended up with the // wrong parent and subsequently failed the Verifier. void baz(id b); diff --git a/test/CodeGenObjC/debug-info-property-accessors.m b/test/CodeGenObjC/debug-info-property-accessors.m index 274bf6e74db6..d05010095d29 100644 --- a/test/CodeGenObjC/debug-info-property-accessors.m +++ b/test/CodeGenObjC/debug-info-property-accessors.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -x objective-c -g -triple x86_64-apple-macosx10.8.0 %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -x objective-c -debug-info-kind=limited -triple x86_64-apple-macosx10.8.0 %s -o - | FileCheck %s // // rdar://problem/14035789 // diff --git a/test/CodeGenObjC/debug-info-property-class-extension.m b/test/CodeGenObjC/debug-info-property-class-extension.m new file mode 100644 index 000000000000..ea2551799f30 --- /dev/null +++ b/test/CodeGenObjC/debug-info-property-class-extension.m @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s + +// Checks debug info for properties from class extensions for a few cases. + + +// Readonly property in interface made readwrite in a category, with @impl +// The interesting bit is that when the ivar debug info is generated, the corresponding +// property is looked up and also gets debug info. If the debug info from the interface's +// declaration and from the ivar doesn't match, this will end up with two DIObjCProperty +// entries which would be bad. +@interface FooROWithImpl +// CHECK-NOT: !DIObjCProperty(name: "evolvingpropwithimpl"{{.*}}line: [[@LINE+1]] +@property (readonly) int evolvingpropwithimpl; +@end +@interface FooROWithImpl () +// CHECK: !DIObjCProperty(name: "evolvingpropwithimpl"{{.*}}line: [[@LINE+1]] +@property int evolvingpropwithimpl; +@end +@implementation FooROWithImpl +@synthesize evolvingpropwithimpl = _evolvingpropwithimpl; +@end + + +// Simple property from a class extension: +@interface Foo +@end +@interface Foo() +// CHECK: !DIObjCProperty(name: "myprop"{{.*}}line: [[@LINE+1]] +@property int myprop; +@end +// There's intentionally no @implementation for Foo, because that would +// generate debug info for the property via the backing ivar. + + +// Readonly property in interface made readwrite in a category: +@interface FooRO +// Shouldn't be here but in the class extension below. +// CHECK-NOT: !DIObjCProperty(name: "evolvingprop"{{.*}}line: [[@LINE+1]] +@property (readonly) int evolvingprop; +@end +@interface FooRO () +// CHECK: !DIObjCProperty(name: "evolvingprop"{{.*}}line: [[@LINE+1]] +@property int evolvingprop; +@end + + +// This references types in this file to force emission of their debug info. +void foo(Foo *f, FooRO *g, FooROWithImpl* h) { } diff --git a/test/CodeGenObjC/debug-info-property.m b/test/CodeGenObjC/debug-info-property.m index 6e2dcda8b54b..9b471be23dbd 100644 --- a/test/CodeGenObjC/debug-info-property.m +++ b/test/CodeGenObjC/debug-info-property.m @@ -1,5 +1,5 @@ // FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -debug-info-kind=limited %s -o - | FileCheck %s // CHECK: AT_APPLE_property_name // CHECK: AT_APPLE_property_attribute diff --git a/test/CodeGenObjC/debug-info-property2.m b/test/CodeGenObjC/debug-info-property2.m index 41140dc20425..6a15922c932c 100644 --- a/test/CodeGenObjC/debug-info-property2.m +++ b/test/CodeGenObjC/debug-info-property2.m @@ -1,5 +1,5 @@ // FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -debug-info-kind=limited %s -o - | FileCheck %s // CHECK: AT_APPLE_property_name @interface C { diff --git a/test/CodeGenObjC/debug-info-property3.m b/test/CodeGenObjC/debug-info-property3.m index 68cb234878a3..20880600a781 100644 --- a/test/CodeGenObjC/debug-info-property3.m +++ b/test/CodeGenObjC/debug-info-property3.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -S -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s @interface I1 // CHECK: !DIObjCProperty(name: "p1" diff --git a/test/CodeGenObjC/debug-info-property4.m b/test/CodeGenObjC/debug-info-property4.m index 2057d4d1d974..f862c85b344d 100644 --- a/test/CodeGenObjC/debug-info-property4.m +++ b/test/CodeGenObjC/debug-info-property4.m @@ -1,5 +1,5 @@ // FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -debug-info-kind=limited %s -o - | FileCheck %s // CHECK: AT_APPLE_property_name // CHECK-NOT: AT_APPLE_property_getter diff --git a/test/CodeGenObjC/debug-info-property5.m b/test/CodeGenObjC/debug-info-property5.m index 126d0a2677e2..191da9c16fcc 100644 --- a/test/CodeGenObjC/debug-info-property5.m +++ b/test/CodeGenObjC/debug-info-property5.m @@ -1,5 +1,5 @@ // FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -masm-verbose -S -debug-info-kind=limited %s -o - | FileCheck %s // CHECK: AT_APPLE_property_name // CHECK: AT_APPLE_property_getter diff --git a/test/CodeGenObjC/debug-info-pubtypes.m b/test/CodeGenObjC/debug-info-pubtypes.m index e95ddab9049e..ce3896f652fe 100644 --- a/test/CodeGenObjC/debug-info-pubtypes.m +++ b/test/CodeGenObjC/debug-info-pubtypes.m @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -g -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "H" // CHECK-SAME: line: [[@LINE+1]], diff --git a/test/CodeGenObjC/debug-info-selector.m b/test/CodeGenObjC/debug-info-selector.m index 67642ac3bebe..13130b1bde5e 100644 --- a/test/CodeGenObjC/debug-info-selector.m +++ b/test/CodeGenObjC/debug-info-selector.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s // Radar 8494540 // CHECK: objc_selector diff --git a/test/CodeGenObjC/debug-info-self.m b/test/CodeGenObjC/debug-info-self.m index 225a0bdef63f..0391ac477d64 100644 --- a/test/CodeGenObjC/debug-info-self.m +++ b/test/CodeGenObjC/debug-info-self.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited %s -o - | FileCheck %s // self and _cmd are marked as DW_AT_artificial. // myarg is not marked as DW_AT_artificial. @@ -14,15 +14,15 @@ } @end -// CHECK: !DILocalVariable(tag: DW_TAG_arg_variable, name: "self", arg: 1, +// CHECK: !DILocalVariable(name: "self", arg: 1, // CHECK-SAME: scope: ![[CTOR:[0-9]+]] // CHECK-NOT: line: // CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer{{[,)]}} -// CHECK: !DILocalVariable(tag: DW_TAG_arg_variable, name: "_cmd", arg: 2, +// CHECK: !DILocalVariable(name: "_cmd", arg: 2, // CHECK-SAME: scope: ![[CTOR]] // CHECK-NOT: line: // CHECK-SAME: flags: DIFlagArtificial{{[,)]}} -// CHECK: !DILocalVariable(tag: DW_TAG_arg_variable, name: "myarg", arg: 3, +// CHECK: !DILocalVariable(name: "myarg", arg: 3, // CHECK-SAME: scope: ![[CTOR]] // CHECK-SAME: line: 11 // CHECK-NOT: flags: diff --git a/test/CodeGenObjC/debug-info-static-var.m b/test/CodeGenObjC/debug-info-static-var.m index 50334250dfae..331ab0a283a8 100644 --- a/test/CodeGenObjC/debug-info-static-var.m +++ b/test/CodeGenObjC/debug-info-static-var.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -g -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s // Radar 8801045 // Do not emit AT_MIPS_linkage_name for static variable i diff --git a/test/CodeGenObjC/debug-info-synthesis.m b/test/CodeGenObjC/debug-info-synthesis.m index 2bf001b28cba..8d2846e7312b 100644 --- a/test/CodeGenObjC/debug-info-synthesis.m +++ b/test/CodeGenObjC/debug-info-synthesis.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -g -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -w -triple x86_64-apple-darwin10 %s -o - | FileCheck %s # 1 "foo.m" 1 # 1 "foo.m" 2 # 1 "./foo.h" 1 diff --git a/test/CodeGenObjC/debug-info-variadic-method.m b/test/CodeGenObjC/debug-info-variadic-method.m index 828d4dc4a164..d57019810839 100644 --- a/test/CodeGenObjC/debug-info-variadic-method.m +++ b/test/CodeGenObjC/debug-info-variadic-method.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -o - -emit-llvm -g %s | FileCheck %s +// RUN: %clang_cc1 -o - -emit-llvm -debug-info-kind=limited %s | FileCheck %s // This test verifies that variadic ObjC methods get the // DW_TAG_unspecified_parameter marker. diff --git a/test/CodeGenObjC/debug-property-synth.m b/test/CodeGenObjC/debug-property-synth.m index 8367478b943b..74ee775f751a 100644 --- a/test/CodeGenObjC/debug-property-synth.m +++ b/test/CodeGenObjC/debug-property-synth.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -g %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s // rdar://problem/9468526 // // Setting a breakpoint on a property should create breakpoints in diff --git a/test/CodeGenObjC/debuginfo-properties.m b/test/CodeGenObjC/debuginfo-properties.m index b2c479c03100..5593b0d87f6a 100644 --- a/test/CodeGenObjC/debuginfo-properties.m +++ b/test/CodeGenObjC/debuginfo-properties.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -g -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s +// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s // Check that we emit the correct method names for properties from a protocol. // rdar://problem/13798000 @protocol NSObject diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m index 0002c0f6e460..710e65be62da 100644 --- a/test/CodeGenObjC/encode-test.m +++ b/test/CodeGenObjC/encode-test.m @@ -177,3 +177,6 @@ const char g13[] = @encode(__typeof__(*test_class)); const char g14[] = @encode(__typeof__(*test_id)); // CHECK: constant [14 x i8] c"{objc_class=}\00" // CHECK: constant [15 x i8] c"{objc_object=}\00" + +// CHECK: @g15 = constant [2 x i8] c":\00" +const char g15[] = @encode(SEL); diff --git a/test/CodeGenObjC/exceptions.m b/test/CodeGenObjC/exceptions.m index 075b714f29e2..56c9a0e907be 100644 --- a/test/CodeGenObjC/exceptions.m +++ b/test/CodeGenObjC/exceptions.m @@ -124,7 +124,7 @@ void f3() { } // CHECK: call void @f3_helper(i32 4, i32* nonnull [[X]]) - // CHECK-NEXT: call void @llvm.lifetime.end(i64 4, i8* [[XPTR]]) + // CHECK-NEXT: call void @llvm.lifetime.end(i64 4, i8* nonnull [[XPTR]]) // CHECK-NEXT: ret void f3_helper(4, &x); } diff --git a/test/CodeGenObjC/fragile-arc.m b/test/CodeGenObjC/fragile-arc.m new file mode 100644 index 000000000000..ecb955bd34ac --- /dev/null +++ b/test/CodeGenObjC/fragile-arc.m @@ -0,0 +1,175 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-exceptions -fobjc-runtime=macosx-fragile-10.10 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-exceptions -fobjc-runtime=macosx-fragile-10.10 -o - %s | FileCheck %s -check-prefix=GLOBALS + +@class Opaque; + +@interface Root { + Class isa; +} +@end + +@interface A : Root { + Opaque *strong; + __weak Opaque *weak; +} +@end + +// GLOBALS-LABEL @OBJC_METACLASS_A +// Strong layout: scan the first word. +// GLOBALS: @OBJC_CLASS_NAME_{{.*}} = private global [2 x i8] c"\01\00" +// Weak layout: skip the first word, scan the second word. +// GLOBALS: @OBJC_CLASS_NAME_{{.*}} = private global [2 x i8] c"\11\00" + +// 0x04002001 +// ^ is compiled by ARC (controls interpretation of layouts) +// ^ has C++ structors (no distinction for zero-initializable) +// ^ factory (always set on non-metaclasses) +// GLOBALS: @OBJC_CLASS_A = private global {{.*}} i32 67117057 + +@implementation A +// CHECK-LABEL: define internal void @"\01-[A testStrong]" +// CHECK: [[SELFVAR:%.*]] = alloca [[A:%.*]]*, align 4 +- (void) testStrong { +// CHECK: [[X:%.*]] = alloca [[OPAQUE:%.*]]*, align 4 +// CHECK: [[SELF:%.*]] = load [[A]]*, [[A]]** [[SELFVAR]] +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[SELF]] to i8* +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i32 4 +// CHECK-NEXT: [[IVAR:%.*]] = bitcast i8* [[T1]] to [[OPAQUE]]** +// CHECK-NEXT: [[T0:%.*]] = load [[OPAQUE]]*, [[OPAQUE]]** [[IVAR]] +// CHECK-NEXT: [[T1:%.*]] = bitcast [[OPAQUE]]* [[T0]] to i8* +// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) +// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[OPAQUE]]* +// CHECK-NEXT: store [[OPAQUE]]* [[T3]], [[OPAQUE]]** [[X]] + Opaque *x = strong; +// CHECK-NEXT: [[VALUE:%.*]] = load [[OPAQUE]]*, [[OPAQUE]]** [[X]] +// CHECK-NEXT: [[SELF:%.*]] = load [[A]]*, [[A]]** [[SELFVAR]] +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[SELF]] to i8* +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i32 4 +// CHECK-NEXT: [[IVAR:%.*]] = bitcast i8* [[T1]] to [[OPAQUE]]** +// CHECK-NEXT: [[T0:%.*]] = bitcast [[OPAQUE]]** [[IVAR]] to i8** +// CHECK-NEXT: [[T1:%.*]] = bitcast [[OPAQUE]]* [[VALUE]] to i8* +// CHECK-NEXT: call void @objc_storeStrong(i8** [[T0]], i8* [[T1]]) + strong = x; +// CHECK-NEXT: [[T0:%.*]] = bitcast [[OPAQUE]]** [[X]] to i8** +// CHECK-NEXT: call void @objc_storeStrong(i8** [[T0]], i8* null) +// CHECK-NEXT: ret void +} + +// CHECK-LABEL: define internal void @"\01-[A testWeak]" +// CHECK: [[SELFVAR:%.*]] = alloca [[A]]*, align 4 +- (void) testWeak { +// CHECK: [[X:%.*]] = alloca [[OPAQUE]]*, align 4 +// CHECK: [[SELF:%.*]] = load [[A]]*, [[A]]** [[SELFVAR]] +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[SELF]] to i8* +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i32 8 +// CHECK-NEXT: [[IVAR:%.*]] = bitcast i8* [[T1]] to [[OPAQUE]]** +// CHECK-NEXT: [[T0:%.*]] = bitcast [[OPAQUE]]** [[IVAR]] to i8** +// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_loadWeakRetained(i8** [[T0]]) +// CHECK-NEXT: [[T2:%.*]] = bitcast i8* [[T1]] to [[OPAQUE]]* +// CHECK-NEXT: store [[OPAQUE]]* [[T2]], [[OPAQUE]]** [[X]] + Opaque *x = weak; +// CHECK-NEXT: [[VALUE:%.*]] = load [[OPAQUE]]*, [[OPAQUE]]** [[X]] +// CHECK-NEXT: [[SELF:%.*]] = load [[A]]*, [[A]]** [[SELFVAR]] +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[SELF]] to i8* +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i32 8 +// CHECK-NEXT: [[IVAR:%.*]] = bitcast i8* [[T1]] to [[OPAQUE]]** +// CHECK-NEXT: [[T0:%.*]] = bitcast [[OPAQUE]]** [[IVAR]] to i8** +// CHECK-NEXT: [[T1:%.*]] = bitcast [[OPAQUE]]* [[VALUE]] to i8* +// CHECK-NEXT: call i8* @objc_storeWeak(i8** [[T0]], i8* [[T1]]) + weak = x; +// CHECK-NEXT: [[T0:%.*]] = bitcast [[OPAQUE]]** [[X]] to i8** +// CHECK-NEXT: call void @objc_storeStrong(i8** [[T0]], i8* null) +// CHECK-NEXT: ret void +} + +// CHECK-LABEL: define internal void @"\01-[A .cxx_destruct]" +// CHECK: [[SELFVAR:%.*]] = alloca [[A]]*, align 4 +// CHECK: [[SELF:%.*]] = load [[A]]*, [[A]]** [[SELFVAR]] +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[SELF]] to i8* +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i32 8 +// CHECK-NEXT: [[IVAR:%.*]] = bitcast i8* [[T1]] to [[OPAQUE]]** +// CHECK-NEXT: [[T0:%.*]] = bitcast [[OPAQUE]]** [[IVAR]] to i8** +// CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]* [[SELF]] to i8* +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds i8, i8* [[T0]], i32 4 +// CHECK-NEXT: [[IVAR:%.*]] = bitcast i8* [[T1]] to [[OPAQUE]]** +// CHECK-NEXT: [[T0:%.*]] = bitcast [[OPAQUE]]** [[IVAR]] to i8** +// CHECK-NEXT: call void @objc_storeStrong(i8** [[T0]], i8* null) +// CHECK-NEXT: ret void +@end + +// Test case for corner case of ivar layout. +@interface B : A { + char _b_flag; +} +@end + +@interface C : B { + char _c_flag; + __unsafe_unretained id c_unsafe[5]; + id c_strong[4]; + __weak id c_weak[3]; + id c_strong2[7]; +} +@end +@implementation C @end + +// Note that these layouts implicitly start at the end of the previous +// class rounded up to pointer alignment. +// GLOBALS-LABEL: @OBJC_METACLASS_C +// Strong layout: skip five, scan four, skip three, scan seven +// 'T' == 0x54, '7' == 0x37 +// GLOBALS: @OBJC_CLASS_NAME_{{.*}} = private global [3 x i8] c"T7\00" +// Weak layout: skip nine, scan three +// GLOBALS: @OBJC_CLASS_NAME_{{.*}} = private global [2 x i8] c"\93\00" + +extern void useBlock(void (^block)(void)); + +// 256 == 0x100 == starts with 1 strong +// GLOBALS: @__block_descriptor_tmp{{.*}} = internal constant {{.*}}, i32 256 } +void testBlockLayoutStrong(id x) { + useBlock(^{ (void) x; }); +} + +// 1 == 0x001 == starts with 1 weak +// GLOBALS: @__block_descriptor_tmp{{.*}} = internal constant {{.*}}, i32 1 } +void testBlockLayoutWeak(__weak id x) { + useBlock(^{ (void) x; }); +} + +// CHECK-LABEL: define void @testCatch() +// CHECK: [[X:%.*]] = alloca [[A:%.*]]*, align 4 +// CHECK: [[Y:%.*]] = alloca i8*, align 4 +// CHECK: call void @objc_exception_try_enter +// CHECK: br i1 +// CHECK: call void @checkpoint(i32 0) +// CHECK: call void @objc_exception_try_exit +// CHECK: br label +// CHECK: call void @checkpoint(i32 3) +// CHECK: [[EXN:%.*]] = call i8* @objc_exception_extract +// CHECK: call i32 @objc_exception_match( +// CHECK: br i1 +// CHECK: [[T0:%.*]] = bitcast i8* [[EXN]] to [[A]]* +// CHECK: [[T1:%.*]] = bitcast [[A]]* [[T0]] to i8* +// CHECK: [[T2:%.*]] = call i8* @objc_retain(i8* [[T1]]) +// CHECK: [[T3:%.*]] = bitcast i8* [[T2]] to [[A]]* +// CHECK: store [[A]]* [[T3]], [[A]]** [[X]] +// CHECK: call void @checkpoint(i32 1) +// CHECK: [[T0:%.*]] = bitcast [[A]]** [[X]] to i8** +// CHECK: call void @objc_storeStrong(i8** [[T0]], i8* null) +// CHECK: br label +// CHECK: [[T0:%.*]] = call i8* @objc_retain(i8* [[EXN]]) +// CHECK: store i8* [[T0]], i8** [[Y]] +// CHECK: call void @checkpoint(i32 2) +// CHECK: call void @objc_storeStrong(i8** [[Y]], i8* null) +extern void checkpoint(int n); +void testCatch() { + @try { + checkpoint(0); + } @catch (A *x) { + checkpoint(1); + } @catch (id y) { + checkpoint(2); + } + checkpoint(3); +} diff --git a/test/CodeGenObjC/ivar-base-as-invariant-load.m b/test/CodeGenObjC/ivar-base-as-invariant-load.m index 4a17eb16f6be..a3201e04011e 100644 --- a/test/CodeGenObjC/ivar-base-as-invariant-load.m +++ b/test/CodeGenObjC/ivar-base-as-invariant-load.m @@ -23,7 +23,7 @@ @end -// CHECK: [[T1:%.*]] = load i64, i64* @"OBJC_IVAR_$_A._flags", !invariant.load ![[MD_NUM:[0-9]+]] -// CHECK: [[T2:%.*]] = load i64, i64* @"OBJC_IVAR_$_A._flags", !invariant.load ![[MD_NUM]] -// CHECK: [[T3:%.*]] = load i64, i64* @"OBJC_IVAR_$_A._flags", !invariant.load ![[MD_NUM]] +// CHECK: [[T1:%.*]] = load i64, i64* @"OBJC_IVAR_$_A._flags", align 8, !invariant.load ![[MD_NUM:[0-9]+]] +// CHECK: [[T2:%.*]] = load i64, i64* @"OBJC_IVAR_$_A._flags", align 8, !invariant.load ![[MD_NUM]] +// CHECK: [[T3:%.*]] = load i64, i64* @"OBJC_IVAR_$_A._flags", align 8, !invariant.load ![[MD_NUM]] // diff --git a/test/CodeGenObjC/ivar-invariant.m b/test/CodeGenObjC/ivar-invariant.m index b9c5bec93063..eb1ba9a0d73d 100644 --- a/test/CodeGenObjC/ivar-invariant.m +++ b/test/CodeGenObjC/ivar-invariant.m @@ -29,7 +29,7 @@ @end // CHECK: define internal i8* @"\01-[Derived init]" -// CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", !invariant.load +// CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", align 8, !invariant.load void * variant_load_1(int i) { void *ptr; @@ -41,7 +41,7 @@ void * variant_load_1(int i) { } // CHECK-LABEL: define i8* @variant_load_1(i32 %i) -// CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member"{{$}} +// CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", align 8{{$}} @interface Container : Derived @end @implementation Container @@ -51,8 +51,8 @@ void * variant_load_1(int i) { } @end -// CHECK: define internal i8* @"\01-[Container invariant_load_1]" -// CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", !invariant.load +// CHECK-LABEL: define internal i8* @"\01-[Container invariant_load_1]" +// CHECK: [[IVAR:%.*]] = load i64, i64* @"OBJC_IVAR_$_Derived.member", align 8, !invariant.load @interface ForBlock { diff --git a/test/CodeGenObjC/ivar-layout-64.m b/test/CodeGenObjC/ivar-layout-64.m index 0dfdbb960857..0866704ecf92 100644 --- a/test/CodeGenObjC/ivar-layout-64.m +++ b/test/CodeGenObjC/ivar-layout-64.m @@ -112,3 +112,50 @@ typedef unsigned int FSCatalogInfoBitmap; // CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\02\10\00" @implementation Foo @end + +// GC layout strings aren't capable of expressing __strong ivars at +// non-word alignments. +struct __attribute__((packed)) PackedStruct { + char c; + __strong id x; +}; +@interface Packed : NSObject { + struct PackedStruct _packed; +} +@end +@implementation Packed @end +// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"Packed\00" +// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\01 \00" +// ' ' == 0x20 + +// Ensure that layout descends into anonymous unions and structs. +// Hilariously, anonymous unions and structs that appear directly as ivars +// are completely ignored by layout. + +@interface AnonymousUnion : NSObject { + struct { + union { + id _object; + void *_ptr; + }; + } a; +} +@end +@implementation AnonymousUnion @end +// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"AnonymousUnion\00" +// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\02\00" + +@interface AnonymousStruct : NSObject { + struct { + struct { + id _object; + __weak id _weakref; + }; + } a; +} +@end +@implementation AnonymousStruct @end +// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"AnonymousStruct\00" +// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"\02\10\00" +// CHECK: @OBJC_CLASS_NAME_{{.*}} = private global {{.*}} c"!\00" +// '!' == 0x21 diff --git a/test/CodeGenObjC/layout-bitfield-crash.m b/test/CodeGenObjC/layout-bitfield-crash.m index 5d0e7bfd2e7f..6f0943e927b5 100644 --- a/test/CodeGenObjC/layout-bitfield-crash.m +++ b/test/CodeGenObjC/layout-bitfield-crash.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-gc -emit-llvm -g -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-gc -emit-llvm -debug-info-kind=limited -o - %s // Check that this doesn't crash when compiled with debugging on. @class Foo; typedef struct Bar *BarRef; diff --git a/test/CodeGenObjC/local-static-block.m b/test/CodeGenObjC/local-static-block.m index b55cc6af4d65..73c670f5c925 100644 --- a/test/CodeGenObjC/local-static-block.m +++ b/test/CodeGenObjC/local-static-block.m @@ -14,8 +14,13 @@ static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSA return (NSArray *)0; }; +extern NSArray *address; +extern unsigned long level; + void FUNC() { + ArrayRecurs(address, level); + static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) { for(id rawAddress in addresses) @@ -25,6 +30,7 @@ void FUNC() } return (NSArray *)0; }; + ArrayRecurs(address, level); if (ArrayRecurs) { static NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) { @@ -36,6 +42,7 @@ void FUNC() } return (NSArray *)0; }; + ArrayRecurs(address, level); } } @@ -50,8 +57,9 @@ void FUNC1() } return (NSArray *)0; }; + ArrayRecurs(address, level); } // CHECK-LP64: @ArrayRecurs = internal global // CHECK-LP64: @FUNC.ArrayRecurs = internal global -// CHECK-LP64: @FUNC.ArrayRecurs.3 = internal global +// CHECK-LP64: @FUNC.ArrayRecurs.1 = internal global // CHECK-LP64: @FUNC1.ArrayRecurs = internal global diff --git a/test/CodeGenObjC/mrc-weak.m b/test/CodeGenObjC/mrc-weak.m new file mode 100644 index 000000000000..e2c78f073367 --- /dev/null +++ b/test/CodeGenObjC/mrc-weak.m @@ -0,0 +1,191 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.10 -emit-llvm -fblocks -fobjc-weak -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-MODERN +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.10 -emit-llvm -fblocks -fobjc-weak -o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-FRAGILE + +@interface Object +- (instancetype) retain; +- (void) run; +@end + +// The ivars in HighlyAlignedSubclass should be placed in the tail-padding +// of the superclass. Ensure that they're still covered by layouts. +@interface HighlyAligned : Object { + __attribute__((aligned(32))) void *array[2]; +} +@end +// CHECK-MODERN: @"OBJC_IVAR_$_HighlyAlignedSubclass.ivar2" = global i64 24, +// CHECK-MODERN: @"OBJC_IVAR_$_HighlyAlignedSubclass.ivar" = global i64 16, +// CHECK-MODERN: @OBJC_CLASS_NAME_{{.*}} = {{.*}} c"\02\00" +// CHECK-MODERN: @"\01l_OBJC_CLASS_RO_$_HighlyAlignedSubclass" = {{.*}} { +// CHECK-FRAGILE: @OBJC_INSTANCE_VARIABLES_HighlyAlignedSubclass = {{.*}}, i32 8 }, {{.*}}, i32 12 }] +// CHECK-FRAGILE: @OBJC_CLASS_NAME_{{.*}} = {{.*}} c"\02\00" +// CHECK-FRAGILE: @OBJC_CLASS_HighlyAlignedSubclass +@interface HighlyAlignedSubclass : HighlyAligned { + __weak id ivar; + __weak id ivar2; +} +@end +@implementation HighlyAlignedSubclass @end + +// CHECK-MODERN: @OBJC_CLASS_NAME_{{.*}} = {{.*}} c"\01\00" +// CHECK-MODERN: @"\01l_OBJC_CLASS_RO_$_Foo" = {{.*}} { i32 772 +// 772 == 0x304 +// ^ HasMRCWeakIvars +// ^ HasCXXDestructorOnly +// ^ HasCXXStructors + +// CHECK-FRAGILE: @OBJC_CLASS_NAME_{{.*}} = {{.*}} c"\01\00" +// CHECK-FRAGILE: @OBJC_CLASS_Foo = {{.*}} i32 134225921, +// 134225921 == 0x08002001 +// ^ HasMRCWeakIvars +// ^ HasCXXStructors +// ^ Factory +@interface Foo : Object { + __weak id ivar; +} +@end + +@implementation Foo +// CHECK-LABEL: define internal void @"\01-[Foo .cxx_destruct]" +// CHECK: call void @objc_destroyWeak +@end + + +void test1(__weak id x) {} +// CHECK-LABEL: define void @test1 +// CHECK: [[X:%.*]] = alloca i8*, +// CHECK-NEXT: objc_initWeak +// CHECK-NEXT: objc_destroyWeak +// CHECK-NEXT: ret void + +void test2(id y) { + __weak id z = y; +} +// CHECK-LABEL: define void @test2 +// CHECK: [[Y:%.*]] = alloca i8*, +// CHECK-NEXT: [[Z:%.*]] = alloca i8*, +// CHECK-NEXT: store +// CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[Y]] +// CHECK-NEXT: call i8* @objc_initWeak(i8** [[Z]], i8* [[T0]]) +// CHECK-NEXT: call void @objc_destroyWeak(i8** [[Z]]) +// CHECK-NEXT: ret void + +void test3(id y) { + __weak id z; + z = y; +} +// CHECK-LABEL: define void @test3 +// CHECK: [[Y:%.*]] = alloca i8*, +// CHECK-NEXT: [[Z:%.*]] = alloca i8*, +// CHECK-NEXT: store +// CHECK-NEXT: store i8* null, i8** [[Z]] +// CHECK-NEXT: [[T0:%.*]] = load i8*, i8** [[Y]] +// CHECK-NEXT: call i8* @objc_storeWeak(i8** [[Z]], i8* [[T0]]) +// CHECK-NEXT: call void @objc_destroyWeak(i8** [[Z]]) +// CHECK-NEXT: ret void + +void test4(__weak id *p) { + id y = *p; +} +// CHECK-LABEL: define void @test4 +// CHECK: [[P:%.*]] = alloca i8**, +// CHECK-NEXT: [[Y:%.*]] = alloca i8*, +// CHECK-NEXT: store +// CHECK-NEXT: [[T0:%.*]] = load i8**, i8*** [[P]] +// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_loadWeak(i8** [[T0]]) +// CHECK-NEXT: store i8* [[T1]], i8** [[Y]] +// CHECK-NEXT: ret void + +void test5(__weak id *p) { + id y = [*p retain]; +} +// CHECK-LABEL: define void @test5 +// CHECK: [[P:%.*]] = alloca i8**, +// CHECK-NEXT: [[Y:%.*]] = alloca i8*, +// CHECK-NEXT: store +// CHECK-NEXT: [[T0:%.*]] = load i8**, i8*** [[P]] +// CHECK-NEXT: [[T1:%.*]] = call i8* @objc_loadWeakRetained(i8** [[T0]]) +// CHECK-NEXT: store i8* [[T1]], i8** [[Y]] +// CHECK-NEXT: ret void + +void test6(__weak Foo **p) { + Foo *y = [*p retain]; +} +// CHECK-LABEL: define void @test6 +// CHECK: [[P:%.*]] = alloca [[FOO:%.*]]**, +// CHECK-NEXT: [[Y:%.*]] = alloca [[FOO]]*, +// CHECK-NEXT: store +// CHECK-NEXT: [[T0:%.*]] = load [[FOO]]**, [[FOO]]*** [[P]] +// CHECK-NEXT: [[T1:%.*]] = bitcast [[FOO]]** [[T0]] to i8** +// CHECK-NEXT: [[T2:%.*]] = call i8* @objc_loadWeakRetained(i8** [[T1]]) +// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[FOO]]* +// CHECK-NEXT: store [[FOO]]* [[T3]], [[FOO]]** [[Y]] +// CHECK-NEXT: ret void + +extern id get_object(void); +extern void use_block(void (^)(void)); + +void test7(void) { + __weak Foo *p = get_object(); + use_block(^{ [p run ]; }); +} +// CHECK-LABEL: define void @test7 +// CHECK: [[P:%.*]] = alloca [[FOO]]*, +// CHECK: [[T0:%.*]] = call i8* @get_object() +// CHECK-NEXT: [[T1:%.*]] = bitcast i8* [[T0]] to [[FOO]]* +// CHECK-NEXT: [[T2:%.*]] = bitcast [[FOO]]** [[P]] to i8** +// CHECK-NEXT: [[T3:%.*]] = bitcast [[FOO]]* [[T1]] to i8* +// CHECK-NEXT: call i8* @objc_initWeak(i8** [[T2]], i8* [[T3]]) +// CHECK: call void @objc_copyWeak +// CHECK: call void @use_block +// CHECK: call void @objc_destroyWeak + +// CHECK-LABEL: define internal void @__copy_helper_block +// CHECK: @objc_copyWeak + +// CHECK-LABEL: define internal void @__destroy_helper_block +// CHECK: @objc_destroyWeak + +void test8(void) { + __block __weak Foo *p = get_object(); + use_block(^{ [p run ]; }); +} +// CHECK-LABEL: define void @test8 +// CHECK: call i8* @objc_initWeak +// CHECK-NOT: call void @objc_copyWeak +// CHECK: call void @use_block +// CHECK: call void @objc_destroyWeak + +// CHECK-LABEL: define internal void @__Block_byref_object_copy +// CHECK: call void @objc_moveWeak + +// CHECK-LABEL: define internal void @__Block_byref_object_dispose +// CHECK: call void @objc_destroyWeak + +// CHECK-LABEL: define void @test9_baseline() +// CHECK: define internal void @__copy_helper +// CHECK: define internal void @__destroy_helper +void test9_baseline(void) { + Foo *p = get_object(); + use_block(^{ [p run]; }); +} + +// CHECK-LABEL: define void @test9() +// CHECK-NOT: define internal void @__copy_helper +// CHECK-NOT: define internal void @__destroy_helper +// CHECK: define void @test9_fin() +void test9(void) { + __unsafe_unretained Foo *p = get_object(); + use_block(^{ [p run]; }); +} +void test9_fin() {} + +// CHECK-LABEL: define void @test10() +// CHECK-NOT: define internal void @__copy_helper +// CHECK-NOT: define internal void @__destroy_helper +// CHECK: define void @test10_fin() +void test10(void) { + typedef __unsafe_unretained Foo *UnsafeFooPtr; + UnsafeFooPtr p = get_object(); + use_block(^{ [p run]; }); +} +void test10_fin() {} diff --git a/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m b/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m index 6ea656443a8b..76b7cfd118b5 100644 --- a/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m +++ b/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout -// RUN: FileCheck --input-file=%t-64.layout %s -// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -triple i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-32.layout -// RUN: FileCheck -check-prefix=CHECK-i386 --input-file=%t-32.layout %s +// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout +// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-64 --input-file=%t-64.layout %s +// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -fobjc-arc -triple i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-32.layout +// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-32 --input-file=%t-32.layout %s // rdar://12184410 // rdar://12184410 @@ -20,15 +20,13 @@ void f() { __block id bl_var1; // block variable layout: BL_STRONG:1, BL_OPERATOR:0 -// CHECK: Inline instruction for block variable layout: 0x0100 -// CHECK-i386: Inline instruction for block variable layout: 0x0100 +// CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0 void (^b)() = ^{ x(bar); }; // block variable layout: BL_STRONG:2, BL_BYREF:1, BL_OPERATOR:0 -// CHECK: Inline instruction for block variable layout: 0x0210 -// CHECK-i386: Inline instruction for block variable layout: 0x0210 +// CHECK: Inline block variable layout: 0x0210, BL_STRONG:2, BL_BYREF:1, BL_OPERATOR:0 void (^c)() = ^{ x(bar); x(baz); @@ -36,8 +34,7 @@ void f() { }; // block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0 -// CHECK: Inline instruction for block variable layout: 0x0230 -// CHECK-i386: Inline instruction for block variable layout: 0x0230 +// CHECK: Inline block variable layout: 0x0230, BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0 void (^d)() = ^{ x(bar); x(baz); @@ -47,8 +44,7 @@ void f() { }; // block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0 -// CHECK: Inline instruction for block variable layout: 0x0230 -// CHECK-i386: Inline instruction for block variable layout: 0x0230 +// CHECK: Inline block variable layout: 0x0230, BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0 id (^e)() = ^{ x(bar); x(baz); @@ -58,8 +54,7 @@ void f() { return wid; }; -// CHECK: Inline instruction for block variable layout: 0x020 -// CHECK-i386: Inline instruction for block variable layout: 0x020 +// CHECK: Inline block variable layout: 0x020, BL_BYREF:2, BL_OPERATOR:0 void (^ii)() = ^{ byref_int = 1; byref_bab = 0; diff --git a/test/CodeGenObjC/objc-fixed-enum.m b/test/CodeGenObjC/objc-fixed-enum.m index 52811b1d68bc..532959aab9b3 100644 --- a/test/CodeGenObjC/objc-fixed-enum.m +++ b/test/CodeGenObjC/objc-fixed-enum.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -g -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s // The DWARF standard says the underlying data type of an enum may be // stored in an DW_AT_type entry in the enum DIE. This is useful to have // so the debugger knows about the signedness of the underlying type. @@ -59,22 +59,22 @@ int main() { // CHECK-SAME: line: 22 // CHECK-SAME: baseType: ![[ENUMERATOR3]] -// CHECK: ![[ENUM0]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "e0" +// CHECK: ![[ENUM0]] = !DILocalVariable(name: "e0" // CHECK-SAME: type: ![[TYPE0:[0-9]+]] // CHECK: ![[TYPE0]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Enum0", // CHECK-SAME: baseType: ![[ENUMERATOR0]] -// CHECK: ![[ENUM1]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "e1" +// CHECK: ![[ENUM1]] = !DILocalVariable(name: "e1" // CHECK-SAME: type: ![[TYPE1:[0-9]+]] // CHECK: ![[TYPE1]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Enum1" // CHECK-SAME: baseType: ![[ENUMERATOR1]] -// CHECK: ![[ENUM2]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "e2" +// CHECK: ![[ENUM2]] = !DILocalVariable(name: "e2" // CHECK-SAME: type: ![[TYPE2:[0-9]+]] // CHECK: ![[TYPE2]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Enum2" // CHECK-SAME: baseType: ![[ENUMERATOR2]] -// CHECK: ![[ENUM3]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "e3" +// CHECK: ![[ENUM3]] = !DILocalVariable(name: "e3" // CHECK-SAME: type: ![[TYPE3:[0-9]+]] // CHECK: ![[TYPE3]] = !DIDerivedType(tag: DW_TAG_typedef, name: "Enum3" // CHECK-SAME: baseType: ![[ENUMERATOR3]] diff --git a/test/CodeGenObjC/objc-literal-tests.m b/test/CodeGenObjC/objc-literal-tests.m index c53ee644f059..03286e24563e 100644 --- a/test/CodeGenObjC/objc-literal-tests.m +++ b/test/CodeGenObjC/objc-literal-tests.m @@ -94,4 +94,4 @@ void baz(void) { bar(^(void) { return YES; }); } -// CHECK: attributes [[NUW]] = { nounwind{{.*}} } +// CHECK: attributes [[NUW]] = { {{(norecurse )?}}nounwind{{.*}} } diff --git a/test/CodeGenObjC/objc2-weak-ivar-debug.m b/test/CodeGenObjC/objc2-weak-ivar-debug.m index 8c323b75213e..4377f6715490 100644 --- a/test/CodeGenObjC/objc2-weak-ivar-debug.m +++ b/test/CodeGenObjC/objc2-weak-ivar-debug.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -debug-info-kind=limited -emit-llvm -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -debug-info-kind=limited -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -debug-info-kind=limited -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -debug-info-kind=limited -emit-llvm -o - %s // rdar://7252252 @interface Loop { diff --git a/test/CodeGenObjC/optimize-ivar-offset-load.m b/test/CodeGenObjC/optimize-ivar-offset-load.m index 0317c094033f..6a073dbd29c1 100644 --- a/test/CodeGenObjC/optimize-ivar-offset-load.m +++ b/test/CodeGenObjC/optimize-ivar-offset-load.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Os -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -O0 -emit-llvm %s -o - | FileCheck %s // rdar://16095748 @interface NSObject @@ -31,7 +31,7 @@ extern void foo(int); // CHECK: [[ADDPTR:%.*]] = getelementptr inbounds i8, i8* [[THREE]], i64 [[IVAR]] // CHECK: [[FOUR:%.*]] = bitcast i8* [[ADDPTR]] to i32* // CHECK: [[FIVE:%.*]] = load i32, i32* [[FOUR]], align 4 -// CHECK: tail call void @foo(i32 [[FIVE]]) +// CHECK: call void @foo(i32 [[FIVE]]) @implementation SampleClass + (SampleClass*) new { return 0; } diff --git a/test/CodeGenObjC/parameterized_classes.m b/test/CodeGenObjC/parameterized_classes.m index 1d8e9a259934..b75cf2e3ad2d 100644 --- a/test/CodeGenObjC/parameterized_classes.m +++ b/test/CodeGenObjC/parameterized_classes.m @@ -24,6 +24,8 @@ __attribute__((objc_root_class)) - (void)addObject:(T)object; - (void)sortWithFunction:(int (*)(T, T))function; - (void)getObjects:(T __strong *)objects length:(unsigned*)length; +- (T)objectAtIndexedSubscript:(unsigned)index; +- (void)setObject:(T)object atIndexedSubscript:(unsigned)index; @end NSString *getFirstObjectProp(NSMutableArray<NSString *> *array) { @@ -58,6 +60,11 @@ void printMe(NSString *name) { } // CHECK-LABEL: define void @blockTest void blockTest(NSMutableArray<void (^)(void)> *array, NSString *name) { + // CHECK-NOT: ret void // CHECK: call i8* @objc_retainBlock [array addObject: ^ { printMe(name); }]; + // CHECK-NOT: ret void + array[0] = ^ { printMe(name); }; + // CHECK: call i8* @objc_retainBlock + // CHECK: ret void } diff --git a/test/CodeGenObjC/property-dbg.m b/test/CodeGenObjC/property-dbg.m index e0cac9850f25..fb70747f5db8 100644 --- a/test/CodeGenObjC/property-dbg.m +++ b/test/CodeGenObjC/property-dbg.m @@ -1,5 +1,5 @@ // FIXME: Check IR rather than asm, then triple is not needed. -// RUN: %clang_cc1 -triple %itanium_abi_triple -S -g -masm-verbose -x objective-c < %s | grep DW_AT_name +// RUN: %clang_cc1 -triple %itanium_abi_triple -S -debug-info-kind=limited -masm-verbose -x objective-c < %s | grep DW_AT_name @interface Foo { int i; } diff --git a/test/CodeGenObjC/property-list-in-extension.m b/test/CodeGenObjC/property-list-in-extension.m new file mode 100644 index 000000000000..878745e73e4d --- /dev/null +++ b/test/CodeGenObjC/property-list-in-extension.m @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-weak -fobjc-runtime-has-weak -emit-llvm %s -o - | FileCheck %s + +// Checks metadata for properties in a few cases. + + +// Property from a class extension: +__attribute__((objc_root_class)) +@interface Foo +@end + +@interface Foo() +@property int myprop; +@end + +@implementation Foo +@synthesize myprop = _myprop; +@end +// Metadata for _myprop should be present, and PROP_LIST for Foo should have +// only one entry. +// CHECK: = private global [12 x i8] c"Ti,V_myprop\00", +// CHECK: @"\01l_OBJC_$_PROP_LIST_Foo" = private global { i32, i32, [1 x %struct._prop_t] } + +// Readonly property in interface made readwrite in a category: +__attribute__((objc_root_class)) +@interface FooRO +@property (readonly) int evolvingprop; +@property (nonatomic,readonly,getter=isBooleanProp) int booleanProp; +@property (nonatomic,readonly,weak) Foo *weakProp; +@end + +@interface FooRO () +@property int evolvingprop; +@property int booleanProp; +@property Foo *weakProp; +@end + +@implementation FooRO +@synthesize evolvingprop = _evolvingprop; +@end +// Metadata for _evolvingprop should be present, and PROP_LIST for FooRO should +// still have only one entry, and the one entry should point to the version of +// the property with a getter and setter. +// CHECK: [[evolvinggetter:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [13 x i8] c"evolvingprop\00" +// CHECK: [[evolvingsetter:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [18 x i8] c"Ti,V_evolvingprop\00", +// CHECK: [[booleanmetadata:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [34 x i8] c"Ti,N,GisBooleanProp,V_booleanProp\00" +// CHECK: [[weakmetadata:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [23 x i8] c"T@\22Foo\22,W,N,V_weakProp\00" +// CHECK: @"\01l_OBJC_$_PROP_LIST_FooRO" = private global { i32, i32, [3 x %struct._prop_t] }{{.*}}[[evolvinggetter]]{{.*}}[[evolvingsetter]]{{.*}}[[booleanmetadata]] diff --git a/test/CodeGenObjC/selector-ref-invariance.m b/test/CodeGenObjC/selector-ref-invariance.m index 5758a1cd7ff1..18fb828d29de 100644 --- a/test/CodeGenObjC/selector-ref-invariance.m +++ b/test/CodeGenObjC/selector-ref-invariance.m @@ -3,7 +3,7 @@ // rdar://6027699 void test(id x) { -// CHECK: load i8*, i8** @OBJC_SELECTOR_REFERENCES_, !invariant.load +// CHECK: load i8*, i8** @OBJC_SELECTOR_REFERENCES_, align 8, !invariant.load // CHECK: @objc_msgSend [x foo]; } diff --git a/test/CodeGenObjC/stret-1.m b/test/CodeGenObjC/stret-1.m index f45d1219da65..a7bcdda48b14 100644 --- a/test/CodeGenObjC/stret-1.m +++ b/test/CodeGenObjC/stret-1.m @@ -1,8 +1,7 @@ -// RUN: %clang_cc1 -fblocks -triple arm64-apple-darwin %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-ARM64 +// RUN: %clang_cc1 -fblocks -triple arm64-apple-darwin %s -emit-llvm -o - | FileCheck %s // rdar://12416433 struct stret { int x[100]; }; -struct stret zero; struct stret one = {{1}}; @interface Test @end @@ -13,8 +12,12 @@ struct stret one = {{1}}; int main(int argc, const char **argv) { - struct stret st2 = one; - if (argc) st2 = [(id)(argc&~255) method]; -} + [(id)(argc&~255) method]; + // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (%struct.stret*, i8*, i8*)*)(%struct.stret* sret [[T0:%[^,]+]] + // CHECK: [[T0P:%.*]] = bitcast %struct.stret* [[T0]] to i8* + // CHECK: call void @llvm.memset.p0i8.i64(i8* [[T0P]], i8 0, i64 400, i32 4, i1 false) -// CHECK-ARM64: call void @llvm.memset.p0i8.i64(i8* [[T0:%.*]], i8 0, i64 400, i32 4, i1 false) + [Test method]; + // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (%struct.stret*, i8*, i8*)*)(%struct.stret* sret [[T1:%[^,]+]] + // CHECK-NOT: call void @llvm.memset.p0i8.i64( +} |