1# RUN: llc -o - %s -mtriple=aarch64-windows -start-after=prologepilog \
2# RUN:   -disable-branch-fold  -filetype=obj \
3# RUN: | llvm-readobj --unwind | FileCheck %s
4# Check that identical multiple epilgoues are correctly shared in .xdata.
5
6# CHECK:        ExceptionData {
7# CHECK-NEXT:      FunctionLength: 164
8# CHECK-NEXT:      Version: 0
9# CHECK-NEXT:      ExceptionData: No
10# CHECK-NEXT:      EpiloguePacked: No
11# CHECK-NEXT:      EpilogueScopes: 2
12# CHECK-NEXT:      ByteCodeLength: 32
13# CHECK-NEXT:      Prologue [
14# CHECK-NEXT:        0xc80c              ; stp x19, x20, [sp, #96]
15# CHECK-NEXT:        0xc88a              ; stp x21, x22, [sp, #80]
16# CHECK-NEXT:        0xc908              ; stp x23, x24, [sp, #64]
17# CHECK-NEXT:        0xc986              ; stp x25, x26, [sp, #48]
18# CHECK-NEXT:        0xca04              ; stp x27, x28, [sp, #32]
19# CHECK-NEXT:        0xd802              ; stp d8, d9, [sp, #16]
20# CHECK-NEXT:        0xda8d              ; stp d10, d11, [sp, #-112]!
21# CHECK-NEXT:        0xe4                ; end
22# CHECK-NEXT:      ]
23# CHECK-NEXT:      EpilogueScopes [
24# CHECK-NEXT:        EpilogueScope {
25# CHECK-NEXT:          StartOffset: 16
26# CHECK-NEXT:          EpilogueStartIndex: 15
27# CHECK-NEXT:          Opcodes [
28# CHECK-NEXT:            0xc80c              ; ldp x19, x20, [sp, #96]
29# CHECK-NEXT:            0xc88a              ; ldp x21, x22, [sp, #80]
30# CHECK-NEXT:            0xc908              ; ldp x23, x24, [sp, #64]
31# CHECK-NEXT:            0xc986              ; ldp x25, x26, [sp, #48]
32# CHECK-NEXT:            0xca04              ; ldp x27, x28, [sp, #32]
33# CHECK-NEXT:            0xd802              ; ldp d8, d9, [sp, #16]
34# CHECK-NEXT:            0xda8d              ; ldp d10, d11, [sp], #112
35# CHECK-NEXT:            0xe4                ; end
36# CHECK-NEXT:          ]
37# CHECK-NEXT:        }
38# CHECK-NEXT:        EpilogueScope {
39# CHECK-NEXT:          StartOffset: 33
40# CHECK-NEXT:          EpilogueStartIndex: 15
41# CHECK-NEXT:          Opcodes [
42# CHECK-NEXT:            0xc80c              ; ldp x19, x20, [sp, #96]
43# CHECK-NEXT:            0xc88a              ; ldp x21, x22, [sp, #80]
44# CHECK-NEXT:            0xc908              ; ldp x23, x24, [sp, #64]
45# CHECK-NEXT:            0xc986              ; ldp x25, x26, [sp, #48]
46# CHECK-NEXT:            0xca04              ; ldp x27, x28, [sp, #32]
47# CHECK-NEXT:            0xd802              ; ldp d8, d9, [sp, #16]
48# CHECK-NEXT:            0xda8d              ; ldp d10, d11, [sp], #112
49# CHECK-NEXT:            0xe4                ; end
50# CHECK-NEXT:          ]
51# CHECK-NEXT:        }
52# CHECK-NEXT:      ]
53# CHECK-NEXT:    }
54...
55---
56name:            test
57alignment:       4
58exposesReturnsTwice: false
59legalized:       false
60regBankSelected: false
61selected:        false
62failedISel:      false
63tracksRegLiveness: true
64hasWinCFI:       true
65registers:
66liveins:
67  - { reg: '$w0', virtual-reg: '' }
68frameInfo:
69  isFrameAddressTaken: false
70  isReturnAddressTaken: false
71  hasStackMap:     false
72  hasPatchPoint:   false
73  stackSize:       112
74  offsetAdjustment: 0
75  maxAlignment:    8
76  adjustsStack:    false
77  hasCalls:        false
78  stackProtector:  ''
79  maxCallFrameSize: 0
80  hasOpaqueSPAdjustment: true
81  hasVAStart:      false
82  hasMustTailInVarArgFunc: false
83  localFrameSize:  0
84  savePoint:       ''
85  restorePoint:    ''
86fixedStack:
87stack:
88  - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
89      stack-id: default, callee-saved-register: '$x19', callee-saved-restored: true,
90      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
91  - { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
92      stack-id: default, callee-saved-register: '$x20', callee-saved-restored: true,
93      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
94  - { id: 2, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8,
95      stack-id: default, callee-saved-register: '$x21', callee-saved-restored: true,
96      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
97  - { id: 3, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8,
98      stack-id: default, callee-saved-register: '$x22', callee-saved-restored: true,
99      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
100  - { id: 4, name: '', type: spill-slot, offset: -40, size: 8, alignment: 8,
101      stack-id: default, callee-saved-register: '$x23', callee-saved-restored: true,
102      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
103  - { id: 5, name: '', type: spill-slot, offset: -48, size: 8, alignment: 8,
104      stack-id: default, callee-saved-register: '$x24', callee-saved-restored: true,
105      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
106  - { id: 6, name: '', type: spill-slot, offset: -56, size: 8, alignment: 8,
107      stack-id: default, callee-saved-register: '$x25', callee-saved-restored: true,
108      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
109  - { id: 7, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
110      stack-id: default, callee-saved-register: '$x26', callee-saved-restored: true,
111      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
112  - { id: 8, name: '', type: spill-slot, offset: -72, size: 8, alignment: 8,
113      stack-id: default, callee-saved-register: '$x27', callee-saved-restored: true,
114      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
115  - { id: 9, name: '', type: spill-slot, offset: -80, size: 8, alignment: 8,
116      stack-id: default, callee-saved-register: '$x28', callee-saved-restored: true,
117      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
118  - { id: 10, name: '', type: spill-slot, offset: -88, size: 8, alignment: 8,
119      stack-id: default, callee-saved-register: '$d8', callee-saved-restored: true,
120      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
121  - { id: 11, name: '', type: spill-slot, offset: -96, size: 8, alignment: 8,
122      stack-id: default, callee-saved-register: '$d9', callee-saved-restored: true,
123      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
124  - { id: 12, name: '', type: spill-slot, offset: -104, size: 8, alignment: 8,
125      stack-id: default, callee-saved-register: '$d10', callee-saved-restored: true,
126      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
127  - { id: 13, name: '', type: spill-slot, offset: -112, size: 8, alignment: 8,
128      stack-id: default, callee-saved-register: '$d11', callee-saved-restored: true,
129      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
130constants:
131body:             |
132  bb.0.entry:
133    successors: %bb.2(0x40000000), %bb.1(0x40000000)
134    liveins: $x0, $x1, $d0, $d1, $d10, $d11, $d8, $d9, $x27, $x28, $x25, $x26, $x23, $x24, $x21, $x22, $x19, $x20
135
136    early-clobber $sp = frame-setup STPDpre killed $d10, killed $d11, $sp, -14 :: (store 8 into %stack.12), (store 8 into %stack.13)
137    frame-setup SEH_SaveFRegP_X 10, 11, -112
138    frame-setup STPDi killed $d8, killed $d9, $sp, 2 :: (store 8 into %stack.10), (store 8 into %stack.11)
139    frame-setup SEH_SaveFRegP 8, 9, 16
140    frame-setup STPXi killed $x27, killed $x28, $sp, 4 :: (store 8 into %stack.8), (store 8 into %stack.9)
141    frame-setup SEH_SaveRegP 27, 28, 32
142    frame-setup STPXi killed $x25, killed $x26, $sp, 6 :: (store 8 into %stack.6), (store 8 into %stack.7)
143    frame-setup SEH_SaveRegP 25, 26, 48
144    frame-setup STPXi killed $x23, killed $x24, $sp, 8 :: (store 8 into %stack.4), (store 8 into %stack.5)
145    frame-setup SEH_SaveRegP 23, 24, 64
146    frame-setup STPXi killed $x21, killed $x22, $sp, 10 :: (store 8 into %stack.2), (store 8 into %stack.3)
147    frame-setup SEH_SaveRegP 21, 22, 80
148    frame-setup STPXi killed $x19, killed $x20, $sp, 12 :: (store 8 into %stack.0), (store 8 into %stack.1)
149    frame-setup SEH_SaveRegP 19, 20, 96
150    frame-setup SEH_PrologEnd
151    frame-setup CFI_INSTRUCTION def_cfa_offset 112
152    frame-setup CFI_INSTRUCTION offset $w19, -8
153    frame-setup CFI_INSTRUCTION offset $w20, -16
154    frame-setup CFI_INSTRUCTION offset $w21, -24
155    frame-setup CFI_INSTRUCTION offset $w22, -32
156    frame-setup CFI_INSTRUCTION offset $w23, -40
157    frame-setup CFI_INSTRUCTION offset $w24, -48
158    frame-setup CFI_INSTRUCTION offset $w25, -56
159    frame-setup CFI_INSTRUCTION offset $w26, -64
160    frame-setup CFI_INSTRUCTION offset $w27, -72
161    frame-setup CFI_INSTRUCTION offset $w28, -80
162    frame-setup CFI_INSTRUCTION offset $b8, -88
163    frame-setup CFI_INSTRUCTION offset $b9, -96
164    frame-setup CFI_INSTRUCTION offset $b10, -104
165    frame-setup CFI_INSTRUCTION offset $b11, -112
166    $x19 = ADDXrr $x0, killed $x1
167    $d8 = FADDDrr killed $d0, $d1
168    $d9 = FADDDrr $d8, $d1
169    $d10 = FADDDrr $d9, $d8
170    $d11 = FADDDrr killed $d9, $d10
171    $x20 = SUBSXrr $x19, killed $x0, implicit-def $nzcv
172    Bcc 1, %bb.2, implicit killed $nzcv
173    B %bb.1
174
175  bb.1:
176    liveins: $x19, $x20
177
178    $x21 = ADDXrr $x20, killed $x19
179    $x22 = ADDXrr $x21, killed $x20
180    $x23 = ADDXrr $x22, killed $x21
181    $x24 = ADDXrr $x23, killed $x22
182    $x25 = ADDXrr $x24, killed $x23
183    $x26 = ADDXrr $x25, killed $x24
184    $x27 = ADDXrr $x26, killed $x25
185    $x28 = ADDXrr $x27, killed $x26
186    $x0 = COPY $x28
187    frame-destroy SEH_EpilogStart
188    $x19, $x20 = frame-destroy LDPXi $sp, 12 :: (load 8 from %stack.0), (load 8 from %stack.1)
189    frame-destroy SEH_SaveRegP 19, 20, 96
190    $x21, $x22 = frame-destroy LDPXi $sp, 10 :: (load 8 from %stack.2), (load 8 from %stack.3)
191    frame-destroy SEH_SaveRegP 21, 22, 80
192    $x23, $x24 = frame-destroy LDPXi $sp, 8 :: (load 8 from %stack.4), (load 8 from %stack.5)
193    frame-destroy SEH_SaveRegP 23, 24, 64
194    $x25, $x26 = frame-destroy LDPXi $sp, 6 :: (load 8 from %stack.6), (load 8 from %stack.7)
195    frame-destroy SEH_SaveRegP 25, 26, 48
196    $x27, $x28 = frame-destroy LDPXi $sp, 4 :: (load 8 from %stack.8), (load 8 from %stack.9)
197    frame-destroy SEH_SaveRegP 27, 28, 32
198    $d8, $d9 = frame-destroy LDPDi $sp, 2 :: (load 8 from %stack.10), (load 8 from %stack.11)
199    frame-destroy SEH_SaveFRegP 8, 9, 16
200    early-clobber $sp, $d10, $d11 = frame-destroy LDPDpost $sp, 14 :: (load 8 from %stack.12), (load 8 from %stack.13)
201    frame-destroy SEH_SaveFRegP_X 10, 11, -112
202    frame-destroy SEH_EpilogEnd
203    RET_ReallyLR implicit $x0
204
205  bb.2:
206    liveins: $x28, $d11
207
208    $x0 = COPY $d11
209    $x0 = ADDXrr $x0, killed $x28
210    frame-destroy SEH_EpilogStart
211    $x19, $x20 = frame-destroy LDPXi $sp, 12 :: (load 8 from %stack.0), (load 8 from %stack.1)
212    frame-destroy SEH_SaveRegP 19, 20, 96
213    $x21, $x22 = frame-destroy LDPXi $sp, 10 :: (load 8 from %stack.2), (load 8 from %stack.3)
214    frame-destroy SEH_SaveRegP 21, 22, 80
215    $x23, $x24 = frame-destroy LDPXi $sp, 8 :: (load 8 from %stack.4), (load 8 from %stack.5)
216    frame-destroy SEH_SaveRegP 23, 24, 64
217    $x25, $x26 = frame-destroy LDPXi $sp, 6 :: (load 8 from %stack.6), (load 8 from %stack.7)
218    frame-destroy SEH_SaveRegP 25, 26, 48
219    $x27, $x28 = frame-destroy LDPXi $sp, 4 :: (load 8 from %stack.8), (load 8 from %stack.9)
220    frame-destroy SEH_SaveRegP 27, 28, 32
221    $d8, $d9 = frame-destroy LDPDi $sp, 2 :: (load 8 from %stack.10), (load 8 from %stack.11)
222    frame-destroy SEH_SaveFRegP 8, 9, 16
223    early-clobber $sp, $d10, $d11 = frame-destroy LDPDpost $sp, 14 :: (load 8 from %stack.12), (load 8 from %stack.13)
224    frame-destroy SEH_SaveFRegP_X 10, 11, -112
225    frame-destroy SEH_EpilogEnd
226    RET_ReallyLR implicit $x0
227
228...
229