blob: b35fc4b5a58b361952a9023c4e021741fcedf3b8 [file] [log] [blame]
Evan Chenga6bff982010-01-30 01:22:00 +00001; RUN: llc < %s -march=x86 -asm-verbose=false | FileCheck %s -check-prefix=32
2; RUN: llc < %s -march=x86-64 -asm-verbose=false | FileCheck %s -check-prefix=64
Evan Cheng8148ae82010-02-03 21:40:40 +00003; XFAIL: *
Evan Chengb1712452010-01-27 06:25:16 +00004
Evan Cheng7096ae42010-01-29 06:45:59 +00005define void @t1(i32 %x) nounwind ssp {
Evan Chengb1712452010-01-27 06:25:16 +00006entry:
Evan Chenga6bff982010-01-30 01:22:00 +00007; 32: t1:
8; 32: jmp {{_?}}foo
9
10; 64: t1:
11; 64: jmp {{_?}}foo
Evan Chengb1712452010-01-27 06:25:16 +000012 tail call void @foo() nounwind
13 ret void
14}
15
16declare void @foo()
Evan Cheng7096ae42010-01-29 06:45:59 +000017
18define void @t2() nounwind ssp {
19entry:
Evan Chenga6bff982010-01-30 01:22:00 +000020; 32: t2:
21; 32: jmp {{_?}}foo2
22
23; 64: t2:
24; 64: jmp {{_?}}foo2
Evan Cheng7096ae42010-01-29 06:45:59 +000025 %0 = tail call i32 @foo2() nounwind
26 ret void
27}
28
29declare i32 @foo2()
30
31define void @t3() nounwind ssp {
32entry:
Evan Chenga6bff982010-01-30 01:22:00 +000033; 32: t3:
34; 32: jmp {{_?}}foo3
35
36; 64: t3:
37; 64: jmp {{_?}}foo3
Evan Cheng7096ae42010-01-29 06:45:59 +000038 %0 = tail call i32 @foo3() nounwind
39 ret void
40}
41
42declare i32 @foo3()
Evan Chenga6bff982010-01-30 01:22:00 +000043
44define void @t4(void (i32)* nocapture %x) nounwind ssp {
45entry:
46; 32: t4:
47; 32: call *
48; FIXME: gcc can generate a tailcall for this. But it's tricky.
49
50; 64: t4:
51; 64-NOT: call
52; 64: jmpq *
53 tail call void %x(i32 0) nounwind
54 ret void
55}
56
57define void @t5(void ()* nocapture %x) nounwind ssp {
58entry:
59; 32: t5:
60; 32-NOT: call
61; 32: jmpl *
62
63; 64: t5:
64; 64-NOT: call
65; 64: jmpq *
66 tail call void %x() nounwind
67 ret void
68}
Evan Cheng843bd692010-01-31 06:44:49 +000069
70define i32 @t6(i32 %x) nounwind ssp {
71entry:
72; 32: t6:
73; 32: call {{_?}}t6
74; 32: call {{_?}}bar
75
76; 64: t6:
Evan Cheng0a4fd462010-02-01 02:13:39 +000077; 64: jmp {{_?}}t6
Evan Cheng843bd692010-01-31 06:44:49 +000078; 64: jmp {{_?}}bar
79 %0 = icmp slt i32 %x, 10
80 br i1 %0, label %bb, label %bb1
81
82bb:
83 %1 = add nsw i32 %x, -1
84 %2 = tail call i32 @t6(i32 %1) nounwind ssp
85 ret i32 %2
86
87bb1:
88 %3 = tail call i32 @bar(i32 %x) nounwind
89 ret i32 %3
90}
91
92declare i32 @bar(i32)
Evan Chengb2c92902010-02-02 02:22:50 +000093
94define i32 @t7(i32 %a, i32 %b, i32 %c) nounwind ssp {
95entry:
96; 32: t7:
97; 32: jmp {{_?}}bar2
98
99; 64: t7:
100; 64: jmp {{_?}}bar2
101 %0 = tail call i32 @bar2(i32 %a, i32 %b, i32 %c) nounwind
102 ret i32 %0
103}
104
105declare i32 @bar2(i32, i32, i32)
Evan Cheng86809cc2010-02-03 03:28:02 +0000106
107define signext i16 @t8() nounwind ssp {
108entry:
109; 32: t8:
110; 32: jmp {{_?}}bar3
111
112; 64: t8:
113; 64: jmp {{_?}}bar3
114 %0 = tail call signext i16 @bar3() nounwind ; <i16> [#uses=1]
115 ret i16 %0
116}
117
118declare signext i16 @bar3()
119
120define signext i16 @t9(i32 (i32)* nocapture %x) nounwind ssp {
121entry:
122; 32: t9:
123; 32: call *
124
125; 64: t9:
126; 64: callq *
127 %0 = bitcast i32 (i32)* %x to i16 (i32)*
128 %1 = tail call signext i16 %0(i32 0) nounwind
129 ret i16 %1
130}
Evan Chengfebc8162010-02-03 03:55:59 +0000131
132define void @t10() nounwind ssp {
133entry:
134; 32: t10:
135; 32: call
136
137; 64: t10:
138; 64: callq
139 %0 = tail call i32 @foo4() noreturn nounwind
140 unreachable
141}
142
143declare i32 @foo4()