1 ; RUN: llc -march=hexagon -mcpu=hexagonv62 -mtriple=hexagon-unknown-linux-musl -O0 < %s | FileCheck %s
5 ; Check function prologue generation
6 ; CHECK: r29 = add(r29,#-24)
7 ; CHECK: memw(r29+#4) = r1
8 ; CHECK: memw(r29+#8) = r2
9 ; CHECK: memw(r29+#12) = r3
10 ; CHECK: memw(r29+#16) = r4
11 ; CHECK: memw(r29+#20) = r5
12 ; CHECK: r29 = add(r29,#24)
15 %struct.AAA = type { i32, i32, i32, i32 }
16 %struct.__va_list_tag = type { ptr, ptr, ptr }
18 @aaa = global %struct.AAA { i32 100, i32 200, i32 300, i32 400 }, align 4
19 @.str = private unnamed_addr constant [13 x i8] c"result = %d\0A\00", align 1
21 ; Function Attrs: nounwind
22 define i32 @foo(i32 %xx, ...) #0 {
24 %ap = alloca [1 x %struct.__va_list_tag], align 8
25 call void @llvm.va_start(ptr %ap)
26 %__current_saved_reg_area_pointer = load ptr, ptr %ap, align 8
27 %__saved_reg_area_end_pointer_p = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %ap, i32 0, i32 0, i32 1
28 %__saved_reg_area_end_pointer = load ptr, ptr %__saved_reg_area_end_pointer_p, align 4
29 %__new_saved_reg_area_pointer = getelementptr i8, ptr %__current_saved_reg_area_pointer, i32 4
30 %0 = icmp sgt ptr %__new_saved_reg_area_pointer, %__saved_reg_area_end_pointer
31 %__overflow_area_pointer_p = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %ap, i32 0, i32 0, i32 2
32 %__overflow_area_pointer = load ptr, ptr %__overflow_area_pointer_p, align 8
33 br i1 %0, label %vaarg.on_stack, label %vaarg.end
35 vaarg.on_stack: ; preds = %entry
36 %__overflow_area_pointer.next = getelementptr i8, ptr %__overflow_area_pointer, i32 4
37 store ptr %__overflow_area_pointer.next, ptr %__overflow_area_pointer_p, align 8
40 vaarg.end: ; preds = %entry, %vaarg.on_stack
41 %__overflow_area_pointer5 = phi ptr [ %__overflow_area_pointer.next, %vaarg.on_stack ], [ %__overflow_area_pointer, %entry ]
42 %storemerge32 = phi ptr [ %__overflow_area_pointer.next, %vaarg.on_stack ], [ %__new_saved_reg_area_pointer, %entry ]
43 %vaarg.addr.in = phi ptr [ %__overflow_area_pointer, %vaarg.on_stack ], [ %__current_saved_reg_area_pointer, %entry ]
44 store ptr %storemerge32, ptr %ap, align 8
45 %1 = load i32, ptr %vaarg.addr.in, align 4
46 %__overflow_area_pointer_p4 = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %ap, i32 0, i32 0, i32 2
47 %__overflow_area_pointer.next6 = getelementptr i8, ptr %__overflow_area_pointer5, i32 16
48 store ptr %__overflow_area_pointer.next6, ptr %__overflow_area_pointer_p4, align 8
49 %bbb.sroa.1.0.idx27 = getelementptr inbounds i8, ptr %__overflow_area_pointer5, i32 12
50 %bbb.sroa.1.0.copyload = load i32, ptr %bbb.sroa.1.0.idx27, align 4
51 %add8 = add nsw i32 %bbb.sroa.1.0.copyload, %1
52 %__new_saved_reg_area_pointer15 = getelementptr i8, ptr %storemerge32, i32 4
53 %2 = icmp sgt ptr %__new_saved_reg_area_pointer15, %__saved_reg_area_end_pointer
54 br i1 %2, label %vaarg.on_stack17, label %vaarg.end21
56 vaarg.on_stack17: ; preds = %vaarg.end
57 %__overflow_area_pointer.next20 = getelementptr i8, ptr %__overflow_area_pointer5, i32 20
58 store ptr %__overflow_area_pointer.next20, ptr %__overflow_area_pointer_p4, align 8
61 vaarg.end21: ; preds = %vaarg.end, %vaarg.on_stack17
62 %storemerge = phi ptr [ %__overflow_area_pointer.next20, %vaarg.on_stack17 ], [ %__new_saved_reg_area_pointer15, %vaarg.end ]
63 %vaarg.addr22.in = phi ptr [ %__overflow_area_pointer.next6, %vaarg.on_stack17 ], [ %storemerge32, %vaarg.end ]
64 store ptr %storemerge, ptr %ap, align 8
65 %3 = load i32, ptr %vaarg.addr22.in, align 4
66 %add23 = add nsw i32 %add8, %3
67 call void @llvm.va_end(ptr %ap)
71 ; Function Attrs: nounwind
72 declare void @llvm.va_start(ptr) #1
74 ; Function Attrs: nounwind
75 declare void @llvm.va_end(ptr) #1
77 ; Function Attrs: nounwind
78 define i32 @main() #0 {
80 %call = tail call i32 (i32, ...) @foo(i32 undef, i32 2, ptr byval(%struct.AAA) align 4 @aaa, i32 4)
81 %call1 = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %call) #1
85 ; Function Attrs: nounwind
86 declare i32 @printf(ptr nocapture readonly, ...) #0
88 attributes #0 = { nounwind }