blob: a5400c5bf208392e11d7ccbef538a937cd092b59 [file] [log] [blame]
Fariborz Jahanian23290b02012-11-01 18:32:55 +00001// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -O0 -emit-llvm %s -o %t-64.s
2// rdar://12184410
3
4void x(id y) {}
5void y(int a) {}
6
7extern id opaque_id();
8
9void f() {
10 __block int byref_int = 0;
11 const id bar = (id) opaque_id();
12 id baz = 0;
13 __strong id strong_void_sta;
14 __block id byref_bab = (id)0;
15 __block id bl_var1;
16
17// Inline instruction for block variable layout: 0x0100
18// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 256 }
19 void (^b)() = ^{
20 x(bar);
21 };
22
23// Inline instruction for block variable layout: 0x0210
24// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 528 }
25 void (^c)() = ^{
26 x(bar);
27 x(baz);
28 byref_int = 1;
29 };
30
31// Inline instruction for block variable layout: 0x0230
32// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 560 }
33 void (^d)() = ^{
34 x(bar);
35 x(baz);
36 byref_int = 1;
37 bl_var1 = 0;
38 byref_bab = 0;
39 };
40
41// Inline instruction for block variable layout: 0x0231
42// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 561 }
43 __weak id wid;
44 id (^e)() = ^{
45 x(bar);
46 x(baz);
47 byref_int = 1;
48 bl_var1 = 0;
49 byref_bab = 0;
50 return wid;
51 };
52
53// Inline instruction for block variable layout: 0x0235
54// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 565 }
55 __weak id wid1, wid2, wid3, wid4;
56 id (^f)() = ^{
57 x(bar);
58 x(baz);
59 byref_int = 1;
60 bl_var1 = 0;
61 byref_bab = 0;
62 x(wid1);
63 x(wid2);
64 x(wid3);
65 x(wid4);
66 return wid;
67 };
68
69// Inline instruction for block variable layout: 0x035
70// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 53 }
71 id (^g)() = ^{
72 byref_int = 1;
73 bl_var1 = 0;
74 byref_bab = 0;
75 x(wid1);
76 x(wid2);
77 x(wid3);
78 x(wid4);
79 return wid;
80 };
81
82// Inline instruction for block variable layout: 0x01
83// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 1 }
84 id (^h)() = ^{
85 return wid;
86 };
87
88// Inline instruction for block variable layout: 0x020
89// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 32 }
90 void (^ii)() = ^{
91 byref_int = 1;
92 byref_bab = 0;
93 };
94
95// Inline instruction for block variable layout: 0x0102
96// CKECK-LP64: i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i64 258 }
97 void (^jj)() = ^{
98 x(bar);
99 x(wid1);
100 x(wid2);
101 };
102}