about summary refs log tree commit diff
path: root/tests/codegen-llvm/become-musttail.rs
blob: 07f335719104253997d2e7aa87fddb2971187ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//@ compile-flags: -C opt-level=0 -Cpanic=abort -C no-prepopulate-passes
//@ needs-unwind

#![crate_type = "lib"]
#![feature(explicit_tail_calls)]

// CHECK-LABEL: define {{.*}}@fibonacci(
#[no_mangle]
#[inline(never)]
pub fn fibonacci(n: u64, a: u64, b: u64) -> u64 {
    // CHECK: musttail call {{.*}}@fibonacci(
    // CHECK-NEXT: ret i64
    match n {
        0 => a,
        1 => b,
        _ => become fibonacci(n - 1, b, a + b),
    }
}