xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/arm64-call-tailcalls.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=arm64-apple-ios7.0 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker@t = weak global i32 ()* null
4*9880d681SAndroid Build Coastguard Worker@x = external global i32, align 4
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine void @t2() {
7*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t2:
8*9880d681SAndroid Build Coastguard Worker; CHECK: adrp	x[[GOTADDR:[0-9]+]], _t@GOTPAGE
9*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	x[[ADDR:[0-9]+]], [x[[GOTADDR]], _t@GOTPAGEOFF]
10*9880d681SAndroid Build Coastguard Worker; CHECK: ldr	x[[DEST:[0-9]+]], [x[[ADDR]]]
11*9880d681SAndroid Build Coastguard Worker; CHECK: br	x[[DEST]]
12*9880d681SAndroid Build Coastguard Worker  %tmp = load i32 ()*, i32 ()** @t
13*9880d681SAndroid Build Coastguard Worker  %tmp.upgrd.2 = tail call i32 %tmp()
14*9880d681SAndroid Build Coastguard Worker  ret void
15*9880d681SAndroid Build Coastguard Worker}
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerdefine void @t3() {
18*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t3:
19*9880d681SAndroid Build Coastguard Worker; CHECK: b	_t2
20*9880d681SAndroid Build Coastguard Worker  tail call void @t2()
21*9880d681SAndroid Build Coastguard Worker  ret void
22*9880d681SAndroid Build Coastguard Worker}
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Workerdefine double @t4(double %a) nounwind readonly ssp {
25*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t4:
26*9880d681SAndroid Build Coastguard Worker; CHECK: b	_sin
27*9880d681SAndroid Build Coastguard Worker  %tmp = tail call double @sin(double %a) nounwind readonly
28*9880d681SAndroid Build Coastguard Worker  ret double %tmp
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workerdefine float @t5(float %a) nounwind readonly ssp {
32*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t5:
33*9880d681SAndroid Build Coastguard Worker; CHECK: b	_sinf
34*9880d681SAndroid Build Coastguard Worker  %tmp = tail call float @sinf(float %a) nounwind readonly
35*9880d681SAndroid Build Coastguard Worker  ret float %tmp
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Workerdefine void @t7() nounwind {
39*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t7:
40*9880d681SAndroid Build Coastguard Worker; CHECK: b	_foo
41*9880d681SAndroid Build Coastguard Worker; CHECK: b	_bar
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %bb, label %bb1.lr.ph
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Workerbb1.lr.ph:                                        ; preds = %entry
46*9880d681SAndroid Build Coastguard Worker  tail call void @bar() nounwind
47*9880d681SAndroid Build Coastguard Worker  ret void
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerbb:                                               ; preds = %entry
50*9880d681SAndroid Build Coastguard Worker  tail call void @foo() nounwind
51*9880d681SAndroid Build Coastguard Worker  ret void
52*9880d681SAndroid Build Coastguard Worker}
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Workerdefine i32 @t8(i32 %x) nounwind ssp {
55*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: t8:
56*9880d681SAndroid Build Coastguard Worker; CHECK: b	_c
57*9880d681SAndroid Build Coastguard Worker; CHECK: b	_a
58*9880d681SAndroid Build Coastguard Worker; CHECK: b	_b
59*9880d681SAndroid Build Coastguard Worker  %and = and i32 %x, 1
60*9880d681SAndroid Build Coastguard Worker  %tobool = icmp eq i32 %and, 0
61*9880d681SAndroid Build Coastguard Worker  br i1 %tobool, label %if.end, label %if.then
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %entry
64*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @a(i32 %x) nounwind
65*9880d681SAndroid Build Coastguard Worker  br label %return
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Workerif.end:                                           ; preds = %entry
68*9880d681SAndroid Build Coastguard Worker  %and1 = and i32 %x, 2
69*9880d681SAndroid Build Coastguard Worker  %tobool2 = icmp eq i32 %and1, 0
70*9880d681SAndroid Build Coastguard Worker  br i1 %tobool2, label %if.end5, label %if.then3
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Workerif.then3:                                         ; preds = %if.end
73*9880d681SAndroid Build Coastguard Worker  %call4 = tail call i32 @b(i32 %x) nounwind
74*9880d681SAndroid Build Coastguard Worker  br label %return
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Workerif.end5:                                          ; preds = %if.end
77*9880d681SAndroid Build Coastguard Worker  %call6 = tail call i32 @c(i32 %x) nounwind
78*9880d681SAndroid Build Coastguard Worker  br label %return
79*9880d681SAndroid Build Coastguard Worker
80*9880d681SAndroid Build Coastguard Workerreturn:                                           ; preds = %if.end5, %if.then3, %if.then
81*9880d681SAndroid Build Coastguard Worker  %retval.0 = phi i32 [ %call, %if.then ], [ %call4, %if.then3 ], [ %call6, %if.end5 ]
82*9880d681SAndroid Build Coastguard Worker  ret i32 %retval.0
83*9880d681SAndroid Build Coastguard Worker}
84*9880d681SAndroid Build Coastguard Worker
85*9880d681SAndroid Build Coastguard Workerdeclare float @sinf(float) nounwind readonly
86*9880d681SAndroid Build Coastguard Workerdeclare double @sin(double) nounwind readonly
87*9880d681SAndroid Build Coastguard Workerdeclare void @bar() nounwind
88*9880d681SAndroid Build Coastguard Workerdeclare void @foo() nounwind
89*9880d681SAndroid Build Coastguard Workerdeclare i32 @a(i32)
90*9880d681SAndroid Build Coastguard Workerdeclare i32 @b(i32)
91*9880d681SAndroid Build Coastguard Workerdeclare i32 @c(i32)
92