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 { i8*, i8*, i8* }
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 %arraydecay1 = bitcast [1 x %struct.__va_list_tag]* %ap to i8*
26 call void @llvm.va_start(i8* %arraydecay1)
27 %__current_saved_reg_area_pointer_p = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0, i32 0
28 %__current_saved_reg_area_pointer = load i8*, i8** %__current_saved_reg_area_pointer_p, align 8
29 %__saved_reg_area_end_pointer_p = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0, i32 1
30 %__saved_reg_area_end_pointer = load i8*, i8** %__saved_reg_area_end_pointer_p, align 4
31 %__new_saved_reg_area_pointer = getelementptr i8, i8* %__current_saved_reg_area_pointer, i32 4
32 %0 = icmp sgt i8* %__new_saved_reg_area_pointer, %__saved_reg_area_end_pointer
33 %__overflow_area_pointer_p = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0, i32 2
34 %__overflow_area_pointer = load i8*, i8** %__overflow_area_pointer_p, align 8
35 br i1 %0, label %vaarg.on_stack, label %vaarg.end
37 vaarg.on_stack: ; preds = %entry
38 %__overflow_area_pointer.next = getelementptr i8, i8* %__overflow_area_pointer, i32 4
39 store i8* %__overflow_area_pointer.next, i8** %__overflow_area_pointer_p, align 8
42 vaarg.end: ; preds = %entry, %vaarg.on_stack
43 %__overflow_area_pointer5 = phi i8* [ %__overflow_area_pointer.next, %vaarg.on_stack ], [ %__overflow_area_pointer, %entry ]
44 %storemerge32 = phi i8* [ %__overflow_area_pointer.next, %vaarg.on_stack ], [ %__new_saved_reg_area_pointer, %entry ]
45 %vaarg.addr.in = phi i8* [ %__overflow_area_pointer, %vaarg.on_stack ], [ %__current_saved_reg_area_pointer, %entry ]
46 store i8* %storemerge32, i8** %__current_saved_reg_area_pointer_p, align 8
47 %vaarg.addr = bitcast i8* %vaarg.addr.in to i32*
48 %1 = load i32, i32* %vaarg.addr, align 4
49 %__overflow_area_pointer_p4 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0, i32 2
50 %__overflow_area_pointer.next6 = getelementptr i8, i8* %__overflow_area_pointer5, i32 16
51 store i8* %__overflow_area_pointer.next6, i8** %__overflow_area_pointer_p4, align 8
52 %bbb.sroa.1.0.idx27 = getelementptr inbounds i8, i8* %__overflow_area_pointer5, i32 12
53 %2 = bitcast i8* %bbb.sroa.1.0.idx27 to i32*
54 %bbb.sroa.1.0.copyload = load i32, i32* %2, align 4
55 %add8 = add nsw i32 %bbb.sroa.1.0.copyload, %1
56 %__new_saved_reg_area_pointer15 = getelementptr i8, i8* %storemerge32, i32 4
57 %3 = icmp sgt i8* %__new_saved_reg_area_pointer15, %__saved_reg_area_end_pointer
58 br i1 %3, label %vaarg.on_stack17, label %vaarg.end21
60 vaarg.on_stack17: ; preds = %vaarg.end
61 %__overflow_area_pointer.next20 = getelementptr i8, i8* %__overflow_area_pointer5, i32 20
62 store i8* %__overflow_area_pointer.next20, i8** %__overflow_area_pointer_p4, align 8
65 vaarg.end21: ; preds = %vaarg.end, %vaarg.on_stack17
66 %storemerge = phi i8* [ %__overflow_area_pointer.next20, %vaarg.on_stack17 ], [ %__new_saved_reg_area_pointer15, %vaarg.end ]
67 %vaarg.addr22.in = phi i8* [ %__overflow_area_pointer.next6, %vaarg.on_stack17 ], [ %storemerge32, %vaarg.end ]
68 store i8* %storemerge, i8** %__current_saved_reg_area_pointer_p, align 8
69 %vaarg.addr22 = bitcast i8* %vaarg.addr22.in to i32*
70 %4 = load i32, i32* %vaarg.addr22, align 4
71 %add23 = add nsw i32 %add8, %4
72 call void @llvm.va_end(i8* %arraydecay1)
76 ; Function Attrs: nounwind
77 declare void @llvm.va_start(i8*) #1
79 ; Function Attrs: nounwind
80 declare void @llvm.va_end(i8*) #1
82 ; Function Attrs: nounwind
83 define i32 @main() #0 {
85 %call = tail call i32 (i32, ...) @foo(i32 undef, i32 2, %struct.AAA* byval(%struct.AAA) align 4 @aaa, i32 4)
86 %call1 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i32 %call) #1
90 ; Function Attrs: nounwind
91 declare i32 @printf(i8* nocapture readonly, ...) #0
93 attributes #0 = { nounwind }