rust/tests/mir-opt
Guillaume Gomez 208f6ed95c
Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obk
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const

Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`.

Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all.

However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish...

``@oli-obk`` any ideas?
2023-09-21 13:25:39 +02:00
..
building
const_prop
copy-prop
dataflow-const-prop
dead-store-elimination
deref-patterns
dest-prop
inline
issues
nll
pre-codegen rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
sroa
address_of.address_of_reborrow.SimplifyCfg-initial.after.mir
address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
address_of.rs
array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-abort.mir
array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
array_index_is_temporary.rs
asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir
asm_unwind_panic_abort.rs
basic_assignment.main.ElaborateDrops.diff
basic_assignment.main.SimplifyCfg-initial.after.mir
basic_assignment.rs
bool_compare.opt1.InstSimplify.diff
bool_compare.opt2.InstSimplify.diff
bool_compare.opt3.InstSimplify.diff
bool_compare.opt4.InstSimplify.diff
bool_compare.rs
box_expr.main.ElaborateDrops.before.panic-abort.mir
box_expr.main.ElaborateDrops.before.panic-unwind.mir
box_expr.rs
byte_slice.main.SimplifyCfg-elaborate-drops.after.mir
byte_slice.rs
casts.redundant.InstSimplify.diff
casts.redundant.PreCodegen.after.mir
casts.roundtrip.PreCodegen.after.mir
casts.rs
combine_array_len.norm2.InstSimplify.panic-abort.diff
combine_array_len.norm2.InstSimplify.panic-unwind.diff
combine_array_len.rs
combine_clone_of_primitives.rs
combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-abort.diff
combine_clone_of_primitives.{impl#0}-clone.InstSimplify.panic-unwind.diff
combine_transmutes.adt_transmutes.InstSimplify.diff
combine_transmutes.identity_transmutes.InstSimplify.diff
combine_transmutes.integer_transmutes.InstSimplify.diff
combine_transmutes.rs
const_allocation.main.ConstProp.after.32bit.mir
const_allocation.main.ConstProp.after.64bit.mir
const_allocation.rs
const_allocation2.main.ConstProp.after.32bit.mir
const_allocation2.main.ConstProp.after.64bit.mir
const_allocation2.rs
const_allocation3.main.ConstProp.after.32bit.mir
const_allocation3.main.ConstProp.after.64bit.mir
const_allocation3.rs
const_debuginfo.main.ConstDebugInfo.diff
const_debuginfo.rs
const_goto.issue_77355_opt.ConstGoto.diff
const_goto.rs
const_goto_const_eval_fail.f.ConstGoto.diff
const_goto_const_eval_fail.rs
const_goto_storage.match_nested_if.ConstGoto.diff
const_goto_storage.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
const_promotion_extern_static.FOO.PromoteTemps.diff
const_promotion_extern_static.rs
const_prop_miscompile.bar.ConstProp.diff
const_prop_miscompile.foo.ConstProp.diff
const_prop_miscompile.rs
deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff
deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff
deduplicate_blocks.rs
derefer_complex_case.main.Derefer.panic-abort.diff
derefer_complex_case.main.Derefer.panic-unwind.diff
derefer_complex_case.rs
derefer_inline_test.main.Derefer.panic-abort.diff
derefer_inline_test.main.Derefer.panic-unwind.diff
derefer_inline_test.rs
derefer_terminator_test.main.Derefer.panic-abort.diff
derefer_terminator_test.main.Derefer.panic-unwind.diff
derefer_terminator_test.rs
derefer_test.main.Derefer.diff
derefer_test.rs
derefer_test_multiple.main.Derefer.diff
derefer_test_multiple.rs
dont_inline_type_id.call.Inline.diff
dont_inline_type_id.rs
dont_yeet_assert.generic.InstSimplify.diff
dont_yeet_assert.rs
early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
early_otherwise_branch.rs
early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
early_otherwise_branch_3_element_tuple.rs
early_otherwise_branch_68867.rs
early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
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
enum_opt.cand.EnumSizeOpt.32bit.diff
enum_opt.cand.EnumSizeOpt.64bit.diff
enum_opt.invalid.EnumSizeOpt.32bit.diff
enum_opt.invalid.EnumSizeOpt.64bit.diff
enum_opt.rs
enum_opt.trunc.EnumSizeOpt.32bit.diff
enum_opt.trunc.EnumSizeOpt.64bit.diff
enum_opt.unin.EnumSizeOpt.32bit.diff
enum_opt.unin.EnumSizeOpt.64bit.diff
equal_true.opt.InstSimplify.diff
equal_true.rs
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.panic-abort.diff
funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff
funky_arms.rs
generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-abort.mir
generator_drop_cleanup.main-{closure#0}.generator_drop.0.panic-unwind.mir
generator_drop_cleanup.rs
generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir
generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir
generator_storage_dead_unwind.rs
generator_tiny.main-{closure#0}.generator_resume.0.mir
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
inline_generically_if_sized.call.Inline.diff
inline_generically_if_sized.rs
instrument_coverage.bar.InstrumentCoverage.diff
instrument_coverage.main.InstrumentCoverage.diff
instrument_coverage.rs
instsimplify_duplicate_switch_targets.assert_zero.InstSimplify.diff
instsimplify_duplicate_switch_targets.rs
intrinsic_asserts.generic.InstSimplify.diff
intrinsic_asserts.panics.InstSimplify.diff
intrinsic_asserts.removable.InstSimplify.diff
intrinsic_asserts.rs
issue_38669.main.SimplifyCfg-initial.after.mir
issue_38669.rs
issue_41110.main.ElaborateDrops.panic-abort.diff
issue_41110.main.ElaborateDrops.panic-unwind.diff
issue_41110.rs
issue_41110.test.ElaborateDrops.panic-abort.diff
issue_41110.test.ElaborateDrops.panic-unwind.diff
issue_41697.rs
issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir
issue_41888.main.ElaborateDrops.panic-abort.diff
issue_41888.main.ElaborateDrops.panic-unwind.diff
issue_41888.rs
issue_62289.rs
issue_62289.test.ElaborateDrops.before.panic-abort.mir
issue_62289.test.ElaborateDrops.before.panic-unwind.mir
issue_72181.bar.built.after.mir
issue_72181.foo.built.after.mir
issue_72181.main.built.after.mir
issue_72181.rs
issue_72181_1.f.built.after.mir
issue_72181_1.main.built.after.mir
issue_72181_1.rs
issue_76432.rs
issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff
issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff
issue_78192.f.InstSimplify.diff
issue_78192.rs
issue_91633.bar.built.after.mir
issue_91633.foo.built.after.mir
issue_91633.fun.built.after.mir
issue_91633.hey.built.after.mir
issue_91633.rs
issue_99325.main.built.after.32bit.mir
issue_99325.main.built.after.64bit.mir
issue_99325.rs
issue_101973.inner.ConstProp.panic-abort.diff
issue_101973.inner.ConstProp.panic-unwind.diff
issue_101973.rs
issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.panic-abort.mir
issue_104451_unwindable_intrinsics.main.AbortUnwindingCalls.after.panic-unwind.mir
issue_104451_unwindable_intrinsics.rs
loop_test.main.SimplifyCfg-promote-consts.after.mir
loop_test.rs
lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff
lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff
lower_array_len.array_len.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_len.NormalizeArrayLen.panic-unwind.diff
lower_array_len.array_len_by_value.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_len_by_value.NormalizeArrayLen.panic-unwind.diff
lower_array_len.array_len_raw.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_len_raw.NormalizeArrayLen.panic-unwind.diff
lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_len_reborrow.NormalizeArrayLen.panic-unwind.diff
lower_array_len.rs
lower_intrinsics.align_of.LowerIntrinsics.panic-abort.diff
lower_intrinsics.align_of.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.assume.LowerIntrinsics.panic-abort.diff
lower_intrinsics.assume.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.discriminant.LowerIntrinsics.panic-abort.diff
lower_intrinsics.discriminant.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-abort.diff
lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.forget.LowerIntrinsics.panic-abort.diff
lower_intrinsics.forget.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.non_const.LowerIntrinsics.panic-abort.diff
lower_intrinsics.non_const.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.option_payload.LowerIntrinsics.panic-abort.diff
lower_intrinsics.option_payload.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.ptr_offset.LowerIntrinsics.panic-abort.diff
lower_intrinsics.ptr_offset.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.panic-abort.diff
lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-abort.diff
lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.rs
lower_intrinsics.size_of.LowerIntrinsics.panic-abort.diff
lower_intrinsics.size_of.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.transmute_inhabited.LowerIntrinsics.panic-abort.diff
lower_intrinsics.transmute_inhabited.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.transmute_ref_dst.LowerIntrinsics.panic-abort.diff
lower_intrinsics.transmute_ref_dst.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-abort.diff
lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.panic-abort.diff
lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.panic-abort.diff
lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.transmute_uninhabited.LowerIntrinsics.panic-abort.diff
lower_intrinsics.transmute_uninhabited.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.unchecked.LowerIntrinsics.panic-abort.diff
lower_intrinsics.unchecked.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.unreachable.LowerIntrinsics.panic-abort.diff
lower_intrinsics.unreachable.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.with_overflow.LowerIntrinsics.panic-abort.diff
lower_intrinsics.with_overflow.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.wrapping.LowerIntrinsics.panic-abort.diff
lower_intrinsics.wrapping.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-abort.diff
lower_intrinsics.write_via_move_string.LowerIntrinsics.panic-unwind.diff
lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff
lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff
lower_slice_len.rs
match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff
match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff
match_arm_scopes.rs
match_test.main.SimplifyCfg-initial.after.mir
match_test.rs
matches_reduce_branches.bar.MatchBranchSimplification.diff
matches_reduce_branches.foo.MatchBranchSimplification.diff
matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff
matches_reduce_branches.rs
matches_u8.exhaustive_match.MatchBranchSimplification.diff
matches_u8.exhaustive_match_i8.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.panic-abort.mir
no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
no_spurious_drop_after_call.main.ElaborateDrops.before.panic-abort.mir
no_spurious_drop_after_call.main.ElaborateDrops.before.panic-unwind.mir
no_spurious_drop_after_call.rs
not_equal_false.opt.InstSimplify.diff
not_equal_false.rs
nrvo_miscompile_111005.rs
nrvo_miscompile_111005.wrong.RenameReturnPlace.diff
nrvo_simple.nrvo.RenameReturnPlace.panic-abort.diff
nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff
nrvo_simple.rs
packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.panic-abort.mir
packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
packed_struct_drop_aligned.rs
README.md
reference_prop.debuginfo.ReferencePropagation.diff
reference_prop.dominate_storage.ReferencePropagation.diff
reference_prop.maybe_dead.ReferencePropagation.diff
reference_prop.multiple_storage.ReferencePropagation.diff
reference_prop.mut_raw_then_mut_shr.ReferencePropagation.diff
reference_prop.read_through_raw.ReferencePropagation.diff
reference_prop.reference_propagation.ReferencePropagation.diff
reference_prop.reference_propagation_const_ptr.ReferencePropagation.diff
reference_prop.reference_propagation_mut.ReferencePropagation.diff
reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff
reference_prop.rs
reference_prop.unique_with_copies.ReferencePropagation.diff
remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-abort.diff
remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-unwind.diff
remove_fake_borrows.rs
remove_never_const.no_codegen.PreCodegen.after.mir
remove_never_const.rs
remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff
remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff
remove_storage_markers.rs
remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-abort.diff
remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.panic-unwind.diff
remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-abort.diff
remove_unneeded_drops.dont_opt.RemoveUnneededDrops.panic-unwind.diff
remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff
remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff
remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-abort.diff
remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff
remove_unneeded_drops.rs
remove_zsts.get_union.PreCodegen.after.mir
remove_zsts.get_union.RemoveZsts.diff
remove_zsts.rs
retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir
retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-abort.mir
retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.panic-unwind.mir
retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.panic-abort.mir
retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
retag.main.SimplifyCfg-elaborate-drops.after.panic-abort.mir
retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
retag.rs
retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-abort.mir
retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-abort.mir
retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-unwind.mir
return_an_array.rs
separate_const_switch.identity.SeparateConstSwitch.diff
separate_const_switch.rs
separate_const_switch.too_complex.SeparateConstSwitch.diff
simplify_arm.id_try.SimplifyArmIdentity.diff
simplify_arm.id_try.SimplifyBranchSame.diff
simplify_arm.rs
simplify_arm_identity.rs
simplify_cfg.main.SimplifyCfg-early-opt.diff
simplify_cfg.main.SimplifyCfg-initial.diff
simplify_cfg.rs
simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff
simplify_duplicate_unreachable_blocks.rs
simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff
simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff
simplify_if.rs
simplify_locals.c.SimplifyLocals-before-const-prop.diff
simplify_locals.d1.SimplifyLocals-before-const-prop.diff
simplify_locals.d2.SimplifyLocals-before-const-prop.diff
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_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff
simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff
simplify_locals_fixedpoint.rs
simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.panic-abort.diff
simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.panic-unwind.diff
simplify_locals_removes_unused_consts.rs
simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff
simplify_locals_removes_unused_discriminant_reads.rs
simplify_match.main.ConstProp.panic-abort.diff
simplify_match.main.ConstProp.panic-unwind.diff
simplify_match.rs
simplify_try_if_let.rs
simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff
slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir
slice_drop_shim.rs
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
storage_ranges.rs
switch_to_self.rs
switch_to_self.test.MatchBranchSimplification.diff
tls_access.main.PreCodegen.after.mir
tls_access.rs
uninhabited_enum.process_never.SimplifyLocals-final.after.mir
uninhabited_enum.process_void.SimplifyLocals-final.after.mir
uninhabited_enum.rs
uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
uninhabited_enum_branching.main.UninhabitedEnumBranching.diff
uninhabited_enum_branching.rs
uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff
uninhabited_enum_branching2.rs
uninhabited_fallthrough_elimination.eliminate_fallthrough.UninhabitedEnumBranching.diff
uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff
uninhabited_fallthrough_elimination.rs
unreachable.main.UnreachablePropagation.panic-abort.diff
unreachable.main.UnreachablePropagation.panic-unwind.diff
unreachable.rs
unreachable_diverging.main.UnreachablePropagation.panic-abort.diff
unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff
unreachable_diverging.rs
unusual_item_types.core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir
unusual_item_types.E-V-{constant#0}.built.after.mir
unusual_item_types.rs
unusual_item_types.Test-X-{constructor#0}.built.after.mir
unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir
while_storage.rs
while_storage.while_loop.PreCodegen.after.panic-abort.mir
while_storage.while_loop.PreCodegen.after.panic-unwind.mir

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