about summary refs log tree commit diff
path: root/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs
blob: 1c4eb41f35ec6671c41c61177af0ade058f9a285 (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
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ test-mir-pass: DataflowConstProp

#[inline(never)]
fn escape<T>(x: &T) {}

#[inline(never)]
fn some_function() {}

// EMIT_MIR ref_without_sb.main.DataflowConstProp.diff
// CHECK-LABEL: fn main(
fn main() {
    // CHECK: debug a => [[a:_.*]];
    // CHECK: debug b => [[b:_.*]];

    let mut a = 0;

    // CHECK: {{_.*}} = escape::<i32>(move {{_.*}}) ->  {{.*}}
    escape(&a);
    a = 1;

    // CHECK: {{_.*}} = some_function() ->  {{.*}}
    some_function();
    // This should currently not be propagated.

    // CHECK-NOT: [[b]] = const
    // CHECK: [[b]] = copy [[a]];
    // CHECK-NOT: [[b]] = const
    let b = a;
}