rust/tests/mir-opt/const_prop
bors 79611d90b6 Auto merge of #122551 - RayMuir:copy_fmt, r=saethlin
Added "copy" to Debug fmt for copy operands

In MIR's debug mode (--emit mir) the printing for Operands is slightly inconsistent.

The RValues - values on the right side of an Assign - are usually printed with their Operand when they are Places.

Example:
_2 = move _3

But for arguments, the operand is omitted.

_2 = _1

I propose a change be made, to display the place with the operand.

_2 = copy _1

Move and copy have different semantics, meaning this difference is important and helpful to the user. It also adds consistency to the pretty printing.

-- EDIT --

 Consider this example Rust program and its MIR output with the **updated pretty printer.**

This was generated with the arguments --emit mir --crate-type lib -Zmir-opt-level=0 (Otherwise, it's optimised away since it's a junk program).

```rust
fn main(foo: i32) {
    let v = 10;

    if v == 20 {
        foo;
    }
    else {
        v;
    }
}
```

```MIR
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn main(_1: i32) -> () {
    debug foo => _1;
    let mut _0: ();
    let _2: i32;
    let mut _3: bool;
    let mut _4: i32;
    let _5: i32;
    let _6: i32;
    scope 1 {
        debug v => _2;
    }

    bb0: {
        StorageLive(_2);
        _2 = const 10_i32;
        StorageLive(_3);
        StorageLive(_4);
        _4 = copy _2;
        _3 = Eq(move _4, const 20_i32);
        switchInt(move _3) -> [0: bb2, otherwise: bb1];
    }

    bb1: {
        StorageDead(_4);
        StorageLive(_5);
        _5 = copy _1;
        StorageDead(_5);
        _0 = const ();
        goto -> bb3;
    }

    bb2: {
        StorageDead(_4);
        StorageLive(_6);
        _6 = copy _2;
        StorageDead(_6);
        _0 = const ();
        goto -> bb3;
    }

    bb3: {
        StorageDead(_3);
        StorageDead(_2);
        return;
    }
}
```

In this example program, we can see that when we move a place, it is preceded by "move". e.g. ``` _3 = Eq(move _4, const 20_i32);```. However, when we copy a place such as ```_5 = _1;```, it is not preceded by the operand in the original printout. I propose to change the print to include the copy ```_5 = copy _1``` as in this example.

