• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -mtriple=i686-windows | FileCheck %s
2; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefix=LINUX64
3
4declare void @param1(i32 %a)
5declare i32 @param2_ret(i32 %a, i32 %b)
6declare i64 @param2_ret64(i32 %a, i32 %b)
7declare void @param2(i32 %a, i32 %b)
8declare void @param3(i32 %a, i32 %b, i32 %c)
9declare void @param8(i64, i64, i64, i64, i64, i64, i64, i64)
10declare i32 @param8_ret(i64, i64, i64, i64, i64, i64, i64, i64)
11
12
13define void @test() minsize nounwind {
14; CHECK-LABEL: test:
15; CHECK: calll _param1
16; CHECK-NEXT: popl %eax
17; CHECK: calll _param2
18; CHECK-NEXT: popl %eax
19; CHECK-NEXT: popl %ecx
20; CHECK: calll _param2_ret
21; CHECK-NEXT: popl %ecx
22; CHECK-NEXT: popl %edx
23; CHECK-NEXT: pushl %eax
24; CHECK: calll _param3
25; CHECK-NEXT: addl $12, %esp
26; CHECK: calll _param2_ret64
27; CHECK-NEXT: popl %ecx
28; CHECK-NEXT: popl %ecx
29  call void @param1(i32 1)
30  call void @param2(i32 1, i32 2)
31  %ret = call i32 @param2_ret(i32 1, i32 2)
32  call void @param3(i32 1, i32 2, i32 %ret)
33  %ret64 = call i64 @param2_ret64(i32 1, i32 2)
34  ret void
35}
36
37define void @negative(i32 %k) {
38; CHECK-LABEL: negative:
39; CHECK: calll _param1
40; CHECK-NEXT: addl $4, %esp
41; CHECK: calll _param2
42; CHECK-NEXT: addl $8, %esp
43; CHECK: calll _param3
44; CHECK-NEXT: movl %ebp, %esp
45  %v = alloca i32, i32 %k
46  call void @param1(i32 1)
47  call void @param2(i32 1, i32 2)
48  call void @param3(i32 1, i32 2, i32 3)
49  ret void
50}
51
52define void @spill(i32 inreg %a, i32 inreg %b, i32 inreg %c) minsize nounwind {
53; CHECK-LABEL: spill:
54; CHECK-DAG: movl %ecx,
55; CHECK-DAG: movl %edx,
56; CHECK: calll _param2_ret
57; CHECK-NEXT: popl %ecx
58; CHECK-NEXT: popl %edx
59; CHECK-DAG: movl {{.*}}, %ecx
60; CHECK-DAG: movl {{.*}}, %edx
61; CHECK: calll _spill
62  %i = call i32 @param2_ret(i32 1, i32 2)
63  call void @spill(i32 %a, i32 %b, i32 %c)
64  ret void
65}
66
67define void @test_linux64(i32 %size) minsize nounwind {
68; LINUX64-LABEL: test_linux64:
69; LINUX64: pushq %rbp
70; LINUX64: callq param8
71; LINUX64-NEXT: popq %rax
72; LINUX64-NEXT: popq %rcx
73
74  %a = alloca i64, i32 %size, align 8
75  call void @param8(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8)
76  ret void
77}
78
79define i32 @test_linux64_i32(i32 %size) minsize nounwind {
80; LINUX64-LABEL: test_linux64_i32:
81; LINUX64: callq param8_ret
82; LINUX64-NOT: popq %rax
83; LINUX64: retq
84  %a = alloca i64, i32 %size, align 8
85  %r = call i32 @param8_ret(i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8)
86  ret i32 %r
87}
88