rust/tests/mir-opt
bors 59bb9505bc Auto merge of #103208 - cjgillot:match-fake-read, r=oli-obk,RalfJung
Allow partially moved values in match

This PR attempts to unify the behaviour between `let _ = PLACE`, `let _: TY = PLACE;` and `match PLACE { _ => {} }`.
The logical conclusion is that the `match` version should not check for uninitialised places nor check that borrows are still live.

The `match PLACE {}` case is handled by keeping a `FakeRead` in the unreachable fallback case to verify that `PLACE` has a legal value.

Schematically, `match PLACE { arms }` in surface rust becomes in MIR:
```rust
PlaceMention(PLACE)
match PLACE {
  // Decision tree for the explicit arms
  arms,
  // An extra fallback arm
  _ => {
    FakeRead(ForMatchedPlace, PLACE);
    unreachable
  }
}
```

`match *borrow { _ => {} }` continues to check that `*borrow` is live, but does not read the value.
`match *borrow {}` both checks that `*borrow` is live, and fake-reads the value.

Continuation of ~https://github.com/rust-lang/rust/pull/102256~ ~https://github.com/rust-lang/rust/pull/104844~

Fixes https://github.com/rust-lang/rust/issues/99180 https://github.com/rust-lang/rust/issues/53114
2023-10-27 18:51:43 +00:00
..
building Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
const_prop Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
copy-prop Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
dataflow-const-prop Auto merge of #103208 - cjgillot:match-fake-read, r=oli-obk,RalfJung 2023-10-27 18:51:43 +00:00
dead-store-elimination Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
deref-patterns Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
dest-prop Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
inline Require target features to match exactly during inlining 2023-10-24 22:49:15 +02:00
instsimplify Never consider raw pointer casts to be trival 2023-10-25 23:15:18 +02:00
issues Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
nll Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
pre-codegen Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
sroa Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
address_of.address_of_reborrow.SimplifyCfg-initial.after.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
address_of.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 FileCheck array_index_is_temporary.rs 2023-10-19 15:51:53 +00:00
asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir
asm_unwind_panic_abort.rs FileCheck asm_unwind_panic_abort.rs 2023-10-19 15:51:53 +00:00
basic_assignment.main.ElaborateDrops.diff
basic_assignment.main.SimplifyCfg-initial.after.mir FileCheck basic_assignment.rs. 2023-10-19 15:51:53 +00:00
basic_assignment.rs FileCheck basic_assignment.rs. 2023-10-19 15:51:53 +00:00
box_expr.main.ElaborateDrops.diff FileCheck box_expr.rs 2023-10-19 15:51:53 +00:00
box_expr.rs FileCheck box_expr.rs 2023-10-19 15:51:53 +00:00
byte_slice.main.SimplifyCfg-elaborate-drops.after.mir Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
byte_slice.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_allocation2.main.ConstProp.after.32bit.mir Stop trying to preserve pretty-printing. 2023-10-16 19:15:28 +00:00
const_allocation2.main.ConstProp.after.64bit.mir Stop trying to preserve pretty-printing. 2023-10-16 19:15:28 +00:00
const_allocation2.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_allocation3.main.ConstProp.after.32bit.mir Stop trying to preserve pretty-printing. 2023-10-16 19:15:28 +00:00
const_allocation3.main.ConstProp.after.64bit.mir Stop trying to preserve pretty-printing. 2023-10-16 19:15:28 +00:00
const_allocation3.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_allocation.main.ConstProp.after.32bit.mir Stop trying to preserve pretty-printing. 2023-10-16 19:15:28 +00:00
const_allocation.main.ConstProp.after.64bit.mir Stop trying to preserve pretty-printing. 2023-10-16 19:15:28 +00:00
const_allocation.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_debuginfo.main.ConstDebugInfo.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
const_debuginfo.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_goto_const_eval_fail.f.ConstGoto.diff
const_goto_const_eval_fail.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_goto_storage.match_nested_if.ConstGoto.diff
const_goto_storage.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_goto.issue_77355_opt.ConstGoto.diff
const_goto.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
const_promotion_extern_static.BAR.PromoteTemps.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
const_promotion_extern_static.BOP.built.after.mir
const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
const_promotion_extern_static.FOO.PromoteTemps.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
const_promotion_extern_static.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
const_prop_miscompile.bar.ConstProp.diff
const_prop_miscompile.foo.ConstProp.diff
const_prop_miscompile.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
coroutine_drop_cleanup.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
coroutine_storage_dead_unwind.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
coroutine_tiny.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
derefer_complex_case.main.Derefer.panic-abort.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
derefer_complex_case.main.Derefer.panic-unwind.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
derefer_complex_case.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
derefer_inline_test.main.Derefer.panic-abort.diff
derefer_inline_test.main.Derefer.panic-unwind.diff
derefer_inline_test.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
derefer_terminator_test.main.Derefer.panic-abort.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
derefer_terminator_test.main.Derefer.panic-unwind.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
derefer_terminator_test.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
derefer_test_multiple.main.Derefer.diff
derefer_test_multiple.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
derefer_test.main.Derefer.diff
derefer_test.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
dont_inline_type_id.call.Inline.diff Don't resolve generic instances if they may be shadowed by dyn 2023-09-19 05:42:23 +00:00
dont_inline_type_id.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
early_otherwise_branch_3_element_tuple.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
early_otherwise_branch_68867.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff
early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff
early_otherwise_branch_noopt.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
early_otherwise_branch_soundness.no_deref_ptr.EarlyOtherwiseBranch.diff
early_otherwise_branch_soundness.no_downcast.EarlyOtherwiseBranch.diff
early_otherwise_branch_soundness.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
early_otherwise_branch.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
enum_opt.cand.EnumSizeOpt.32bit.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
enum_opt.cand.EnumSizeOpt.64bit.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
enum_opt.invalid.EnumSizeOpt.32bit.diff
enum_opt.invalid.EnumSizeOpt.64bit.diff
enum_opt.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
enum_opt.trunc.EnumSizeOpt.32bit.diff
enum_opt.trunc.EnumSizeOpt.64bit.diff
enum_opt.unin.EnumSizeOpt.32bit.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
enum_opt.unin.EnumSizeOpt.64bit.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
exponential_or.match_tuple.SimplifyCfg-initial.after.mir Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
exponential_or.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir
fn_ptr_shim.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff Automatically enable cross-crate inlining for small functions 2023-10-17 19:53:51 -04:00
funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff Automatically enable cross-crate inlining for small functions 2023-10-17 19:53:51 -04:00
funky_arms.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
graphviz.main.built.after.dot
graphviz.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
gvn.arithmetic_checked.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.arithmetic_checked.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.arithmetic_float.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.arithmetic_float.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.arithmetic.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.arithmetic.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.cast.GVN.panic-abort.diff Embed simplification into VnState. 2023-09-24 09:09:04 +00:00
gvn.cast.GVN.panic-unwind.diff Embed simplification into VnState. 2023-09-24 09:09:04 +00:00
gvn.dereferences.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.dereferences.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.multiple_branches.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.multiple_branches.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.references.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.references.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.repeated_index.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.repeated_index.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
gvn.slices.GVN.panic-abort.diff Do not clone valtree and slice constants. 2023-09-24 09:09:05 +00:00
gvn.slices.GVN.panic-unwind.diff Do not clone valtree and slice constants. 2023-09-24 09:09:05 +00:00
gvn.subexpression_elimination.GVN.panic-abort.diff Embed simplification into VnState. 2023-09-24 09:09:04 +00:00
gvn.subexpression_elimination.GVN.panic-unwind.diff Embed simplification into VnState. 2023-09-24 09:09:04 +00:00
gvn.wrap_unwrap.GVN.panic-abort.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
gvn.wrap_unwrap.GVN.panic-unwind.diff Add global value numbering pass. 2023-09-24 09:09:04 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
inline_generically_if_sized.call.Inline.diff Don't resolve generic instances if they may be shadowed by dyn 2023-09-19 05:42:23 +00:00
inline_generically_if_sized.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
instrument_coverage.bar.InstrumentCoverage.diff Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
instrument_coverage.main.InstrumentCoverage.diff Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
instrument_coverage.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_38669.main.SimplifyCfg-initial.after.mir
issue_38669.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_41110.main.ElaborateDrops.panic-abort.diff
issue_41110.main.ElaborateDrops.panic-unwind.diff
issue_41110.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_41110.test.ElaborateDrops.panic-abort.diff
issue_41110.test.ElaborateDrops.panic-unwind.diff
issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_41697.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_41888.main.ElaborateDrops.panic-abort.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
issue_41888.main.ElaborateDrops.panic-unwind.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
issue_41888.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_62289.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_62289.test.ElaborateDrops.before.panic-abort.mir Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
issue_62289.test.ElaborateDrops.before.panic-unwind.mir Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
issue_72181_1.f.built.after.mir Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
issue_72181_1.main.built.after.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_72181_1.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_72181.bar.built.after.mir
issue_72181.foo.built.after.mir
issue_72181.main.built.after.mir
issue_72181.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_76432.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff Do not clone valtree and slice constants. 2023-09-24 09:09:05 +00:00
issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff Do not clone valtree and slice constants. 2023-09-24 09:09:05 +00:00
issue_78192.f.InstSimplify.diff
issue_78192.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_99325.main.built.after.32bit.mir Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
issue_99325.main.built.after.64bit.mir Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
issue_99325.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_101973.inner.ConstProp.panic-abort.diff Preserve DebugInfo in DeadStoreElimination. 2023-10-06 15:46:11 +00:00
issue_101973.inner.ConstProp.panic-unwind.diff Preserve DebugInfo in DeadStoreElimination. 2023-10-06 15:46:11 +00:00
issue_101973.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
jump_threading.custom_discr.JumpThreading.panic-abort.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.custom_discr.JumpThreading.panic-unwind.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.dfa.JumpThreading.panic-abort.diff Correct loop_headers logic. 2023-10-21 07:08:53 +00:00
jump_threading.dfa.JumpThreading.panic-unwind.diff Correct loop_headers logic. 2023-10-21 07:08:53 +00:00
jump_threading.disappearing_bb.JumpThreading.panic-abort.diff FileCheck annotations. 2023-10-21 07:08:53 +00:00
jump_threading.disappearing_bb.JumpThreading.panic-unwind.diff FileCheck annotations. 2023-10-21 07:08:53 +00:00
jump_threading.duplicate_chain.JumpThreading.panic-abort.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.duplicate_chain.JumpThreading.panic-unwind.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.identity.JumpThreading.panic-abort.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.identity.JumpThreading.panic-unwind.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.multiple_match.JumpThreading.panic-abort.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.multiple_match.JumpThreading.panic-unwind.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.mutable_ref.JumpThreading.panic-abort.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.mutable_ref.JumpThreading.panic-unwind.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.mutate_discriminant.JumpThreading.panic-abort.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.mutate_discriminant.JumpThreading.panic-unwind.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.renumbered_bb.JumpThreading.panic-abort.diff Handle more terminators. 2023-10-21 07:01:24 +00:00
jump_threading.renumbered_bb.JumpThreading.panic-unwind.diff Handle more terminators. 2023-10-21 07:01:24 +00:00
jump_threading.rs FileCheck annotations. 2023-10-21 07:08:53 +00:00
jump_threading.too_complex.JumpThreading.panic-abort.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
jump_threading.too_complex.JumpThreading.panic-unwind.diff Implement JumpThreading pass. 2023-10-21 06:58:38 +00:00
loop_test.main.SimplifyCfg-promote-consts.after.mir
loop_test.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff
lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_bound.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.array_len.NormalizeArrayLen.panic-abort.diff
lower_array_len.array_len.NormalizeArrayLen.panic-unwind.diff
lower_array_len.rs FileCheck lower_array_len. 2023-10-19 15:51:54 +00:00
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 FileCheck lower_intrinsics. 2023-10-19 15:51:54 +00:00
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 Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.panic-unwind.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.panic-abort.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.panic-unwind.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.panic-abort.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.panic-unwind.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
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 FileCheck lower_slice_len. 2023-10-19 15:51:54 +00:00
match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
match_arm_scopes.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
match_test.main.SimplifyCfg-initial.after.mir Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
match_test.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
matches_reduce_branches.bar.MatchBranchSimplification.diff
matches_reduce_branches.foo.MatchBranchSimplification.diff
matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff
matches_reduce_branches.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff
matches_u8.exhaustive_match.MatchBranchSimplification.diff
matches_u8.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
multiple_return_terminators.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
multiple_return_terminators.test.MultipleReturnTerminators.diff
no_drop_for_inactive_variant.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
nrvo_miscompile_111005.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
nrvo_miscompile_111005.wrong.RenameReturnPlace.diff
nrvo_simple.nrvo.RenameReturnPlace.panic-abort.diff
nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff
nrvo_simple.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
README.md Mention skip in README. 2023-10-19 15:51:54 +00:00
reference_prop.debuginfo.ReferencePropagation.diff Also consider call and yield as MIR SSA. 2023-10-08 16:05:26 +00:00
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_const_ptr.ReferencePropagation.diff
reference_prop.reference_propagation_mut_ptr.ReferencePropagation.diff
reference_prop.reference_propagation_mut.ReferencePropagation.diff
reference_prop.reference_propagation.ReferencePropagation.diff
reference_prop.rs Run filecheck on reference_prop.rs 2023-10-19 15:51:53 +00:00
reference_prop.unique_with_copies.ReferencePropagation.diff
remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-abort.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
remove_fake_borrows.match_guard.CleanupPostBorrowck.panic-unwind.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
remove_fake_borrows.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
remove_never_const.no_codegen.PreCodegen.after.mir
remove_never_const.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff
remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff
remove_storage_markers.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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_generic_copy.RemoveUnneededDrops.panic-abort.diff
remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.panic-unwind.diff
remove_unneeded_drops.opt.RemoveUnneededDrops.panic-abort.diff
remove_unneeded_drops.opt.RemoveUnneededDrops.panic-unwind.diff
remove_unneeded_drops.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
remove_zsts.get_union.PreCodegen.after.mir
remove_zsts.get_union.RemoveZsts.diff
remove_zsts.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-abort.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
retag.{impl#0}-foo_shr.SimplifyCfg-elaborate-drops.after.panic-unwind.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-abort.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.panic-unwind.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 adjust how closure/generator types and rvalues are printed 2023-09-21 22:20:58 +02:00
retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.panic-unwind.mir adjust how closure/generator types and rvalues are printed 2023-09-21 22:20:58 +02:00
retag.main.SimplifyCfg-elaborate-drops.after.panic-abort.mir have better explanation for relate_types 2023-10-02 23:39:45 +03:00
retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir have better explanation for relate_types 2023-10-02 23:39:45 +03:00
retag.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
return_an_array.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
separate_const_switch.identity.SeparateConstSwitch.diff Remove mir::LocalDecl::internal. 2023-10-04 17:55:15 +00:00
separate_const_switch.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
separate_const_switch.too_complex.SeparateConstSwitch.diff
simplify_arm_identity.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
simplify_arm.id_try.SimplifyArmIdentity.diff
simplify_arm.id_try.SimplifyBranchSame.diff
simplify_arm.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
simplify_cfg.main.SimplifyCfg-early-opt.diff
simplify_cfg.main.SimplifyCfg-initial.diff
simplify_cfg.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
simplify_duplicate_unreachable_blocks.assert_nonzero_nonmax.SimplifyCfg-after-uninhabited-enum-branching.diff
simplify_duplicate_unreachable_blocks.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff Do not clone valtree and slice constants. 2023-09-24 09:09:05 +00:00
simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff Do not clone valtree and slice constants. 2023-09-24 09:09:05 +00:00
simplify_if.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff
simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff
simplify_locals_fixedpoint.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff
simplify_locals_removes_unused_discriminant_reads.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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.panic-abort.diff
simplify_match.main.ConstProp.panic-unwind.diff
simplify_match.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff
simplify_try_if_let.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir
slice_drop_shim.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
spanview_block.main.built.after.html Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
spanview_block.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
spanview_statement.main.built.after.html Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
spanview_statement.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
spanview_terminator.main.built.after.html Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
spanview_terminator.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
ssa_unreachable_116212.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
storage_ranges.main.nll.0.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
storage_ranges.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
switch_to_self.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
switch_to_self.test.MatchBranchSimplification.diff
tls_access.main.PreCodegen.after.mir
tls_access.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff
uninhabited_enum_branching2.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir
uninhabited_enum_branching.main.UninhabitedEnumBranching.diff
uninhabited_enum_branching.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
uninhabited_enum.process_never.SimplifyLocals-final.after.mir
uninhabited_enum.process_void.SimplifyLocals-final.after.mir
uninhabited_enum.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
uninhabited_fallthrough_elimination.eliminate_fallthrough.UninhabitedEnumBranching.diff
uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff
uninhabited_fallthrough_elimination.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
unreachable_diverging.main.UnreachablePropagation.panic-abort.diff
unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff
unreachable_diverging.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
unreachable.main.UnreachablePropagation.panic-abort.diff
unreachable.main.UnreachablePropagation.panic-unwind.diff
unreachable.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
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 Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
unusual_item_types.Test-X-{constructor#0}.built.after.mir
while_storage.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
while_storage.while_loop.PreCodegen.after.panic-abort.mir Rebase fallout. 2023-10-21 07:08:48 +00:00
while_storage.while_loop.PreCodegen.after.panic-unwind.mir Rebase fallout. 2023-10-21 07:08:48 +00: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

FileCheck directives

The LLVM FileCheck tool is used to verify the contents of output MIR against CHECK directives present in the test file. This works on the runtime MIR, generated by --emit=mir, and not on the output of a individual passes.

Use // skip-filecheck to prevent FileCheck from running.

To check MIR for function foo, start with a // CHECK-LABEL fn foo( directive.

{{regex}} syntax allows to match regex.

[[name:regex]] syntax allows to bind name to a string matching regex, and refer to it as [[name]] in later directives, regex should be written not to match a leading space. Use [[my_local:_.*]] to name a local, and [[my_bb:bb.*]] to name a block.

Documentation for FileCheck is available here: https://www.llvm.org/docs/CommandGuide/FileCheck.html