blob: b891b7d90728ebb2080d2d3fc0bb656207eae8ed [file] [log] [blame]
Simon Dardisd2ed8ab2016-09-27 13:15:54 +00001; RUN: llc -march=mips -mcpu=mips32 -O0 -relocation-model=pic -mips-tail-calls=1 < %s | FileCheck \
Simon Dardis9a66bbe2016-09-21 09:43:40 +00002; RUN: %s -check-prefix=MIPS32
3; RUN: llc -march=mips64 -mcpu=mips64 -O0 -relocation-model=pic -target-abi n64 \
Simon Dardisd2ed8ab2016-09-27 13:15:54 +00004; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=MIPS64
Simon Dardis9a66bbe2016-09-21 09:43:40 +00005; RUN: llc -march=mips64 -mcpu=mips64 -O0 -relocation-model=pic -target-abi n32 \
Simon Dardisd2ed8ab2016-09-27 13:15:54 +00006; RUN: -mips-tail-calls=1 < %s | FileCheck %s -check-prefix=MIPS64
Simon Dardis9a66bbe2016-09-21 09:43:40 +00007
8
9; LLVM PR/30197
10; Test that the scheduler does not order loads and stores of arguments that
11; are passed on the stack such that the arguments of the caller are clobbered
12; too early.
13
14; This test is more fragile than I'd like. The -NEXT directives enforce an
15; assumption that any GOT related instructions will not appear between the
16; loads and stores.
17
18; O32 case: The last two arguments should appear at 16(sp), 20(sp). The order
19; of the loads doesn't matter, but they have to become before the
20; stores
21declare i32 @func2(i32, i32, i32, i32, i32, i32)
22
23define i32 @func1(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f){
Vasileios Kalintiris3955b752016-10-18 13:05:42 +000024; MIPS32-LABEL: func1:
Simon Dardis9a66bbe2016-09-21 09:43:40 +000025
26; MIPS32: lw ${{[0-9]+}}, {{[0-9]+}}($sp)
27; MIPS32-NEXT: lw ${{[0-9]+}}, {{[0-9]+}}($sp)
28; MIPS32-NEXT: sw ${{[0-9]+}}, {{[0-9]+}}($sp)
29; MIPS32-NEXT: sw ${{[0-9]+}}, {{[0-9]+}}($sp)
30 %retval = tail call i32 @func1(i32 %a, i32 %f, i32 %c, i32 %d, i32 %e, i32 %b)
31
32 ret i32 %retval
33}
34
35; N64, N32 cases: N64 and N32 both pass 8 arguments in registers. The order
36; of the loads doesn't matter, but they have to become before the
37; stores
38
39declare i64 @func4(i64, i64, i64, i64, i64, i64, i64, i64, i64, i64)
40
41define i64 @func3(i64 %a, i64 %b, i64 %c, i64 %d,
42 i64 %e, i64 %f, i64 %g, i64 %h,
43 i64 %i, i64 %j){
Vasileios Kalintiris3955b752016-10-18 13:05:42 +000044; MIPS64-LABEL: func3:
Simon Dardis9a66bbe2016-09-21 09:43:40 +000045
46; MIPS64: ld ${{[0-9]+}}, {{[0-9]+}}($sp)
47; MIPS64-NEXT: ld ${{[0-9]+}}, {{[0-9]+}}($sp)
48; MIPS64-NEXT: sd ${{[0-9]+}}, {{[0-9]+}}($sp)
49; MIPS64-NEXT: sd ${{[0-9]+}}, {{[0-9]+}}($sp)
50 %retval = tail call i64 @func4(i64 %a, i64 %j, i64 %c, i64 %d, i64 %e, i64 %f, i64 %g, i64 %h, i64 %i, i64 %b)
51
52 ret i64 %retval
53}
54
55