|
6 | 6 | #![feature(custom_mir)] |
7 | 7 | #![allow(internal_features)] |
8 | 8 |
|
| 9 | +use std::convert::identity; |
9 | 10 | use std::intrinsics::mir::*; |
10 | 11 |
|
11 | 12 | #[inline(never)] |
@@ -40,31 +41,43 @@ fn move_packed(packed: Packed) { |
40 | 41 | } |
41 | 42 | } |
42 | 43 |
|
43 | | -#[inline(never)] |
44 | | -fn passthrough_usize(a: usize) -> usize { |
45 | | - a |
46 | | -} |
47 | | - |
48 | 44 | // EMIT_MIR call_arg_copy.move_index.DeadStoreElimination-final.diff |
49 | 45 | #[custom_mir(dialect = "analysis")] |
50 | 46 | fn move_index(a: [usize; 10], b: usize) { |
51 | 47 | // CHECK-LABEL: fn move_index( |
52 | | - // CHECK: = passthrough_usize(copy _2) |
| 48 | + // CHECK: = identity::<usize>(copy _2) |
53 | 49 | mir! { |
54 | 50 | { |
55 | 51 | // The index is used again after the operand is evaluated to |
56 | | - // evaluate the destionation place, so the argument cannot be turned |
| 52 | + // evaluate the destination place, so the argument cannot be turned |
57 | 53 | // into a move. |
58 | | - Call(a[b] = passthrough_usize(b), ReturnTo(ret), UnwindContinue()) |
| 54 | + Call(a[b] = identity(b), ReturnTo(ret), UnwindContinue()) |
59 | 55 | } |
60 | 56 | ret = { |
61 | 57 | Return() |
62 | 58 | } |
63 | 59 | } |
64 | 60 | } |
65 | 61 |
|
| 62 | +// EMIT_MIR call_arg_copy.ret_is_arg.DeadStoreElimination-final.diff |
| 63 | +#[custom_mir(dialect = "runtime")] |
| 64 | +fn ret_is_arg(x: [u64; 5]) -> [u64; 5] { |
| 65 | + // CHECK-LABEL: fn ret_is_arg(_1 |
| 66 | + // CHECK: _1 = identity::<[u64; 5]>(copy _1) -> |
| 67 | + mir! { |
| 68 | + { |
| 69 | + Call(x = identity(x), ReturnTo(bb1), UnwindUnreachable()) |
| 70 | + } |
| 71 | + bb1 = { |
| 72 | + RET = x; |
| 73 | + Return() |
| 74 | + } |
| 75 | + } |
| 76 | +} |
| 77 | + |
66 | 78 | fn main() { |
67 | 79 | move_simple(1); |
68 | 80 | move_packed(Packed { x: 0, y: 1 }); |
69 | 81 | move_index([0; _], 1); |
| 82 | + ret_is_arg([0; 5]); |
70 | 83 | } |
0 commit comments