summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/dead-store-elimination/call_arg_copy.rs
blob: f09cdee14822e4bc36043fb23db0cc2a193dcc83 (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
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: DeadStoreElimination
// compile-flags: -Zmir-enable-passes=+CopyProp

#![feature(core_intrinsics)]
#![feature(custom_mir)]
#![allow(internal_features)]

use std::intrinsics::mir::*;

#[inline(never)]
fn use_both(_: i32, _: i32) {}

// EMIT_MIR call_arg_copy.move_simple.DeadStoreElimination.diff
fn move_simple(x: i32) {
    use_both(x, x);
}

#[repr(packed)]
struct Packed {
    x: u8,
    y: i32,
}

// EMIT_MIR call_arg_copy.move_packed.DeadStoreElimination.diff
#[custom_mir(dialect = "analysis")]
fn move_packed(packed: Packed) {
    mir!(
        {
            Call(RET = use_both(0, packed.y), ret)
        }
        ret = {
            Return()
        }
    )
}

fn main() {
    move_simple(1);
    move_packed(Packed { x: 0, y: 1 });
}