1 ; RUN: llc -o - %s | FileCheck %s
2 ; Check that we reserve an emergency spill slot, even if we added an extra
3 ; CSR spill for the values used by the swiftself parameter.
5 ; CHECK: str [[REG:x[0-9]+]], [sp]
6 ; CHECK: add [[REG]], sp, #248
7 ; CHECK: str xzr, [{{\s*}}[[REG]], #32760]
8 ; CHECK: ldr [[REG]], [sp]
9 target triple = "arm64-apple-ios"
11 @ptr8 = external global ptr
12 @ptr64 = external global i64
14 define hidden swiftcc void @func(ptr swiftself %arg) #0 {
16 %stack0 = alloca ptr, i32 5000, align 8
17 %stack1 = alloca ptr, i32 32, align 8
19 %v0 = load volatile i64, ptr @ptr64, align 8
20 %v1 = load volatile i64, ptr @ptr64, align 8
21 %v2 = load volatile i64, ptr @ptr64, align 8
22 %v3 = load volatile i64, ptr @ptr64, align 8
23 %v4 = load volatile i64, ptr @ptr64, align 8
24 %v5 = load volatile i64, ptr @ptr64, align 8
25 %v6 = load volatile i64, ptr @ptr64, align 8
26 %v7 = load volatile i64, ptr @ptr64, align 8
27 %v8 = load volatile i64, ptr @ptr64, align 8
28 %v9 = load volatile i64, ptr @ptr64, align 8
29 %v10 = load volatile i64, ptr @ptr64, align 8
30 %v11 = load volatile i64, ptr @ptr64, align 8
31 %v12 = load volatile i64, ptr @ptr64, align 8
32 %v13 = load volatile i64, ptr @ptr64, align 8
33 %v14 = load volatile i64, ptr @ptr64, align 8
34 %v15 = load volatile i64, ptr @ptr64, align 8
35 %v16 = load volatile i64, ptr @ptr64, align 8
36 %v17 = load volatile i64, ptr @ptr64, align 8
37 %v18 = load volatile i64, ptr @ptr64, align 8
38 %v19 = load volatile i64, ptr @ptr64, align 8
39 %v20 = load volatile i64, ptr @ptr64, align 8
40 %v21 = load volatile i64, ptr @ptr64, align 8
41 %v22 = load volatile i64, ptr @ptr64, align 8
42 %v23 = load volatile i64, ptr @ptr64, align 8
43 %v24 = load volatile i64, ptr @ptr64, align 8
44 %v25 = load volatile i64, ptr @ptr64, align 8
46 ; this should exceed stack-relative addressing limits and need an emergency
48 %s = getelementptr inbounds ptr, ptr %stack0, i64 4092
49 store volatile ptr null, ptr %s
50 store volatile ptr null, ptr %stack1
52 store volatile i64 %v0, ptr @ptr64, align 8
53 store volatile i64 %v1, ptr @ptr64, align 8
54 store volatile i64 %v2, ptr @ptr64, align 8
55 store volatile i64 %v3, ptr @ptr64, align 8
56 store volatile i64 %v4, ptr @ptr64, align 8
57 store volatile i64 %v5, ptr @ptr64, align 8
58 store volatile i64 %v6, ptr @ptr64, align 8
59 store volatile i64 %v7, ptr @ptr64, align 8
60 store volatile i64 %v8, ptr @ptr64, align 8
61 store volatile i64 %v9, ptr @ptr64, align 8
62 store volatile i64 %v10, ptr @ptr64, align 8
63 store volatile i64 %v11, ptr @ptr64, align 8
64 store volatile i64 %v12, ptr @ptr64, align 8
65 store volatile i64 %v13, ptr @ptr64, align 8
66 store volatile i64 %v14, ptr @ptr64, align 8
67 store volatile i64 %v15, ptr @ptr64, align 8
68 store volatile i64 %v16, ptr @ptr64, align 8
69 store volatile i64 %v17, ptr @ptr64, align 8
70 store volatile i64 %v18, ptr @ptr64, align 8
71 store volatile i64 %v19, ptr @ptr64, align 8
72 store volatile i64 %v20, ptr @ptr64, align 8
73 store volatile i64 %v21, ptr @ptr64, align 8
74 store volatile i64 %v22, ptr @ptr64, align 8
75 store volatile i64 %v23, ptr @ptr64, align 8
76 store volatile i64 %v24, ptr @ptr64, align 8
77 store volatile i64 %v25, ptr @ptr64, align 8
79 ; use swiftself parameter late so it stays alive throughout the function.
80 store volatile ptr %arg, ptr @ptr8