1; RUN: llc < %s -tailcallopt -mcpu=generic -mtriple=x86_64-linux -post-RA-scheduler=true | FileCheck %s
2; RUN: llc < %s -tailcallopt -mcpu=generic -mtriple=x86_64-win32 -post-RA-scheduler=true | FileCheck %s
3
4; FIXME: Redundant unused stack allocation could be eliminated.
5; CHECK: subq  ${{24|72|80}}, %rsp
6
7; Check that lowered arguments on the stack do not overwrite each other.
8; Add %in1 %p1 to a different temporary register (%eax).
9; CHECK: movl  [[A1:32|144]](%rsp), [[R1:%e..]]
10; Move param %in1 to temp register (%r10d).
11; CHECK: movl  [[A2:40|152]](%rsp), [[R2:%[a-z0-9]+]]
12; Add %in1 %p1 to a different temporary register (%eax).
13; CHECK: addl {{%edi|%ecx}}, [[R1]]
14; Move param %in2 to stack.
15; CHECK-DAG: movl  [[R2]], [[A1]](%rsp)
16; Move result of addition to stack.
17; CHECK-DAG: movl  [[R1]], [[A2]](%rsp)
18; Eventually, do a TAILCALL
19; CHECK: TAILCALL
20
21declare fastcc i32 @tailcallee(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %p6, i32 %a, i32 %b) nounwind
22
23define fastcc i32 @tailcaller(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %p6, i32 %in1, i32 %in2) nounwind {
24entry:
25        %tmp = add i32 %in1, %p1
26        %retval = tail call fastcc i32 @tailcallee(i32 %p1, i32 %p2, i32 %p3, i32 %p4, i32 %p5, i32 %p6, i32 %in2,i32 %tmp)
27        ret i32 %retval
28}
29