xref: /aosp_15_r20/external/llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker// RUN: llvm-mc -triple=arm64-apple-ios -filetype=obj < %s | \
2*9880d681SAndroid Build Coastguard Worker// RUN: llvm-readobj --expand-relocs -sections -section-relocations -section-data | \
3*9880d681SAndroid Build Coastguard Worker// RUN: FileCheck %s
4*9880d681SAndroid Build Coastguard Worker//
5*9880d681SAndroid Build Coastguard Worker// rdar://13070556
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker// FIXME: we should add compact unwind support to llvm-objdump -unwind-info
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker// CHECK:      Section {
10*9880d681SAndroid Build Coastguard Worker// CHECK:        Index: 1
11*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Name: __compact_unwind
12*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Segment: __LD
13*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Address:
14*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Size:
15*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Offset:
16*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Alignment:
17*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   RelocationOffset:
18*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   RelocationCount:
19*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Type:
20*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Attributes [
21*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     Debug
22*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   ]
23*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Reserved1:
24*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Reserved2:
25*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Reserved3:
26*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   Relocations [
27*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     Relocation {
28*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Offset: 0x60
29*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       PCRel: 0
30*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Length: 3
31*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
32*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Section: __text (1)
33*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     }
34*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     Relocation {
35*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Offset: 0x40
36*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       PCRel: 0
37*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Length: 3
38*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
39*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Section: __text (1)
40*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     }
41*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     Relocation {
42*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Offset: 0x20
43*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       PCRel: 0
44*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Length: 3
45*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
46*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Section: __text (1)
47*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     }
48*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     Relocation {
49*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Offset: 0x0
50*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       PCRel: 0
51*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Length: 3
52*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Type: ARM64_RELOC_UNSIGNED (0)
53*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:       Section: __text (1)
54*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     }
55*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   ]
56*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   SectionData (
57*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0000: 00000000 00000000 08000000 00000002
58*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0010: 00000000 00000000 00000000 00000000
59*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0020: 08000000 00000000 40000000 00900002
60*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0030: 00000000 00000000 00000000 00000000
61*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0040: 48000000 00000000 D4000000 0F400002
62*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0050: 00000000 00000000 00000000 00000000
63*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0060: 1C010000 00000000 54000000 10100202
64*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:     0070: 00000000 00000000 00000000 00000000
65*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT:   )
66*9880d681SAndroid Build Coastguard Worker// CHECK-NEXT: }
67*9880d681SAndroid Build Coastguard Worker
68*9880d681SAndroid Build Coastguard Worker	.section	__TEXT,__text,regular,pure_instructions
69*9880d681SAndroid Build Coastguard Worker	.globl	_foo1
70*9880d681SAndroid Build Coastguard Worker	.align	2
71*9880d681SAndroid Build Coastguard Worker_foo1:                                  ; @foo1
72*9880d681SAndroid Build Coastguard Worker	.cfi_startproc
73*9880d681SAndroid Build Coastguard Worker; BB#0:                                 ; %entry
74*9880d681SAndroid Build Coastguard Worker	add	w0, w0, #42             ; =#42
75*9880d681SAndroid Build Coastguard Worker	ret
76*9880d681SAndroid Build Coastguard Worker	.cfi_endproc
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Worker	.globl	_foo2
79*9880d681SAndroid Build Coastguard Worker	.align	2
80*9880d681SAndroid Build Coastguard Worker_foo2:                                  ; @foo2
81*9880d681SAndroid Build Coastguard Worker	.cfi_startproc
82*9880d681SAndroid Build Coastguard Worker; BB#0:                                 ; %entry
83*9880d681SAndroid Build Coastguard Worker	sub	sp, sp, #144            ; =#144
84*9880d681SAndroid Build Coastguard WorkerLtmp2:
85*9880d681SAndroid Build Coastguard Worker	.cfi_def_cfa_offset 144
86*9880d681SAndroid Build Coastguard Worker	mov	x9, xzr
87*9880d681SAndroid Build Coastguard Worker	mov	x8, sp
88*9880d681SAndroid Build Coastguard WorkerLBB1_1:                                 ; %for.body
89*9880d681SAndroid Build Coastguard Worker                                        ; =>This Inner Loop Header: Depth=1
90*9880d681SAndroid Build Coastguard Worker	str	w9, [x8, x9, lsl #2]
91*9880d681SAndroid Build Coastguard Worker	add	x9, x9, #1              ; =#1
92*9880d681SAndroid Build Coastguard Worker	cmp	w9, #36                 ; =#36
93*9880d681SAndroid Build Coastguard Worker	b.ne	LBB1_1
94*9880d681SAndroid Build Coastguard Worker; BB#2:
95*9880d681SAndroid Build Coastguard Worker	mov	x9, xzr
96*9880d681SAndroid Build Coastguard Worker	mov	w0, wzr
97*9880d681SAndroid Build Coastguard WorkerLBB1_3:                                 ; %for.body4
98*9880d681SAndroid Build Coastguard Worker                                        ; =>This Inner Loop Header: Depth=1
99*9880d681SAndroid Build Coastguard Worker	ldr	w10, [x8, x9]
100*9880d681SAndroid Build Coastguard Worker	add	x9, x9, #4              ; =#4
101*9880d681SAndroid Build Coastguard Worker	cmp	w9, #144                ; =#144
102*9880d681SAndroid Build Coastguard Worker	add	w0, w10, w0
103*9880d681SAndroid Build Coastguard Worker	b.ne	LBB1_3
104*9880d681SAndroid Build Coastguard Worker; BB#4:                                 ; %for.end9
105*9880d681SAndroid Build Coastguard Worker	add	sp, sp, #144            ; =#144
106*9880d681SAndroid Build Coastguard Worker	ret
107*9880d681SAndroid Build Coastguard Worker	.cfi_endproc
108*9880d681SAndroid Build Coastguard Worker
109*9880d681SAndroid Build Coastguard Worker	.globl	_foo3
110*9880d681SAndroid Build Coastguard Worker	.align	2
111*9880d681SAndroid Build Coastguard Worker_foo3:                                  ; @foo3
112*9880d681SAndroid Build Coastguard Worker	.cfi_startproc
113*9880d681SAndroid Build Coastguard Worker; BB#0:                                 ; %entry
114*9880d681SAndroid Build Coastguard Worker	stp	x26, x25, [sp, #-64]!
115*9880d681SAndroid Build Coastguard Worker	stp	x24, x23, [sp, #16]
116*9880d681SAndroid Build Coastguard Worker	stp	x22, x21, [sp, #32]
117*9880d681SAndroid Build Coastguard Worker	stp	x20, x19, [sp, #48]
118*9880d681SAndroid Build Coastguard WorkerLtmp3:
119*9880d681SAndroid Build Coastguard Worker	.cfi_def_cfa_offset 64
120*9880d681SAndroid Build Coastguard WorkerLtmp4:
121*9880d681SAndroid Build Coastguard Worker	.cfi_offset w19, -16
122*9880d681SAndroid Build Coastguard WorkerLtmp5:
123*9880d681SAndroid Build Coastguard Worker	.cfi_offset w20, -24
124*9880d681SAndroid Build Coastguard WorkerLtmp6:
125*9880d681SAndroid Build Coastguard Worker	.cfi_offset w21, -32
126*9880d681SAndroid Build Coastguard WorkerLtmp7:
127*9880d681SAndroid Build Coastguard Worker	.cfi_offset w22, -40
128*9880d681SAndroid Build Coastguard WorkerLtmp8:
129*9880d681SAndroid Build Coastguard Worker	.cfi_offset w23, -48
130*9880d681SAndroid Build Coastguard WorkerLtmp9:
131*9880d681SAndroid Build Coastguard Worker	.cfi_offset w24, -56
132*9880d681SAndroid Build Coastguard WorkerLtmp10:
133*9880d681SAndroid Build Coastguard Worker	.cfi_offset w25, -64
134*9880d681SAndroid Build Coastguard WorkerLtmp11:
135*9880d681SAndroid Build Coastguard Worker	.cfi_offset w26, -72
136*9880d681SAndroid Build Coastguard WorkerLloh0:
137*9880d681SAndroid Build Coastguard Worker	adrp	x8, _bar@GOTPAGE
138*9880d681SAndroid Build Coastguard WorkerLloh1:
139*9880d681SAndroid Build Coastguard Worker	ldr	x8, [x8, _bar@GOTPAGEOFF]
140*9880d681SAndroid Build Coastguard Worker	ldr	w9, [x8]
141*9880d681SAndroid Build Coastguard Worker	ldr	w10, [x8]
142*9880d681SAndroid Build Coastguard Worker	ldr	w11, [x8]
143*9880d681SAndroid Build Coastguard Worker	ldr	w12, [x8]
144*9880d681SAndroid Build Coastguard Worker	ldr	w13, [x8]
145*9880d681SAndroid Build Coastguard Worker	ldr	w14, [x8]
146*9880d681SAndroid Build Coastguard Worker	ldr	w15, [x8]
147*9880d681SAndroid Build Coastguard Worker	ldr	w16, [x8]
148*9880d681SAndroid Build Coastguard Worker	ldr	w17, [x8]
149*9880d681SAndroid Build Coastguard Worker	ldr	w0, [x8]
150*9880d681SAndroid Build Coastguard Worker	ldr	w19, [x8]
151*9880d681SAndroid Build Coastguard Worker	ldr	w20, [x8]
152*9880d681SAndroid Build Coastguard Worker	ldr	w21, [x8]
153*9880d681SAndroid Build Coastguard Worker	ldr	w22, [x8]
154*9880d681SAndroid Build Coastguard Worker	ldr	w23, [x8]
155*9880d681SAndroid Build Coastguard Worker	ldr	w24, [x8]
156*9880d681SAndroid Build Coastguard Worker	ldr	w25, [x8]
157*9880d681SAndroid Build Coastguard Worker	ldr	w8, [x8]
158*9880d681SAndroid Build Coastguard Worker	add	w9, w10, w9
159*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w11
160*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w12
161*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w13
162*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w14
163*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w15
164*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w16
165*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w17
166*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w0
167*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w19
168*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w20
169*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w21
170*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w22
171*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w23
172*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w24
173*9880d681SAndroid Build Coastguard Worker	add	w9, w9, w25
174*9880d681SAndroid Build Coastguard Worker	sub	w8, w8, w9
175*9880d681SAndroid Build Coastguard Worker	sub	w8, w8, w7, lsl #1
176*9880d681SAndroid Build Coastguard Worker	sub	w8, w8, w6, lsl #1
177*9880d681SAndroid Build Coastguard Worker	sub	w8, w8, w5, lsl #1
178*9880d681SAndroid Build Coastguard Worker	sub	w8, w8, w4, lsl #1
179*9880d681SAndroid Build Coastguard Worker	sub	w8, w8, w3, lsl #1
180*9880d681SAndroid Build Coastguard Worker	sub	w8, w8, w2, lsl #1
181*9880d681SAndroid Build Coastguard Worker	sub	w0, w8, w1, lsl #1
182*9880d681SAndroid Build Coastguard Worker	ldp	x20, x19, [sp, #48]
183*9880d681SAndroid Build Coastguard Worker	ldp	x22, x21, [sp, #32]
184*9880d681SAndroid Build Coastguard Worker	ldp	x24, x23, [sp, #16]
185*9880d681SAndroid Build Coastguard Worker	ldp	x26, x25, [sp], #64
186*9880d681SAndroid Build Coastguard Worker	ret
187*9880d681SAndroid Build Coastguard Worker	.loh AdrpLdrGot	Lloh0, Lloh1
188*9880d681SAndroid Build Coastguard Worker	.cfi_endproc
189*9880d681SAndroid Build Coastguard Worker
190*9880d681SAndroid Build Coastguard Worker	.globl	_foo4
191*9880d681SAndroid Build Coastguard Worker	.align	2
192*9880d681SAndroid Build Coastguard Worker_foo4:                                  ; @foo4
193*9880d681SAndroid Build Coastguard Worker	.cfi_startproc
194*9880d681SAndroid Build Coastguard Worker; BB#0:                                 ; %entry
195*9880d681SAndroid Build Coastguard Worker	stp	x28, x27, [sp, #-16]!
196*9880d681SAndroid Build Coastguard Worker	sub	sp, sp, #512            ; =#512
197*9880d681SAndroid Build Coastguard WorkerLtmp12:
198*9880d681SAndroid Build Coastguard Worker	.cfi_def_cfa_offset 528
199*9880d681SAndroid Build Coastguard WorkerLtmp13:
200*9880d681SAndroid Build Coastguard Worker	.cfi_offset w27, -16
201*9880d681SAndroid Build Coastguard WorkerLtmp14:
202*9880d681SAndroid Build Coastguard Worker	.cfi_offset w28, -24
203*9880d681SAndroid Build Coastguard Worker                                        ; kill: W0<def> W0<kill> X0<def>
204*9880d681SAndroid Build Coastguard Worker	mov	x9, xzr
205*9880d681SAndroid Build Coastguard Worker	ubfx	x10, x0, #0, #32
206*9880d681SAndroid Build Coastguard Worker	mov	x8, sp
207*9880d681SAndroid Build Coastguard WorkerLBB3_1:                                 ; %for.body
208*9880d681SAndroid Build Coastguard Worker                                        ; =>This Inner Loop Header: Depth=1
209*9880d681SAndroid Build Coastguard Worker	add	w11, w10, w9
210*9880d681SAndroid Build Coastguard Worker	str	w11, [x8, x9, lsl #2]
211*9880d681SAndroid Build Coastguard Worker	add	x9, x9, #1              ; =#1
212*9880d681SAndroid Build Coastguard Worker	cmp	w9, #128                ; =#128
213*9880d681SAndroid Build Coastguard Worker	b.ne	LBB3_1
214*9880d681SAndroid Build Coastguard Worker; BB#2:                                 ; %for.cond2.preheader
215*9880d681SAndroid Build Coastguard Worker	mov	x9, xzr
216*9880d681SAndroid Build Coastguard Worker	mov	w0, wzr
217*9880d681SAndroid Build Coastguard Worker	add	x8, x8, w5, sxtw #2
218*9880d681SAndroid Build Coastguard WorkerLBB3_3:                                 ; %for.body4
219*9880d681SAndroid Build Coastguard Worker                                        ; =>This Inner Loop Header: Depth=1
220*9880d681SAndroid Build Coastguard Worker	ldr	w10, [x8, x9]
221*9880d681SAndroid Build Coastguard Worker	add	x9, x9, #4              ; =#4
222*9880d681SAndroid Build Coastguard Worker	cmp	w9, #512                ; =#512
223*9880d681SAndroid Build Coastguard Worker	add	w0, w10, w0
224*9880d681SAndroid Build Coastguard Worker	b.ne	LBB3_3
225*9880d681SAndroid Build Coastguard Worker; BB#4:                                 ; %for.end11
226*9880d681SAndroid Build Coastguard Worker	add	sp, sp, #512            ; =#512
227*9880d681SAndroid Build Coastguard Worker	ldp	x28, x27, [sp], #16
228*9880d681SAndroid Build Coastguard Worker	ret
229*9880d681SAndroid Build Coastguard Worker	.cfi_endproc
230*9880d681SAndroid Build Coastguard Worker
231*9880d681SAndroid Build Coastguard Worker	.comm	_bar,4,2                ; @bar
232*9880d681SAndroid Build Coastguard Worker
233*9880d681SAndroid Build Coastguard Worker.subsections_via_symbols
234