1 ; RUN: llc -march=hexagon -mcpu=hexagonv62 -mtriple=hexagon-unknown-linux-musl -O0 < %s | FileCheck %s
5 ; Check Function prologue.
6 ; Note. All register numbers and offset are fixed.
7 ; Hence, no need of regular expression.
9 ; CHECK: r29 = add(r29,#-16)
10 ; CHECK: r7:6 = memd(r29+#16)
11 ; CHECK: memd(r29+#0) = r7:6
12 ; CHECK: r7:6 = memd(r29+#24)
13 ; CHECK: memd(r29+#8) = r7:6
14 ; CHECK: r7:6 = memd(r29+#32)
15 ; CHECK: memd(r29+#16) = r7:6
16 ; CHECK: r7:6 = memd(r29+#40)
17 ; CHECK: memd(r29+#24) = r7:6
18 ; CHECK: memw(r29+#36) = r3
19 ; CHECK: memw(r29+#40) = r4
20 ; CHECK: memw(r29+#44) = r5
21 ; CHECK: r29 = add(r29,#16)
23 %struct.AAA = type { i32, i32, i32, i32 }
24 %struct.__va_list_tag = type { ptr, ptr, ptr }
26 @aaa = global %struct.AAA { i32 100, i32 200, i32 300, i32 400 }, align 4
27 @xxx = global %struct.AAA { i32 100, i32 200, i32 300, i32 400 }, align 4
28 @yyy = global %struct.AAA { i32 100, i32 200, i32 300, i32 400 }, align 4
29 @ccc = global %struct.AAA { i32 10, i32 20, i32 30, i32 40 }, align 4
30 @fff = global %struct.AAA { i32 1, i32 2, i32 3, i32 4 }, align 4
31 @.str = private unnamed_addr constant [13 x i8] c"result = %d\0A\00", align 1
33 ; Function Attrs: nounwind
34 define i32 @foo(i32 %xx, i32 %z, i32 %m, ptr byval(%struct.AAA) align 4 %bbb, ptr byval(%struct.AAA) align 4 %GGG, ...) #0 {
36 %xx.addr = alloca i32, align 4
37 %z.addr = alloca i32, align 4
38 %m.addr = alloca i32, align 4
39 %ap = alloca [1 x %struct.__va_list_tag], align 8
40 %d = alloca i32, align 4
41 %ret = alloca i32, align 4
42 %ddd = alloca %struct.AAA, align 4
43 %ggg = alloca %struct.AAA, align 4
44 %nnn = alloca %struct.AAA, align 4
45 store i32 %xx, ptr %xx.addr, align 4
46 store i32 %z, ptr %z.addr, align 4
47 store i32 %m, ptr %m.addr, align 4
48 store i32 0, ptr %ret, align 4
49 call void @llvm.va_start(ptr %ap)
50 %d2 = getelementptr inbounds %struct.AAA, ptr %bbb, i32 0, i32 3
51 %0 = load i32, ptr %d2, align 4
52 %1 = load i32, ptr %ret, align 4
53 %add = add nsw i32 %1, %0
54 store i32 %add, ptr %ret, align 4
55 %2 = load i32, ptr %z.addr, align 4
56 %3 = load i32, ptr %ret, align 4
57 %add3 = add nsw i32 %3, %2
58 store i32 %add3, ptr %ret, align 4
59 br label %vaarg.maybe_reg
61 vaarg.maybe_reg: ; preds = %entry
62 %__current_saved_reg_area_pointer = load ptr, ptr %ap
63 %__saved_reg_area_end_pointer_p = getelementptr inbounds %struct.__va_list_tag, ptr %ap, i32 0, i32 1
64 %__saved_reg_area_end_pointer = load ptr, ptr %__saved_reg_area_end_pointer_p
65 %__new_saved_reg_area_pointer = getelementptr i8, ptr %__current_saved_reg_area_pointer, i32 4
66 %4 = icmp sgt ptr %__new_saved_reg_area_pointer, %__saved_reg_area_end_pointer
67 br i1 %4, label %vaarg.on_stack, label %vaarg.in_reg
69 vaarg.in_reg: ; preds = %vaarg.maybe_reg
70 store ptr %__new_saved_reg_area_pointer, ptr %ap
73 vaarg.on_stack: ; preds = %vaarg.maybe_reg
74 %__overflow_area_pointer_p = getelementptr inbounds %struct.__va_list_tag, ptr %ap, i32 0, i32 2
75 %__overflow_area_pointer = load ptr, ptr %__overflow_area_pointer_p
76 %__overflow_area_pointer.next = getelementptr i8, ptr %__overflow_area_pointer, i32 4
77 store ptr %__overflow_area_pointer.next, ptr %__overflow_area_pointer_p
78 store ptr %__overflow_area_pointer.next, ptr %ap
81 vaarg.end: ; preds = %vaarg.on_stack, %vaarg.in_reg
82 %vaarg.addr = phi ptr [ %__current_saved_reg_area_pointer, %vaarg.in_reg ], [ %__overflow_area_pointer, %vaarg.on_stack ]
83 %5 = load i32, ptr %vaarg.addr
84 store i32 %5, ptr %d, align 4
85 %6 = load i32, ptr %d, align 4
86 %7 = load i32, ptr %ret, align 4
87 %add5 = add nsw i32 %7, %6
88 store i32 %add5, ptr %ret, align 4
89 %__overflow_area_pointer_p7 = getelementptr inbounds %struct.__va_list_tag, ptr %ap, i32 0, i32 2
90 %__overflow_area_pointer8 = load ptr, ptr %__overflow_area_pointer_p7
91 %__overflow_area_pointer.next9 = getelementptr i8, ptr %__overflow_area_pointer8, i32 16
92 store ptr %__overflow_area_pointer.next9, ptr %__overflow_area_pointer_p7
93 call void @llvm.memcpy.p0.p0.i32(ptr %ddd, ptr %__overflow_area_pointer8, i32 16, i32 4, i1 false)
94 %d10 = getelementptr inbounds %struct.AAA, ptr %ddd, i32 0, i32 3
95 %8 = load i32, ptr %d10, align 4
96 %9 = load i32, ptr %ret, align 4
97 %add11 = add nsw i32 %9, %8
98 store i32 %add11, ptr %ret, align 4
99 %__overflow_area_pointer_p13 = getelementptr inbounds %struct.__va_list_tag, ptr %ap, i32 0, i32 2
100 %__overflow_area_pointer14 = load ptr, ptr %__overflow_area_pointer_p13
101 %__overflow_area_pointer.next15 = getelementptr i8, ptr %__overflow_area_pointer14, i32 16
102 store ptr %__overflow_area_pointer.next15, ptr %__overflow_area_pointer_p13
103 call void @llvm.memcpy.p0.p0.i32(ptr %ggg, ptr %__overflow_area_pointer14, i32 16, i32 4, i1 false)
104 %d16 = getelementptr inbounds %struct.AAA, ptr %ggg, i32 0, i32 3
105 %10 = load i32, ptr %d16, align 4
106 %11 = load i32, ptr %ret, align 4
107 %add17 = add nsw i32 %11, %10
108 store i32 %add17, ptr %ret, align 4
109 %__overflow_area_pointer_p19 = getelementptr inbounds %struct.__va_list_tag, ptr %ap, i32 0, i32 2
110 %__overflow_area_pointer20 = load ptr, ptr %__overflow_area_pointer_p19
111 %__overflow_area_pointer.next21 = getelementptr i8, ptr %__overflow_area_pointer20, i32 16
112 store ptr %__overflow_area_pointer.next21, ptr %__overflow_area_pointer_p19
113 call void @llvm.memcpy.p0.p0.i32(ptr %nnn, ptr %__overflow_area_pointer20, i32 16, i32 4, i1 false)
114 %d22 = getelementptr inbounds %struct.AAA, ptr %nnn, i32 0, i32 3
115 %12 = load i32, ptr %d22, align 4
116 %13 = load i32, ptr %ret, align 4
117 %add23 = add nsw i32 %13, %12
118 store i32 %add23, ptr %ret, align 4
119 br label %vaarg.maybe_reg25
121 vaarg.maybe_reg25: ; preds = %vaarg.end
122 %__current_saved_reg_area_pointer27 = load ptr, ptr %ap
123 %__saved_reg_area_end_pointer_p28 = getelementptr inbounds %struct.__va_list_tag, ptr %ap, i32 0, i32 1
124 %__saved_reg_area_end_pointer29 = load ptr, ptr %__saved_reg_area_end_pointer_p28
125 %__new_saved_reg_area_pointer30 = getelementptr i8, ptr %__current_saved_reg_area_pointer27, i32 4
126 %14 = icmp sgt ptr %__new_saved_reg_area_pointer30, %__saved_reg_area_end_pointer29
127 br i1 %14, label %vaarg.on_stack32, label %vaarg.in_reg31
129 vaarg.in_reg31: ; preds = %vaarg.maybe_reg25
130 store ptr %__new_saved_reg_area_pointer30, ptr %ap
131 br label %vaarg.end36
133 vaarg.on_stack32: ; preds = %vaarg.maybe_reg25
134 %__overflow_area_pointer_p33 = getelementptr inbounds %struct.__va_list_tag, ptr %ap, i32 0, i32 2
135 %__overflow_area_pointer34 = load ptr, ptr %__overflow_area_pointer_p33
136 %__overflow_area_pointer.next35 = getelementptr i8, ptr %__overflow_area_pointer34, i32 4
137 store ptr %__overflow_area_pointer.next35, ptr %__overflow_area_pointer_p33
138 store ptr %__overflow_area_pointer.next35, ptr %ap
139 br label %vaarg.end36
141 vaarg.end36: ; preds = %vaarg.on_stack32, %vaarg.in_reg31
142 %vaarg.addr37 = phi ptr [ %__current_saved_reg_area_pointer27, %vaarg.in_reg31 ], [ %__overflow_area_pointer34, %vaarg.on_stack32 ]
143 %15 = load i32, ptr %vaarg.addr37
144 store i32 %15, ptr %d, align 4
145 %16 = load i32, ptr %d, align 4
146 %17 = load i32, ptr %ret, align 4
147 %add38 = add nsw i32 %17, %16
148 store i32 %add38, ptr %ret, align 4
149 %18 = load i32, ptr %m.addr, align 4
150 %19 = load i32, ptr %ret, align 4
151 %add39 = add nsw i32 %19, %18
152 store i32 %add39, ptr %ret, align 4
153 call void @llvm.va_end(ptr %ap)
154 %20 = load i32, ptr %ret, align 4
158 ; Function Attrs: nounwind
159 declare void @llvm.va_start(ptr) #1
161 ; Function Attrs: nounwind
162 declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture readonly, i32, i32, i1) #1
164 ; Function Attrs: nounwind
165 declare void @llvm.va_end(ptr) #1
167 ; Function Attrs: nounwind
168 define i32 @main() #0 {
170 %retval = alloca i32, align 4
171 %x = alloca i32, align 4
172 store i32 0, ptr %retval
173 %call = call i32 (i32, i32, i32, ptr, ptr, ...) @foo(i32 1, i32 3, i32 5, ptr byval(%struct.AAA) align 4 @aaa, ptr byval(%struct.AAA) align 4 @fff, i32 2, ptr byval(%struct.AAA) align 4 @xxx, ptr byval(%struct.AAA) align 4 @yyy, ptr byval(%struct.AAA) align 4 @ccc, i32 4)
174 store i32 %call, ptr %x, align 4
175 %0 = load i32, ptr %x, align 4
176 %call1 = call i32 (ptr, ...) @printf(ptr @.str, i32 %0)
177 %1 = load i32, ptr %x, align 4
181 declare i32 @printf(ptr, ...) #2
183 attributes #0 = { nounwind }