Regarding the arguments part. When I originally submitted this PR, I was under the impression this only affected the print for arguments to a function, but actually, it affects anything that uses a copy. This is preferable anyway with regard to consistency. The PR is about making ```copy``` explicit.
2024-08-19 23:10:46 +00:00
..
address_of_pair.fn0.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
address_of_pair.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
aggregate.foo.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
aggregate.foo.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
aggregate.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
aggregate.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
aggregate.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
array_index.main.GVN.32bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
array_index.main.GVN.32bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
array_index.main.GVN.64bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
array_index.main.GVN.64bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
array_index.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
bad_op_div_by_zero.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_div_by_zero.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_div_by_zero.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
bad_op_mod_by_zero.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_mod_by_zero.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_mod_by_zero.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
bad_op_unsafe_oob_for_slices.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
boolean_identities.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
boolean_identities.test.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
boxes.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
boxes.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
boxes.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
cast.main.GVN.diff Replace legacy ConstProp by GVN. 2023-12-24 20:08:57 +00:00
cast.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
checked_add.main.GVN.panic-abort.diff Bless mir-opt for excluded alloc bytes 2024-06-26 15:30:47 -07:00
checked_add.main.GVN.panic-unwind.diff Bless mir-opt for excluded alloc bytes 2024-06-26 15:30:47 -07:00
checked_add.rs Use `-Zdump-mir-exclude-alloc-bytes` in some mir-opt tests 2024-06-26 15:05:01 -07:00
control_flow_simplification.hello.GVN.panic-abort.diff MIR printing: print the path of uneval'd const; refer to promoteds in a consistent way 2024-03-10 14:59:41 +01:00
control_flow_simplification.hello.GVN.panic-unwind.diff MIR printing: print the path of uneval'd const; refer to promoteds in a consistent way 2024-03-10 14:59:41 +01:00
control_flow_simplification.hello.PreCodegen.before.panic-abort.mir Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
control_flow_simplification.hello.PreCodegen.before.panic-unwind.mir Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
control_flow_simplification.rs rustfmt `tests/mir-opt`. 2024-06-03 14:17:16 +10:00
discriminant.main.GVN.32bit.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
discriminant.main.GVN.64bit.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
discriminant.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
indirect.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
indirect.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
indirect.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
indirect_mutation.bar.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
indirect_mutation.foo.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
indirect_mutation.rs Auto merge of #122551 - RayMuir:copy_fmt, r=saethlin 2024-08-19 23:10:46 +00:00
inherit_overflow.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
inherit_overflow.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
inherit_overflow.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
invalid_constant.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
invalid_constant.main.RemoveZsts.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
invalid_constant.rs Split part of `adt_const_params` into `unsized_const_params` 2024-07-17 11:01:29 +01:00
issue_66971.main.GVN.panic-abort.diff Replace legacy ConstProp by GVN. 2023-12-24 20:08:57 +00:00
issue_66971.main.GVN.panic-unwind.diff Replace legacy ConstProp by GVN. 2023-12-24 20:08:57 +00:00
issue_66971.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
issue_67019.main.GVN.panic-abort.diff Do not re-simplify SSA locals. 2024-01-07 13:54:05 +00:00
issue_67019.main.GVN.panic-unwind.diff Do not re-simplify SSA locals. 2024-01-07 13:54:05 +00:00
issue_67019.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
large_array_index.main.GVN.32bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
large_array_index.main.GVN.32bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
large_array_index.main.GVN.64bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
large_array_index.main.GVN.64bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
large_array_index.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
mult_by_zero.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
mult_by_zero.test.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
mutable_variable_aggregate.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable_aggregate.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
mutable_variable_aggregate_mut_ref.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable_aggregate_mut_ref.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
mutable_variable_aggregate_partial_read.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable_aggregate_partial_read.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable_aggregate_partial_read.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
mutable_variable_no_prop.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable_no_prop.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
mutable_variable_unprop_assign.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable_unprop_assign.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
mutable_variable_unprop_assign.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
offset_of.concrete.GVN.panic-abort.diff Update mir-opt tests, add proper regression test 2024-04-28 21:10:09 +01:00
offset_of.concrete.GVN.panic-unwind.diff Update mir-opt tests, add proper regression test 2024-04-28 21:10:09 +01:00
offset_of.generic.GVN.panic-abort.diff Update mir-opt tests, add proper regression test 2024-04-28 21:10:09 +01:00
offset_of.generic.GVN.panic-unwind.diff Update mir-opt tests, add proper regression test 2024-04-28 21:10:09 +01:00
offset_of.rs Stabilize offset_of_nested 2024-07-29 17:50:12 +01:00
overwrite_with_const_with_params.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
overwrite_with_const_with_params.size_of.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
pointer_expose_provenance.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
pointer_expose_provenance.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
pointer_expose_provenance.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
read_immutable_static.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
read_immutable_static.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
ref_deref.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
ref_deref.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
ref_deref_project.main.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
ref_deref_project.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
reify_fn_ptr.main.GVN.diff rename `expose_addr` to `expose_provenance` 2024-04-03 16:00:38 +02:00
reify_fn_ptr.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
repeat.main.GVN.32bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
repeat.main.GVN.32bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
repeat.main.GVN.64bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
repeat.main.GVN.64bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
repeat.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
return_place.add.GVN.panic-abort.diff Bless mir-opt for excluded alloc bytes 2024-06-26 15:30:47 -07:00
return_place.add.GVN.panic-unwind.diff Bless mir-opt for excluded alloc bytes 2024-06-26 15:30:47 -07:00
return_place.add.PreCodegen.before.panic-abort.mir Bless mir-opt for excluded alloc bytes 2024-06-26 15:30:47 -07:00
return_place.add.PreCodegen.before.panic-unwind.mir Bless mir-opt for excluded alloc bytes 2024-06-26 15:30:47 -07:00
return_place.rs Use `-Zdump-mir-exclude-alloc-bytes` in some mir-opt tests 2024-06-26 15:05:01 -07:00
scalar_literal_propagation.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
scalar_literal_propagation.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
scalar_literal_propagation.rs rustfmt `tests/mir-opt`. 2024-06-03 14:17:16 +10:00
slice_len.main.GVN.32bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
slice_len.main.GVN.32bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
slice_len.main.GVN.64bit.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
slice_len.main.GVN.64bit.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
slice_len.rs Update mir-opt filechecks 2024-08-18 15:52:23 -07:00
switch_int.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
switch_int.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
switch_int.main.SimplifyConstCondition-after-const-prop.panic-abort.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
switch_int.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff Bless tests 2023-06-23 18:36:25 +01:00
switch_int.rs rustfmt `tests/mir-opt`. 2024-06-03 14:17:16 +10:00
transmute.from_char.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.from_char.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.invalid_bool.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.invalid_bool.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.invalid_char.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.invalid_char.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.less_as_i8.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.less_as_i8.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.rs rustfmt `tests/mir-opt`. 2024-06-03 14:17:16 +10:00
transmute.undef_union_as_integer.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.undef_union_as_integer.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.unreachable_box.GVN.32bit.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
transmute.unreachable_box.GVN.64bit.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
transmute.unreachable_direct.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.unreachable_direct.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.unreachable_mut.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.unreachable_mut.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.unreachable_ref.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.unreachable_ref.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.valid_char.GVN.32bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
transmute.valid_char.GVN.64bit.diff Remove MIR unsafe check 2024-04-03 08:50:12 +00:00
tuple_literal_propagation.main.GVN.panic-abort.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
tuple_literal_propagation.main.GVN.panic-unwind.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
tuple_literal_propagation.rs Use `-Zdump-mir-exclude-alloc-bytes` in some mir-opt tests 2024-06-26 15:05:01 -07:00
while_let_loops.change_loop_body.GVN.diff Bless *all* the mir-opt tests 2024-08-18 16:07:33 -07:00
while_let_loops.rs mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00