xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/sibcall-win64.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Workerdeclare x86_64_win64cc void @win64_callee(i32)
4*9880d681SAndroid Build Coastguard Workerdeclare x86_64_win64cc void (i32)* @win64_indirect()
5*9880d681SAndroid Build Coastguard Workerdeclare x86_64_win64cc void @win64_other(i32)
6*9880d681SAndroid Build Coastguard Workerdeclare void @sysv_callee(i32)
7*9880d681SAndroid Build Coastguard Workerdeclare void (i32)* @sysv_indirect()
8*9880d681SAndroid Build Coastguard Workerdeclare void @sysv_other(i32)
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine void @sysv_caller(i32 %p1) {
11*9880d681SAndroid Build Coastguard Workerentry:
12*9880d681SAndroid Build Coastguard Worker  tail call x86_64_win64cc void @win64_callee(i32 %p1)
13*9880d681SAndroid Build Coastguard Worker  ret void
14*9880d681SAndroid Build Coastguard Worker}
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sysv_caller:
17*9880d681SAndroid Build Coastguard Worker; CHECK: subq $40, %rsp
18*9880d681SAndroid Build Coastguard Worker; CHECK: callq win64_callee
19*9880d681SAndroid Build Coastguard Worker; CHECK: addq $40, %rsp
20*9880d681SAndroid Build Coastguard Worker; CHECK: retq
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerdefine x86_64_win64cc void @win64_caller(i32 %p1) {
23*9880d681SAndroid Build Coastguard Workerentry:
24*9880d681SAndroid Build Coastguard Worker  tail call void @sysv_callee(i32 %p1)
25*9880d681SAndroid Build Coastguard Worker  ret void
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: win64_caller:
29*9880d681SAndroid Build Coastguard Worker; CHECK: callq sysv_callee
30*9880d681SAndroid Build Coastguard Worker; CHECK: retq
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Workerdefine void @sysv_matched(i32 %p1) {
33*9880d681SAndroid Build Coastguard Worker  tail call void @sysv_callee(i32 %p1)
34*9880d681SAndroid Build Coastguard Worker  ret void
35*9880d681SAndroid Build Coastguard Worker}
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sysv_matched:
38*9880d681SAndroid Build Coastguard Worker; CHECK: jmp sysv_callee # TAILCALL
39*9880d681SAndroid Build Coastguard Worker
40*9880d681SAndroid Build Coastguard Workerdefine x86_64_win64cc void @win64_matched(i32 %p1) {
41*9880d681SAndroid Build Coastguard Worker  tail call x86_64_win64cc void @win64_callee(i32 %p1)
42*9880d681SAndroid Build Coastguard Worker  ret void
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: win64_matched:
46*9880d681SAndroid Build Coastguard Worker; CHECK: jmp win64_callee # TAILCALL
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Workerdefine x86_64_win64cc void @win64_indirect_caller(i32 %p1) {
49*9880d681SAndroid Build Coastguard Worker  %1 = call x86_64_win64cc void (i32)* @win64_indirect()
50*9880d681SAndroid Build Coastguard Worker  call x86_64_win64cc void @win64_other(i32 0)
51*9880d681SAndroid Build Coastguard Worker  tail call x86_64_win64cc void %1(i32 %p1)
52*9880d681SAndroid Build Coastguard Worker  ret void
53*9880d681SAndroid Build Coastguard Worker}
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: win64_indirect_caller:
56*9880d681SAndroid Build Coastguard Worker; CHECK: jmpq *%{{rax|rcx|rdx|r8|r9|r11}} # TAILCALL
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Workerdefine void @sysv_indirect_caller(i32 %p1) {
59*9880d681SAndroid Build Coastguard Worker  %1 = call void (i32)* @sysv_indirect()
60*9880d681SAndroid Build Coastguard Worker  call void @sysv_other(i32 0)
61*9880d681SAndroid Build Coastguard Worker  tail call void %1(i32 %p1)
62*9880d681SAndroid Build Coastguard Worker  ret void
63*9880d681SAndroid Build Coastguard Worker}
64*9880d681SAndroid Build Coastguard Worker
65*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sysv_indirect_caller:
66*9880d681SAndroid Build Coastguard Worker; CHECK: jmpq *%{{rax|rcx|rdx|rsi|rdi|r8|r9|r11}} # TAILCALL
67