1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --extra_scrub
2; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -O0 -global-isel=0 -global-isel-abort=0 < %s | FileCheck %s
3; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -O0 -global-isel=1 -global-isel-abort=0 < %s | FileCheck %s --check-prefix=GISEL
4
5; Test that z0 is saved/restored, as the unwinder may only retain the low 64bits (d0).
6define <vscale x 4 x i32> @invoke_callee_may_throw_sve(<vscale x 4 x i32> %v) personality i8 0 {
7; CHECK-LABEL: invoke_callee_may_throw_sve:
8; CHECK:       .Lfunc_begin0:
9; CHECK-NEXT:    .cfi_startproc
10; CHECK-NEXT:  // %bb.0:
11; CHECK-NEXT:    stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
12; CHECK-NEXT:    addvl sp, sp, #-18
13; CHECK-NEXT:    str p15, [sp, #4, mul vl] // 2-byte Folded Spill
14; CHECK-NEXT:    str p14, [sp, #5, mul vl] // 2-byte Folded Spill
15; CHECK-NEXT:    str p13, [sp, #6, mul vl] // 2-byte Folded Spill
16; CHECK-NEXT:    str p12, [sp, #7, mul vl] // 2-byte Folded Spill
17; CHECK-NEXT:    str p11, [sp, #8, mul vl] // 2-byte Folded Spill
18; CHECK-NEXT:    str p10, [sp, #9, mul vl] // 2-byte Folded Spill
19; CHECK-NEXT:    str p9, [sp, #10, mul vl] // 2-byte Folded Spill
20; CHECK-NEXT:    str p8, [sp, #11, mul vl] // 2-byte Folded Spill
21; CHECK-NEXT:    str p7, [sp, #12, mul vl] // 2-byte Folded Spill
22; CHECK-NEXT:    str p6, [sp, #13, mul vl] // 2-byte Folded Spill
23; CHECK-NEXT:    str p5, [sp, #14, mul vl] // 2-byte Folded Spill
24; CHECK-NEXT:    str p4, [sp, #15, mul vl] // 2-byte Folded Spill
25; CHECK-NEXT:    str z23, [sp, #2, mul vl] // 16-byte Folded Spill
26; CHECK-NEXT:    str z22, [sp, #3, mul vl] // 16-byte Folded Spill
27; CHECK-NEXT:    str z21, [sp, #4, mul vl] // 16-byte Folded Spill
28; CHECK-NEXT:    str z20, [sp, #5, mul vl] // 16-byte Folded Spill
29; CHECK-NEXT:    str z19, [sp, #6, mul vl] // 16-byte Folded Spill
30; CHECK-NEXT:    str z18, [sp, #7, mul vl] // 16-byte Folded Spill
31; CHECK-NEXT:    str z17, [sp, #8, mul vl] // 16-byte Folded Spill
32; CHECK-NEXT:    str z16, [sp, #9, mul vl] // 16-byte Folded Spill
33; CHECK-NEXT:    str z15, [sp, #10, mul vl] // 16-byte Folded Spill
34; CHECK-NEXT:    str z14, [sp, #11, mul vl] // 16-byte Folded Spill
35; CHECK-NEXT:    str z13, [sp, #12, mul vl] // 16-byte Folded Spill
36; CHECK-NEXT:    str z12, [sp, #13, mul vl] // 16-byte Folded Spill
37; CHECK-NEXT:    str z11, [sp, #14, mul vl] // 16-byte Folded Spill
38; CHECK-NEXT:    str z10, [sp, #15, mul vl] // 16-byte Folded Spill
39; CHECK-NEXT:    str z9, [sp, #16, mul vl] // 16-byte Folded Spill
40; CHECK-NEXT:    str z8, [sp, #17, mul vl] // 16-byte Folded Spill
41; CHECK-NEXT:    addvl sp, sp, #-2
42; CHECK-NEXT:    .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xa0, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 160 * VG
43; CHECK-NEXT:    .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG
44; CHECK-NEXT:    .cfi_escape 0x10, 0x49, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x70, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d9 @ cfa - 16 - 16 * VG
45; CHECK-NEXT:    .cfi_escape 0x10, 0x4a, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x68, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d10 @ cfa - 16 - 24 * VG
46; CHECK-NEXT:    .cfi_escape 0x10, 0x4b, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x60, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d11 @ cfa - 16 - 32 * VG
47; CHECK-NEXT:    .cfi_escape 0x10, 0x4c, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x58, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d12 @ cfa - 16 - 40 * VG
48; CHECK-NEXT:    .cfi_escape 0x10, 0x4d, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x50, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d13 @ cfa - 16 - 48 * VG
49; CHECK-NEXT:    .cfi_escape 0x10, 0x4e, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x48, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d14 @ cfa - 16 - 56 * VG
50; CHECK-NEXT:    .cfi_escape 0x10, 0x4f, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x40, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d15 @ cfa - 16 - 64 * VG
51; CHECK-NEXT:    .cfi_offset w30, -8
52; CHECK-NEXT:    .cfi_offset w29, -16
53; CHECK-NEXT:    str z0, [sp] // 16-byte Folded Spill
54; CHECK-NEXT:  .Ltmp0:
55; CHECK-NEXT:    bl may_throw_sve
56; CHECK-NEXT:  .Ltmp1:
57; CHECK-NEXT:    str z0, [sp, #1, mul vl] // 16-byte Folded Spill
58; CHECK-NEXT:    b .LBB0_1
59; CHECK-NEXT:  .LBB0_1: // %.Lcontinue
60; CHECK-NEXT:    ldr z0, [sp, #1, mul vl] // 16-byte Folded Reload
61; CHECK-NEXT:    addvl sp, sp, #2
62; CHECK-NEXT:    ldr p15, [sp, #4, mul vl] // 2-byte Folded Reload
63; CHECK-NEXT:    ldr p14, [sp, #5, mul vl] // 2-byte Folded Reload
64; CHECK-NEXT:    ldr p13, [sp, #6, mul vl] // 2-byte Folded Reload
65; CHECK-NEXT:    ldr p12, [sp, #7, mul vl] // 2-byte Folded Reload
66; CHECK-NEXT:    ldr p11, [sp, #8, mul vl] // 2-byte Folded Reload
67; CHECK-NEXT:    ldr p10, [sp, #9, mul vl] // 2-byte Folded Reload
68; CHECK-NEXT:    ldr p9, [sp, #10, mul vl] // 2-byte Folded Reload
69; CHECK-NEXT:    ldr p8, [sp, #11, mul vl] // 2-byte Folded Reload
70; CHECK-NEXT:    ldr p7, [sp, #12, mul vl] // 2-byte Folded Reload
71; CHECK-NEXT:    ldr p6, [sp, #13, mul vl] // 2-byte Folded Reload
72; CHECK-NEXT:    ldr p5, [sp, #14, mul vl] // 2-byte Folded Reload
73; CHECK-NEXT:    ldr p4, [sp, #15, mul vl] // 2-byte Folded Reload
74; CHECK-NEXT:    ldr z23, [sp, #2, mul vl] // 16-byte Folded Reload
75; CHECK-NEXT:    ldr z22, [sp, #3, mul vl] // 16-byte Folded Reload
76; CHECK-NEXT:    ldr z21, [sp, #4, mul vl] // 16-byte Folded Reload
77; CHECK-NEXT:    ldr z20, [sp, #5, mul vl] // 16-byte Folded Reload
78; CHECK-NEXT:    ldr z19, [sp, #6, mul vl] // 16-byte Folded Reload
79; CHECK-NEXT:    ldr z18, [sp, #7, mul vl] // 16-byte Folded Reload
80; CHECK-NEXT:    ldr z17, [sp, #8, mul vl] // 16-byte Folded Reload
81; CHECK-NEXT:    ldr z16, [sp, #9, mul vl] // 16-byte Folded Reload
82; CHECK-NEXT:    ldr z15, [sp, #10, mul vl] // 16-byte Folded Reload
83; CHECK-NEXT:    ldr z14, [sp, #11, mul vl] // 16-byte Folded Reload
84; CHECK-NEXT:    ldr z13, [sp, #12, mul vl] // 16-byte Folded Reload
85; CHECK-NEXT:    ldr z12, [sp, #13, mul vl] // 16-byte Folded Reload
86; CHECK-NEXT:    ldr z11, [sp, #14, mul vl] // 16-byte Folded Reload
87; CHECK-NEXT:    ldr z10, [sp, #15, mul vl] // 16-byte Folded Reload
88; CHECK-NEXT:    ldr z9, [sp, #16, mul vl] // 16-byte Folded Reload
89; CHECK-NEXT:    ldr z8, [sp, #17, mul vl] // 16-byte Folded Reload
90; CHECK-NEXT:    addvl sp, sp, #18
91; CHECK-NEXT:    ldp x29, x30, [sp], #16 // 16-byte Folded Reload
92; CHECK-NEXT:    ret
93; CHECK-NEXT:  .LBB0_2: // %.Lunwind
94; CHECK-NEXT:  .Ltmp2:
95; CHECK-NEXT:    ldr z0, [sp] // 16-byte Folded Reload
96; CHECK-NEXT:    addvl sp, sp, #2
97; CHECK-NEXT:    ldr p15, [sp, #4, mul vl] // 2-byte Folded Reload
98; CHECK-NEXT:    ldr p14, [sp, #5, mul vl] // 2-byte Folded Reload
99; CHECK-NEXT:    ldr p13, [sp, #6, mul vl] // 2-byte Folded Reload
100; CHECK-NEXT:    ldr p12, [sp, #7, mul vl] // 2-byte Folded Reload
101; CHECK-NEXT:    ldr p11, [sp, #8, mul vl] // 2-byte Folded Reload
102; CHECK-NEXT:    ldr p10, [sp, #9, mul vl] // 2-byte Folded Reload
103; CHECK-NEXT:    ldr p9, [sp, #10, mul vl] // 2-byte Folded Reload
104; CHECK-NEXT:    ldr p8, [sp, #11, mul vl] // 2-byte Folded Reload
105; CHECK-NEXT:    ldr p7, [sp, #12, mul vl] // 2-byte Folded Reload
106; CHECK-NEXT:    ldr p6, [sp, #13, mul vl] // 2-byte Folded Reload
107; CHECK-NEXT:    ldr p5, [sp, #14, mul vl] // 2-byte Folded Reload
108; CHECK-NEXT:    ldr p4, [sp, #15, mul vl] // 2-byte Folded Reload
109; CHECK-NEXT:    ldr z23, [sp, #2, mul vl] // 16-byte Folded Reload
110; CHECK-NEXT:    ldr z22, [sp, #3, mul vl] // 16-byte Folded Reload
111; CHECK-NEXT:    ldr z21, [sp, #4, mul vl] // 16-byte Folded Reload
112; CHECK-NEXT:    ldr z20, [sp, #5, mul vl] // 16-byte Folded Reload
113; CHECK-NEXT:    ldr z19, [sp, #6, mul vl] // 16-byte Folded Reload
114; CHECK-NEXT:    ldr z18, [sp, #7, mul vl] // 16-byte Folded Reload
115; CHECK-NEXT:    ldr z17, [sp, #8, mul vl] // 16-byte Folded Reload
116; CHECK-NEXT:    ldr z16, [sp, #9, mul vl] // 16-byte Folded Reload
117; CHECK-NEXT:    ldr z15, [sp, #10, mul vl] // 16-byte Folded Reload
118; CHECK-NEXT:    ldr z14, [sp, #11, mul vl] // 16-byte Folded Reload
119; CHECK-NEXT:    ldr z13, [sp, #12, mul vl] // 16-byte Folded Reload
120; CHECK-NEXT:    ldr z12, [sp, #13, mul vl] // 16-byte Folded Reload
121; CHECK-NEXT:    ldr z11, [sp, #14, mul vl] // 16-byte Folded Reload
122; CHECK-NEXT:    ldr z10, [sp, #15, mul vl] // 16-byte Folded Reload
123; CHECK-NEXT:    ldr z9, [sp, #16, mul vl] // 16-byte Folded Reload
124; CHECK-NEXT:    ldr z8, [sp, #17, mul vl] // 16-byte Folded Reload
125; CHECK-NEXT:    addvl sp, sp, #18
126; CHECK-NEXT:    ldp x29, x30, [sp], #16 // 16-byte Folded Reload
127; CHECK-NEXT:    ret
128;
129; GISEL-LABEL: invoke_callee_may_throw_sve:
130; GISEL:       .Lfunc_begin0:
131; GISEL-NEXT:    .cfi_startproc
132; GISEL-NEXT:  // %bb.0:
133; GISEL-NEXT:    stp x29, x30, [sp, #-16]! // 16-byte Folded Spill
134; GISEL-NEXT:    addvl sp, sp, #-18
135; GISEL-NEXT:    str p15, [sp, #4, mul vl] // 2-byte Folded Spill
136; GISEL-NEXT:    str p14, [sp, #5, mul vl] // 2-byte Folded Spill
137; GISEL-NEXT:    str p13, [sp, #6, mul vl] // 2-byte Folded Spill
138; GISEL-NEXT:    str p12, [sp, #7, mul vl] // 2-byte Folded Spill
139; GISEL-NEXT:    str p11, [sp, #8, mul vl] // 2-byte Folded Spill
140; GISEL-NEXT:    str p10, [sp, #9, mul vl] // 2-byte Folded Spill
141; GISEL-NEXT:    str p9, [sp, #10, mul vl] // 2-byte Folded Spill
142; GISEL-NEXT:    str p8, [sp, #11, mul vl] // 2-byte Folded Spill
143; GISEL-NEXT:    str p7, [sp, #12, mul vl] // 2-byte Folded Spill
144; GISEL-NEXT:    str p6, [sp, #13, mul vl] // 2-byte Folded Spill
145; GISEL-NEXT:    str p5, [sp, #14, mul vl] // 2-byte Folded Spill
146; GISEL-NEXT:    str p4, [sp, #15, mul vl] // 2-byte Folded Spill
147; GISEL-NEXT:    str z23, [sp, #2, mul vl] // 16-byte Folded Spill
148; GISEL-NEXT:    str z22, [sp, #3, mul vl] // 16-byte Folded Spill
149; GISEL-NEXT:    str z21, [sp, #4, mul vl] // 16-byte Folded Spill
150; GISEL-NEXT:    str z20, [sp, #5, mul vl] // 16-byte Folded Spill
151; GISEL-NEXT:    str z19, [sp, #6, mul vl] // 16-byte Folded Spill
152; GISEL-NEXT:    str z18, [sp, #7, mul vl] // 16-byte Folded Spill
153; GISEL-NEXT:    str z17, [sp, #8, mul vl] // 16-byte Folded Spill
154; GISEL-NEXT:    str z16, [sp, #9, mul vl] // 16-byte Folded Spill
155; GISEL-NEXT:    str z15, [sp, #10, mul vl] // 16-byte Folded Spill
156; GISEL-NEXT:    str z14, [sp, #11, mul vl] // 16-byte Folded Spill
157; GISEL-NEXT:    str z13, [sp, #12, mul vl] // 16-byte Folded Spill
158; GISEL-NEXT:    str z12, [sp, #13, mul vl] // 16-byte Folded Spill
159; GISEL-NEXT:    str z11, [sp, #14, mul vl] // 16-byte Folded Spill
160; GISEL-NEXT:    str z10, [sp, #15, mul vl] // 16-byte Folded Spill
161; GISEL-NEXT:    str z9, [sp, #16, mul vl] // 16-byte Folded Spill
162; GISEL-NEXT:    str z8, [sp, #17, mul vl] // 16-byte Folded Spill
163; GISEL-NEXT:    addvl sp, sp, #-2
164; GISEL-NEXT:    .cfi_escape 0x0f, 0x0d, 0x8f, 0x00, 0x11, 0x10, 0x22, 0x11, 0xa0, 0x01, 0x92, 0x2e, 0x00, 0x1e, 0x22 // sp + 16 + 160 * VG
165; GISEL-NEXT:    .cfi_escape 0x10, 0x48, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x78, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d8 @ cfa - 16 - 8 * VG
166; GISEL-NEXT:    .cfi_escape 0x10, 0x49, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x70, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d9 @ cfa - 16 - 16 * VG
167; GISEL-NEXT:    .cfi_escape 0x10, 0x4a, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x68, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d10 @ cfa - 16 - 24 * VG
168; GISEL-NEXT:    .cfi_escape 0x10, 0x4b, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x60, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d11 @ cfa - 16 - 32 * VG
169; GISEL-NEXT:    .cfi_escape 0x10, 0x4c, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x58, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d12 @ cfa - 16 - 40 * VG
170; GISEL-NEXT:    .cfi_escape 0x10, 0x4d, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x50, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d13 @ cfa - 16 - 48 * VG
171; GISEL-NEXT:    .cfi_escape 0x10, 0x4e, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x48, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d14 @ cfa - 16 - 56 * VG
172; GISEL-NEXT:    .cfi_escape 0x10, 0x4f, 0x0a, 0x11, 0x70, 0x22, 0x11, 0x40, 0x92, 0x2e, 0x00, 0x1e, 0x22 // $d15 @ cfa - 16 - 64 * VG
173; GISEL-NEXT:    .cfi_offset w30, -8
174; GISEL-NEXT:    .cfi_offset w29, -16
175; GISEL-NEXT:    str z0, [sp] // 16-byte Folded Spill
176; GISEL-NEXT:  .Ltmp0:
177; GISEL-NEXT:    bl may_throw_sve
178; GISEL-NEXT:  .Ltmp1:
179; GISEL-NEXT:    str z0, [sp, #1, mul vl] // 16-byte Folded Spill
180; GISEL-NEXT:    b .LBB0_1
181; GISEL-NEXT:  .LBB0_1: // %.Lcontinue
182; GISEL-NEXT:    ldr z0, [sp, #1, mul vl] // 16-byte Folded Reload
183; GISEL-NEXT:    addvl sp, sp, #2
184; GISEL-NEXT:    ldr p15, [sp, #4, mul vl] // 2-byte Folded Reload
185; GISEL-NEXT:    ldr p14, [sp, #5, mul vl] // 2-byte Folded Reload
186; GISEL-NEXT:    ldr p13, [sp, #6, mul vl] // 2-byte Folded Reload
187; GISEL-NEXT:    ldr p12, [sp, #7, mul vl] // 2-byte Folded Reload
188; GISEL-NEXT:    ldr p11, [sp, #8, mul vl] // 2-byte Folded Reload
189; GISEL-NEXT:    ldr p10, [sp, #9, mul vl] // 2-byte Folded Reload
190; GISEL-NEXT:    ldr p9, [sp, #10, mul vl] // 2-byte Folded Reload
191; GISEL-NEXT:    ldr p8, [sp, #11, mul vl] // 2-byte Folded Reload
192; GISEL-NEXT:    ldr p7, [sp, #12, mul vl] // 2-byte Folded Reload
193; GISEL-NEXT:    ldr p6, [sp, #13, mul vl] // 2-byte Folded Reload
194; GISEL-NEXT:    ldr p5, [sp, #14, mul vl] // 2-byte Folded Reload
195; GISEL-NEXT:    ldr p4, [sp, #15, mul vl] // 2-byte Folded Reload
196; GISEL-NEXT:    ldr z23, [sp, #2, mul vl] // 16-byte Folded Reload
197; GISEL-NEXT:    ldr z22, [sp, #3, mul vl] // 16-byte Folded Reload
198; GISEL-NEXT:    ldr z21, [sp, #4, mul vl] // 16-byte Folded Reload
199; GISEL-NEXT:    ldr z20, [sp, #5, mul vl] // 16-byte Folded Reload
200; GISEL-NEXT:    ldr z19, [sp, #6, mul vl] // 16-byte Folded Reload
201; GISEL-NEXT:    ldr z18, [sp, #7, mul vl] // 16-byte Folded Reload
202; GISEL-NEXT:    ldr z17, [sp, #8, mul vl] // 16-byte Folded Reload
203; GISEL-NEXT:    ldr z16, [sp, #9, mul vl] // 16-byte Folded Reload
204; GISEL-NEXT:    ldr z15, [sp, #10, mul vl] // 16-byte Folded Reload
205; GISEL-NEXT:    ldr z14, [sp, #11, mul vl] // 16-byte Folded Reload
206; GISEL-NEXT:    ldr z13, [sp, #12, mul vl] // 16-byte Folded Reload
207; GISEL-NEXT:    ldr z12, [sp, #13, mul vl] // 16-byte Folded Reload
208; GISEL-NEXT:    ldr z11, [sp, #14, mul vl] // 16-byte Folded Reload
209; GISEL-NEXT:    ldr z10, [sp, #15, mul vl] // 16-byte Folded Reload
210; GISEL-NEXT:    ldr z9, [sp, #16, mul vl] // 16-byte Folded Reload
211; GISEL-NEXT:    ldr z8, [sp, #17, mul vl] // 16-byte Folded Reload
212; GISEL-NEXT:    addvl sp, sp, #18
213; GISEL-NEXT:    ldp x29, x30, [sp], #16 // 16-byte Folded Reload
214; GISEL-NEXT:    ret
215; GISEL-NEXT:  .LBB0_2: // %.Lunwind
216; GISEL-NEXT:  .Ltmp2:
217; GISEL-NEXT:    ldr z0, [sp] // 16-byte Folded Reload
218; GISEL-NEXT:    addvl sp, sp, #2
219; GISEL-NEXT:    ldr p15, [sp, #4, mul vl] // 2-byte Folded Reload
220; GISEL-NEXT:    ldr p14, [sp, #5, mul vl] // 2-byte Folded Reload
221; GISEL-NEXT:    ldr p13, [sp, #6, mul vl] // 2-byte Folded Reload
222; GISEL-NEXT:    ldr p12, [sp, #7, mul vl] // 2-byte Folded Reload
223; GISEL-NEXT:    ldr p11, [sp, #8, mul vl] // 2-byte Folded Reload
224; GISEL-NEXT:    ldr p10, [sp, #9, mul vl] // 2-byte Folded Reload
225; GISEL-NEXT:    ldr p9, [sp, #10, mul vl] // 2-byte Folded Reload
226; GISEL-NEXT:    ldr p8, [sp, #11, mul vl] // 2-byte Folded Reload
227; GISEL-NEXT:    ldr p7, [sp, #12, mul vl] // 2-byte Folded Reload
228; GISEL-NEXT:    ldr p6, [sp, #13, mul vl] // 2-byte Folded Reload
229; GISEL-NEXT:    ldr p5, [sp, #14, mul vl] // 2-byte Folded Reload
230; GISEL-NEXT:    ldr p4, [sp, #15, mul vl] // 2-byte Folded Reload
231; GISEL-NEXT:    ldr z23, [sp, #2, mul vl] // 16-byte Folded Reload
232; GISEL-NEXT:    ldr z22, [sp, #3, mul vl] // 16-byte Folded Reload
233; GISEL-NEXT:    ldr z21, [sp, #4, mul vl] // 16-byte Folded Reload
234; GISEL-NEXT:    ldr z20, [sp, #5, mul vl] // 16-byte Folded Reload
235; GISEL-NEXT:    ldr z19, [sp, #6, mul vl] // 16-byte Folded Reload
236; GISEL-NEXT:    ldr z18, [sp, #7, mul vl] // 16-byte Folded Reload
237; GISEL-NEXT:    ldr z17, [sp, #8, mul vl] // 16-byte Folded Reload
238; GISEL-NEXT:    ldr z16, [sp, #9, mul vl] // 16-byte Folded Reload
239; GISEL-NEXT:    ldr z15, [sp, #10, mul vl] // 16-byte Folded Reload
240; GISEL-NEXT:    ldr z14, [sp, #11, mul vl] // 16-byte Folded Reload
241; GISEL-NEXT:    ldr z13, [sp, #12, mul vl] // 16-byte Folded Reload
242; GISEL-NEXT:    ldr z12, [sp, #13, mul vl] // 16-byte Folded Reload
243; GISEL-NEXT:    ldr z11, [sp, #14, mul vl] // 16-byte Folded Reload
244; GISEL-NEXT:    ldr z10, [sp, #15, mul vl] // 16-byte Folded Reload
245; GISEL-NEXT:    ldr z9, [sp, #16, mul vl] // 16-byte Folded Reload
246; GISEL-NEXT:    ldr z8, [sp, #17, mul vl] // 16-byte Folded Reload
247; GISEL-NEXT:    addvl sp, sp, #18
248; GISEL-NEXT:    ldp x29, x30, [sp], #16 // 16-byte Folded Reload
249; GISEL-NEXT:    ret
250  %result = invoke <vscale x 4 x i32> @may_throw_sve(<vscale x 4 x i32> %v) to label %.Lcontinue unwind label %.Lunwind
251.Lcontinue:
252  ret <vscale x 4 x i32> %result
253.Lunwind:
254  %lp = landingpad { i8*, i32 } cleanup
255  ret <vscale x 4 x i32> %v;
256}
257
258declare <vscale x 4 x i32> @may_throw_sve(<vscale x 4 x i32> %v);
259
260
261; Test that q0 is saved/restored, as the unwinder may only retain the low 64bits (d0).
262define aarch64_vector_pcs <4 x i32> @invoke_callee_may_throw_neon(<4 x i32> %v) personality i8 0 {
263; CHECK-LABEL: invoke_callee_may_throw_neon:
264; CHECK:       .Lfunc_begin1:
265; CHECK-NEXT:    .cfi_startproc
266; CHECK-NEXT:  // %bb.0:
267; CHECK-NEXT:    sub sp, sp, #304 // =304
268; CHECK-NEXT:    stp q23, q22, [sp, #32] // 32-byte Folded Spill
269; CHECK-NEXT:    stp q21, q20, [sp, #64] // 32-byte Folded Spill
270; CHECK-NEXT:    stp q19, q18, [sp, #96] // 32-byte Folded Spill
271; CHECK-NEXT:    stp q17, q16, [sp, #128] // 32-byte Folded Spill
272; CHECK-NEXT:    stp q15, q14, [sp, #160] // 32-byte Folded Spill
273; CHECK-NEXT:    stp q13, q12, [sp, #192] // 32-byte Folded Spill
274; CHECK-NEXT:    stp q11, q10, [sp, #224] // 32-byte Folded Spill
275; CHECK-NEXT:    stp q9, q8, [sp, #256] // 32-byte Folded Spill
276; CHECK-NEXT:    stp x29, x30, [sp, #288] // 16-byte Folded Spill
277; CHECK-NEXT:    .cfi_def_cfa_offset 304
278; CHECK-NEXT:    .cfi_offset w30, -8
279; CHECK-NEXT:    .cfi_offset w29, -16
280; CHECK-NEXT:    .cfi_offset b8, -32
281; CHECK-NEXT:    .cfi_offset b9, -48
282; CHECK-NEXT:    .cfi_offset b10, -64
283; CHECK-NEXT:    .cfi_offset b11, -80
284; CHECK-NEXT:    .cfi_offset b12, -96
285; CHECK-NEXT:    .cfi_offset b13, -112
286; CHECK-NEXT:    .cfi_offset b14, -128
287; CHECK-NEXT:    .cfi_offset b15, -144
288; CHECK-NEXT:    .cfi_offset b16, -160
289; CHECK-NEXT:    .cfi_offset b17, -176
290; CHECK-NEXT:    .cfi_offset b18, -192
291; CHECK-NEXT:    .cfi_offset b19, -208
292; CHECK-NEXT:    .cfi_offset b20, -224
293; CHECK-NEXT:    .cfi_offset b21, -240
294; CHECK-NEXT:    .cfi_offset b22, -256
295; CHECK-NEXT:    .cfi_offset b23, -272
296; CHECK-NEXT:    str q0, [sp] // 16-byte Folded Spill
297; CHECK-NEXT:  .Ltmp3:
298; CHECK-NEXT:    bl may_throw_neon
299; CHECK-NEXT:  .Ltmp4:
300; CHECK-NEXT:    str q0, [sp, #16] // 16-byte Folded Spill
301; CHECK-NEXT:    b .LBB1_1
302; CHECK-NEXT:  .LBB1_1: // %.Lcontinue
303; CHECK-NEXT:    ldr q0, [sp, #16] // 16-byte Folded Reload
304; CHECK-NEXT:    ldp x29, x30, [sp, #288] // 16-byte Folded Reload
305; CHECK-NEXT:    ldp q9, q8, [sp, #256] // 32-byte Folded Reload
306; CHECK-NEXT:    ldp q11, q10, [sp, #224] // 32-byte Folded Reload
307; CHECK-NEXT:    ldp q13, q12, [sp, #192] // 32-byte Folded Reload
308; CHECK-NEXT:    ldp q15, q14, [sp, #160] // 32-byte Folded Reload
309; CHECK-NEXT:    ldp q17, q16, [sp, #128] // 32-byte Folded Reload
310; CHECK-NEXT:    ldp q19, q18, [sp, #96] // 32-byte Folded Reload
311; CHECK-NEXT:    ldp q21, q20, [sp, #64] // 32-byte Folded Reload
312; CHECK-NEXT:    ldp q23, q22, [sp, #32] // 32-byte Folded Reload
313; CHECK-NEXT:    add sp, sp, #304 // =304
314; CHECK-NEXT:    ret
315; CHECK-NEXT:  .LBB1_2: // %.Lunwind
316; CHECK-NEXT:  .Ltmp5:
317; CHECK-NEXT:    ldr q0, [sp] // 16-byte Folded Reload
318; CHECK-NEXT:    ldp x29, x30, [sp, #288] // 16-byte Folded Reload
319; CHECK-NEXT:    ldp q9, q8, [sp, #256] // 32-byte Folded Reload
320; CHECK-NEXT:    ldp q11, q10, [sp, #224] // 32-byte Folded Reload
321; CHECK-NEXT:    ldp q13, q12, [sp, #192] // 32-byte Folded Reload
322; CHECK-NEXT:    ldp q15, q14, [sp, #160] // 32-byte Folded Reload
323; CHECK-NEXT:    ldp q17, q16, [sp, #128] // 32-byte Folded Reload
324; CHECK-NEXT:    ldp q19, q18, [sp, #96] // 32-byte Folded Reload
325; CHECK-NEXT:    ldp q21, q20, [sp, #64] // 32-byte Folded Reload
326; CHECK-NEXT:    ldp q23, q22, [sp, #32] // 32-byte Folded Reload
327; CHECK-NEXT:    add sp, sp, #304 // =304
328; CHECK-NEXT:    ret
329;
330; GISEL-LABEL: invoke_callee_may_throw_neon:
331; GISEL:       .Lfunc_begin1:
332; GISEL-NEXT:    .cfi_startproc
333; GISEL-NEXT:  // %bb.0:
334; GISEL-NEXT:    sub sp, sp, #304 // =304
335; GISEL-NEXT:    stp q23, q22, [sp, #32] // 32-byte Folded Spill
336; GISEL-NEXT:    stp q21, q20, [sp, #64] // 32-byte Folded Spill
337; GISEL-NEXT:    stp q19, q18, [sp, #96] // 32-byte Folded Spill
338; GISEL-NEXT:    stp q17, q16, [sp, #128] // 32-byte Folded Spill
339; GISEL-NEXT:    stp q15, q14, [sp, #160] // 32-byte Folded Spill
340; GISEL-NEXT:    stp q13, q12, [sp, #192] // 32-byte Folded Spill
341; GISEL-NEXT:    stp q11, q10, [sp, #224] // 32-byte Folded Spill
342; GISEL-NEXT:    stp q9, q8, [sp, #256] // 32-byte Folded Spill
343; GISEL-NEXT:    stp x29, x30, [sp, #288] // 16-byte Folded Spill
344; GISEL-NEXT:    .cfi_def_cfa_offset 304
345; GISEL-NEXT:    .cfi_offset w30, -8
346; GISEL-NEXT:    .cfi_offset w29, -16
347; GISEL-NEXT:    .cfi_offset b8, -32
348; GISEL-NEXT:    .cfi_offset b9, -48
349; GISEL-NEXT:    .cfi_offset b10, -64
350; GISEL-NEXT:    .cfi_offset b11, -80
351; GISEL-NEXT:    .cfi_offset b12, -96
352; GISEL-NEXT:    .cfi_offset b13, -112
353; GISEL-NEXT:    .cfi_offset b14, -128
354; GISEL-NEXT:    .cfi_offset b15, -144
355; GISEL-NEXT:    .cfi_offset b16, -160
356; GISEL-NEXT:    .cfi_offset b17, -176
357; GISEL-NEXT:    .cfi_offset b18, -192
358; GISEL-NEXT:    .cfi_offset b19, -208
359; GISEL-NEXT:    .cfi_offset b20, -224
360; GISEL-NEXT:    .cfi_offset b21, -240
361; GISEL-NEXT:    .cfi_offset b22, -256
362; GISEL-NEXT:    .cfi_offset b23, -272
363; GISEL-NEXT:    str q0, [sp] // 16-byte Folded Spill
364; GISEL-NEXT:  .Ltmp3:
365; GISEL-NEXT:    bl may_throw_neon
366; GISEL-NEXT:    str q0, [sp, #16] // 16-byte Folded Spill
367; GISEL-NEXT:  .Ltmp4:
368; GISEL-NEXT:  // %bb.1: // %.Lcontinue
369; GISEL-NEXT:    ldr q0, [sp, #16] // 16-byte Folded Reload
370; GISEL-NEXT:    ldp x29, x30, [sp, #288] // 16-byte Folded Reload
371; GISEL-NEXT:    ldp q9, q8, [sp, #256] // 32-byte Folded Reload
372; GISEL-NEXT:    ldp q11, q10, [sp, #224] // 32-byte Folded Reload
373; GISEL-NEXT:    ldp q13, q12, [sp, #192] // 32-byte Folded Reload
374; GISEL-NEXT:    ldp q15, q14, [sp, #160] // 32-byte Folded Reload
375; GISEL-NEXT:    ldp q17, q16, [sp, #128] // 32-byte Folded Reload
376; GISEL-NEXT:    ldp q19, q18, [sp, #96] // 32-byte Folded Reload
377; GISEL-NEXT:    ldp q21, q20, [sp, #64] // 32-byte Folded Reload
378; GISEL-NEXT:    ldp q23, q22, [sp, #32] // 32-byte Folded Reload
379; GISEL-NEXT:    add sp, sp, #304 // =304
380; GISEL-NEXT:    ret
381; GISEL-NEXT:  .LBB1_2: // %.Lunwind
382; GISEL-NEXT:  .Ltmp5:
383; GISEL-NEXT:    ldr q0, [sp] // 16-byte Folded Reload
384; GISEL-NEXT:    ldp x29, x30, [sp, #288] // 16-byte Folded Reload
385; GISEL-NEXT:    ldp q9, q8, [sp, #256] // 32-byte Folded Reload
386; GISEL-NEXT:    ldp q11, q10, [sp, #224] // 32-byte Folded Reload
387; GISEL-NEXT:    ldp q13, q12, [sp, #192] // 32-byte Folded Reload
388; GISEL-NEXT:    ldp q15, q14, [sp, #160] // 32-byte Folded Reload
389; GISEL-NEXT:    ldp q17, q16, [sp, #128] // 32-byte Folded Reload
390; GISEL-NEXT:    ldp q19, q18, [sp, #96] // 32-byte Folded Reload
391; GISEL-NEXT:    ldp q21, q20, [sp, #64] // 32-byte Folded Reload
392; GISEL-NEXT:    ldp q23, q22, [sp, #32] // 32-byte Folded Reload
393; GISEL-NEXT:    add sp, sp, #304 // =304
394; GISEL-NEXT:    ret
395  %result = invoke aarch64_vector_pcs <4 x i32> @may_throw_neon(<4 x i32> %v) to label %.Lcontinue unwind label %.Lunwind
396.Lcontinue:
397  ret <4 x i32> %result
398.Lunwind:
399  %lp = landingpad { i8*, i32 } cleanup
400  ret <4 x i32> %v;
401}
402
403declare aarch64_vector_pcs <4 x i32> @may_throw_neon(<4 x i32> %v);
404