Skip to content

Commit cdd4424

Browse files
committed
Convert tail call tests from Makefile to proper codegen test
- Remove old Makefile-based test in tests/run-make/tail-call-llvm-ir/ - Add new codegen test in tests/codegen/tail-call-become.rs - Tests verify that 'become' generates LLVM tail call instructions - Tests also verify that regular calls don't generate tail calls
1 parent e61a5b3 commit cdd4424

File tree

6 files changed

+56
-1163
lines changed

6 files changed

+56
-1163
lines changed

rmetaQZcwdq/full.rmeta

2.71 KB
Binary file not shown.

tests/codegen/tail-call-become.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//@ compile-flags: -C opt-level=0 -Cpanic=abort
2+
//@ needs-llvm-components: x86
3+
4+
#![feature(explicit_tail_calls)]
5+
#![crate_type = "lib"]
6+
7+
// CHECK-LABEL: @with_tail
8+
pub fn with_tail(n: u32) -> u32 {
9+
// CHECK: tail call noundef i32 @{{.*}}with_tail{{.*}}(i32 noundef %{{.*}})
10+
if n == 0 { 0 } else { become with_tail(n - 1) }
11+
}
12+
13+
// CHECK-LABEL: @no_tail
14+
pub fn no_tail(n: u32) -> u32 {
15+
// CHECK-NOT: tail call
16+
// CHECK: call noundef i32 @{{.*}}no_tail{{.*}}(i32 noundef %{{.*}})
17+
if n == 0 { 0 } else { no_tail(n - 1) }
18+
}
19+
20+
// CHECK-LABEL: @even_with_tail
21+
pub fn even_with_tail(n: u32) -> bool {
22+
// CHECK: tail call noundef {{.*}} @{{.*}}odd_with_tail{{.*}}(i32 noundef %{{.*}})
23+
match n {
24+
0 => true,
25+
_ => become odd_with_tail(n - 1),
26+
}
27+
}
28+
29+
// CHECK-LABEL: @odd_with_tail
30+
pub fn odd_with_tail(n: u32) -> bool {
31+
// CHECK: tail call noundef {{.*}} @{{.*}}even_with_tail{{.*}}(i32 noundef %{{.*}})
32+
match n {
33+
0 => false,
34+
_ => become even_with_tail(n - 1),
35+
}
36+
}
37+
38+
// CHECK-LABEL: @even_no_tail
39+
pub fn even_no_tail(n: u32) -> bool {
40+
// CHECK-NOT: tail call
41+
// CHECK: call noundef {{.*}} @{{.*}}odd_no_tail{{.*}}(i32 noundef %{{.*}})
42+
match n {
43+
0 => true,
44+
_ => odd_no_tail(n - 1),
45+
}
46+
}
47+
48+
// CHECK-LABEL: @odd_no_tail
49+
pub fn odd_no_tail(n: u32) -> bool {
50+
// CHECK-NOT: tail call
51+
// CHECK: call noundef {{.*}} @{{.*}}even_no_tail{{.*}}(i32 noundef %{{.*}})
52+
match n {
53+
0 => false,
54+
_ => even_no_tail(n - 1),
55+
}
56+
}

tests/run-make/tail-call-llvm-ir/Makefile

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)