1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2 ; RUN: llc -mtriple=aarch64 < %s | FileCheck %s
4 %va_list = type { ptr, ptr, ptr, i32, i32 }
6 define preserve_nonecc i32 @callee(i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, ...) nounwind noinline ssp {
8 ; CHECK: // %bb.0: // %entry
9 ; CHECK-NEXT: sub sp, sp, #192
10 ; CHECK-NEXT: mov x8, #-24 // =0xffffffffffffffe8
11 ; CHECK-NEXT: mov x9, sp
12 ; CHECK-NEXT: add x10, sp, #136
13 ; CHECK-NEXT: movk x8, #65408, lsl #32
14 ; CHECK-NEXT: add x9, x9, #128
15 ; CHECK-NEXT: stp x6, x7, [sp, #144]
16 ; CHECK-NEXT: stp x9, x8, [sp, #176]
17 ; CHECK-NEXT: add x9, x10, #24
18 ; CHECK-NEXT: add x10, sp, #192
19 ; CHECK-NEXT: mov w8, #-24 // =0xffffffe8
20 ; CHECK-NEXT: str x5, [sp, #136]
21 ; CHECK-NEXT: stp q0, q1, [sp]
22 ; CHECK-NEXT: stp q2, q3, [sp, #32]
23 ; CHECK-NEXT: stp q4, q5, [sp, #64]
24 ; CHECK-NEXT: stp q6, q7, [sp, #96]
25 ; CHECK-NEXT: stp x10, x9, [sp, #160]
26 ; CHECK-NEXT: tbz w8, #31, .LBB0_3
27 ; CHECK-NEXT: // %bb.1: // %maybe_reg
28 ; CHECK-NEXT: add w9, w8, #8
29 ; CHECK-NEXT: cmp w9, #0
30 ; CHECK-NEXT: str w9, [sp, #184]
31 ; CHECK-NEXT: b.gt .LBB0_3
32 ; CHECK-NEXT: // %bb.2: // %in_reg
33 ; CHECK-NEXT: ldr x9, [sp, #168]
34 ; CHECK-NEXT: add x8, x9, w8, sxtw
35 ; CHECK-NEXT: b .LBB0_4
36 ; CHECK-NEXT: .LBB0_3: // %on_stack
37 ; CHECK-NEXT: ldr x8, [sp, #160]
38 ; CHECK-NEXT: add x9, x8, #8
39 ; CHECK-NEXT: str x9, [sp, #160]
40 ; CHECK-NEXT: .LBB0_4: // %end
41 ; CHECK-NEXT: ldr w0, [x8]
42 ; CHECK-NEXT: add sp, sp, #192
45 %args = alloca %va_list, align 8
46 call void @llvm.va_start(ptr %args)
47 %gr_offs_p = getelementptr inbounds %va_list, ptr %args, i32 0, i32 3
48 %gr_offs = load i32, ptr %gr_offs_p, align 8
49 %0 = icmp sge i32 %gr_offs, 0
50 br i1 %0, label %on_stack, label %maybe_reg
53 %new_reg_offs = add i32 %gr_offs, 8
54 store i32 %new_reg_offs, ptr %gr_offs_p, align 8
55 %inreg = icmp sle i32 %new_reg_offs, 0
56 br i1 %inreg, label %in_reg, label %on_stack
59 %reg_top_p = getelementptr inbounds %va_list, ptr %args, i32 0, i32 1
60 %reg_top = load ptr, ptr %reg_top_p, align 8
61 %reg = getelementptr inbounds i8, ptr %reg_top, i32 %gr_offs
65 %stack_p = getelementptr inbounds %va_list, ptr %args, i32 0, i32 0
66 %stack = load ptr, ptr %stack_p, align 8
67 %new_stack = getelementptr inbounds i8, ptr %stack, i64 8
68 store ptr %new_stack, ptr %stack_p, align 8
72 %p = phi ptr [ %reg, %in_reg ], [ %stack, %on_stack ]
73 %10 = load i32, ptr %p, align 8
74 call void @llvm.va_end.p0(ptr %args)
78 declare void @llvm.va_start(ptr) nounwind
79 declare void @llvm.va_end(ptr) nounwind
81 define i32 @caller() nounwind ssp {
82 ; CHECK-LABEL: caller:
84 ; CHECK-NEXT: sub sp, sp, #176
85 ; CHECK-NEXT: mov w8, #10 // =0xa
86 ; CHECK-NEXT: mov w9, #9 // =0x9
87 ; CHECK-NEXT: mov w0, #1 // =0x1
88 ; CHECK-NEXT: mov w1, #2 // =0x2
89 ; CHECK-NEXT: mov w2, #3 // =0x3
90 ; CHECK-NEXT: mov w3, #4 // =0x4
91 ; CHECK-NEXT: mov w4, #5 // =0x5
92 ; CHECK-NEXT: mov w5, #6 // =0x6
93 ; CHECK-NEXT: mov w6, #7 // =0x7
94 ; CHECK-NEXT: mov w7, #8 // =0x8
95 ; CHECK-NEXT: stp d15, d14, [sp, #16] // 16-byte Folded Spill
96 ; CHECK-NEXT: stp d13, d12, [sp, #32] // 16-byte Folded Spill
97 ; CHECK-NEXT: stp d11, d10, [sp, #48] // 16-byte Folded Spill
98 ; CHECK-NEXT: stp d9, d8, [sp, #64] // 16-byte Folded Spill
99 ; CHECK-NEXT: str x30, [sp, #80] // 8-byte Folded Spill
100 ; CHECK-NEXT: stp x28, x27, [sp, #96] // 16-byte Folded Spill
101 ; CHECK-NEXT: stp x26, x25, [sp, #112] // 16-byte Folded Spill
102 ; CHECK-NEXT: stp x24, x23, [sp, #128] // 16-byte Folded Spill
103 ; CHECK-NEXT: stp x22, x21, [sp, #144] // 16-byte Folded Spill
104 ; CHECK-NEXT: stp x20, x19, [sp, #160] // 16-byte Folded Spill
105 ; CHECK-NEXT: str w8, [sp, #8]
106 ; CHECK-NEXT: str w9, [sp]
107 ; CHECK-NEXT: bl callee
108 ; CHECK-NEXT: ldp x20, x19, [sp, #160] // 16-byte Folded Reload
109 ; CHECK-NEXT: ldr x30, [sp, #80] // 8-byte Folded Reload
110 ; CHECK-NEXT: ldp x22, x21, [sp, #144] // 16-byte Folded Reload
111 ; CHECK-NEXT: ldp x24, x23, [sp, #128] // 16-byte Folded Reload
112 ; CHECK-NEXT: ldp x26, x25, [sp, #112] // 16-byte Folded Reload
113 ; CHECK-NEXT: ldp x28, x27, [sp, #96] // 16-byte Folded Reload
114 ; CHECK-NEXT: ldp d9, d8, [sp, #64] // 16-byte Folded Reload
115 ; CHECK-NEXT: ldp d11, d10, [sp, #48] // 16-byte Folded Reload
116 ; CHECK-NEXT: ldp d13, d12, [sp, #32] // 16-byte Folded Reload
117 ; CHECK-NEXT: ldp d15, d14, [sp, #16] // 16-byte Folded Reload
118 ; CHECK-NEXT: add sp, sp, #176
120 %r = tail call preserve_nonecc i32 (i32, i32, i32, i32, i32, ...) @callee(i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10)