xref: /llvm-project/compiler-rt/test/orc/TestCases/Darwin/arm64/objc-protocol-ref.S (revision 0f286f8a3688250b1f4c263836827ad0e2467f82)
1// Test that we register protocol reference metadata. Without registration,
2// protocol pointers will not be uniqued correctly and @protocol(NSObject) will
3// not match the runtime's pointer.
4//
5// RUN: %clang -c -o %t.o %s
6// RUN: %llvm_jitlink -preload libobjc.A.dylib %t.o
7//
8// REQUIRES: jit-compatible-osx-swift-runtime
9
10	.section	__TEXT,__text,regular,pure_instructions
11	.build_version macos, 15, 0	sdk_version 15, 0
12	.globl	_main                           ; -- Begin function main
13	.p2align	2
14_main:                                  ; @main
15	.cfi_startproc
16; %bb.0:
17	sub	sp, sp, #32
18	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
19	add	x29, sp, #16
20	.cfi_def_cfa w29, 16
21	.cfi_offset w30, -8
22	.cfi_offset w29, -16
23	stur	wzr, [x29, #-4]
24	adrp	x8, __OBJC_PROTOCOL_REFERENCE_$_NSObject@PAGE
25	ldr	x8, [x8, __OBJC_PROTOCOL_REFERENCE_$_NSObject@PAGEOFF]
26	str	x8, [sp]                        ; 8-byte Folded Spill
27	adrp	x0, l_.str@PAGE
28	add	x0, x0, l_.str@PAGEOFF
29	bl	_objc_getProtocol
30	ldr	x8, [sp]                        ; 8-byte Folded Reload
31	subs	x8, x8, x0
32	cset	w8, eq
33	and	w8, w8, #0x1
34	ands	w8, w8, #0x1
35	cset	w0, eq
36	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
37	add	sp, sp, #32
38	ret
39	.cfi_endproc
40                                        ; -- End function
41	.section	__TEXT,__objc_classname,cstring_literals
42l_OBJC_CLASS_NAME_:                     ; @OBJC_CLASS_NAME_
43	.asciz	"NSObject"
44
45	.private_extern	__OBJC_PROTOCOL_$_NSObject ; @"_OBJC_PROTOCOL_$_NSObject"
46	.section	__DATA,__data
47	.globl	__OBJC_PROTOCOL_$_NSObject
48	.weak_definition	__OBJC_PROTOCOL_$_NSObject
49	.p2align	3, 0x0
50__OBJC_PROTOCOL_$_NSObject:
51	.quad	0
52	.quad	l_OBJC_CLASS_NAME_
53	.quad	0
54	.quad	0
55	.quad	0
56	.quad	0
57	.quad	0
58	.quad	0
59	.long	96                              ; 0x60
60	.long	0                               ; 0x0
61	.quad	0
62	.quad	0
63	.quad	0
64
65	.private_extern	__OBJC_LABEL_PROTOCOL_$_NSObject ; @"_OBJC_LABEL_PROTOCOL_$_NSObject"
66	.section	__DATA,__objc_protolist,coalesced,no_dead_strip
67	.globl	__OBJC_LABEL_PROTOCOL_$_NSObject
68	.weak_definition	__OBJC_LABEL_PROTOCOL_$_NSObject
69	.p2align	3, 0x0
70__OBJC_LABEL_PROTOCOL_$_NSObject:
71	.quad	__OBJC_PROTOCOL_$_NSObject
72
73	.private_extern	__OBJC_PROTOCOL_REFERENCE_$_NSObject ; @"_OBJC_PROTOCOL_REFERENCE_$_NSObject"
74	.section	__DATA,__objc_protorefs,coalesced,no_dead_strip
75	.globl	__OBJC_PROTOCOL_REFERENCE_$_NSObject
76	.weak_definition	__OBJC_PROTOCOL_REFERENCE_$_NSObject
77	.p2align	3, 0x0
78__OBJC_PROTOCOL_REFERENCE_$_NSObject:
79	.quad	__OBJC_PROTOCOL_$_NSObject
80
81	.section	__TEXT,__cstring,cstring_literals
82l_.str:                                 ; @.str
83	.asciz	"NSObject"
84
85	.no_dead_strip	__OBJC_PROTOCOL_$_NSObject
86	.no_dead_strip	__OBJC_LABEL_PROTOCOL_$_NSObject
87	.no_dead_strip	__OBJC_PROTOCOL_REFERENCE_$_NSObject
88	.section	__DATA,__objc_imageinfo,regular,no_dead_strip
89L_OBJC_IMAGE_INFO:
90	.long	0
91	.long	64
92
93.subsections_via_symbols
94