rust/tests/mir-opt
bors e9e1bbc7a8 Auto merge of #111568 - scottmcm:undo-opt, r=WaffleLapkin
Stop turning transmutes into discriminant reads in mir-opt

Partially reverts #109612, as after #109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place.

Having this "simplification" meant that similar-looking code actually did somewhat different things.  For example,
```rust
pub unsafe fn demo1(x: std::cmp::Ordering) -> u8 {
    std::mem::transmute(x)
}
pub unsafe fn demo2(x: std::cmp::Ordering) -> i8 {
    std::mem::transmute(x)
}
```
in nightly today is generating <https://rust.godbolt.org/z/dPK58zW18>
```llvm
define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef %x) unnamed_addr #0 {
  %0 = icmp uge i8 %x, -1
  %1 = icmp ule i8 %x, 1
  %2 = or i1 %0, %1
  call void `@llvm.assume(i1` %2)
  ret i8 %x
}

define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef %0) unnamed_addr #0 {
  %x = alloca i8, align 1
  store i8 %0, ptr %x, align 1
  %1 = load i8, ptr %x, align 1, !range !2, !noundef !3
  ret i8 %1
}
```

Which feels too different when the original code is essentially identical.

---

Aside: that example is different *after* optimizations too:
```llvm
define noundef i8 `@_ZN7example5demo117h341ef313673d2ee6E(i8` noundef returned %x) unnamed_addr #0 {
  %0 = add i8 %x, 1
  %1 = icmp ult i8 %0, 3
  tail call void `@llvm.assume(i1` %1)
  ret i8 %x
}

define noundef i8 `@_ZN7example5demo217h5ad29f361a3f5700E(i8` noundef returned %0) unnamed_addr #1 {
  ret i8 %0
}
```
so turning the `Transmute` into a `Discriminant` was arguably just making things worse, so leaving it alone instead -- and thus having less code in rustc -- seems clearly better.
2023-05-17 18:53:26 +00:00
..
building Address FIXME 2023-05-15 12:05:17 +02:00
const_prop Rollup merge of #110694 - est31:builtin, r=petrochenkov 2023-05-09 12:33:45 +05:30
copy-prop Merge return place with other locals in CopyProp. 2023-05-14 12:06:34 +00:00
dataflow-const-prop Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
dead-store-elimination Make PlaceMention a non-mutating use. 2023-04-29 16:14:33 +00:00
deref-patterns Bless tests 2023-04-06 09:34:17 +01:00
dest-prop Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
inline Merge return place with other locals in CopyProp. 2023-05-14 12:06:34 +00:00
issues Turn on ConstDebugInfo pass. 2023-04-22 23:41:48 +02:00
nll bless 2023-05-16 17:16:06 +01:00
pre-codegen Merge return place with other locals in CopyProp. 2023-05-14 12:06:34 +00:00
sroa Update tests. 2023-04-24 16:16:14 +02:00
address_of.address_of_reborrow.SimplifyCfg-initial.after.mir Tweak debug outputs to make debugging new solver easier 2023-04-05 03:18:29 +00:00
address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
address_of.rs
array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
array_index_is_temporary.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir Bless tests 2023-04-06 09:34:17 +01:00
asm_unwind_panic_abort.rs
basic_assignment.main.ElaborateDrops.diff Bless tests 2023-04-06 09:34:17 +01:00
basic_assignment.main.SimplifyCfg-initial.after.mir Bless tests 2023-04-06 09:34:17 +01:00
basic_assignment.rs Add needs-unwind 2023-03-03 16:33:12 +01:00
bool_compare.opt1.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
bool_compare.opt2.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
bool_compare.opt3.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
bool_compare.opt4.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
bool_compare.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
box_expr.main.ElaborateDrops.before.mir Bless tests 2023-04-06 09:34:17 +01:00
box_expr.rs Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
byte_slice.main.SimplifyCfg-elaborate-drops.after.mir
byte_slice.rs
casts.redundant.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
casts.redundant.PreCodegen.after.mir Add an InstCombine for redundant casts 2023-02-19 23:14:58 -05:00
casts.roundtrip.PreCodegen.after.mir Add an InstCombine for redundant casts 2023-02-19 23:14:58 -05:00
casts.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
combine_array_len.norm2.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
combine_array_len.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
combine_clone_of_primitives.{impl#0}-clone.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
combine_clone_of_primitives.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
combine_transmutes.adt_transmutes.InstSimplify.diff Stop turning transmutes into discriminants in mir-opt 2023-05-14 11:46:07 -07:00
combine_transmutes.identity_transmutes.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
combine_transmutes.integer_transmutes.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
combine_transmutes.rs Stop turning transmutes into discriminants in mir-opt 2023-05-14 11:46:07 -07:00
const_allocation2.main.ConstProp.after.32bit.mir add passes to miroptfiles struct and passed to -zdump-mir args 2023-05-04 18:56:32 -04:00
const_allocation2.main.ConstProp.after.64bit.mir add passes to miroptfiles struct and passed to -zdump-mir args 2023-05-04 18:56:32 -04:00
const_allocation2.rs
const_allocation3.main.ConstProp.after.32bit.mir add passes to miroptfiles struct and passed to -zdump-mir args 2023-05-04 18:56:32 -04:00
const_allocation3.main.ConstProp.after.64bit.mir add passes to miroptfiles struct and passed to -zdump-mir args 2023-05-04 18:56:32 -04:00
const_allocation3.rs
const_allocation.main.ConstProp.after.32bit.mir add passes to miroptfiles struct and passed to -zdump-mir args 2023-05-04 18:56:32 -04:00
const_allocation.main.ConstProp.after.64bit.mir add passes to miroptfiles struct and passed to -zdump-mir args 2023-05-04 18:56:32 -04:00
const_allocation.rs
const_debuginfo.main.ConstDebugInfo.diff Simplify construction of replacement map. 2023-02-05 11:44:18 +00:00
const_debuginfo.rs
const_goto_const_eval_fail.f.ConstGoto.diff
const_goto_const_eval_fail.rs
const_goto_storage.match_nested_if.ConstGoto.diff Bless tests. 2023-02-02 23:26:26 +00:00
const_goto_storage.rs
const_goto.issue_77355_opt.ConstGoto.diff
const_goto.rs
const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir
const_promotion_extern_static.BAR.PromoteTemps.diff
const_promotion_extern_static.BOP.built.after.mir
const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir Run check_match and check_liveness when MIR is built instead of having an explicit phase for them 2023-04-21 22:32:38 +00:00
const_promotion_extern_static.FOO.PromoteTemps.diff Run check_match and check_liveness when MIR is built instead of having an explicit phase for them 2023-04-21 22:32:38 +00:00
const_promotion_extern_static.rs
const_prop_miscompile.bar.ConstProp.diff Reject borrows of projections in ConstProp. 2023-05-04 21:51:44 +00:00
const_prop_miscompile.foo.ConstProp.diff Reject borrows of projections in ConstProp. 2023-05-04 21:51:44 +00:00
const_prop_miscompile.rs Make tests unit. 2023-01-27 18:22:44 +00:00
coverage_graphviz.bar.InstrumentCoverage.0.dot
coverage_graphviz.main.InstrumentCoverage.0.dot
coverage_graphviz.rs
deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
deduplicate_blocks.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
derefer_complex_case.main.Derefer.diff
derefer_complex_case.rs
derefer_inline_test.main.Derefer.diff Bless tests 2023-04-06 09:34:17 +01:00
derefer_inline_test.rs Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
derefer_terminator_test.main.Derefer.diff
derefer_terminator_test.rs
derefer_test_multiple.main.Derefer.diff
derefer_test_multiple.rs
derefer_test.main.Derefer.diff
derefer_test.rs
dont_yeet_assert.generic.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
dont_yeet_assert.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch_3_element_tuple.rs
early_otherwise_branch_68867.rs
early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch_noopt.rs
early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff
early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff
early_otherwise_branch_soundness.rs
early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff Bless tests. 2023-02-02 23:26:26 +00:00
early_otherwise_branch.rs
enum_opt.cand.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.cand.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.invalid.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.invalid.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.rs Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.trunc.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.trunc.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.unin.EnumSizeOpt.32bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
enum_opt.unin.EnumSizeOpt.64bit.diff Add de-init to destination place 2023-02-08 02:04:07 +00:00
equal_true.opt.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
equal_true.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
exponential_or.match_tuple.SimplifyCfg-initial.after.mir
exponential_or.rs
fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir
fn_ptr_shim.rs
funky_arms.float_to_exponential_common.ConstProp.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
funky_arms.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir Bless mir-opt tests. 2023-01-27 22:01:47 +00:00
generator_drop_cleanup.rs
generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir Bless tests 2023-04-06 09:34:17 +01:00
generator_storage_dead_unwind.rs
generator_tiny.main-{closure#0}.generator_resume.0.mir Bless tests 2023-04-06 09:34:17 +01:00
generator_tiny.rs
graphviz.main.built.after.dot
graphviz.rs
if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff
if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff
if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff
if_condition_int.opt_char.SimplifyComparisonIntegral.diff
if_condition_int.opt_i8.SimplifyComparisonIntegral.diff
if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff
if_condition_int.opt_negative.SimplifyComparisonIntegral.diff
if_condition_int.opt_u32.SimplifyComparisonIntegral.diff
if_condition_int.rs
instrument_coverage.bar.InstrumentCoverage.diff
instrument_coverage.main.InstrumentCoverage.diff Bless tests 2023-04-06 09:34:17 +01:00
instrument_coverage.rs
instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
instsimplify_duplicate_switch_targets.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
intrinsic_asserts.generic.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
intrinsic_asserts.panics.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
intrinsic_asserts.removable.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
intrinsic_asserts.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
issue_38669.main.SimplifyCfg-initial.after.mir Bless tests 2023-04-06 09:34:17 +01:00
issue_38669.rs
issue_41110.main.ElaborateDrops.diff Bless tests 2023-04-06 09:34:17 +01:00
issue_41110.rs Emit diff instead of after mir in ElaborateDrops tests 2023-02-23 14:03:51 +01:00
issue_41110.test.ElaborateDrops.diff Bless tests 2023-04-06 09:34:17 +01:00
issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir
issue_41697.rs
issue_41888.main.ElaborateDrops.diff Make drop_flags an IndexVec. 2023-04-28 20:12:45 +00:00
issue_41888.rs Emit diff instead of after mir in ElaborateDrops tests 2023-02-23 14:03:51 +01:00
issue_62289.rs Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
issue_62289.test.ElaborateDrops.before.mir Bless tests 2023-04-06 09:34:17 +01:00
issue_72181_1.f.built.after.mir
issue_72181_1.main.built.after.mir Tweak debug outputs to make debugging new solver easier 2023-04-05 03:18:29 +00:00
issue_72181_1.rs
issue_72181.bar.built.after.mir
issue_72181.foo.built.after.mir
issue_72181.main.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
issue_72181.rs
issue_76432.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
issue_76432.test.SimplifyComparisonIntegral.diff Support ConstantIndex in debuginfo. 2023-05-13 10:12:15 +00:00
issue_78192.f.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
issue_78192.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
issue_91633.bar.built.after.mir Bless tests 2023-04-06 09:34:17 +01:00
issue_91633.foo.built.after.mir Bless tests 2023-04-06 09:34:17 +01:00
issue_91633.fun.built.after.mir
issue_91633.hey.built.after.mir Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
issue_91633.rs
issue_99325.main.built.after.mir bless 2023-05-16 17:16:06 +01:00
issue_99325.rs
issue_101973.inner.ConstProp.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
issue_101973.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.mir Add regression test 2023-04-13 12:35:12 +01:00
issue_104451_unwindable_intrinsics.rs Add regression test 2023-04-13 12:35:12 +01:00
loop_test.main.SimplifyCfg-promote-consts.after.mir Bless tests 2023-04-06 09:34:17 +01:00
loop_test.rs
lower_array_len.array_bound_mut.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_bound.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len_by_value.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len_raw.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len_reborrow.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.array_len.NormalizeArrayLen.diff Reimplement NormalizeArrayLen. 2023-01-29 21:19:02 +00:00
lower_array_len.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
lower_intrinsics.align_of.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.assume.LowerIntrinsics.diff Bless tests 2023-04-12 14:05:05 +01:00
lower_intrinsics.discriminant.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff Bless tests 2023-04-12 14:05:05 +01:00
lower_intrinsics.forget.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.non_const.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.option_payload.LowerIntrinsics.diff Codegen fewer instructions in mem::replace 2023-04-30 22:33:04 -07:00
lower_intrinsics.ptr_offset.LowerIntrinsics.diff Codegen fewer instructions in mem::replace 2023-04-30 22:33:04 -07:00
lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff Bless tests 2023-04-12 14:05:05 +01:00
lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff Bless tests 2023-04-12 14:05:05 +01:00
lower_intrinsics.rs Codegen fewer instructions in mem::replace 2023-04-30 22:33:04 -07:00
lower_intrinsics.size_of.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.unreachable.LowerIntrinsics.diff Bless tests 2023-04-06 09:34:17 +01:00
lower_intrinsics.with_overflow.LowerIntrinsics.diff Bless tests 2023-04-12 14:05:05 +01:00
lower_intrinsics.wrapping.LowerIntrinsics.diff Bless tests for portable-simd sync 2023-05-11 12:14:57 -07:00
lower_intrinsics.write_via_move_string.LowerIntrinsics.diff Codegen fewer instructions in mem::replace 2023-04-30 22:33:04 -07:00
lower_slice_len.bound.LowerSliceLenCalls.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
lower_slice_len.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff Bless tests 2023-04-06 09:34:17 +01:00
match_arm_scopes.rs
match_test.main.SimplifyCfg-initial.after.mir
match_test.rs
matches_reduce_branches.bar.MatchBranchSimplification.diff Bless tests. 2023-02-02 23:26:26 +00:00
matches_reduce_branches.foo.MatchBranchSimplification.diff Bless tests. 2023-02-02 23:26:26 +00:00
matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff Bless tests. 2023-02-02 23:26:26 +00:00
matches_reduce_branches.rs
matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff
matches_u8.exhaustive_match.MatchBranchSimplification.diff
matches_u8.rs
multiple_return_terminators.rs
multiple_return_terminators.test.MultipleReturnTerminators.diff
no_drop_for_inactive_variant.rs
no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir
no_spurious_drop_after_call.main.ElaborateDrops.before.mir Bless tests 2023-04-06 09:34:17 +01:00
no_spurious_drop_after_call.rs
not_equal_false.opt.InstSimplify.diff Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
not_equal_false.rs Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
nrvo_miscompile_111005.rs Disable nrvo mir opt 2023-05-08 03:55:41 -07:00
nrvo_miscompile_111005.wrong.RenameReturnPlace.diff Disable nrvo mir opt 2023-05-08 03:55:41 -07:00
nrvo_simple.nrvo.RenameReturnPlace.diff
nrvo_simple.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir Bless tests 2023-04-06 09:34:17 +01:00
packed_struct_drop_aligned.rs
README.md
reference_prop.debuginfo.ReferencePropagation.diff Add multiple borrow test. 2023-05-13 10:32:32 +00:00
reference_prop.dominate_storage.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.maybe_dead.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.multiple_storage.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.read_through_raw.ReferencePropagation.diff Iteratively replace pointers. 2023-05-10 19:22:54 +00:00
reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.reference_propagation_mut.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.reference_propagation.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
reference_prop.rs Add multiple borrow test. 2023-05-13 10:32:32 +00:00
reference_prop.unique_with_copies.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
remove_fake_borrows.match_guard.CleanupPostBorrowck.diff
remove_fake_borrows.rs
remove_never_const.no_codegen.PreCodegen.after.mir
remove_never_const.rs
remove_storage_markers.main.RemoveStorageMarkers.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
remove_storage_markers.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff Generalize operation. 2023-03-13 18:22:55 +00:00
remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff Generalize operation. 2023-03-13 18:22:55 +00:00
remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff Generalize operation. 2023-03-13 18:22:55 +00:00
remove_unneeded_drops.opt.RemoveUnneededDrops.diff Generalize operation. 2023-03-13 18:22:55 +00:00
remove_unneeded_drops.rs
remove_zsts.get_union.PreCodegen.after.mir Replace ZST operands and debuginfo by constants. 2023-03-13 18:19:57 +00:00
remove_zsts.get_union.RemoveZsts.diff Generalize operation. 2023-03-13 18:22:55 +00:00
remove_zsts.rs
retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.mir
retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir
retag.array_casts.SimplifyCfg-elaborate-drops.after.mir Bless tests. 2023-02-02 23:26:26 +00:00
retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir
retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir
retag.main.SimplifyCfg-elaborate-drops.after.mir Bless tests 2023-04-06 09:34:17 +01:00
retag.rs
return_an_array.rs
separate_const_switch.identity.SeparateConstSwitch.diff Wrap the whole LocalInfo in ClearCrossCrate. 2023-03-14 20:52:42 +01:00
separate_const_switch.rs
separate_const_switch.too_complex.SeparateConstSwitch.diff Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
simplify_arm_identity.rs Add some reasons why tests are ignored. 2023-04-15 16:11:42 -07:00
simplify_arm.id_try.SimplifyArmIdentity.diff
simplify_arm.id_try.SimplifyBranchSame.diff
simplify_arm.rs Add some reasons why tests are ignored. 2023-04-15 16:11:42 -07:00
simplify_cfg.main.SimplifyCfg-early-opt.diff
simplify_cfg.main.SimplifyCfg-initial.diff Bless tests 2023-04-06 09:34:17 +01:00
simplify_cfg.rs
simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
simplify_duplicate_unreachable_blocks.rs Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
simplify_if.main.SimplifyConstCondition-after-const-prop.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
simplify_if.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff Enable CopyProp by default, tune the impl a bit 2023-02-12 13:23:53 -05:00
simplify_locals_fixedpoint.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
simplify_locals_removes_unused_consts.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
simplify_locals_removes_unused_discriminant_reads.rs
simplify_locals.c.SimplifyLocals-before-const-prop.diff
simplify_locals.d1.SimplifyLocals-before-const-prop.diff Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
simplify_locals.d2.SimplifyLocals-before-const-prop.diff Bless tests. 2023-02-02 23:26:26 +00:00
simplify_locals.expose_addr.SimplifyLocals-before-const-prop.diff
simplify_locals.r.SimplifyLocals-before-const-prop.diff
simplify_locals.rs
simplify_locals.t1.SimplifyLocals-before-const-prop.diff
simplify_locals.t2.SimplifyLocals-before-const-prop.diff
simplify_locals.t3.SimplifyLocals-before-const-prop.diff
simplify_locals.t4.SimplifyLocals-before-const-prop.diff
simplify_match.main.ConstProp.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
simplify_match.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff
simplify_try_if_let.rs
slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir Bless tests 2023-04-06 09:34:17 +01:00
slice_drop_shim.rs
slice_filter.rs Implement SSA-based reference propagation. 2023-05-09 17:59:34 +00:00
slice_filter.variant_a-{closure#0}.CopyProp.diff Do not consider borrowed Freeze locals as SSA. 2023-05-09 17:59:35 +00:00
slice_filter.variant_a-{closure#0}.DestinationPropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
slice_filter.variant_a-{closure#0}.ReferencePropagation.diff Iterate ReferencePropagation to fixpoint. 2023-05-13 10:17:28 +00:00
slice_filter.variant_b-{closure#0}.CopyProp.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
slice_filter.variant_b-{closure#0}.DestinationPropagation.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
slice_filter.variant_b-{closure#0}.ReferencePropagation.diff Implement SSA-based reference propagation. 2023-05-09 17:59:34 +00:00
spanview_block.main.built.after.html
spanview_block.rs
spanview_statement.main.built.after.html
spanview_statement.rs
spanview_terminator.main.built.after.html
spanview_terminator.rs
storage_ranges.main.nll.0.mir vars are ? 2023-04-25 19:53:09 +00:00
storage_ranges.rs
tls_access.main.PreCodegen.after.mir
tls_access.rs
uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
uninhabited_enum_branching2.rs
uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
uninhabited_enum_branching.main.UninhabitedEnumBranching.diff Remove duplicate unreachable blocks 2023-03-18 14:29:04 -04:00
uninhabited_enum_branching.rs
uninhabited_enum.process_never.SimplifyLocals-final.after.mir
uninhabited_enum.process_void.SimplifyLocals-final.after.mir Implement references VarDebugInfo. 2023-05-13 10:12:14 +00:00
uninhabited_enum.rs
uninhabited_fallthrough_elimination.eliminate_fallthrough.UninhabitedEnumBranching.diff
uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff
uninhabited_fallthrough_elimination.rs
unreachable_diverging.main.UnreachablePropagation.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
unreachable_diverging.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
unreachable.main.UnreachablePropagation.diff Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
unreachable.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir
unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir Bless tests 2023-04-06 09:34:17 +01:00
unusual_item_types.E-V-{constant#0}.built.after.mir
unusual_item_types.rs
unusual_item_types.Test-X-{constructor#0}.built.after.mir Stop deaggregating enums in MIR. 2023-02-02 23:20:27 +00:00
while_storage.rs Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00
while_storage.while_loop.PreCodegen.after.mir Ignore many tests on wasm32 2023-04-06 10:08:07 +01:00

This folder contains tests for MIR optimizations.

The mir-opt test format emits MIR to extra files that you can automatically update by specifying --bless on the command line (just like ui tests updating .stderr files).

--blessable test format

By default 32 bit and 64 bit targets use the same dump files, which can be problematic in the presence of pointers in constants or other bit width dependent things. In that case you can add

// EMIT_MIR_FOR_EACH_BIT_WIDTH

to your test, causing separate files to be generated for 32bit and 64bit systems.

Unit testing

If you are only testing the behavior of a particular mir-opt pass on some specific input (as is usually the case), you should add

// unit-test: PassName

to the top of the file. This makes sure that other passes don't run which means you'll get the input you expected and your test won't break when other code changes.

Emit a diff of the mir for a specific optimization

This is what you want most often when you want to see how an optimization changes the MIR.

// EMIT_MIR $file_name_of_some_mir_dump.diff

Emit mir after a specific optimization

Use this if you are just interested in the final state after an optimization.

// EMIT_MIR $file_name_of_some_mir_dump.after.mir

Emit mir before a specific optimization

This exists mainly for completeness and is rarely useful.

// EMIT_MIR $file_name_of_some_mir_dump.before.mir