1 // 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
2 // RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.layout %s
7 extern id opaque_id(void);
11 __block int byref_int = 0;
16 const id bar = (id) opaque_id();
18 __strong id strong_void_sta;
19 __block id byref_bab = (id)0;
23 // The patterns here are a sequence of bytes, each saying first how
24 // many sizeof(void*) chunks to skip (high nibble) and then how many
25 // to scan (low nibble). A zero byte says that we've reached the end
28 // All of these patterns start with 01 3x because the block header on
29 // LP64 consists of an isa pointer (which we're supposed to scan for
30 // some reason) followed by three words (2 ints, a function pointer,
31 // and a descriptor pointer).
34 // Inline instruction for block variable layout: 0x0320 (3 strong 2 byref)
35 // CHECK-LP64: Inline block variable layout: 0x0320, BL_STRONG:3, BL_BYREF:2, BL_OPERATOR:0
37 byref_int = sh + ch+ch1+ch2 ;
40 x((id)strong_void_sta);
46 // Inline instruction for block variable layout: 0x0331 (3 strong 3 byref 1 weak)
47 // CHECK-LP64: Inline block variable layout: 0x0331, BL_STRONG:3, BL_BYREF:3, BL_WEAK:1, BL_OPERATOR:0
49 byref_int = sh + ch+ch1+ch2 ;
52 x((id)strong_void_sta);
59 @class NSString, NSNumber;
64 __weak id weak_delegate;
68 // Inline instruction for block variable layout: 0x0401 (4 strong 0 byref 1 weak)
69 // CHECK-LP64: Inline block variable layout: 0x0401, BL_STRONG:4, BL_WEAK:1, BL_OPERATOR:0
81 // Test 5 (unions/structs and their nesting):
85 __unsafe_unretained id o1;
88 __unsafe_unretained id o2;
93 __unsafe_unretained id o1;
95 __unsafe_unretained id o3;
101 __unsafe_unretained id o1;
103 __unsafe_unretained id o3;
110 // 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
119 // Test for array of stuff.
122 __unsafe_unretained id unsafe_unretained_var[4];
125 // CHECK-LP64: Block variable layout: BL_UNRETAINED:4, BL_OPERATOR:0
127 x(imported_s.unsafe_unretained_var[2]);
133 // Test2 for array of stuff.
137 __unsafe_unretained id unsafe_unretained_var[4];
140 // CHECK-LP64: Block variable layout: BL_NON_OBJECT_WORD:1, BL_UNRETAINED:4, BL_OPERATOR:0
142 x(imported_s.unsafe_unretained_var[2]);
148 // Test3 for array of stuff.
152 __unsafe_unretained id unsafe_unretained_var[0];
155 // CHECK-LP64: Block variable layout: BL_OPERATOR:0
157 int i = imported_s.a;
164 // Test4 for array of stuff.
169 __unsafe_unretained id s_f0;
170 __unsafe_unretained id s_f1;
173 __unsafe_unretained id f1;
177 __unsafe_unretained B *f1;
181 // 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
183 id i = captured_s.f0.s_f1;
189 // Test1 bitfield in cpatured aggregate.
199 // CHECK-LP64: Block variable layout: BL_OPERATOR:0
206 // Test2 bitfield in cpatured aggregate.
212 // CHECK-LP64: Block variable layout: BL_OPERATOR:0
219 // Test3 bitfield in cpatured aggregate.
223 unsigned short _reserved : 16;
225 unsigned char _draggedNodesAreDeletable: 1;
226 unsigned char _draggedOutsideOutlineView : 1;
227 unsigned char _adapterRespondsTo_addRootPaths : 1;
228 unsigned char _adapterRespondsTo_moveDataNodes : 1;
229 unsigned char _adapterRespondsTo_removeRootDataNode : 1;
230 unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
231 unsigned char _adapterRespondsTo_selectDataNode : 1;
232 unsigned char _adapterRespondsTo_textDidEndEditing : 1;
233 unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
234 unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
235 unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
236 unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
237 unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
238 unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
240 unsigned int _filler : 32;
243 // CHECK-LP64: Block variable layout: BL_OPERATOR:0
244 unsigned char (^c)(void) = ^{
245 return _flags._draggedNodesAreDeletable;
251 // Test4 unnamed bitfield
255 unsigned short _reserved : 16;
257 unsigned char _draggedNodesAreDeletable: 1;
258 unsigned char _draggedOutsideOutlineView : 1;
259 unsigned char _adapterRespondsTo_addRootPaths : 1;
260 unsigned char _adapterRespondsTo_moveDataNodes : 1;
261 unsigned char _adapterRespondsTo_removeRootDataNode : 1;
262 unsigned char _adapterRespondsTo_doubleClickDataNode : 1;
263 unsigned char _adapterRespondsTo_selectDataNode : 1;
264 unsigned char _adapterRespondsTo_textDidEndEditing : 1;
266 unsigned long long : 64;
268 unsigned char _adapterRespondsTo_updateAndSaveRoots : 1;
269 unsigned char _adapterRespondsTo_askToDeleteRootNodes : 1;
270 unsigned char _adapterRespondsTo_contextMenuForSelectedNodes : 1;
271 unsigned char _adapterRespondsTo_pasteboardFilenamesForNodes : 1;
272 unsigned char _adapterRespondsTo_writeItemsToPasteboard : 1;
273 unsigned char _adapterRespondsTo_writeItemsToPasteboardXXXX : 1;
275 unsigned int _filler : 32;
278 // CHECK-LP64: Block variable layout: BL_OPERATOR:0
279 unsigned char (^c)(void) = ^{
280 return _flags._draggedNodesAreDeletable;
288 // Test5 unnamed bitfield.
291 unsigned char flag : 1;
293 unsigned char flag1 : 1;
296 // CHECK-LP64: Block variable layout: BL_OPERATOR:0
297 unsigned char (^c)(void) = ^{
305 // Test6 0 length bitfield.
308 unsigned char flag : 1;
310 unsigned char flag1 : 1;
313 // CHECK-LP64: Block variable layout: BL_OPERATOR:0
314 unsigned char (^c)(void) = ^{
321 // Test7 large number of captured variables.
324 __weak id wid1, wid2, wid3, wid4;
325 __weak id wid5, wid6, wid7, wid8;
326 __weak id wid9, wid10, wid11, wid12;
327 __weak id wid13, wid14, wid15, wid16;
328 const id bar = (id) opaque_id();
329 // CHECK-LP64: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_OPERATOR:0
352 // Test 8 very large number of captured variables.
355 __weak id wid1, wid2, wid3, wid4;
356 __weak id wid5, wid6, wid7, wid8;
357 __weak id wid9, wid10, wid11, wid12;
358 __weak id wid13, wid14, wid15, wid16;
359 __weak id w1, w2, w3, w4;
360 __weak id w5, w6, w7, w8;
361 __weak id w9, w10, w11, w12;
362 __weak id w13, w14, w15, w16;
363 const id bar = (id) opaque_id();
364 // CHECK-LP64: Block variable layout: BL_STRONG:1, BL_WEAK:16, BL_WEAK:16, BL_WEAK:1, BL_OPERATOR:0