about summary refs log tree commit diff
path: root/tests/mir-opt/dest-prop/simple.rs
blob: 927a9c5b24cdbecb4be13645e7b8b70daff03452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too.
//@ test-mir-pass: DestinationPropagation
// EMIT_MIR simple.nrvo.DestinationPropagation.diff
fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
    // CHECK-LABEL: fn nrvo(
    // CHECK: debug init => [[init:_.*]];
    // CHECK: debug buf => [[buf:_.*]];
    // CHECK: [[buf]] = [const 0_u8; 1024];
    // CHECK-NOT: {{_.*}} = copy [[init]];
    // CHECK: move [[init]](move {{_.*}})
    // CHECK: {{_.*}} = copy [[buf]]
    let mut buf = [0; 1024];
    init(&mut buf);
    buf
}

fn main() {
    let _ = nrvo(|buf| {
        buf[4] = 4;
    });
}