• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -march=hexagon -mcpu=hexagonv62 -mtriple=hexagon-unknown-linux-musl -O0 < %s | FileCheck %s
2
3; CHECK-LABEL: foo:
4
5; Check Function prologue.
6; Note. All register numbers and offset are fixed.
7; Hence, no need of regular expression.
8
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)
22
23%struct.AAA = type { i32, i32, i32, i32 }
24%struct.__va_list_tag = type { i8*, i8*, i8* }
25
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
32
33; Function Attrs: nounwind
34define i32 @foo(i32 %xx, i32 %z, i32 %m, %struct.AAA* byval(%struct.AAA) align 4 %bbb, %struct.AAA* byval(%struct.AAA) align 4 %GGG, ...) #0 {
35entry:
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, i32* %xx.addr, align 4
46  store i32 %z, i32* %z.addr, align 4
47  store i32 %m, i32* %m.addr, align 4
48  store i32 0, i32* %ret, align 4
49  %arraydecay = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
50  %arraydecay1 = bitcast %struct.__va_list_tag* %arraydecay to i8*
51  call void @llvm.va_start(i8* %arraydecay1)
52  %d2 = getelementptr inbounds %struct.AAA, %struct.AAA* %bbb, i32 0, i32 3
53  %0 = load i32, i32* %d2, align 4
54  %1 = load i32, i32* %ret, align 4
55  %add = add nsw i32 %1, %0
56  store i32 %add, i32* %ret, align 4
57  %2 = load i32, i32* %z.addr, align 4
58  %3 = load i32, i32* %ret, align 4
59  %add3 = add nsw i32 %3, %2
60  store i32 %add3, i32* %ret, align 4
61  %arraydecay4 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
62  br label %vaarg.maybe_reg
63
64vaarg.maybe_reg:                                  ; preds = %entry
65  %__current_saved_reg_area_pointer_p = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay4, i32 0, i32 0
66  %__current_saved_reg_area_pointer = load i8*, i8** %__current_saved_reg_area_pointer_p
67  %__saved_reg_area_end_pointer_p = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay4, i32 0, i32 1
68  %__saved_reg_area_end_pointer = load i8*, i8** %__saved_reg_area_end_pointer_p
69  %__new_saved_reg_area_pointer = getelementptr i8, i8* %__current_saved_reg_area_pointer, i32 4
70  %4 = icmp sgt i8* %__new_saved_reg_area_pointer, %__saved_reg_area_end_pointer
71  br i1 %4, label %vaarg.on_stack, label %vaarg.in_reg
72
73vaarg.in_reg:                                     ; preds = %vaarg.maybe_reg
74  %5 = bitcast i8* %__current_saved_reg_area_pointer to i32*
75  store i8* %__new_saved_reg_area_pointer, i8** %__current_saved_reg_area_pointer_p
76  br label %vaarg.end
77
78vaarg.on_stack:                                   ; preds = %vaarg.maybe_reg
79  %__overflow_area_pointer_p = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay4, i32 0, i32 2
80  %__overflow_area_pointer = load i8*, i8** %__overflow_area_pointer_p
81  %__overflow_area_pointer.next = getelementptr i8, i8* %__overflow_area_pointer, i32 4
82  store i8* %__overflow_area_pointer.next, i8** %__overflow_area_pointer_p
83  store i8* %__overflow_area_pointer.next, i8** %__current_saved_reg_area_pointer_p
84  %6 = bitcast i8* %__overflow_area_pointer to i32*
85  br label %vaarg.end
86
87vaarg.end:                                        ; preds = %vaarg.on_stack, %vaarg.in_reg
88  %vaarg.addr = phi i32* [ %5, %vaarg.in_reg ], [ %6, %vaarg.on_stack ]
89  %7 = load i32, i32* %vaarg.addr
90  store i32 %7, i32* %d, align 4
91  %8 = load i32, i32* %d, align 4
92  %9 = load i32, i32* %ret, align 4
93  %add5 = add nsw i32 %9, %8
94  store i32 %add5, i32* %ret, align 4
95  %arraydecay6 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
96  %__overflow_area_pointer_p7 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay6, i32 0, i32 2
97  %__overflow_area_pointer8 = load i8*, i8** %__overflow_area_pointer_p7
98  %10 = bitcast i8* %__overflow_area_pointer8 to %struct.AAA*
99  %__overflow_area_pointer.next9 = getelementptr i8, i8* %__overflow_area_pointer8, i32 16
100  store i8* %__overflow_area_pointer.next9, i8** %__overflow_area_pointer_p7
101  %11 = bitcast %struct.AAA* %ddd to i8*
102  %12 = bitcast %struct.AAA* %10 to i8*
103  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %11, i8* %12, i32 16, i32 4, i1 false)
104  %d10 = getelementptr inbounds %struct.AAA, %struct.AAA* %ddd, i32 0, i32 3
105  %13 = load i32, i32* %d10, align 4
106  %14 = load i32, i32* %ret, align 4
107  %add11 = add nsw i32 %14, %13
108  store i32 %add11, i32* %ret, align 4
109  %arraydecay12 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
110  %__overflow_area_pointer_p13 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay12, i32 0, i32 2
111  %__overflow_area_pointer14 = load i8*, i8** %__overflow_area_pointer_p13
112  %15 = bitcast i8* %__overflow_area_pointer14 to %struct.AAA*
113  %__overflow_area_pointer.next15 = getelementptr i8, i8* %__overflow_area_pointer14, i32 16
114  store i8* %__overflow_area_pointer.next15, i8** %__overflow_area_pointer_p13
115  %16 = bitcast %struct.AAA* %ggg to i8*
116  %17 = bitcast %struct.AAA* %15 to i8*
117  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %16, i8* %17, i32 16, i32 4, i1 false)
118  %d16 = getelementptr inbounds %struct.AAA, %struct.AAA* %ggg, i32 0, i32 3
119  %18 = load i32, i32* %d16, align 4
120  %19 = load i32, i32* %ret, align 4
121  %add17 = add nsw i32 %19, %18
122  store i32 %add17, i32* %ret, align 4
123  %arraydecay18 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
124  %__overflow_area_pointer_p19 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay18, i32 0, i32 2
125  %__overflow_area_pointer20 = load i8*, i8** %__overflow_area_pointer_p19
126  %20 = bitcast i8* %__overflow_area_pointer20 to %struct.AAA*
127  %__overflow_area_pointer.next21 = getelementptr i8, i8* %__overflow_area_pointer20, i32 16
128  store i8* %__overflow_area_pointer.next21, i8** %__overflow_area_pointer_p19
129  %21 = bitcast %struct.AAA* %nnn to i8*
130  %22 = bitcast %struct.AAA* %20 to i8*
131  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %21, i8* %22, i32 16, i32 4, i1 false)
132  %d22 = getelementptr inbounds %struct.AAA, %struct.AAA* %nnn, i32 0, i32 3
133  %23 = load i32, i32* %d22, align 4
134  %24 = load i32, i32* %ret, align 4
135  %add23 = add nsw i32 %24, %23
136  store i32 %add23, i32* %ret, align 4
137  %arraydecay24 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
138  br label %vaarg.maybe_reg25
139
140vaarg.maybe_reg25:                                ; preds = %vaarg.end
141  %__current_saved_reg_area_pointer_p26 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay24, i32 0, i32 0
142  %__current_saved_reg_area_pointer27 = load i8*, i8** %__current_saved_reg_area_pointer_p26
143  %__saved_reg_area_end_pointer_p28 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay24, i32 0, i32 1
144  %__saved_reg_area_end_pointer29 = load i8*, i8** %__saved_reg_area_end_pointer_p28
145  %__new_saved_reg_area_pointer30 = getelementptr i8, i8* %__current_saved_reg_area_pointer27, i32 4
146  %25 = icmp sgt i8* %__new_saved_reg_area_pointer30, %__saved_reg_area_end_pointer29
147  br i1 %25, label %vaarg.on_stack32, label %vaarg.in_reg31
148
149vaarg.in_reg31:                                   ; preds = %vaarg.maybe_reg25
150  %26 = bitcast i8* %__current_saved_reg_area_pointer27 to i32*
151  store i8* %__new_saved_reg_area_pointer30, i8** %__current_saved_reg_area_pointer_p26
152  br label %vaarg.end36
153
154vaarg.on_stack32:                                 ; preds = %vaarg.maybe_reg25
155  %__overflow_area_pointer_p33 = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %arraydecay24, i32 0, i32 2
156  %__overflow_area_pointer34 = load i8*, i8** %__overflow_area_pointer_p33
157  %__overflow_area_pointer.next35 = getelementptr i8, i8* %__overflow_area_pointer34, i32 4
158  store i8* %__overflow_area_pointer.next35, i8** %__overflow_area_pointer_p33
159  store i8* %__overflow_area_pointer.next35, i8** %__current_saved_reg_area_pointer_p26
160  %27 = bitcast i8* %__overflow_area_pointer34 to i32*
161  br label %vaarg.end36
162
163vaarg.end36:                                      ; preds = %vaarg.on_stack32, %vaarg.in_reg31
164  %vaarg.addr37 = phi i32* [ %26, %vaarg.in_reg31 ], [ %27, %vaarg.on_stack32 ]
165  %28 = load i32, i32* %vaarg.addr37
166  store i32 %28, i32* %d, align 4
167  %29 = load i32, i32* %d, align 4
168  %30 = load i32, i32* %ret, align 4
169  %add38 = add nsw i32 %30, %29
170  store i32 %add38, i32* %ret, align 4
171  %31 = load i32, i32* %m.addr, align 4
172  %32 = load i32, i32* %ret, align 4
173  %add39 = add nsw i32 %32, %31
174  store i32 %add39, i32* %ret, align 4
175  %arraydecay40 = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
176  %arraydecay4041 = bitcast %struct.__va_list_tag* %arraydecay40 to i8*
177  call void @llvm.va_end(i8* %arraydecay4041)
178  %33 = load i32, i32* %ret, align 4
179  ret i32 %33
180}
181
182; Function Attrs: nounwind
183declare void @llvm.va_start(i8*) #1
184
185; Function Attrs: nounwind
186declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #1
187
188; Function Attrs: nounwind
189declare void @llvm.va_end(i8*) #1
190
191; Function Attrs: nounwind
192define i32 @main() #0 {
193entry:
194  %retval = alloca i32, align 4
195  %x = alloca i32, align 4
196  store i32 0, i32* %retval
197  %call = call i32 (i32, i32, i32, %struct.AAA*, %struct.AAA*, ...) @foo(i32 1, i32 3, i32 5, %struct.AAA* byval(%struct.AAA) align 4 @aaa, %struct.AAA* byval(%struct.AAA) align 4 @fff, i32 2, %struct.AAA* byval(%struct.AAA) align 4 @xxx, %struct.AAA* byval(%struct.AAA) align 4 @yyy, %struct.AAA* byval(%struct.AAA) align 4 @ccc, i32 4)
198  store i32 %call, i32* %x, align 4
199  %0 = load i32, i32* %x, align 4
200  %call1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0), i32 %0)
201  %1 = load i32, i32* %x, align 4
202  ret i32 %1
203}
204
205declare i32 @printf(i8*, ...) #2
206
207attributes #0 = { nounwind }
208
209!llvm.ident = !{!0}
210
211!0 = !{!"Clang 3.1"}
212