summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/inline/exponential_runtime.rs
blob: 1199ce4e5588e4bc7211d999ec96ae31653605a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// Checks that code with exponential runtime does not have exponential behavior in inlining.

trait A {
    fn call();
}

trait B {
    fn call();
}
impl<T: A> B for T {
    #[inline]
    fn call() {
        <T as A>::call();
        <T as A>::call();
        <T as A>::call();
    }
}

trait C {
    fn call();
}
impl<T: B> C for T {
    #[inline]
    fn call() {
        <T as B>::call();
        <T as B>::call();
        <T as B>::call();
    }
}

trait D {
    fn call();
}
impl<T: C> D for T {
    #[inline]
    fn call() {
        <T as C>::call();
        <T as C>::call();
        <T as C>::call();
    }
}

trait E {
    fn call();
}
impl<T: D> E for T {
    #[inline]
    fn call() {
        <T as D>::call();
        <T as D>::call();
        <T as D>::call();
    }
}

trait F {
    fn call();
}
impl<T: E> F for T {
    #[inline]
    fn call() {
        <T as E>::call();
        <T as E>::call();
        <T as E>::call();
    }
}

trait G {
    fn call();
}
impl<T: F> G for T {
    #[inline]
    fn call() {
        <T as F>::call();
        <T as F>::call();
        <T as F>::call();
    }
}

impl A for () {
    #[inline(never)]
    fn call() {}
}

// EMIT_MIR exponential_runtime.main.Inline.diff
fn main() {
    // CHECK-LABEL: fn main(
    // CHECK-NOT: inlined
    // CHECK: (inlined <() as G>::call)
    // CHECK: (inlined <() as F>::call)
    // CHECK: (inlined <() as E>::call)
    // CHECK: (inlined <() as D>::call)
    // CHECK: (inlined <() as C>::call)
    // CHECK: (inlined <() as B>::call)
    // CHECK-NOT: inlined
    <() as G>::call();
}