xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/tailcall-ccmismatch.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -o - %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Workertarget triple="aarch64--"
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Workerdeclare void @somefunc()
5*9880d681SAndroid Build Coastguard Workerdefine preserve_mostcc void @test_ccmismatch_notail() {
6*9880d681SAndroid Build Coastguard Worker; Ensure that no tail call is used here, as the called function somefunc does
7*9880d681SAndroid Build Coastguard Worker; not preserve enough registers for preserve_mostcc.
8*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_ccmismatch_notail:
9*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: b somefunc
10*9880d681SAndroid Build Coastguard Worker; CHECK: bl somefunc
11*9880d681SAndroid Build Coastguard Worker  tail call void @somefunc()
12*9880d681SAndroid Build Coastguard Worker  ret void
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workerdeclare preserve_mostcc void @some_preserve_most_func()
16*9880d681SAndroid Build Coastguard Workerdefine void @test_ccmismatch_tail() {
17*9880d681SAndroid Build Coastguard Worker; We can perform a tail call here, because some_preserve_most_func preserves
18*9880d681SAndroid Build Coastguard Worker; all registers necessary for test_ccmismatch_tail.
19*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_ccmismatch_tail:
20*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: bl some_preserve_most_func
21*9880d681SAndroid Build Coastguard Worker; CHECK: b some_preserve_most_func
22*9880d681SAndroid Build Coastguard Worker  tail call preserve_mostcc void @some_preserve_most_func()
23*9880d681SAndroid Build Coastguard Worker  ret void
24*9880d681SAndroid Build Coastguard Worker}
25