1 ; RUN: llc -march=mipsel -relocation-model=pic \
2 ; RUN: -verify-machineinstrs -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,PIC32
3 ; RUN: llc -march=mipsel -relocation-model=static \
4 ; RUN: -verify-machineinstrs -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,STATIC32
5 ; RUN: llc -march=mips64el -mcpu=mips64r2 -relocation-model=pic \
6 ; RUN: -verify-machineinstrs -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,PIC64
7 ; RUN: llc -march=mips64el -mcpu=mips64r2 -relocation-model=static \
8 ; RUN: -verify-machineinstrs -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,STATIC64
9 ; RUN: llc -march=mipsel -mattr=mips16 -relocation-model=pic \
10 ; RUN: -verify-machineinstrs -mips-tail-calls=1 < %s | \
11 ; RUN: FileCheck %s -check-prefixes=ALL,PIC16
13 ; RUN: llc -march=mipsel -relocation-model=pic -mattr=+micromips -verify-machineinstrs \
14 ; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,PIC32MM
15 ; RUN: llc -march=mipsel -relocation-model=static -mattr=+micromips -verify-machineinstrs \
16 ; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,STATIC32
18 ; RUN: llc -march=mipsel -relocation-model=pic -mcpu=mips32r6 -verify-machineinstrs \
19 ; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,PIC32R6
20 ; RUN: llc -march=mipsel -relocation-model=static -mcpu=mips32r2 -verify-machineinstrs \
21 ; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,STATIC32
22 ; RUN: llc -march=mips64el -relocation-model=pic -mcpu=mips64r2 -verify-machineinstrs \
23 ; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=PIC64
24 ; RUN: llc -march=mips64el -relocation-model=pic -mcpu=mips64r6 -verify-machineinstrs \
25 ; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=STATIC64
27 ; RUN: llc -march=mipsel -relocation-model=pic -mcpu=mips32r6 -mattr=+micromips -verify-machineinstrs \
28 ; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,PIC32MM
29 ; RUN: llc -march=mipsel -relocation-model=static -mcpu=mips32r6 -verify-machineinstrs \
30 ; RUN: -mattr=+micromips -mips-tail-calls=1 < %s | FileCheck %s -check-prefixes=ALL,STATIC32MMR6
32 @g0 = common global i32 0, align 4
33 @g1 = common global i32 0, align 4
34 @g2 = common global i32 0, align 4
35 @g3 = common global i32 0, align 4
36 @g4 = common global i32 0, align 4
37 @g5 = common global i32 0, align 4
38 @g6 = common global i32 0, align 4
39 @g7 = common global i32 0, align 4
40 @g8 = common global i32 0, align 4
41 @g9 = common global i32 0, align 4
43 define i32 @caller1(i32 %a0) nounwind {
55 %call = tail call i32 @callee1(i32 1, i32 1, i32 1, i32 %a0) nounwind
59 declare i32 @callee1(i32, i32, i32, i32)
61 define i32 @caller2(i32 %a0, i32 %a1, i32 %a2, i32 %a3) nounwind {
73 %call = tail call i32 @callee2(i32 1, i32 %a0, i32 %a1, i32 %a2, i32 %a3) nounwind
77 declare i32 @callee2(i32, i32, i32, i32, i32)
79 define i32 @caller3(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4) nounwind {
91 %call = tail call i32 @callee3(i32 1, i32 1, i32 1, i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4) nounwind
95 declare i32 @callee3(i32, i32, i32, i32, i32, i32, i32, i32)
97 define i32 @caller4(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7) nounwind {
110 %call = tail call i32 @callee4(i32 1, i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7) nounwind
114 declare i32 @callee4(i32, i32, i32, i32, i32, i32, i32, i32, i32)
116 define i32 @caller5() nounwind readonly {
118 ; ALL-LABEL: caller5:
128 %0 = load i32, i32* @g0, align 4
129 %1 = load i32, i32* @g1, align 4
130 %2 = load i32, i32* @g2, align 4
131 %3 = load i32, i32* @g3, align 4
132 %4 = load i32, i32* @g4, align 4
133 %5 = load i32, i32* @g5, align 4
134 %6 = load i32, i32* @g6, align 4
135 %7 = load i32, i32* @g7, align 4
136 %8 = load i32, i32* @g8, align 4
137 %9 = load i32, i32* @g9, align 4
138 %call = tail call fastcc i32 @callee5(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9)
142 define internal fastcc i32 @callee5(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7, i32 %a8, i32 %a9) nounwind readnone noinline {
144 %add = add nsw i32 %a1, %a0
145 %add1 = add nsw i32 %add, %a2
146 %add2 = add nsw i32 %add1, %a3
147 %add3 = add nsw i32 %add2, %a4
148 %add4 = add nsw i32 %add3, %a5
149 %add5 = add nsw i32 %add4, %a6
150 %add6 = add nsw i32 %add5, %a7
151 %add7 = add nsw i32 %add6, %a8
152 %add8 = add nsw i32 %add7, %a9
156 declare i32 @callee8(i32, ...)
158 define i32 @caller8_0() nounwind {
160 ; ALL-LABEL: caller8_0:
171 %call = tail call fastcc i32 @caller8_1()
175 define internal fastcc i32 @caller8_1() nounwind noinline {
177 ; ALL-LABEL: caller8_1:
187 %call = tail call i32 (i32, ...) @callee8(i32 2, i32 1) nounwind
191 %struct.S = type { [2 x i32] }
193 @gs1 = external global %struct.S
195 declare i32 @callee9(%struct.S* byval)
197 define i32 @caller9_0() nounwind {
199 ; ALL-LABEL: caller9_0:
209 %call = tail call fastcc i32 @caller9_1()
213 define internal fastcc i32 @caller9_1() nounwind noinline {
215 ; ALL-LABEL: caller9_1:
226 %call = tail call i32 @callee9(%struct.S* byval @gs1) nounwind
230 declare i32 @callee10(i32, i32, i32, i32, i32, i32, i32, i32, i32)
232 define i32 @caller10(i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7, i32 %a8) nounwind {
234 ; ALL-LABEL: caller10:
245 %call = tail call i32 @callee10(i32 %a8, i32 %a0, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7) nounwind
249 declare i32 @callee11(%struct.S* byval)
251 define i32 @caller11() nounwind noinline {
253 ; ALL-LABEL: caller11:
264 %call = tail call i32 @callee11(%struct.S* byval @gs1) nounwind
268 declare i32 @callee12()
270 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i1) nounwind
272 define i32 @caller12(%struct.S* nocapture byval %a0) nounwind {
274 ; ALL-LABEL: caller12:
285 %0 = bitcast %struct.S* %a0 to i8*
286 tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 bitcast (%struct.S* @gs1 to i8*), i8* align 4 %0, i32 8, i1 false)
287 %call = tail call i32 @callee12() nounwind
291 declare i32 @callee13(i32, ...)
293 define i32 @caller13() nounwind {
295 ; ALL-LABEL: caller13:
306 %call = tail call i32 (i32, ...) @callee13(i32 1, i32 2) nounwind
310 ; Check that there is a chain edge between the load and store nodes.
312 ; ALL-LABEL: caller14:
313 ; PIC32: lw ${{[0-9]+}}, 48($sp)
314 ; PIC32: sw $4, 16($sp)
316 ; PIC32MM: lw ${{[0-9]+}}, 48($sp)
317 ; PIC32MM: sw16 $4, 16(${{[0-9]+}})
319 define void @caller14(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
321 tail call void @callee14(i32 %e, i32 %b, i32 %c, i32 %d, i32 %a)
325 declare void @callee14(i32, i32, i32, i32, i32)