rust/tests/mir-opt
Matthias Krüger 3cf567e3c0
Rollup merge of #127136 - compiler-errors:coroutine-closure-env-shim, r=oli-obk
Fix `FnMut::call_mut`/`Fn::call` shim for async closures that capture references

I adjusted async closures to be able to implement `Fn` and `FnMut` *even if* they capture references, as long as those references did not need to borrow data from the closure captures themselves. See #125259.

However, when I did this, I didn't actually relax an assertion in the `build_construct_coroutine_by_move_shim` shim code, which builds the `Fn`/`FnMut`/`FnOnce` implementations for async closures. Therefore, if we actually tried to *call* `FnMut`/`Fn` on async closures, it would ICE.

This PR adjusts this assertion to ensure that we only capture immutable references in closures if they implement `Fn`/`FnMut`. It also adds a bunch of tests and makes more of the async-closure tests into `build-pass` since we often care about these tests actually generating the right closure shims and stuff. I think it might be excessive to *always* use build-pass here, but 🤷 it's not that big of a deal.

Fixes #127019
Fixes #127012

r? oli-obk
2024-07-02 17:47:46 +02:00
..
building Don't use fake wildcards when we can get the failure block directly 2024-06-22 19:05:48 +02:00
const_prop rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
copy-prop rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
coverage coverage: Replace the old span refiner with a single function 2024-06-12 22:59:24 +10:00
dataflow-const-prop Ban ArrayToPointer and MutToConstPointer from runtime MIR 2024-06-19 10:44:01 -07:00
dead-store-elimination Reformat mir! macro invocations to use braces. 2024-06-03 13:24:44 +10:00
dest-prop Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
inline Avoid MIR bloat in inlining 2024-07-01 05:17:13 -07:00
instsimplify Ban ArrayToPointer and MutToConstPointer from runtime MIR 2024-06-19 10:44:01 -07:00
issues rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
nll rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
pre-codegen Avoid MIR bloat in inlining 2024-07-01 05:17:13 -07:00
sroa rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
unnamed-fields rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
address_of.address_of_reborrow.SimplifyCfg-initial.after.mir
address_of.borrow_and_cast.SimplifyCfg-initial.after.mir
address_of.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
array_index_is_temporary.main.SimplifyCfg-pre-optimizations.after.panic-abort.mir
array_index_is_temporary.main.SimplifyCfg-pre-optimizations.after.panic-unwind.mir
array_index_is_temporary.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
asm_unwind_panic_abort.main.AbortUnwindingCalls.after.mir
asm_unwind_panic_abort.rs
async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.coroutine_by_move.0.panic-abort.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.coroutine_by_move.0.panic-unwind.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.coroutine_by_move.0.panic-abort.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.coroutine_by_move.0.panic-unwind.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_move.0.panic-abort.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_move.0.panic-unwind.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_ref.0.panic-abort.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_ref.0.panic-unwind.mir Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
async_closure_shims.rs Fix FnMut/Fn shim for coroutine-closures that capture references 2024-06-29 17:38:02 -04:00
basic_assignment.main.ElaborateDrops.diff
basic_assignment.main.SimplifyCfg-initial.after.mir
basic_assignment.rs
box_expr.main.ElaborateDrops.diff
box_expr.rs
byte_slice.main.SimplifyCfg-pre-optimizations.after.mir
byte_slice.rs
const_allocation2.main.GVN.after.32bit.mir
const_allocation2.main.GVN.after.64bit.mir
const_allocation2.rs
const_allocation3.main.GVN.after.32bit.mir
const_allocation3.main.GVN.after.64bit.mir
const_allocation3.rs
const_allocation.main.GVN.after.32bit.mir
const_allocation.main.GVN.after.64bit.mir
const_allocation.rs
const_debuginfo.main.SingleUseConsts.diff Delete ConstDebugInfo pass 2024-06-10 00:06:02 -07:00
const_debuginfo.rs Delete ConstDebugInfo pass 2024-06-10 00:06:02 -07:00
const_goto_const_eval_fail.f.JumpThreading.diff
const_goto_const_eval_fail.rs
const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-pre-optimizations.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-pre-optimizations.after.mir
const_promotion_extern_static.FOO.PromoteTemps.diff
const_promotion_extern_static.rs
coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir
coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir
coroutine_drop_cleanup.rs
coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-abort.mir
coroutine_storage_dead_unwind.main-{closure#0}.StateTransform.before.panic-unwind.mir
coroutine_storage_dead_unwind.rs
coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir
coroutine_tiny.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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
derefer_test_multiple.main.Derefer.diff
derefer_test_multiple.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
derefer_test.main.Derefer.diff
derefer_test.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
dont_inline_type_id.call.Inline.diff
dont_inline_type_id.rs
early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
early_otherwise_branch_3_element_tuple.opt2.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
early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff
early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff
early_otherwise_branch.opt4.EarlyOtherwiseBranch.diff
early_otherwise_branch.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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
enum_opt.trunc.EnumSizeOpt.32bit.diff
enum_opt.trunc.EnumSizeOpt.64bit.diff
enum_opt.unin.EnumSizeOpt.32bit.diff
enum_opt.unin.EnumSizeOpt.64bit.diff
fn_ptr_shim.core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir
fn_ptr_shim.rs
funky_arms.float_to_exponential_common.GVN.panic-abort.diff
funky_arms.float_to_exponential_common.GVN.panic-unwind.diff
funky_arms.rs
graphviz.main.built.after.dot
graphviz.rs
gvn_copy_moves.fn0.GVN.diff
gvn_copy_moves.rs
gvn_ptr_eq_with_constant.main.GVN.diff Only update Eq operands in GVN if you can update both sides 2024-06-28 19:05:01 -07:00
gvn_ptr_eq_with_constant.rs Only update Eq operands in GVN if you can update both sides 2024-06-28 19:05:01 -07:00
gvn_uninhabited.f.GVN.panic-abort.diff
gvn_uninhabited.f.GVN.panic-unwind.diff
gvn_uninhabited.rs
gvn.arithmetic_checked.GVN.panic-abort.diff
gvn.arithmetic_checked.GVN.panic-unwind.diff
gvn.arithmetic_float.GVN.panic-abort.diff
gvn.arithmetic_float.GVN.panic-unwind.diff
gvn.arithmetic.GVN.panic-abort.diff
gvn.arithmetic.GVN.panic-unwind.diff
gvn.array_len.GVN.panic-abort.diff More GVN for PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.array_len.GVN.panic-unwind.diff More GVN for PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.borrowed.GVN.panic-abort.diff
gvn.borrowed.GVN.panic-unwind.diff
gvn.cast_pointer_eq.GVN.panic-abort.diff GVN away PtrToPtr before comparisons 2024-06-22 20:27:08 -07:00
gvn.cast_pointer_eq.GVN.panic-unwind.diff GVN away PtrToPtr before comparisons 2024-06-22 20:27:08 -07:00
gvn.cast_pointer_then_transmute.GVN.panic-abort.diff GVN away PtrToPtr-then-Transmute when possible 2024-06-22 20:34:09 -07:00
gvn.cast_pointer_then_transmute.GVN.panic-unwind.diff GVN away PtrToPtr-then-Transmute when possible 2024-06-22 20:34:09 -07:00
gvn.cast.GVN.panic-abort.diff
gvn.cast.GVN.panic-unwind.diff
gvn.casts_before_aggregate_raw_ptr.GVN.panic-abort.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.casts_before_aggregate_raw_ptr.GVN.panic-unwind.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.comparison.GVN.panic-abort.diff
gvn.comparison.GVN.panic-unwind.diff
gvn.constant_index_overflow.GVN.panic-abort.diff
gvn.constant_index_overflow.GVN.panic-unwind.diff
gvn.dereferences.GVN.panic-abort.diff
gvn.dereferences.GVN.panic-unwind.diff
gvn.duplicate_slice.GVN.panic-abort.diff
gvn.duplicate_slice.GVN.panic-unwind.diff
gvn.fn_pointers.GVN.panic-abort.diff More GVN for PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.fn_pointers.GVN.panic-unwind.diff More GVN for PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.generic_cast_metadata.GVN.panic-abort.diff [GVN] Add tests for generic pointees with PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.generic_cast_metadata.GVN.panic-unwind.diff [GVN] Add tests for generic pointees with PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.indirect_static.GVN.panic-abort.diff
gvn.indirect_static.GVN.panic-unwind.diff
gvn.manual_slice_mut_len.GVN.panic-abort.diff More GVN for PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.manual_slice_mut_len.GVN.panic-unwind.diff More GVN for PtrMetadata 2024-06-20 22:16:59 -07:00
gvn.meta_of_ref_to_slice.GVN.panic-abort.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.meta_of_ref_to_slice.GVN.panic-unwind.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.multiple_branches.GVN.panic-abort.diff
gvn.multiple_branches.GVN.panic-unwind.diff
gvn.non_freeze.GVN.panic-abort.diff
gvn.non_freeze.GVN.panic-unwind.diff
gvn.references.GVN.panic-abort.diff
gvn.references.GVN.panic-unwind.diff
gvn.remove_casts_must_change_both_sides.GVN.panic-abort.diff Add a GVN test for 127089 that doesn't optimize to a constant 2024-06-30 11:30:54 -07:00
gvn.remove_casts_must_change_both_sides.GVN.panic-unwind.diff Add a GVN test for 127089 that doesn't optimize to a constant 2024-06-30 11:30:54 -07:00
gvn.repeat.GVN.panic-abort.diff
gvn.repeat.GVN.panic-unwind.diff
gvn.repeated_index.GVN.panic-abort.diff
gvn.repeated_index.GVN.panic-unwind.diff
gvn.rs Add a GVN test for 127089 that doesn't optimize to a constant 2024-06-30 11:30:54 -07:00
gvn.slice_const_length.GVN.panic-abort.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.slice_const_length.GVN.panic-unwind.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.slice_from_raw_parts_as_ptr.GVN.panic-abort.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.slice_from_raw_parts_as_ptr.GVN.panic-unwind.diff Enable GVN for AggregateKind::RawPtr & UnOp::PtrMetadata 2024-06-06 00:25:58 -07:00
gvn.slices.GVN.panic-abort.diff
gvn.slices.GVN.panic-unwind.diff
gvn.subexpression_elimination.GVN.panic-abort.diff
gvn.subexpression_elimination.GVN.panic-unwind.diff
gvn.unary.GVN.panic-abort.diff
gvn.unary.GVN.panic-unwind.diff
gvn.wide_ptr_integer.GVN.panic-abort.diff
gvn.wide_ptr_integer.GVN.panic-unwind.diff
gvn.wide_ptr_provenance.GVN.panic-abort.diff
gvn.wide_ptr_provenance.GVN.panic-unwind.diff
gvn.wide_ptr_same_provenance.GVN.panic-abort.diff
gvn.wide_ptr_same_provenance.GVN.panic-unwind.diff
gvn.wrap_unwrap.GVN.panic-abort.diff
gvn.wrap_unwrap.GVN.panic-unwind.diff
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_coroutine_body.rs
inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff
inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff
inline_generically_if_sized.call.Inline.diff
inline_generically_if_sized.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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10: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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
issue_41697.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
issue_41888.main.ElaborateDrops.panic-abort.diff
issue_41888.main.ElaborateDrops.panic-unwind.diff
issue_41888.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
issue_62289.rs
issue_62289.test.ElaborateDrops.before.panic-abort.mir
issue_62289.test.ElaborateDrops.before.panic-unwind.mir
issue_72181_1.f.built.after.mir
issue_72181_1.main.built.after.mir
issue_72181_1.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
issue_72181.bar.built.after.mir
issue_72181.foo.built.after.mir
issue_72181.main.built.after.mir
issue_72181.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
issue_76432.rs Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
issue_99325.main.built.after.32bit.mir Bless tests and handle tests/crashes 2024-06-05 22:25:42 +01:00
issue_99325.main.built.after.64bit.mir Bless tests and handle tests/crashes 2024-06-05 22:25:42 +01:00
issue_99325.rs
issue_101973.inner.GVN.panic-abort.diff
issue_101973.inner.GVN.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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
issue_120925_unsafefncast.rs
jump_threading.aggregate.JumpThreading.panic-abort.diff
jump_threading.aggregate.JumpThreading.panic-unwind.diff
jump_threading.assume.JumpThreading.panic-abort.diff
jump_threading.assume.JumpThreading.panic-unwind.diff
jump_threading.custom_discr.JumpThreading.panic-abort.diff
jump_threading.custom_discr.JumpThreading.panic-unwind.diff
jump_threading.dfa.JumpThreading.panic-abort.diff
jump_threading.dfa.JumpThreading.panic-unwind.diff
jump_threading.disappearing_bb.JumpThreading.panic-abort.diff
jump_threading.disappearing_bb.JumpThreading.panic-unwind.diff
jump_threading.duplicate_chain.JumpThreading.panic-abort.diff
jump_threading.duplicate_chain.JumpThreading.panic-unwind.diff
jump_threading.identity.JumpThreading.panic-abort.diff
jump_threading.identity.JumpThreading.panic-unwind.diff
jump_threading.multiple_match.JumpThreading.panic-abort.diff
jump_threading.multiple_match.JumpThreading.panic-unwind.diff
jump_threading.mutable_ref.JumpThreading.panic-abort.diff
jump_threading.mutable_ref.JumpThreading.panic-unwind.diff
jump_threading.mutate_discriminant.JumpThreading.panic-abort.diff
jump_threading.mutate_discriminant.JumpThreading.panic-unwind.diff
jump_threading.renumbered_bb.JumpThreading.panic-abort.diff
jump_threading.renumbered_bb.JumpThreading.panic-unwind.diff
jump_threading.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
jump_threading.too_complex.JumpThreading.panic-abort.diff
jump_threading.too_complex.JumpThreading.panic-unwind.diff
loop_test.main.SimplifyCfg-promote-consts.after.mir
loop_test.rs
lower_array_len.array_bound_mut.GVN.panic-abort.diff Add a pointee_metadata_ty_or_projection helper 2024-06-22 20:27:08 -07:00
lower_array_len.array_bound_mut.GVN.panic-unwind.diff Add a pointee_metadata_ty_or_projection helper 2024-06-22 20:27:08 -07:00
lower_array_len.array_bound.GVN.panic-abort.diff Add a pointee_metadata_ty_or_projection helper 2024-06-22 20:27:08 -07:00
lower_array_len.array_bound.GVN.panic-unwind.diff Add a pointee_metadata_ty_or_projection helper 2024-06-22 20:27:08 -07:00
lower_array_len.array_len_by_value.GVN.panic-abort.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.array_len_by_value.GVN.panic-unwind.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.array_len_raw.GVN.panic-abort.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.array_len_raw.GVN.panic-unwind.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.array_len_reborrow.GVN.panic-abort.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.array_len_reborrow.GVN.panic-unwind.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.array_len.GVN.panic-abort.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.array_len.GVN.panic-unwind.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_array_len.rs Add a pointee_metadata_ty_or_projection helper 2024-06-22 20:27:08 -07: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.get_metadata.LowerIntrinsics.panic-abort.diff
lower_intrinsics.get_metadata.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.make_pointers.LowerIntrinsics.panic-abort.diff
lower_intrinsics.make_pointers.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.non_const.LowerIntrinsics.panic-abort.diff
lower_intrinsics.non_const.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.three_way_compare_char.LowerIntrinsics.panic-abort.diff
lower_intrinsics.three_way_compare_char.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.three_way_compare_signed.LowerIntrinsics.panic-abort.diff
lower_intrinsics.three_way_compare_signed.LowerIntrinsics.panic-unwind.diff
lower_intrinsics.three_way_compare_unsigned.LowerIntrinsics.panic-abort.diff
lower_intrinsics.three_way_compare_unsigned.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 Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff Replace NormalizeArrayLen with GVN 2024-06-20 22:16:59 -07:00
lower_slice_len.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
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
matches_reduce_branches.bar.MatchBranchSimplification.diff
matches_reduce_branches.foo.MatchBranchSimplification.diff
matches_reduce_branches.match_i8_i16_failed.MatchBranchSimplification.diff
matches_reduce_branches.match_i8_i16.MatchBranchSimplification.diff
matches_reduce_branches.match_i16_i8.MatchBranchSimplification.diff
matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff
matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff
matches_reduce_branches.match_u8_i16_2.MatchBranchSimplification.diff
matches_reduce_branches.match_u8_i16_failed.MatchBranchSimplification.diff
matches_reduce_branches.match_u8_i16_fallback.MatchBranchSimplification.diff
matches_reduce_branches.match_u8_i16.MatchBranchSimplification.diff
matches_reduce_branches.match_u8_u16_2.MatchBranchSimplification.diff
matches_reduce_branches.match_u8_u16.MatchBranchSimplification.diff
matches_reduce_branches.rs Reformat mir! macro invocations to use braces. 2024-06-03 13:24:44 +10:00
matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff
matches_u8.exhaustive_match.MatchBranchSimplification.diff
matches_u8.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
multiple_return_terminators.rs
multiple_return_terminators.test.MultipleReturnTerminators.diff
no_drop_for_inactive_variant.rs
no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.after.panic-abort.mir
no_drop_for_inactive_variant.unwrap.SimplifyCfg-pre-optimizations.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
nrvo_miscompile_111005.rs Reformat mir! macro invocations to use braces. 2024-06-03 13:24:44 +10:00
nrvo_miscompile_111005.wrong.RenameReturnPlace.diff
nrvo_simple.nrvo.RenameReturnPlace.panic-abort.diff
nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff
nrvo_simple.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
or_pattern.rs Add tests 2024-06-16 18:23:48 +02:00
or_pattern.shortcut_second_or.SimplifyCfg-initial.after.mir Add tests 2024-06-16 18:23:48 +02:00
or_pattern.single_switchint.SimplifyCfg-initial.after.mir Expand or-candidates mixed with candidates above 2024-06-16 18:39:50 +02:00
packed_struct_drop_aligned.main.SimplifyCfg-pre-optimizations.after.panic-abort.mir
packed_struct_drop_aligned.main.SimplifyCfg-pre-optimizations.after.panic-unwind.mir
packed_struct_drop_aligned.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
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_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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
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_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
remove_zsts.get_union.PreCodegen.after.mir
remove_zsts.get_union.RemoveZsts.diff
remove_zsts.rs
retag.{impl#0}-foo_shr.SimplifyCfg-pre-optimizations.after.panic-abort.mir
retag.{impl#0}-foo_shr.SimplifyCfg-pre-optimizations.after.panic-unwind.mir
retag.{impl#0}-foo.SimplifyCfg-pre-optimizations.after.panic-abort.mir
retag.{impl#0}-foo.SimplifyCfg-pre-optimizations.after.panic-unwind.mir
retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-abort.mir Ban ArrayToPointer and MutToConstPointer from runtime MIR 2024-06-19 10:44:01 -07:00
retag.array_casts.SimplifyCfg-pre-optimizations.after.panic-unwind.mir Ban ArrayToPointer and MutToConstPointer from runtime MIR 2024-06-19 10:44:01 -07:00
retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.after.panic-abort.mir
retag.box_to_raw_mut.SimplifyCfg-pre-optimizations.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-pre-optimizations.after.panic-abort.mir
retag.main-{closure#0}.SimplifyCfg-pre-optimizations.after.panic-unwind.mir
retag.main.SimplifyCfg-pre-optimizations.after.panic-abort.mir
retag.main.SimplifyCfg-pre-optimizations.after.panic-unwind.mir
retag.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
return_an_array.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
separate_const_switch.identity.JumpThreading.diff
separate_const_switch.rs
separate_const_switch.too_complex.JumpThreading.diff
set_no_discriminant.f.JumpThreading.diff
set_no_discriminant.generic.JumpThreading.diff
set_no_discriminant.rs Reformat mir! macro invocations to use braces. 2024-06-03 13:24:44 +10:00
simplify_arm_identity.rs
simplify_arm.id_try.SimplifyArmIdentity.diff
simplify_arm.id_try.SimplifyBranchSame.diff
simplify_arm.rs
simplify_cfg.main.SimplifyCfg-initial.diff
simplify_cfg.main.SimplifyCfg-post-analysis.diff
simplify_cfg.rs
simplify_dead_blocks.assert_nonzero_nonmax.SimplifyCfg-after-unreachable-enum-branching.diff
simplify_dead_blocks.rs Reformat mir! macro invocations to use braces. 2024-06-03 13:24:44 +10:00
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_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff
simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff
simplify_locals_fixedpoint.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10: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
simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff
simplify_locals_removes_unused_discriminant_reads.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_provenance.SimplifyLocals-before-const-prop.diff
simplify_locals.r.SimplifyLocals-before-const-prop.diff
simplify_locals.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10: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.GVN.panic-abort.diff
simplify_match.main.GVN.panic-unwind.diff
simplify_match.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff
simplify_try_if_let.rs
single_use_consts.assign_const_to_return.SingleUseConsts.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.assign_const_to_return.SingleUseConsts.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.if_const_debug.SingleUseConsts.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.if_const_debug.SingleUseConsts.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.if_const.SingleUseConsts.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.if_const.SingleUseConsts.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.keep_parameter.SingleUseConsts.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.keep_parameter.SingleUseConsts.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.match_const.SingleUseConsts.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.match_const.SingleUseConsts.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.never_used_debug.SingleUseConsts.panic-abort.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.never_used_debug.SingleUseConsts.panic-unwind.diff Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
single_use_consts.rs Add SingleUseConsts mir-opt pass 2024-06-10 00:06:02 -07:00
slice_drop_shim.core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir
slice_drop_shim.rs
ssa_unreachable_116212.rs
storage_ranges.main.nll.0.mir
storage_ranges.rs
switch_to_self.rs Reformat mir! macro invocations to use braces. 2024-06-03 13:24:44 +10:00
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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
uninhabited_fallthrough_elimination.eliminate_fallthrough.UnreachableEnumBranching.diff
uninhabited_fallthrough_elimination.keep_fallthrough.UnreachableEnumBranching.diff
uninhabited_fallthrough_elimination.rs
unreachable_diverging.main.UnreachablePropagation.panic-abort.diff
unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff
unreachable_diverging.rs
unreachable_enum_branching.byref.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.byref.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.custom_discriminant.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.custom_discriminant.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.otherwise_t1.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.otherwise_t2.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.otherwise_t2.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.otherwise_t3.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.otherwise_t4_unreachable_default_2.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.otherwise_t4_unreachable_default.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.otherwise_t4.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.otherwise_t5_unreachable_default.UnreachableEnumBranching.panic-unwind.diff
unreachable_enum_branching.rs
unreachable_enum_branching.simple.UnreachableEnumBranching.panic-abort.diff
unreachable_enum_branching.simple.UnreachableEnumBranching.panic-unwind.diff
unreachable.as_match.UnreachablePropagation.panic-abort.diff
unreachable.as_match.UnreachablePropagation.panic-unwind.diff
unreachable.if_let.UnreachablePropagation.panic-abort.diff
unreachable.if_let.UnreachablePropagation.panic-unwind.diff
unreachable.rs rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10: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 rustfmt tests/mir-opt. 2024-06-03 14:17:16 +10:00
unusual_item_types.Test-X-{constructor#0}.built.after.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.

Testing a particular MIR pass

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

//@ test-mir-pass: 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. This also lets you test passes that are disabled by default.

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