1; RUN: llc < %s | FileCheck %s
2
3; Vararg saving must save Q registers using the equivalent of STR/STP.
4
5target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
6target triple = "aarch64_be-arm-none-eabi"
7
8%struct.__va_list = type { i8*, i8*, i8*, i32, i32 }
9
10declare void @llvm.va_start(i8*) nounwind
11declare void @llvm.va_end(i8*) nounwind
12
13define double @callee(i32 %a, ...) {
14; CHECK: stp
15; CHECK: stp
16; CHECK: stp
17; CHECK: stp
18; CHECK: stp
19; CHECK: stp
20entry:
21  %vl = alloca %struct.__va_list, align 8
22  %vl1 = bitcast %struct.__va_list* %vl to i8*
23  call void @llvm.va_start(i8* %vl1)
24  %vr_offs_p = getelementptr inbounds %struct.__va_list, %struct.__va_list* %vl, i64 0, i32 4
25  %vr_offs = load i32, i32* %vr_offs_p, align 4
26  %0 = icmp sgt i32 %vr_offs, -1
27  br i1 %0, label %vaarg.on_stack, label %vaarg.maybe_reg
28
29vaarg.maybe_reg:                                  ; preds = %entry
30  %new_reg_offs = add i32 %vr_offs, 16
31  store i32 %new_reg_offs, i32* %vr_offs_p, align 4
32  %inreg = icmp slt i32 %new_reg_offs, 1
33  br i1 %inreg, label %vaarg.in_reg, label %vaarg.on_stack
34
35vaarg.in_reg:                                     ; preds = %vaarg.maybe_reg
36  %reg_top_p = getelementptr inbounds %struct.__va_list, %struct.__va_list* %vl, i64 0, i32 2
37  %reg_top = load i8*, i8** %reg_top_p, align 8
38  %1 = sext i32 %vr_offs to i64
39  %2 = getelementptr i8, i8* %reg_top, i64 %1
40  %3 = ptrtoint i8* %2 to i64
41  %align_be = add i64 %3, 8
42  %4 = inttoptr i64 %align_be to i8*
43  br label %vaarg.end
44
45vaarg.on_stack:                                   ; preds = %vaarg.maybe_reg, %entry
46  %stack_p = getelementptr inbounds %struct.__va_list, %struct.__va_list* %vl, i64 0, i32 0
47  %stack = load i8*, i8** %stack_p, align 8
48  %new_stack = getelementptr i8, i8* %stack, i64 8
49  store i8* %new_stack, i8** %stack_p, align 8
50  br label %vaarg.end
51
52vaarg.end:                                        ; preds = %vaarg.on_stack, %vaarg.in_reg
53  %.sink = phi i8* [ %4, %vaarg.in_reg ], [ %stack, %vaarg.on_stack ]
54  %5 = bitcast i8* %.sink to double*
55  %6 = load double, double* %5, align 8
56  call void @llvm.va_end(i8* %vl1)
57  ret double %6
58}
59