From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- ...76803_regression.encode.SimplifyBranchSame.diff | 29 --- tests/mir-opt/76803_regression.rs | 19 -- ...sync_await.a-{closure#0}.generator_resume.0.mir | 4 +- ...sync_await.b-{closure#0}.generator_resume.0.mir | 28 ++- .../building/custom/arrays.arrays.built.after.mir | 14 ++ tests/mir-opt/building/custom/arrays.rs | 19 ++ tests/mir-opt/building/custom/enums.rs | 1 + .../custom/enums.set_discr.built.after.mir | 5 +- .../building/custom/operators.f.built.after.mir | 30 +++ tests/mir-opt/building/custom/operators.rs | 31 +++ tests/mir-opt/casts.redundant.InstCombine.diff | 25 ++ tests/mir-opt/casts.redundant.PreCodegen.after.mir | 14 ++ tests/mir-opt/casts.roundtrip.PreCodegen.after.mir | 15 ++ tests/mir-opt/casts.rs | 17 ++ ...e_of_primitives.{impl#0}-clone.InstCombine.diff | 5 +- ...const_allocation.main.ConstProp.after.32bit.mir | 16 +- ...const_allocation.main.ConstProp.after.64bit.mir | 16 +- .../const_debuginfo.main.ConstDebugInfo.diff | 34 +-- ...nst_goto_storage.match_nested_if.ConstGoto.diff | 2 +- .../const_prop/aggregate.foo.ConstProp.diff | 55 ++++ .../const_prop/aggregate.foo.PreCodegen.after.mir | 49 ++++ .../const_prop/aggregate.main.ConstProp.diff | 40 +-- .../const_prop/aggregate.main.PreCodegen.after.mir | 35 ++- tests/mir-opt/const_prop/aggregate.rs | 9 + .../bad_op_div_by_zero.main.ConstProp.diff | 3 +- .../bad_op_mod_by_zero.main.ConstProp.diff | 18 +- ...unsafe_oob_for_slices.main.ConstProp.32bit.diff | 11 +- ...unsafe_oob_for_slices.main.ConstProp.64bit.diff | 11 +- .../boolean_identities.test.ConstProp.diff | 12 +- .../discriminant.main.ConstProp.32bit.diff | 11 +- .../discriminant.main.ConstProp.64bit.diff | 11 +- .../inherit_overflow.main.ConstProp.diff | 39 +++ tests/mir-opt/const_prop/inherit_overflow.rs | 9 + .../invalid_constant.main.ConstProp.diff | 6 +- .../const_prop/issue_66971.main.ConstProp.diff | 7 +- .../const_prop/issue_67019.main.ConstProp.diff | 9 +- .../const_prop/mult_by_zero.test.ConstProp.diff | 5 +- .../mutable_variable_aggregate.main.ConstProp.diff | 25 +- ..._variable_aggregate_mut_ref.main.ConstProp.diff | 14 +- ...able_variable_unprop_assign.main.ConstProp.diff | 10 +- ...timizes_into_variable.main.ConstProp.32bit.diff | 9 +- ...timizes_into_variable.main.ConstProp.64bit.diff | 9 +- ...s_into_variable.main.PreCodegen.after.32bit.mir | 4 +- ...s_into_variable.main.PreCodegen.after.64bit.mir | 4 +- ...e.main.ScalarReplacementOfAggregates.32bit.diff | 9 +- ...e.main.ScalarReplacementOfAggregates.64bit.diff | 9 +- ...iable.main.SimplifyLocals-final.after.32bit.mir | 4 +- ...iable.main.SimplifyLocals-final.after.64bit.mir | 4 +- .../const_prop/ref_deref.main.ConstProp.diff | 9 +- .../const_prop/ref_deref.main.PromoteTemps.diff | 30 --- tests/mir-opt/const_prop/ref_deref.rs | 3 +- .../ref_deref_project.main.ConstProp.diff | 4 +- .../ref_deref_project.main.PromoteTemps.diff | 30 --- tests/mir-opt/const_prop/ref_deref_project.rs | 3 +- .../scalar_literal_propagation.main.ConstProp.diff | 8 +- .../const_prop/slice_len.main.ConstProp.32bit.diff | 6 +- .../const_prop/slice_len.main.ConstProp.64bit.diff | 6 +- tests/mir-opt/const_prop/slice_len.rs | 3 +- .../tuple_literal_propagation.main.ConstProp.diff | 13 +- .../const_prop_miscompile.bar.ConstProp.diff | 37 +-- .../const_prop_miscompile.foo.ConstProp.diff | 5 +- tests/mir-opt/const_prop_miscompile.rs | 1 + .../copy-prop/borrowed_local.f.CopyProp.diff | 34 +++ tests/mir-opt/copy-prop/borrowed_local.rs | 39 +++ tests/mir-opt/copy-prop/branch.foo.CopyProp.diff | 65 +++++ tests/mir-opt/copy-prop/branch.rs | 27 ++ .../copy_propagation_arg.arg_src.CopyProp.diff | 21 ++ .../copy_propagation_arg.bar.CopyProp.diff | 28 +++ .../copy_propagation_arg.baz.CopyProp.diff | 18 ++ .../copy_propagation_arg.foo.CopyProp.diff | 28 +++ tests/mir-opt/copy-prop/copy_propagation_arg.rs | 40 +++ .../copy-prop/custom_move_arg.f.CopyProp.diff | 31 +++ tests/mir-opt/copy-prop/custom_move_arg.rs | 32 +++ tests/mir-opt/copy-prop/cycle.main.CopyProp.diff | 60 +++++ tests/mir-opt/copy-prop/cycle.rs | 15 ++ .../dead_stores_79191.f.CopyProp.after.mir | 29 +++ tests/mir-opt/copy-prop/dead_stores_79191.rs | 17 ++ .../dead_stores_better.f.CopyProp.after.mir | 29 +++ tests/mir-opt/copy-prop/dead_stores_better.rs | 21 ++ .../copy-prop/issue_107511.main.CopyProp.diff | 138 ++++++++++ tests/mir-opt/copy-prop/issue_107511.rs | 13 + tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff | 40 +++ tests/mir-opt/copy-prop/move_arg.rs | 15 ++ .../copy-prop/move_projection.f.CopyProp.diff | 31 +++ tests/mir-opt/copy-prop/move_projection.rs | 34 +++ .../mutate_through_pointer.f.CopyProp.diff | 19 ++ tests/mir-opt/copy-prop/mutate_through_pointer.rs | 32 +++ .../mir-opt/copy-prop/non_dominate.f.CopyProp.diff | 29 +++ tests/mir-opt/copy-prop/non_dominate.rs | 26 ++ .../checked.main.DataflowConstProp.diff | 2 +- .../enum.main.DataflowConstProp.diff | 61 ----- .../enum.multiple.DataflowConstProp.diff | 82 ++++++ ...enum.mutate_discriminant.DataflowConstProp.diff | 26 ++ tests/mir-opt/dataflow-const-prop/enum.rs | 61 ++++- .../enum.simple.DataflowConstProp.diff | 63 +++++ .../inherit_overflow.main.DataflowConstProp.diff | 34 +-- .../dataflow-const-prop/inherit_overflow.rs | 7 +- .../repr_transparent.main.DataflowConstProp.diff | 8 +- .../sibling_ptr.main.DataflowConstProp.diff | 6 +- tests/mir-opt/dataflow-const-prop/sibling_ptr.rs | 9 +- .../struct.main.DataflowConstProp.diff | 3 +- .../tuple.main.DataflowConstProp.diff | 8 +- .../deaggregator_test.bar.Deaggregator.diff | 21 -- tests/mir-opt/deaggregator_test.rs | 17 -- .../deaggregator_test_enum.bar.Deaggregator.diff | 20 -- tests/mir-opt/deaggregator_test_enum.rs | 19 -- tests/mir-opt/deaggregator_test_enum_2.rs | 21 -- ...eaggregator_test_enum_2.test1.Deaggregator.diff | 45 ---- tests/mir-opt/deaggregator_test_multiple.rs | 17 -- ...aggregator_test_multiple.test.Deaggregator.diff | 35 --- ...iv_overflow.const_dividend.PreCodegen.after.mir | 2 +- ...div_overflow.const_divisor.PreCodegen.after.mir | 2 +- .../dont_yeet_assert.generic.InstCombine.diff | 23 ++ tests/mir-opt/dont_yeet_assert.rs | 11 + ...otherwise_branch.opt1.EarlyOtherwiseBranch.diff | 4 +- ...otherwise_branch.opt2.EarlyOtherwiseBranch.diff | 4 +- ...otherwise_branch.opt3.EarlyOtherwiseBranch.diff | 4 +- ..._3_element_tuple.opt1.EarlyOtherwiseBranch.diff | 5 +- ..._branch_68867.try_sum.EarlyOtherwiseBranch.diff | 30 +-- ...e_branch_noopt.noopt1.EarlyOtherwiseBranch.diff | 4 +- tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff | 68 +++++ tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff | 68 +++++ .../enum_opt.invalid.EnumSizeOpt.32bit.diff | 28 +++ .../enum_opt.invalid.EnumSizeOpt.64bit.diff | 28 +++ tests/mir-opt/enum_opt.rs | 86 +++++++ .../mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff | 37 +++ .../mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff | 37 +++ tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff | 68 +++++ tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff | 68 +++++ ...arms.float_to_exponential_common.ConstProp.diff | 43 +--- ...p_cleanup.main-{closure#0}.generator_drop.0.mir | 9 +- ...or_tiny.main-{closure#0}.generator_resume.0.mir | 13 +- tests/mir-opt/inline/cycle.f.Inline.diff | 2 +- .../mir-opt/inline/dyn_trait.get_query.Inline.diff | 4 +- .../inline/dyn_trait.try_execute_query.Inline.diff | 2 +- .../inline/inline_any_operand.bar.Inline.after.mir | 2 +- .../inline/inline_closure.foo.Inline.after.mir | 14 +- ...inline_closure_borrows_arg.foo.Inline.after.mir | 14 +- .../inline_closure_captures.foo.Inline.after.mir | 19 +- .../mir-opt/inline/inline_diverging.h.Inline.diff | 4 +- .../inline/inline_generator.main.Inline.diff | 78 +++--- .../inline/inline_into_box_place.main.Inline.diff | 4 +- .../inline_trait_method_2.test2.Inline.after.mir | 2 +- ...e_58867_inline_as_ref_as_mut.a.Inline.after.mir | 6 +- ...e_58867_inline_as_ref_as_mut.b.Inline.after.mir | 18 +- ...7_inline_scopes_parenting.main.Inline.after.mir | 14 +- tests/mir-opt/inline/issue_78442.bar.Inline.diff | 2 +- .../mir-opt/inline/issue_78442.bar.RevealAll.diff | 2 +- .../intrinsic_asserts.generic.InstCombine.diff | 42 ++++ .../intrinsic_asserts.panics.InstCombine.diff | 47 ++++ .../intrinsic_asserts.removable.InstCombine.diff | 45 ++++ tests/mir-opt/intrinsic_asserts.rs | 28 +++ tests/mir-opt/issue_101973.inner.ConstProp.diff | 22 +- .../issue_41110.main.ElaborateDrops.after.mir | 70 ------ tests/mir-opt/issue_41110.main.ElaborateDrops.diff | 75 ++++++ tests/mir-opt/issue_41110.rs | 4 +- .../issue_41110.test.ElaborateDrops.after.mir | 101 -------- tests/mir-opt/issue_41110.test.ElaborateDrops.diff | 109 ++++++++ .../issue_41888.main.ElaborateDrops.after.mir | 152 ----------- tests/mir-opt/issue_41888.main.ElaborateDrops.diff | 158 ++++++++++++ tests/mir-opt/issue_41888.rs | 2 +- .../issue_73223.main.SimplifyArmIdentity.diff | 156 ------------ tests/mir-opt/issue_73223.rs | 12 - tests/mir-opt/issue_76432.rs | 1 + ...ssue_76432.test.SimplifyComparisonIntegral.diff | 18 +- .../issue_59352.num_to_digit.PreCodegen.after.mir | 14 +- .../issue_75439.foo.MatchBranchSimplification.diff | 7 +- ...er_array_len.array_bound.NormalizeArrayLen.diff | 6 +- ...rray_len.array_bound_mut.NormalizeArrayLen.diff | 6 +- ...ower_array_len.array_len.NormalizeArrayLen.diff | 6 +- ...y_len.array_len_by_value.NormalizeArrayLen.diff | 6 +- ..._array_len.array_len_raw.NormalizeArrayLen.diff | 50 ++++ ...y_len.array_len_reborrow.NormalizeArrayLen.diff | 44 ++++ tests/mir-opt/lower_array_len.rs | 16 ++ ..._array_len_e2e.array_bound.PreCodegen.after.mir | 45 ---- ...ay_len_e2e.array_bound_mut.PreCodegen.after.mir | 58 ----- ...er_array_len_e2e.array_len.PreCodegen.after.mir | 11 - ...len_e2e.array_len_by_value.PreCodegen.after.mir | 11 - tests/mir-opt/lower_array_len_e2e.rs | 39 --- ...sics.f_copy_nonoverlapping.LowerIntrinsics.diff | 4 +- tests/mir-opt/lower_intrinsics.rs | 7 + ...r_intrinsics.with_overflow.LowerIntrinsics.diff | 83 ++++++ ...uce_branches.bar.MatchBranchSimplification.diff | 10 +- ...uce_branches.foo.MatchBranchSimplification.diff | 2 +- ....match_nested_if.MatchBranchSimplification.diff | 2 +- ...gned.main.SimplifyCfg-elaborate-drops.after.mir | 15 +- ..._storage_markers.main.RemoveStorageMarkers.diff | 4 +- .../remove_zsts.get_union.PreCodegen.after.mir | 5 +- .../mir-opt/remove_zsts.get_union.RemoveZsts.diff | 6 +- ...ray_casts.SimplifyCfg-elaborate-drops.after.mir | 10 +- ...etag.main.SimplifyCfg-elaborate-drops.after.mir | 15 +- ..._const_switch.identity.SeparateConstSwitch.diff | 116 ++++----- ...nst_switch.too_complex.SeparateConstSwitch.diff | 48 ++-- ...imple_option_map_e2e.ezmap.PreCodegen.after.mir | 21 +- ...locals.d1.SimplifyLocals-before-const-prop.diff | 3 +- ...locals.d2.SimplifyLocals-before-const-prop.diff | 10 +- ...locals_fixedpoint.foo.SimplifyLocals-final.diff | 17 +- ...nsts.main.SimplifyLocals-before-const-prop.diff | 30 +-- ...reads.map.SimplifyLocals-before-const-prop.diff | 7 +- tests/mir-opt/simplify_match.main.ConstProp.diff | 8 +- tests/mir-opt/slice_filter.rs | 18 ++ ...lice_filter.variant_a-{closure#0}.CopyProp.diff | 279 +++++++++++++++++++++ ...riant_a-{closure#0}.DestinationPropagation.diff | 237 +++++++++++++++++ ...lice_filter.variant_b-{closure#0}.CopyProp.diff | 139 ++++++++++ ...riant_b-{closure#0}.DestinationPropagation.diff | 109 ++++++++ ...roa.constant.ScalarReplacementOfAggregates.diff | 46 ++++ .../sroa.copies.ScalarReplacementOfAggregates.diff | 91 +++++++ ...roa.dropping.ScalarReplacementOfAggregates.diff | 14 +- .../sroa.enums.ScalarReplacementOfAggregates.diff | 4 +- ...roa.escaping.ScalarReplacementOfAggregates.diff | 47 ++-- .../sroa.flat.ScalarReplacementOfAggregates.diff | 21 +- ...a.ref_copies.ScalarReplacementOfAggregates.diff | 56 +++++ tests/mir-opt/sroa.rs | 48 +++- ...sroa.structs.ScalarReplacementOfAggregates.diff | 9 +- .../sroa.unions.ScalarReplacementOfAggregates.diff | 3 +- .../try_identity_e2e.new.PreCodegen.after.mir | 39 ++- .../try_identity_e2e.old.PreCodegen.after.mir | 10 +- ...yCfg-after-uninhabited-enum-branching.after.mir | 6 +- ...um_branching.main.UninhabitedEnumBranching.diff | 6 +- ...yCfg-after-uninhabited-enum-branching.after.mir | 7 +- ...m_branching2.main.UninhabitedEnumBranching.diff | 7 +- ...em_types.Test-X-{constructor#0}.built.after.mir | 4 +- ...while_let_loops.change_loop_body.ConstProp.diff | 3 +- .../while_storage.while_loop.PreCodegen.after.mir | 22 +- 224 files changed, 4319 insertions(+), 1918 deletions(-) delete mode 100644 tests/mir-opt/76803_regression.encode.SimplifyBranchSame.diff delete mode 100644 tests/mir-opt/76803_regression.rs create mode 100644 tests/mir-opt/building/custom/arrays.arrays.built.after.mir create mode 100644 tests/mir-opt/building/custom/arrays.rs create mode 100644 tests/mir-opt/building/custom/operators.f.built.after.mir create mode 100644 tests/mir-opt/building/custom/operators.rs create mode 100644 tests/mir-opt/casts.redundant.InstCombine.diff create mode 100644 tests/mir-opt/casts.redundant.PreCodegen.after.mir create mode 100644 tests/mir-opt/casts.roundtrip.PreCodegen.after.mir create mode 100644 tests/mir-opt/casts.rs create mode 100644 tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff create mode 100644 tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir create mode 100644 tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff create mode 100644 tests/mir-opt/const_prop/inherit_overflow.rs delete mode 100644 tests/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff delete mode 100644 tests/mir-opt/const_prop/ref_deref_project.main.PromoteTemps.diff create mode 100644 tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/borrowed_local.rs create mode 100644 tests/mir-opt/copy-prop/branch.foo.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/branch.rs create mode 100644 tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/copy_propagation_arg.rs create mode 100644 tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/custom_move_arg.rs create mode 100644 tests/mir-opt/copy-prop/cycle.main.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/cycle.rs create mode 100644 tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir create mode 100644 tests/mir-opt/copy-prop/dead_stores_79191.rs create mode 100644 tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir create mode 100644 tests/mir-opt/copy-prop/dead_stores_better.rs create mode 100644 tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/issue_107511.rs create mode 100644 tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/move_arg.rs create mode 100644 tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/move_projection.rs create mode 100644 tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/mutate_through_pointer.rs create mode 100644 tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff create mode 100644 tests/mir-opt/copy-prop/non_dominate.rs delete mode 100644 tests/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff create mode 100644 tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff create mode 100644 tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff create mode 100644 tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff delete mode 100644 tests/mir-opt/deaggregator_test.bar.Deaggregator.diff delete mode 100644 tests/mir-opt/deaggregator_test.rs delete mode 100644 tests/mir-opt/deaggregator_test_enum.bar.Deaggregator.diff delete mode 100644 tests/mir-opt/deaggregator_test_enum.rs delete mode 100644 tests/mir-opt/deaggregator_test_enum_2.rs delete mode 100644 tests/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff delete mode 100644 tests/mir-opt/deaggregator_test_multiple.rs delete mode 100644 tests/mir-opt/deaggregator_test_multiple.test.Deaggregator.diff create mode 100644 tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff create mode 100644 tests/mir-opt/dont_yeet_assert.rs create mode 100644 tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff create mode 100644 tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff create mode 100644 tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff create mode 100644 tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff create mode 100644 tests/mir-opt/enum_opt.rs create mode 100644 tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff create mode 100644 tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff create mode 100644 tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff create mode 100644 tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff create mode 100644 tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff create mode 100644 tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff create mode 100644 tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff create mode 100644 tests/mir-opt/intrinsic_asserts.rs delete mode 100644 tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir create mode 100644 tests/mir-opt/issue_41110.main.ElaborateDrops.diff delete mode 100644 tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir create mode 100644 tests/mir-opt/issue_41110.test.ElaborateDrops.diff delete mode 100644 tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir create mode 100644 tests/mir-opt/issue_41888.main.ElaborateDrops.diff delete mode 100644 tests/mir-opt/issue_73223.main.SimplifyArmIdentity.diff delete mode 100644 tests/mir-opt/issue_73223.rs create mode 100644 tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.diff create mode 100644 tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.diff delete mode 100644 tests/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir delete mode 100644 tests/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir delete mode 100644 tests/mir-opt/lower_array_len_e2e.array_len.PreCodegen.after.mir delete mode 100644 tests/mir-opt/lower_array_len_e2e.array_len_by_value.PreCodegen.after.mir delete mode 100644 tests/mir-opt/lower_array_len_e2e.rs create mode 100644 tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff create mode 100644 tests/mir-opt/slice_filter.rs create mode 100644 tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff create mode 100644 tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff create mode 100644 tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff create mode 100644 tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff create mode 100644 tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff create mode 100644 tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff create mode 100644 tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff (limited to 'tests/mir-opt') diff --git a/tests/mir-opt/76803_regression.encode.SimplifyBranchSame.diff b/tests/mir-opt/76803_regression.encode.SimplifyBranchSame.diff deleted file mode 100644 index 9780332d8..000000000 --- a/tests/mir-opt/76803_regression.encode.SimplifyBranchSame.diff +++ /dev/null @@ -1,29 +0,0 @@ -- // MIR for `encode` before SimplifyBranchSame -+ // MIR for `encode` after SimplifyBranchSame - - fn encode(_1: Type) -> Type { - debug v => _1; // in scope 0 at $DIR/76803_regression.rs:+0:15: +0:16 - let mut _0: Type; // return place in scope 0 at $DIR/76803_regression.rs:+0:27: +0:31 - let mut _2: isize; // in scope 0 at $DIR/76803_regression.rs:+2:9: +2:16 - - bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/76803_regression.rs:+1:11: +1:12 - switchInt(move _2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/76803_regression.rs:+1:5: +1:12 - } - - bb1: { - _0 = move _1; // scope 0 at $DIR/76803_regression.rs:+3:14: +3:15 - goto -> bb3; // scope 0 at $DIR/76803_regression.rs:+3:14: +3:15 - } - - bb2: { - Deinit(_0); // scope 0 at $DIR/76803_regression.rs:+2:20: +2:27 - discriminant(_0) = 1; // scope 0 at $DIR/76803_regression.rs:+2:20: +2:27 - goto -> bb3; // scope 0 at $DIR/76803_regression.rs:+2:20: +2:27 - } - - bb3: { - return; // scope 0 at $DIR/76803_regression.rs:+5:2: +5:2 - } - } - diff --git a/tests/mir-opt/76803_regression.rs b/tests/mir-opt/76803_regression.rs deleted file mode 100644 index 05dc3c978..000000000 --- a/tests/mir-opt/76803_regression.rs +++ /dev/null @@ -1,19 +0,0 @@ -// compile-flags: -Z mir-opt-level=1 -// EMIT_MIR 76803_regression.encode.SimplifyBranchSame.diff - -#[derive(Debug, Eq, PartialEq)] -pub enum Type { - A, - B, -} - -pub fn encode(v: Type) -> Type { - match v { - Type::A => Type::B, - _ => v, - } -} - -fn main() { - assert_eq!(Type::B, encode(Type::A)); -} diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir index 2a7f90fe9..accb504c0 100644 --- a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir @@ -24,9 +24,7 @@ fn a::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:11:14: 11:16]> bb1: { _4 = move _2; // scope 0 at $DIR/async_await.rs:+0:14: +0:16 _3 = const (); // scope 0 at $DIR/async_await.rs:+0:14: +0:16 - Deinit(_0); // scope 0 at $DIR/async_await.rs:+0:16: +0:16 - ((_0 as Ready).0: ()) = move _3; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 - discriminant(_0) = 0; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 + _0 = Poll::<()>::Ready(move _3); // scope 0 at $DIR/async_await.rs:+0:16: +0:16 discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:11:14: 11:16]))) = 1; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 return; // scope 0 at $DIR/async_await.rs:+0:16: +0:16 } diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index 05edc4797..ad4e5c6fc 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -1,8 +1,22 @@ // MIR for `b::{closure#0}` 0 generator_resume /* generator_layout = GeneratorLayout { field_tys: { - _0: impl std::future::Future, - _1: impl std::future::Future, + _0: GeneratorSavedTy { + ty: impl std::future::Future, + source_info: SourceInfo { + span: $DIR/async_await.rs:15:8: 15:14 (#9), + scope: scope[0], + }, + ignore_for_traits: false, + }, + _1: GeneratorSavedTy { + ty: impl std::future::Future, + source_info: SourceInfo { + span: $DIR/async_await.rs:16:8: 16:14 (#12), + scope: scope[0], + }, + ignore_for_traits: false, + }, }, variant_fields: { Unresumed(0): [], @@ -153,8 +167,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageLive(_19); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 StorageLive(_20); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 _20 = (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - Deinit(_0); // scope 1 at $DIR/async_await.rs:+1:8: +1:14 - discriminant(_0) = 1; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 + _0 = Poll::<()>::Pending; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 3; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 return; // scope 1 at $DIR/async_await.rs:+1:8: +1:14 } @@ -262,8 +275,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, StorageLive(_35); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 StorageLive(_36); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 _36 = (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - Deinit(_0); // scope 4 at $DIR/async_await.rs:+2:8: +2:14 - discriminant(_0) = 1; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 + _0 = Poll::<()>::Pending; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 4; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 return; // scope 4 at $DIR/async_await.rs:+2:8: +2:14 } @@ -303,9 +315,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, } bb26: { - Deinit(_0); // scope 0 at $DIR/async_await.rs:+3:2: +3:2 - ((_0 as Ready).0: ()) = move _37; // scope 0 at $DIR/async_await.rs:+3:2: +3:2 - discriminant(_0) = 0; // scope 0 at $DIR/async_await.rs:+3:2: +3:2 + _0 = Poll::<()>::Ready(move _37); // scope 0 at $DIR/async_await.rs:+3:2: +3:2 discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 1; // scope 0 at $DIR/async_await.rs:+3:2: +3:2 return; // scope 0 at $DIR/async_await.rs:+3:2: +3:2 } diff --git a/tests/mir-opt/building/custom/arrays.arrays.built.after.mir b/tests/mir-opt/building/custom/arrays.arrays.built.after.mir new file mode 100644 index 000000000..4c9212728 --- /dev/null +++ b/tests/mir-opt/building/custom/arrays.arrays.built.after.mir @@ -0,0 +1,14 @@ +// MIR for `arrays` after built + +fn arrays() -> usize { + let mut _0: usize; // return place in scope 0 at $DIR/arrays.rs:+0:32: +0:37 + let mut _1: [i32; C]; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _1 = [const 5_i32; C]; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _2 = Len(_1); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _0 = _2; // scope 0 at $DIR/arrays.rs:+4:9: +4:16 + return; // scope 0 at $DIR/arrays.rs:+5:9: +5:17 + } +} diff --git a/tests/mir-opt/building/custom/arrays.rs b/tests/mir-opt/building/custom/arrays.rs new file mode 100644 index 000000000..8e0a1fd7a --- /dev/null +++ b/tests/mir-opt/building/custom/arrays.rs @@ -0,0 +1,19 @@ +#![feature(custom_mir, core_intrinsics, inline_const)] + +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR arrays.arrays.built.after.mir +#[custom_mir(dialect = "built")] +fn arrays() -> usize { + mir!({ + let x = [5_i32; C]; + let c = Len(x); + RET = c; + Return() + }) +} + +fn main() { + assert_eq!(arrays::<20>(), 20); +} diff --git a/tests/mir-opt/building/custom/enums.rs b/tests/mir-opt/building/custom/enums.rs index e5cd45637..eca5b792e 100644 --- a/tests/mir-opt/building/custom/enums.rs +++ b/tests/mir-opt/building/custom/enums.rs @@ -86,6 +86,7 @@ fn switch_option_repr(option: Bool) -> bool { #[custom_mir(dialect = "runtime", phase = "initial")] fn set_discr(option: &mut Option<()>) { mir!({ + Deinit(*option); SetDiscriminant(*option, 0); Return() }) diff --git a/tests/mir-opt/building/custom/enums.set_discr.built.after.mir b/tests/mir-opt/building/custom/enums.set_discr.built.after.mir index 7de9ed098..6d0747365 100644 --- a/tests/mir-opt/building/custom/enums.set_discr.built.after.mir +++ b/tests/mir-opt/building/custom/enums.set_discr.built.after.mir @@ -4,7 +4,8 @@ fn set_discr(_1: &mut Option<()>) -> () { let mut _0: (); // return place in scope 0 at $DIR/enums.rs:+0:39: +0:39 bb0: { - discriminant((*_1)) = 0; // scope 0 at $DIR/enums.rs:+2:9: +2:36 - return; // scope 0 at $DIR/enums.rs:+3:9: +3:17 + Deinit((*_1)); // scope 0 at $DIR/enums.rs:+2:9: +2:24 + discriminant((*_1)) = 0; // scope 0 at $DIR/enums.rs:+3:9: +3:36 + return; // scope 0 at $DIR/enums.rs:+4:9: +4:17 } } diff --git a/tests/mir-opt/building/custom/operators.f.built.after.mir b/tests/mir-opt/building/custom/operators.f.built.after.mir new file mode 100644 index 000000000..cb43d5e6e --- /dev/null +++ b/tests/mir-opt/building/custom/operators.f.built.after.mir @@ -0,0 +1,30 @@ +// MIR for `f` after built + +fn f(_1: i32, _2: bool) -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/operators.rs:+0:30: +0:33 + let mut _3: (i32, bool); // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _1 = Neg(_1); // scope 0 at $DIR/operators.rs:+2:9: +2:15 + _2 = Not(_2); // scope 0 at $DIR/operators.rs:+3:9: +3:15 + _1 = Add(_1, _1); // scope 0 at $DIR/operators.rs:+4:9: +4:18 + _1 = Sub(_1, _1); // scope 0 at $DIR/operators.rs:+5:9: +5:18 + _1 = Mul(_1, _1); // scope 0 at $DIR/operators.rs:+6:9: +6:18 + _1 = Div(_1, _1); // scope 0 at $DIR/operators.rs:+7:9: +7:18 + _1 = Rem(_1, _1); // scope 0 at $DIR/operators.rs:+8:9: +8:18 + _1 = BitXor(_1, _1); // scope 0 at $DIR/operators.rs:+9:9: +9:18 + _1 = BitAnd(_1, _1); // scope 0 at $DIR/operators.rs:+10:9: +10:18 + _1 = Shl(_1, _1); // scope 0 at $DIR/operators.rs:+11:9: +11:19 + _1 = Shr(_1, _1); // scope 0 at $DIR/operators.rs:+12:9: +12:19 + _2 = Eq(_1, _1); // scope 0 at $DIR/operators.rs:+13:9: +13:19 + _2 = Lt(_1, _1); // scope 0 at $DIR/operators.rs:+14:9: +14:18 + _2 = Le(_1, _1); // scope 0 at $DIR/operators.rs:+15:9: +15:19 + _2 = Ge(_1, _1); // scope 0 at $DIR/operators.rs:+16:9: +16:19 + _2 = Gt(_1, _1); // scope 0 at $DIR/operators.rs:+17:9: +17:18 + _3 = CheckedAdd(_1, _1); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _2 = (_3.1: bool); // scope 0 at $DIR/operators.rs:+19:9: +19:18 + _1 = (_3.0: i32); // scope 0 at $DIR/operators.rs:+20:9: +20:18 + _0 = _1; // scope 0 at $DIR/operators.rs:+21:9: +21:16 + return; // scope 0 at $DIR/operators.rs:+22:9: +22:17 + } +} diff --git a/tests/mir-opt/building/custom/operators.rs b/tests/mir-opt/building/custom/operators.rs new file mode 100644 index 000000000..db7a48317 --- /dev/null +++ b/tests/mir-opt/building/custom/operators.rs @@ -0,0 +1,31 @@ +// compile-flags: --crate-type=lib +#![feature(custom_mir, core_intrinsics, inline_const)] +use std::intrinsics::mir::*; + +// EMIT_MIR operators.f.built.after.mir +#[custom_mir(dialect = "built")] +pub fn f(a: i32, b: bool) -> i32 { + mir!({ + a = -a; + b = !b; + a = a + a; + a = a - a; + a = a * a; + a = a / a; + a = a % a; + a = a ^ a; + a = a & a; + a = a << a; + a = a >> a; + b = a == a; + b = a < a; + b = a <= a; + b = a >= a; + b = a > a; + let res = Checked(a + a); + b = res.1; + a = res.0; + RET = a; + Return() + }) +} diff --git a/tests/mir-opt/casts.redundant.InstCombine.diff b/tests/mir-opt/casts.redundant.InstCombine.diff new file mode 100644 index 000000000..528a8e5a9 --- /dev/null +++ b/tests/mir-opt/casts.redundant.InstCombine.diff @@ -0,0 +1,25 @@ +- // MIR for `redundant` before InstCombine ++ // MIR for `redundant` after InstCombine + + fn redundant(_1: *const &u8) -> *const &u8 { + debug x => _1; // in scope 0 at $DIR/casts.rs:+0:30: +0:31 + let mut _0: *const &u8; // return place in scope 0 at $DIR/casts.rs:+0:51: +0:64 + let mut _2: *const &u8; // in scope 0 at $DIR/casts.rs:+1:5: +1:55 + let mut _3: *const &u8; // in scope 0 at $DIR/casts.rs:+1:36: +1:37 + scope 1 (inlined generic_cast::<&u8, &u8>) { // at $DIR/casts.rs:6:5: 6:38 + debug x => _3; // in scope 1 at $DIR/casts.rs:10:23: 10:24 + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/casts.rs:+1:5: +1:55 + StorageLive(_3); // scope 0 at $DIR/casts.rs:+1:36: +1:37 + _3 = _1; // scope 0 at $DIR/casts.rs:+1:36: +1:37 +- _2 = _3 as *const &u8 (PtrToPtr); // scope 1 at $DIR/casts.rs:11:5: 11:18 ++ _2 = _3; // scope 1 at $DIR/casts.rs:11:5: 11:18 + StorageDead(_3); // scope 0 at $DIR/casts.rs:+1:37: +1:38 + _0 = _2; // scope 0 at $DIR/casts.rs:+1:5: +1:55 + StorageDead(_2); // scope 0 at $DIR/casts.rs:+2:1: +2:2 + return; // scope 0 at $DIR/casts.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/casts.redundant.PreCodegen.after.mir b/tests/mir-opt/casts.redundant.PreCodegen.after.mir new file mode 100644 index 000000000..21a470ea3 --- /dev/null +++ b/tests/mir-opt/casts.redundant.PreCodegen.after.mir @@ -0,0 +1,14 @@ +// MIR for `redundant` after PreCodegen + +fn redundant(_1: *const &u8) -> *const &u8 { + debug x => _1; // in scope 0 at $DIR/casts.rs:+0:30: +0:31 + let mut _0: *const &u8; // return place in scope 0 at $DIR/casts.rs:+0:51: +0:64 + scope 1 (inlined generic_cast::<&u8, &u8>) { // at $DIR/casts.rs:6:5: 6:38 + debug x => _1; // in scope 1 at $DIR/casts.rs:10:23: 10:24 + } + + bb0: { + _0 = _1; // scope 0 at $DIR/casts.rs:+1:5: +1:55 + return; // scope 0 at $DIR/casts.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/casts.roundtrip.PreCodegen.after.mir b/tests/mir-opt/casts.roundtrip.PreCodegen.after.mir new file mode 100644 index 000000000..0c793984c --- /dev/null +++ b/tests/mir-opt/casts.roundtrip.PreCodegen.after.mir @@ -0,0 +1,15 @@ +// MIR for `roundtrip` after PreCodegen + +fn roundtrip(_1: *const u8) -> *const u8 { + debug x => _1; // in scope 0 at $DIR/casts.rs:+0:18: +0:19 + let mut _0: *const u8; // return place in scope 0 at $DIR/casts.rs:+0:35: +0:44 + let mut _2: *mut u8; // in scope 0 at $DIR/casts.rs:+1:5: +1:17 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/casts.rs:+1:5: +1:17 + _2 = _1 as *mut u8 (PtrToPtr); // scope 0 at $DIR/casts.rs:+1:5: +1:17 + _0 = move _2 as *const u8 (Pointer(MutToConstPointer)); // scope 0 at $DIR/casts.rs:+1:5: +1:17 + StorageDead(_2); // scope 0 at $DIR/casts.rs:+1:16: +1:17 + return; // scope 0 at $DIR/casts.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/casts.rs b/tests/mir-opt/casts.rs new file mode 100644 index 000000000..259c462da --- /dev/null +++ b/tests/mir-opt/casts.rs @@ -0,0 +1,17 @@ +#![crate_type = "lib"] + +// EMIT_MIR casts.redundant.InstCombine.diff +// EMIT_MIR casts.redundant.PreCodegen.after.mir +pub fn redundant<'a, 'b: 'a>(x: *const &'a u8) -> *const &'a u8 { + generic_cast::<&'a u8, &'b u8>(x) as *const &'a u8 +} + +#[inline] +fn generic_cast(x: *const T) -> *const U { + x as *const U +} + +// EMIT_MIR casts.roundtrip.PreCodegen.after.mir +pub fn roundtrip(x: *const u8) -> *const u8 { + x as *mut u8 as *const u8 +} diff --git a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff index 6f01553ee..20b0fb964 100644 --- a/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff +++ b/tests/mir-opt/combine_clone_of_primitives.{impl#0}-clone.InstCombine.diff @@ -61,10 +61,7 @@ bb3: { StorageDead(_9); // scope 0 at $DIR/combine_clone_of_primitives.rs:10:15: 10:16 - Deinit(_0); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15 - (_0.0: T) = move _2; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15 - (_0.1: u64) = move _5; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15 - (_0.2: [f32; 3]) = move _8; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15 + _0 = MyThing:: { v: move _2, i: move _5, a: move _8 }; // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:10: +0:15 StorageDead(_8); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15 StorageDead(_5); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15 StorageDead(_2); // scope 0 at $DIR/combine_clone_of_primitives.rs:+0:14: +0:15 diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir index 6140fc52f..9b69f79c2 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir @@ -26,17 +26,17 @@ alloc1 (static: FOO, size: 8, align: 4) { alloc18 (size: 48, align: 4) { 0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc5──╼ 00 00 00 00 │ ....░░░░╾──╼.... - 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc9──╼ 02 00 00 00 │ ....░░░░╾──╼.... - 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc14─╼ 03 00 00 00 │ ....*...╾──╼.... + 0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc8──╼ 02 00 00 00 │ ....░░░░╾──╼.... + 0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc13─╼ 03 00 00 00 │ ....*...╾──╼.... } alloc5 (size: 0, align: 4) {} -alloc9 (size: 16, align: 4) { - ╾─alloc8──╼ 03 00 00 00 ╾─alloc10─╼ 03 00 00 00 │ ╾──╼....╾──╼.... +alloc8 (size: 16, align: 4) { + ╾─alloc9──╼ 03 00 00 00 ╾─alloc10─╼ 03 00 00 00 │ ╾──╼....╾──╼.... } -alloc8 (size: 3, align: 1) { +alloc9 (size: 3, align: 1) { 66 6f 6f │ foo } @@ -44,12 +44,12 @@ alloc10 (size: 3, align: 1) { 62 61 72 │ bar } -alloc14 (size: 24, align: 4) { - 0x00 │ ╾─alloc13─╼ 03 00 00 00 ╾─alloc15─╼ 03 00 00 00 │ ╾──╼....╾──╼.... +alloc13 (size: 24, align: 4) { + 0x00 │ ╾─alloc14─╼ 03 00 00 00 ╾─alloc15─╼ 03 00 00 00 │ ╾──╼....╾──╼.... 0x10 │ ╾─alloc16─╼ 04 00 00 00 │ ╾──╼.... } -alloc13 (size: 3, align: 1) { +alloc14 (size: 3, align: 1) { 6d 65 68 │ meh } diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir index b2ed23c68..d0f196e72 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir @@ -27,19 +27,19 @@ alloc1 (static: FOO, size: 16, align: 8) { alloc18 (size: 72, align: 8) { 0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc5────────╼ │ ....░░░░╾──────╼ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░ - 0x20 │ ╾───────alloc9────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ - 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc14───────╼ │ ....*...╾──────╼ + 0x20 │ ╾───────alloc8────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........ + 0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc13───────╼ │ ....*...╾──────╼ 0x40 │ 03 00 00 00 00 00 00 00 │ ........ } alloc5 (size: 0, align: 8) {} -alloc9 (size: 32, align: 8) { - 0x00 │ ╾───────alloc8────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +alloc8 (size: 32, align: 8) { + 0x00 │ ╾───────alloc9────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ 0x10 │ ╾───────alloc10───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc8 (size: 3, align: 1) { +alloc9 (size: 3, align: 1) { 66 6f 6f │ foo } @@ -47,13 +47,13 @@ alloc10 (size: 3, align: 1) { 62 61 72 │ bar } -alloc14 (size: 48, align: 8) { - 0x00 │ ╾───────alloc13───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ +alloc13 (size: 48, align: 8) { + 0x00 │ ╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ 0x10 │ ╾───────alloc15───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........ 0x20 │ ╾───────alloc16───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } -alloc13 (size: 3, align: 1) { +alloc14 (size: 3, align: 1) { 6d 65 68 │ meh } diff --git a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff index dd548adde..f1f53a481 100644 --- a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff +++ b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff @@ -56,25 +56,13 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/const_debuginfo.rs:+1:9: +1:10 _1 = const 1_u8; // scope 0 at $DIR/const_debuginfo.rs:+1:13: +1:16 - StorageLive(_2); // scope 1 at $DIR/const_debuginfo.rs:+2:9: +2:10 _2 = const 2_u8; // scope 1 at $DIR/const_debuginfo.rs:+2:13: +2:16 - StorageLive(_3); // scope 2 at $DIR/const_debuginfo.rs:+3:9: +3:10 _3 = const 3_u8; // scope 2 at $DIR/const_debuginfo.rs:+3:13: +3:16 StorageLive(_4); // scope 3 at $DIR/const_debuginfo.rs:+4:9: +4:12 StorageLive(_5); // scope 3 at $DIR/const_debuginfo.rs:+4:15: +4:20 - StorageLive(_6); // scope 3 at $DIR/const_debuginfo.rs:+4:15: +4:16 - _6 = const 1_u8; // scope 3 at $DIR/const_debuginfo.rs:+4:15: +4:16 - StorageLive(_7); // scope 3 at $DIR/const_debuginfo.rs:+4:19: +4:20 - _7 = const 2_u8; // scope 3 at $DIR/const_debuginfo.rs:+4:19: +4:20 _5 = const 3_u8; // scope 3 at $DIR/const_debuginfo.rs:+4:15: +4:20 - StorageDead(_7); // scope 3 at $DIR/const_debuginfo.rs:+4:19: +4:20 - StorageDead(_6); // scope 3 at $DIR/const_debuginfo.rs:+4:19: +4:20 - StorageLive(_8); // scope 3 at $DIR/const_debuginfo.rs:+4:23: +4:24 - _8 = const 3_u8; // scope 3 at $DIR/const_debuginfo.rs:+4:23: +4:24 _4 = const 6_u8; // scope 3 at $DIR/const_debuginfo.rs:+4:15: +4:24 - StorageDead(_8); // scope 3 at $DIR/const_debuginfo.rs:+4:23: +4:24 StorageDead(_5); // scope 3 at $DIR/const_debuginfo.rs:+4:23: +4:24 StorageLive(_9); // scope 4 at $DIR/const_debuginfo.rs:+6:9: +6:10 _9 = const "hello, world!"; // scope 4 at $DIR/const_debuginfo.rs:+6:13: +6:28 @@ -84,42 +72,22 @@ StorageLive(_14); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 StorageLive(_15); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 StorageLive(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 - Deinit(_14); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - Deinit(_15); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - Deinit(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 _14 = const true; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 _15 = const false; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 _16 = const 123_u32; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 StorageLive(_10); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10 - Deinit(_10); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 - ((_10 as Some).0: u16) = const 99_u16; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 - discriminant(_10) = 1; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 - StorageLive(_17); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 - StorageLive(_18); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 - Deinit(_17); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 - Deinit(_18); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + _10 = Option::::Some(const 99_u16); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 _17 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 _18 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 StorageLive(_11); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10 - StorageLive(_12); // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 - _12 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 - StorageLive(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22 - _13 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:19: +13:22 _11 = const 64_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:22 - StorageDead(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22 - StorageDead(_12); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22 StorageDead(_11); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_17); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_18); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_10); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_14); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_15); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_16); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_9); // scope 4 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_4); // scope 3 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_3); // scope 2 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_2); // scope 1 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_1); // scope 0 at $DIR/const_debuginfo.rs:+14:1: +14:2 return; // scope 0 at $DIR/const_debuginfo.rs:+14:2: +14:2 } } diff --git a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff b/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff index f54577259..4dc98f856 100644 --- a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff +++ b/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff @@ -17,7 +17,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/const_goto_storage.rs:+1:9: +1:12 - StorageLive(_2); // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23 -- Deinit(_2); // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23 +- _2 = (); // scope 0 at $DIR/const_goto_storage.rs:+1:21: +1:23 - StorageLive(_3); // scope 0 at $DIR/const_goto_storage.rs:+2:15: +6:10 - StorageLive(_4); // scope 0 at $DIR/const_goto_storage.rs:+2:18: +2:76 - StorageLive(_5); // scope 0 at $DIR/const_goto_storage.rs:+2:21: +2:52 diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff b/tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff new file mode 100644 index 000000000..6ac460db8 --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.foo.ConstProp.diff @@ -0,0 +1,55 @@ +- // MIR for `foo` before ConstProp ++ // MIR for `foo` after ConstProp + + fn foo(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/aggregate.rs:+0:8: +0:9 + let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:15: +0:15 + let _2: i32; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:14 + let mut _3: i32; // in scope 0 at $DIR/aggregate.rs:+2:17: +2:25 + let mut _4: (i32, u8); // in scope 0 at $DIR/aggregate.rs:+2:17: +2:23 + let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:21: +2:22 + let mut _7: i32; // in scope 0 at $DIR/aggregate.rs:+3:18: +3:26 + let mut _8: (u8, i32); // in scope 0 at $DIR/aggregate.rs:+3:18: +3:24 + let mut _9: u8; // in scope 0 at $DIR/aggregate.rs:+3:19: +3:20 + scope 1 { + debug first => _2; // in scope 1 at $DIR/aggregate.rs:+2:9: +2:14 + let _6: i32; // in scope 1 at $DIR/aggregate.rs:+3:9: +3:15 + scope 2 { + debug second => _6; // in scope 2 at $DIR/aggregate.rs:+3:9: +3:15 + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+2:9: +2:14 + StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 + StorageLive(_4); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 + StorageLive(_5); // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 + _5 = _1; // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 + _4 = (const 0_i32, move _5); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 + StorageDead(_5); // scope 0 at $DIR/aggregate.rs:+2:22: +2:23 +- _3 = (_4.0: i32); // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 +- _2 = Add(move _3, const 1_i32); // scope 0 at $DIR/aggregate.rs:+2:17: +2:29 ++ _3 = const 0_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 ++ _2 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:29 + StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+2:28: +2:29 + StorageDead(_4); // scope 0 at $DIR/aggregate.rs:+2:29: +2:30 + StorageLive(_6); // scope 1 at $DIR/aggregate.rs:+3:9: +3:15 + StorageLive(_7); // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 + StorageLive(_8); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 + StorageLive(_9); // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 + _9 = _1; // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 + _8 = (move _9, const 1_i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 + StorageDead(_9); // scope 1 at $DIR/aggregate.rs:+3:23: +3:24 +- _7 = (_8.1: i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 +- _6 = Add(move _7, const 2_i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:30 ++ _7 = const 1_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 ++ _6 = const 3_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:30 + StorageDead(_7); // scope 1 at $DIR/aggregate.rs:+3:29: +3:30 + StorageDead(_8); // scope 1 at $DIR/aggregate.rs:+3:30: +3:31 + _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:15: +4:2 + StorageDead(_6); // scope 1 at $DIR/aggregate.rs:+4:1: +4:2 + StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+4:1: +4:2 + return; // scope 0 at $DIR/aggregate.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir new file mode 100644 index 000000000..2ef6d74e5 --- /dev/null +++ b/tests/mir-opt/const_prop/aggregate.foo.PreCodegen.after.mir @@ -0,0 +1,49 @@ +// MIR for `foo` after PreCodegen + +fn foo(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/aggregate.rs:+0:8: +0:9 + let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:15: +0:15 + let _2: i32; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:14 + let mut _3: i32; // in scope 0 at $DIR/aggregate.rs:+2:17: +2:25 + let mut _4: (i32, u8); // in scope 0 at $DIR/aggregate.rs:+2:17: +2:23 + let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:21: +2:22 + let mut _7: i32; // in scope 0 at $DIR/aggregate.rs:+3:18: +3:26 + let mut _8: (u8, i32); // in scope 0 at $DIR/aggregate.rs:+3:18: +3:24 + let mut _9: u8; // in scope 0 at $DIR/aggregate.rs:+3:19: +3:20 + scope 1 { + debug first => _2; // in scope 1 at $DIR/aggregate.rs:+2:9: +2:14 + let _6: i32; // in scope 1 at $DIR/aggregate.rs:+3:9: +3:15 + scope 2 { + debug second => _6; // in scope 2 at $DIR/aggregate.rs:+3:9: +3:15 + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+2:9: +2:14 + StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 + StorageLive(_4); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 + StorageLive(_5); // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 + _5 = _1; // scope 0 at $DIR/aggregate.rs:+2:21: +2:22 + _4 = (const 0_i32, move _5); // scope 0 at $DIR/aggregate.rs:+2:17: +2:23 + StorageDead(_5); // scope 0 at $DIR/aggregate.rs:+2:22: +2:23 + _3 = const 0_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:25 + _2 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+2:17: +2:29 + StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+2:28: +2:29 + StorageDead(_4); // scope 0 at $DIR/aggregate.rs:+2:29: +2:30 + StorageLive(_6); // scope 1 at $DIR/aggregate.rs:+3:9: +3:15 + StorageLive(_7); // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 + StorageLive(_8); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 + StorageLive(_9); // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 + _9 = _1; // scope 1 at $DIR/aggregate.rs:+3:19: +3:20 + _8 = (move _9, const 1_i32); // scope 1 at $DIR/aggregate.rs:+3:18: +3:24 + StorageDead(_9); // scope 1 at $DIR/aggregate.rs:+3:23: +3:24 + _7 = const 1_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:26 + _6 = const 3_i32; // scope 1 at $DIR/aggregate.rs:+3:18: +3:30 + StorageDead(_7); // scope 1 at $DIR/aggregate.rs:+3:29: +3:30 + StorageDead(_8); // scope 1 at $DIR/aggregate.rs:+3:30: +3:31 + _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:15: +4:2 + StorageDead(_6); // scope 1 at $DIR/aggregate.rs:+4:1: +4:2 + StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+4:1: +4:2 + return; // scope 0 at $DIR/aggregate.rs:+4:2: +4:2 + } +} diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff index 04378dbf3..f6e58955b 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/aggregate.main.ConstProp.diff @@ -3,9 +3,11 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/aggregate.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - let mut _3: (i32, i32, i32); // in scope 0 at $DIR/aggregate.rs:+1:13: +1:22 + let _1: u8; // in scope 0 at $DIR/aggregate.rs:+1:9: +1:10 + let mut _2: u8; // in scope 0 at $DIR/aggregate.rs:+1:13: +1:24 + let mut _3: (i32, u8, i32); // in scope 0 at $DIR/aggregate.rs:+1:13: +1:22 + let _4: (); // in scope 0 at $DIR/aggregate.rs:+2:5: +2:11 + let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:10 scope 1 { debug x => _1; // in scope 1 at $DIR/aggregate.rs:+1:9: +1:10 } @@ -14,19 +16,29 @@ StorageLive(_1); // scope 0 at $DIR/aggregate.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - Deinit(_3); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - (_3.0: i32) = const 0_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - (_3.1: i32) = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - (_3.2: i32) = const 2_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 -- _2 = (_3.1: i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 -- _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 -+ _2 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 -+ _1 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 + _3 = (const 0_i32, const 1_u8, const 2_i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 +- _2 = (_3.1: u8); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 +- _1 = Add(move _2, const 0_u8); // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 ++ _2 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 ++ _1 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+1:27: +1:28 StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+1:28: +1:29 - _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/aggregate.rs:+2:1: +2:2 - return; // scope 0 at $DIR/aggregate.rs:+2:2: +2:2 + StorageLive(_4); // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 + StorageLive(_5); // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 +- _5 = _1; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 ++ _5 = const 1_u8; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 + _4 = foo(move _5) -> bb1; // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 + // mir::Constant + // + span: $DIR/aggregate.rs:8:5: 8:8 + // + literal: Const { ty: fn(u8) {foo}, val: Value() } + } + + bb1: { + StorageDead(_5); // scope 1 at $DIR/aggregate.rs:+2:10: +2:11 + StorageDead(_4); // scope 1 at $DIR/aggregate.rs:+2:11: +2:12 + _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:11: +3:2 + StorageDead(_1); // scope 0 at $DIR/aggregate.rs:+3:1: +3:2 + return; // scope 0 at $DIR/aggregate.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir index cfc9a72e3..4706af92c 100644 --- a/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir +++ b/tests/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir @@ -2,9 +2,11 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/aggregate.rs:+1:9: +1:10 - let mut _2: i32; // in scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - let mut _3: (i32, i32, i32); // in scope 0 at $DIR/aggregate.rs:+1:13: +1:22 + let _1: u8; // in scope 0 at $DIR/aggregate.rs:+1:9: +1:10 + let mut _2: u8; // in scope 0 at $DIR/aggregate.rs:+1:13: +1:24 + let mut _3: (i32, u8, i32); // in scope 0 at $DIR/aggregate.rs:+1:13: +1:22 + let _4: (); // in scope 0 at $DIR/aggregate.rs:+2:5: +2:11 + let mut _5: u8; // in scope 0 at $DIR/aggregate.rs:+2:9: +2:10 scope 1 { debug x => _1; // in scope 1 at $DIR/aggregate.rs:+1:9: +1:10 } @@ -13,16 +15,25 @@ fn main() -> () { StorageLive(_1); // scope 0 at $DIR/aggregate.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 StorageLive(_3); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - Deinit(_3); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - (_3.0: i32) = const 0_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - (_3.1: i32) = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - (_3.2: i32) = const 2_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 - _2 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 - _1 = const 1_i32; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 + _3 = (const 0_i32, const 1_u8, const 2_i32); // scope 0 at $DIR/aggregate.rs:+1:13: +1:22 + _2 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:24 + _1 = const 1_u8; // scope 0 at $DIR/aggregate.rs:+1:13: +1:28 StorageDead(_2); // scope 0 at $DIR/aggregate.rs:+1:27: +1:28 StorageDead(_3); // scope 0 at $DIR/aggregate.rs:+1:28: +1:29 - _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/aggregate.rs:+2:1: +2:2 - return; // scope 0 at $DIR/aggregate.rs:+2:2: +2:2 + StorageLive(_4); // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 + StorageLive(_5); // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 + _5 = const 1_u8; // scope 1 at $DIR/aggregate.rs:+2:9: +2:10 + _4 = foo(move _5) -> bb1; // scope 1 at $DIR/aggregate.rs:+2:5: +2:11 + // mir::Constant + // + span: $DIR/aggregate.rs:8:5: 8:8 + // + literal: Const { ty: fn(u8) {foo}, val: Value() } + } + + bb1: { + StorageDead(_5); // scope 1 at $DIR/aggregate.rs:+2:10: +2:11 + StorageDead(_4); // scope 1 at $DIR/aggregate.rs:+2:11: +2:12 + _0 = const (); // scope 0 at $DIR/aggregate.rs:+0:11: +3:2 + StorageDead(_1); // scope 0 at $DIR/aggregate.rs:+3:1: +3:2 + return; // scope 0 at $DIR/aggregate.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index 6a3080384..aa123b7a8 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -5,4 +5,13 @@ // EMIT_MIR aggregate.main.PreCodegen.after.mir fn main() { let x = (0, 1, 2).1 + 0; + foo(x); +} + +// EMIT_MIR aggregate.foo.ConstProp.diff +// EMIT_MIR aggregate.foo.PreCodegen.after.mir +fn foo(x: u8) { + // Verify that we still propagate if part of the aggregate is not known. + let first = (0, x).0 + 1; + let second = (x, 1).1 + 2; } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff index bea32a67e..900061a48 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.diff @@ -24,9 +24,10 @@ StorageLive(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 - _3 = _1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 - _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 +- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 + _3 = const 0_i32; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:18: +2:19 + _4 = const true; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 - assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 ++ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_div_by_zero.rs:+2:14: +2:19 } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff index 8485703e3..ae9ffd519 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.diff @@ -18,35 +18,27 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:9: +1:10 _1 = const 0_i32; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+1:13: +1:14 StorageLive(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:9: +2:11 - StorageLive(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 -- _3 = _1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 -- _4 = Eq(_3, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- _4 = Eq(_1, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _3 = const 0_i32; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 + _4 = const true; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 } bb1: { -- _5 = Eq(_3, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _5 = Eq(_1, const -1_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _6 = Eq(const 1_i32, const i32::MIN); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - _7 = BitAnd(move _5, move _6); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _5 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 +- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _1) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _6 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 + _7 = const false; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, const 0_i32) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 ++ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _1) -> bb2; // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 } bb2: { -- _2 = Rem(const 1_i32, move _3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 -+ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 - StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:18: +2:19 + _2 = Rem(const 1_i32, _1); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+2:14: +2:19 StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 - StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:1: +3:2 return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff index 27e41d486..38d402b8f 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.diff @@ -23,24 +23,21 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _3 = _8; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 - StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 _5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _7 = Lt(const 3_usize, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 } bb1: { diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff index 27e41d486..38d402b8f 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.diff @@ -23,24 +23,21 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - StorageLive(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _8 = const _; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 // mir::Constant // + span: $DIR/bad_op_unsafe_oob_for_slices.rs:5:25: 5:35 // + literal: Const { ty: &[i32; 3], val: Unevaluated(main, [], Some(promoted[0])) } - _3 = _8; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 - _2 = &raw const (*_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 + _2 = &raw const (*_8); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 _1 = move _2 as *const [i32] (Pointer(Unsize)); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:25: +1:35 StorageDead(_2); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:34: +1:35 - StorageDead(_3); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:+1:35: +1:36 StorageLive(_4); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:13: +3:15 StorageLive(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 _5 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:23: +3:24 - _6 = Len((*_1)); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 + _6 = const 3_usize; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - _7 = Lt(_5, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 - assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ _7 = Lt(const 3_usize, _6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 -+ assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ _7 = const false; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 ++ assert(const false, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 3_usize) -> bb1; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:+3:18: +3:25 } bb1: { diff --git a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff index 0de800917..549b4711e 100644 --- a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff @@ -12,18 +12,12 @@ bb0: { StorageLive(_3); // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 - StorageLive(_4); // scope 0 at $DIR/boolean_identities.rs:+1:6: +1:7 - _4 = _2; // scope 0 at $DIR/boolean_identities.rs:+1:6: +1:7 -- _3 = BitOr(move _4, const true); // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 +- _3 = BitOr(_2, const true); // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 + _3 = const true; // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:15 - StorageDead(_4); // scope 0 at $DIR/boolean_identities.rs:+1:14: +1:15 StorageLive(_5); // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 - StorageLive(_6); // scope 0 at $DIR/boolean_identities.rs:+1:19: +1:20 - _6 = _1; // scope 0 at $DIR/boolean_identities.rs:+1:19: +1:20 -- _5 = BitAnd(move _6, const false); // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 -+ _5 = const false; // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 - StorageDead(_6); // scope 0 at $DIR/boolean_identities.rs:+1:28: +1:29 +- _5 = BitAnd(_1, const false); // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 - _0 = BitAnd(move _3, move _5); // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:29 ++ _5 = const false; // scope 0 at $DIR/boolean_identities.rs:+1:18: +1:29 + _0 = const false; // scope 0 at $DIR/boolean_identities.rs:+1:5: +1:29 StorageDead(_5); // scope 0 at $DIR/boolean_identities.rs:+1:28: +1:29 StorageDead(_3); // scope 0 at $DIR/boolean_identities.rs:+1:28: +1:29 diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff index b4dccecc6..b9a10704b 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff @@ -17,17 +17,20 @@ StorageLive(_1); // scope 0 at $DIR/discriminant.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 StorageLive(_3); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - Deinit(_3); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - ((_3 as Some).0: bool) = const true; // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - discriminant(_3) = 1; // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 +- _3 = Option::::Some(const true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - _4 = discriminant(_3); // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 - switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 ++ _3 = const Option::::Some(true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:12:34: 12:44 ++ // + literal: Const { ty: Option, val: Value(Scalar(0x01)) } + _4 = const 1_isize; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 } bb1: { - switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 +- switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 ++ switchInt(const true) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 } bb2: { diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff index b4dccecc6..b9a10704b 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff @@ -17,17 +17,20 @@ StorageLive(_1); // scope 0 at $DIR/discriminant.rs:+1:9: +1:10 StorageLive(_2); // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 StorageLive(_3); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - Deinit(_3); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - ((_3 as Some).0: bool) = const true; // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - discriminant(_3) = 1; // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 +- _3 = Option::::Some(const true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 - _4 = discriminant(_3); // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 - switchInt(move _4) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 ++ _3 = const Option::::Some(true); // scope 2 at $DIR/discriminant.rs:+1:34: +1:44 ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:12:34: 12:44 ++ // + literal: Const { ty: Option, val: Value(Scalar(0x01)) } + _4 = const 1_isize; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 + switchInt(const 1_isize) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 } bb1: { - switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 +- switchInt(((_3 as Some).0: bool)) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 ++ switchInt(const true) -> [0: bb3, otherwise: bb2]; // scope 2 at $DIR/discriminant.rs:+1:21: +1:31 } bb2: { diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff new file mode 100644 index 000000000..d03c23a3f --- /dev/null +++ b/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.diff @@ -0,0 +1,39 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/inherit_overflow.rs:+0:11: +0:11 + let mut _1: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + let mut _2: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + let mut _3: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + scope 1 { + } + scope 2 (inlined ::add) { // at $DIR/inherit_overflow.rs:8:13: 8:47 + debug self => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + debug other => _3; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + let mut _4: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageLive(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + _2 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageLive(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + _3 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 +- _4 = CheckedAdd(_2, _3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL +- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL ++ _4 = const (0_u8, true); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + } + + bb1: { +- _1 = move (_4.0: u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL ++ _1 = const 0_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageDead(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageDead(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:47: +3:48 + _0 = const (); // scope 0 at $DIR/inherit_overflow.rs:+0:11: +4:2 + return; // scope 0 at $DIR/inherit_overflow.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs new file mode 100644 index 000000000..541a8c5c3 --- /dev/null +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -0,0 +1,9 @@ +// unit-test: ConstProp +// compile-flags: -Zmir-enable-passes=+Inline + +// EMIT_MIR inherit_overflow.main.ConstProp.diff +fn main() { + // After inlining, this will contain a `CheckedBinaryOp`. + // Propagating the overflow is ok as codegen will just skip emitting the panic. + let _ = ::add(255, 1); +} diff --git a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff index 6c4757c1a..4f056dd85 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff @@ -32,16 +32,14 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/invalid_constant.rs:+6:9: +6:22 StorageLive(_2); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 - Deinit(_2); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 - (_2.0: u32) = const 1114113_u32; // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 + _2 = InvalidChar { int: const 1114113_u32 }; // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:63 - _1 = (_2.1: char); // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:67 + _1 = const {transmute(0x00110001): char}; // scope 2 at $DIR/invalid_constant.rs:+6:34: +6:67 StorageDead(_2); // scope 0 at $DIR/invalid_constant.rs:+6:69: +6:70 StorageLive(_3); // scope 1 at $DIR/invalid_constant.rs:+13:9: +13:21 StorageLive(_4); // scope 1 at $DIR/invalid_constant.rs:+13:25: +13:59 StorageLive(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 - Deinit(_5); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 - (_5.0: u32) = const 4_u32; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 + _5 = InvalidTag { int: const 4_u32 }; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:55 - _4 = (_5.1: E); // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 - _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 + _4 = const Scalar(0x00000004): E; // scope 4 at $DIR/invalid_constant.rs:+13:34: +13:57 diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff index 488e772d0..964dd3080 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff @@ -5,13 +5,14 @@ let mut _0: (); // return place in scope 0 at $DIR/issue_66971.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 let mut _2: ((), u8, u8); // in scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 + let mut _3: (); // in scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 bb0: { StorageLive(_1); // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 StorageLive(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - Deinit(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - (_2.1: u8) = const 0_u8; // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 - (_2.2: u8) = const 0_u8; // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 + StorageLive(_3); // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 + _2 = (move _3, const 0_u8, const 0_u8); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 + StorageDead(_3); // scope 0 at $DIR/issue_66971.rs:+1:21: +1:22 _1 = encode(move _2) -> bb1; // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 // mir::Constant // + span: $DIR/issue_66971.rs:17:5: 17:11 diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff index cd5304859..a631cb310 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -11,12 +11,9 @@ StorageLive(_1); // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 StorageLive(_2); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 StorageLive(_3); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 - Deinit(_3); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 - (_3.0: u8) = const 1_u8; // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 - (_3.1: u8) = const 2_u8; // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 - Deinit(_2); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 -- (_2.0: (u8, u8)) = move _3; // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 -+ (_2.0: (u8, u8)) = const (1_u8, 2_u8); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 +- _3 = (const 1_u8, const 2_u8); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 ++ _3 = const (1_u8, 2_u8); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 + _2 = (move _3,); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 StorageDead(_3); // scope 0 at $DIR/issue_67019.rs:+1:18: +1:19 _1 = test(move _2) -> bb1; // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 // mir::Constant diff --git a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff index 629c8e601..1cfe47d0a 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff @@ -7,11 +7,8 @@ let mut _2: i32; // in scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 bb0: { - StorageLive(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 - _2 = _1; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:4 -- _0 = Mul(move _2, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 +- _0 = Mul(_1, const 0_i32); // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 + _0 = const 0_i32; // scope 0 at $DIR/mult_by_zero.rs:+1:3: +1:8 - StorageDead(_2); // scope 0 at $DIR/mult_by_zero.rs:+1:7: +1:8 return; // scope 0 at $DIR/mult_by_zero.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff index f6bf52206..d088c4f66 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff @@ -3,26 +3,27 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/mutable_variable_aggregate.rs:+0:11: +0:11 - let mut _1: (i32, i32); // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let mut _3: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let mut _4: i32; // in scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 scope 1 { - debug x => _1; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - let _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug x => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + let _1: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + let _2: i32; // in scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 scope 2 { - debug y => _2; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 + debug y => (i32, i32){ .0 => _3, .1 => _2, }; // in scope 2 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 } } bb0: { - StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 - Deinit(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - (_1.0: i32) = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - (_1.1: i32) = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 - (_1.1: i32) = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 + StorageLive(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:9: +1:14 + _3 = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 + _4 = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate.rs:+1:17: +1:25 + _4 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+2:5: +2:13 StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:9: +3:10 -- _2 = _1; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 -+ _2 = const (42_i32, 99_i32); // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 +- _2 = _4; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 ++ _2 = const 99_i32; // scope 1 at $DIR/mutable_variable_aggregate.rs:+3:13: +3:14 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 - StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 + StorageDead(_4); // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:1: +4:2 return; // scope 0 at $DIR/mutable_variable_aggregate.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff index 213a70227..134f0c080 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff @@ -9,24 +9,26 @@ let _2: &mut (i32, i32); // in scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 scope 2 { debug z => _2; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 - let _3: (i32, i32); // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + let _3: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + let _4: i32; // in scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 scope 3 { - debug y => _3; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + debug y => (i32, i32){ .0 => _3, .1 => _4, }; // in scope 3 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 } } } bb0: { StorageLive(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:9: +1:14 - Deinit(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:17: +1:25 - (_1.0: i32) = const 42_i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:17: +1:25 - (_1.1: i32) = const 43_i32; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:17: +1:25 + _1 = (const 42_i32, const 43_i32); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+1:17: +1:25 StorageLive(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:9: +2:10 _2 = &mut _1; // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+2:13: +2:19 ((*_2).1: i32) = const 99_i32; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+3:5: +3:13 StorageLive(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 - _3 = _1; // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 + StorageLive(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:9: +4:10 + _3 = (_1.0: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 + _4 = (_1.1: i32); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+4:13: +4:14 StorageDead(_3); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 + StorageDead(_4); // scope 2 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_2); // scope 1 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:1: +5:2 return; // scope 0 at $DIR/mutable_variable_aggregate_mut_ref.rs:+5:2: +5:2 diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff index c3f77b960..4010dd6c6 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff @@ -16,7 +16,7 @@ debug y => _3; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 let _4: i32; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 scope 4 { - debug z => _4; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 + debug z => _5; // in scope 4 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 } } } @@ -31,10 +31,7 @@ } bb1: { - StorageLive(_5); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 StorageLive(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - Deinit(_5); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - Deinit(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 _5 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 _6 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 StorageLive(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 @@ -43,12 +40,7 @@ StorageDead(_2); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 _3 = _6; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 - StorageLive(_4); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 -- _4 = _5; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 -+ _4 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 - StorageDead(_4); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_5); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 return; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+6:2: +6:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff index 7c7aeac4c..691aa01a5 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff @@ -17,7 +17,7 @@ debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 scope 3 { - debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 + debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 } } } @@ -50,14 +50,7 @@ + _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 - StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - Deinit(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 _9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- _8 = _9; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 -+ _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 - StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 - StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff index 7c7aeac4c..691aa01a5 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff @@ -17,7 +17,7 @@ debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 scope 3 { - debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 + debug z => _9; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 } } } @@ -50,14 +50,7 @@ + _3 = const 3_i32; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 StorageDead(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 - StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - Deinit(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 _9 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- _8 = _9; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 -+ _8 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 - StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 - StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir index 9db87cfc8..81cfd22db 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir @@ -3,12 +3,12 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 scope 2 { debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 scope 3 { debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 } @@ -18,8 +18,6 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir index 9db87cfc8..81cfd22db 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir @@ -3,12 +3,12 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 scope 2 { debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 scope 3 { debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 } @@ -18,8 +18,6 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff b/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff index 3f9f3b2ea..98cd020da 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff @@ -48,20 +48,19 @@ StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- Deinit(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- (_9.0: u32) = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- (_9.1: u32) = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 +- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 - StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 + StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -+ Deinit(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -+ Deinit(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 + StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 ++ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2 StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff b/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff index 3f9f3b2ea..98cd020da 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff @@ -48,20 +48,19 @@ StorageDead(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:34: +2:35 StorageLive(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageLive(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- Deinit(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- (_9.0: u32) = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -- (_9.1: u32) = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 +- _9 = Point { x: const 12_u32, y: const 42_u32 }; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 - _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 - StorageDead(_9); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 + StorageLive(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + StorageLive(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -+ Deinit(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 -+ Deinit(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _10 = const 12_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _11 = const 42_u32; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + _8 = _11; // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + StorageDead(_10); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 + StorageDead(_11); // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 ++ nop; // scope 2 at $DIR/optimizes_into_variable.rs:+3:38: +3:39 nop; // scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +4:2 StorageDead(_8); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir index d926b9df7..002e914e8 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.mir @@ -3,12 +3,12 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 scope 2 { debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 scope 3 { debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 } @@ -18,8 +18,6 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir b/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir index d926b9df7..002e914e8 100644 --- a/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir +++ b/tests/mir-opt/const_prop/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.mir @@ -3,12 +3,12 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:+0:11: +0:11 let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + let mut _3: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 scope 2 { debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 scope 3 { debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 } @@ -18,8 +18,6 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 StorageLive(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 - StorageLive(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+3:9: +3:10 - StorageDead(_3); // scope 2 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_2); // scope 1 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+4:1: +4:2 return; // scope 0 at $DIR/optimizes_into_variable.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff index 8a73f0390..924a267f3 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff @@ -13,14 +13,13 @@ StorageLive(_2); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 _4 = const _; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 // mir::Constant - // + span: $DIR/ref_deref.rs:6:6: 6:10 + // + span: $DIR/ref_deref.rs:5:6: 5:10 // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } - _2 = _4; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 -- _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 -+ _1 = const 4_i32; // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 + _2 = &(*_4); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 + _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 StorageDead(_2); // scope 0 at $DIR/ref_deref.rs:+1:10: +1:11 StorageDead(_1); // scope 0 at $DIR/ref_deref.rs:+1:10: +1:11 - nop; // scope 0 at $DIR/ref_deref.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/ref_deref.rs:+0:11: +2:2 return; // scope 0 at $DIR/ref_deref.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff b/tests/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff deleted file mode 100644 index 015ec4d07..000000000 --- a/tests/mir-opt/const_prop/ref_deref.main.PromoteTemps.diff +++ /dev/null @@ -1,30 +0,0 @@ -- // MIR for `main` before PromoteTemps -+ // MIR for `main` after PromoteTemps - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/ref_deref.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 - let mut _2: &i32; // in scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - let _3: i32; // in scope 0 at $DIR/ref_deref.rs:+1:8: +1:9 -+ let mut _4: &i32; // in scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 - StorageLive(_2); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 -- StorageLive(_3); // scope 0 at $DIR/ref_deref.rs:+1:8: +1:9 -- _3 = const 4_i32; // scope 0 at $DIR/ref_deref.rs:+1:8: +1:9 -- _2 = &_3; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 -+ _4 = const _; // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 -+ // mir::Constant -+ // + span: $DIR/ref_deref.rs:6:6: 6:10 -+ // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } -+ _2 = &(*_4); // scope 0 at $DIR/ref_deref.rs:+1:6: +1:10 - _1 = (*_2); // scope 0 at $DIR/ref_deref.rs:+1:5: +1:10 -- StorageDead(_3); // scope 0 at $DIR/ref_deref.rs:+1:10: +1:11 - StorageDead(_2); // scope 0 at $DIR/ref_deref.rs:+1:10: +1:11 - StorageDead(_1); // scope 0 at $DIR/ref_deref.rs:+1:10: +1:11 - _0 = const (); // scope 0 at $DIR/ref_deref.rs:+0:11: +2:2 - return; // scope 0 at $DIR/ref_deref.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs index d2549c8b6..76e56916a 100644 --- a/tests/mir-opt/const_prop/ref_deref.rs +++ b/tests/mir-opt/const_prop/ref_deref.rs @@ -1,5 +1,4 @@ -// compile-flags: -Zmir-enable-passes=-SimplifyLocals-before-const-prop -// EMIT_MIR ref_deref.main.PromoteTemps.diff +// unit-test: ConstProp // EMIT_MIR ref_deref.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff index ec3d90433..59095b448 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff @@ -13,13 +13,13 @@ StorageLive(_2); // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 _4 = const _; // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 // mir::Constant - // + span: $DIR/ref_deref_project.rs:6:6: 6:17 + // + span: $DIR/ref_deref_project.rs:5:6: 5:17 // + literal: Const { ty: &(i32, i32), val: Unevaluated(main, [], Some(promoted[0])) } _2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 _1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:+1:5: +1:17 StorageDead(_2); // scope 0 at $DIR/ref_deref_project.rs:+1:17: +1:18 StorageDead(_1); // scope 0 at $DIR/ref_deref_project.rs:+1:17: +1:18 - nop; // scope 0 at $DIR/ref_deref_project.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/ref_deref_project.rs:+0:11: +2:2 return; // scope 0 at $DIR/ref_deref_project.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.PromoteTemps.diff b/tests/mir-opt/const_prop/ref_deref_project.main.PromoteTemps.diff deleted file mode 100644 index cd0616e65..000000000 --- a/tests/mir-opt/const_prop/ref_deref_project.main.PromoteTemps.diff +++ /dev/null @@ -1,30 +0,0 @@ -- // MIR for `main` before PromoteTemps -+ // MIR for `main` after PromoteTemps - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/ref_deref_project.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/ref_deref_project.rs:+1:5: +1:17 - let mut _2: &i32; // in scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 - let _3: (i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:+1:8: +1:14 -+ let mut _4: &(i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/ref_deref_project.rs:+1:5: +1:17 - StorageLive(_2); // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 -- StorageLive(_3); // scope 0 at $DIR/ref_deref_project.rs:+1:8: +1:14 -- _3 = (const 4_i32, const 5_i32); // scope 0 at $DIR/ref_deref_project.rs:+1:8: +1:14 -- _2 = &(_3.1: i32); // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 -+ _4 = const _; // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 -+ // mir::Constant -+ // + span: $DIR/ref_deref_project.rs:6:6: 6:17 -+ // + literal: Const { ty: &(i32, i32), val: Unevaluated(main, [], Some(promoted[0])) } -+ _2 = &((*_4).1: i32); // scope 0 at $DIR/ref_deref_project.rs:+1:6: +1:17 - _1 = (*_2); // scope 0 at $DIR/ref_deref_project.rs:+1:5: +1:17 -- StorageDead(_3); // scope 0 at $DIR/ref_deref_project.rs:+1:17: +1:18 - StorageDead(_2); // scope 0 at $DIR/ref_deref_project.rs:+1:17: +1:18 - StorageDead(_1); // scope 0 at $DIR/ref_deref_project.rs:+1:17: +1:18 - _0 = const (); // scope 0 at $DIR/ref_deref_project.rs:+0:11: +2:2 - return; // scope 0 at $DIR/ref_deref_project.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs index 2fdd4e153..04fc7f8da 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.rs +++ b/tests/mir-opt/const_prop/ref_deref_project.rs @@ -1,5 +1,4 @@ -// compile-flags: -Zmir-enable-passes=-SimplifyLocals-before-const-prop -// EMIT_MIR ref_deref_project.main.PromoteTemps.diff +// unit-test: ConstProp // EMIT_MIR ref_deref_project.main.ConstProp.diff fn main() { diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff index d518eff04..22f710387 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff @@ -11,13 +11,9 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10 _1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14 StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 - StorageLive(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 -- _3 = _1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 -- _2 = consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 -+ _3 = const 1_u32; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 +- _2 = consume(_1) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 + _2 = consume(const 1_u32) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 // mir::Constant // + span: $DIR/scalar_literal_propagation.rs:4:5: 4:12 @@ -25,9 +21,7 @@ } bb1: { - StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:14: +2:15 StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16 - StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+3:1: +3:2 return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 } } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff index 9017fd18e..b99b83b0c 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.diff @@ -20,7 +20,7 @@ StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 // mir::Constant - // + span: $DIR/slice_len.rs:6:6: 6:19 + // + span: $DIR/slice_len.rs:7:6: 7:19 // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 @@ -33,7 +33,7 @@ - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 + _7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 + _8 = const true; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 } bb1: { @@ -43,7 +43,7 @@ StorageDead(_4); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 StorageDead(_2); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 StorageDead(_1); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - nop; // scope 0 at $DIR/slice_len.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/slice_len.rs:+0:11: +2:2 return; // scope 0 at $DIR/slice_len.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff index 9017fd18e..b99b83b0c 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.diff @@ -20,7 +20,7 @@ StorageLive(_4); // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _9 = const _; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 // mir::Constant - // + span: $DIR/slice_len.rs:6:6: 6:19 + // + span: $DIR/slice_len.rs:7:6: 7:19 // + literal: Const { ty: &[u32; 3], val: Unevaluated(main, [], Some(promoted[0])) } _4 = _9; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 _3 = _4; // scope 0 at $DIR/slice_len.rs:+1:6: +1:19 @@ -33,7 +33,7 @@ - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 + _7 = const 3_usize; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 + _8 = const true; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 ++ assert(const true, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1; // scope 0 at $DIR/slice_len.rs:+1:5: +1:33 } bb1: { @@ -43,7 +43,7 @@ StorageDead(_4); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 StorageDead(_2); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 StorageDead(_1); // scope 0 at $DIR/slice_len.rs:+1:33: +1:34 - nop; // scope 0 at $DIR/slice_len.rs:+0:11: +2:2 + _0 = const (); // scope 0 at $DIR/slice_len.rs:+0:11: +2:2 return; // scope 0 at $DIR/slice_len.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index eaaf34b96..8183def0c 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,4 +1,5 @@ -// compile-flags: -Zmir-enable-passes=-SimplifyLocals-before-const-prop +// unit-test: ConstProp +// compile-flags: -Zmir-enable-passes=+InstCombine // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR slice_len.main.ConstProp.diff diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff index e4c92b617..270a1ccf5 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -11,24 +11,17 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:9: +1:10 - Deinit(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 - (_1.0: u32) = const 1_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 - (_1.1: u32) = const 2_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 +- _1 = (const 1_u32, const 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 ++ _1 = const (1_u32, 2_u32); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 - StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 -- _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 -+ _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 - _2 = consume(move _3) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 + _2 = consume(_1) -> bb1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 // mir::Constant // + span: $DIR/tuple_literal_propagation.rs:5:5: 5:12 // + literal: Const { ty: fn((u32, u32)) {consume}, val: Value() } } bb1: { - StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:14: +3:15 StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16 - StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+4:1: +4:2 return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff b/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff index ea9fec0aa..def9fc642 100644 --- a/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff +++ b/tests/mir-opt/const_prop_miscompile.bar.ConstProp.diff @@ -4,32 +4,37 @@ fn bar() -> () { let mut _0: (); // return place in scope 0 at $DIR/const_prop_miscompile.rs:+0:10: +0:10 let mut _1: (i32,); // in scope 0 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 - let mut _2: *mut i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 - let mut _4: i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 + let _2: (); // in scope 0 at $DIR/const_prop_miscompile.rs:+2:5: +4:6 + let mut _3: *mut i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 + let mut _5: i32; // in scope 0 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 scope 1 { debug v => _1; // in scope 1 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 - let _3: bool; // in scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 + let _4: bool; // in scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 scope 2 { } scope 3 { - debug y => _3; // in scope 3 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 + debug y => _4; // in scope 3 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 } } bb0: { StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 - Deinit(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 - (_1.0: i32) = const 1_i32; // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 - StorageLive(_2); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 - _2 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 - (*_2) = const 5_i32; // scope 2 at $DIR/const_prop_miscompile.rs:+3:9: +3:26 - StorageDead(_2); // scope 2 at $DIR/const_prop_miscompile.rs:+3:26: +3:27 - StorageLive(_3); // scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 - StorageLive(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 - _4 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:15: +5:18 - _3 = Eq(move _4, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:25 - StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+5:24: +5:25 - StorageDead(_3); // scope 1 at $DIR/const_prop_miscompile.rs:+6:1: +6:2 +- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 ++ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 + StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:+2:5: +4:6 + StorageLive(_3); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 + _3 = &raw mut (_1.0: i32); // scope 2 at $DIR/const_prop_miscompile.rs:+3:10: +3:22 + (*_3) = const 5_i32; // scope 2 at $DIR/const_prop_miscompile.rs:+3:9: +3:26 + StorageDead(_3); // scope 2 at $DIR/const_prop_miscompile.rs:+3:26: +3:27 + _2 = const (); // scope 2 at $DIR/const_prop_miscompile.rs:+2:5: +4:6 + StorageDead(_2); // scope 1 at $DIR/const_prop_miscompile.rs:+4:5: +4:6 + StorageLive(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+5:9: +5:10 + StorageLive(_5); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:20 + _5 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:15: +5:18 + _4 = Eq(move _5, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:+5:13: +5:25 + StorageDead(_5); // scope 1 at $DIR/const_prop_miscompile.rs:+5:24: +5:25 + _0 = const (); // scope 0 at $DIR/const_prop_miscompile.rs:+0:10: +6:2 + StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+6:1: +6:2 StorageDead(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+6:1: +6:2 return; // scope 0 at $DIR/const_prop_miscompile.rs:+6:2: +6:2 } diff --git a/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff b/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff index 043f40474..b54c10a14 100644 --- a/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff +++ b/tests/mir-opt/const_prop_miscompile.foo.ConstProp.diff @@ -16,8 +16,8 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:9: +1:14 - Deinit(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 - (_1.0: i32) = const 1_i32; // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 +- _1 = (const 1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 ++ _1 = const (1_i32,); // scope 0 at $DIR/const_prop_miscompile.rs:+1:17: +1:21 StorageLive(_2); // scope 1 at $DIR/const_prop_miscompile.rs:+2:6: +2:14 _2 = &mut (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+2:6: +2:14 (*_2) = const 5_i32; // scope 1 at $DIR/const_prop_miscompile.rs:+2:5: +2:18 @@ -27,6 +27,7 @@ _4 = (_1.0: i32); // scope 1 at $DIR/const_prop_miscompile.rs:+3:15: +3:18 _3 = Eq(move _4, const 5_i32); // scope 1 at $DIR/const_prop_miscompile.rs:+3:13: +3:25 StorageDead(_4); // scope 1 at $DIR/const_prop_miscompile.rs:+3:24: +3:25 + _0 = const (); // scope 0 at $DIR/const_prop_miscompile.rs:+0:10: +4:2 StorageDead(_3); // scope 1 at $DIR/const_prop_miscompile.rs:+4:1: +4:2 StorageDead(_1); // scope 0 at $DIR/const_prop_miscompile.rs:+4:1: +4:2 return; // scope 0 at $DIR/const_prop_miscompile.rs:+4:2: +4:2 diff --git a/tests/mir-opt/const_prop_miscompile.rs b/tests/mir-opt/const_prop_miscompile.rs index bc54556b3..dbbe5ee08 100644 --- a/tests/mir-opt/const_prop_miscompile.rs +++ b/tests/mir-opt/const_prop_miscompile.rs @@ -1,3 +1,4 @@ +// unit-test: ConstProp #![feature(raw_ref_op)] // EMIT_MIR const_prop_miscompile.foo.ConstProp.diff diff --git a/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff new file mode 100644 index 000000000..b183865a9 --- /dev/null +++ b/tests/mir-opt/copy-prop/borrowed_local.f.CopyProp.diff @@ -0,0 +1,34 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/borrowed_local.rs:+0:11: +0:15 + let mut _1: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: &u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: &u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _1 = const 5_u8; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _2 = &_1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _3 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _4 = &_3; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _0 = cmp_ref(_2, _4) -> bb1; // scope 0 at $DIR/borrowed_local.rs:+8:13: +8:45 + // mir::Constant + // + span: $DIR/borrowed_local.rs:23:29: 23:36 + // + literal: Const { ty: for<'a, 'b> fn(&'a u8, &'b u8) -> bool {cmp_ref}, val: Value() } + } + + bb1: { +- _0 = opaque::(_3) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 ++ _0 = opaque::(_1) -> bb2; // scope 0 at $DIR/borrowed_local.rs:+12:13: +12:38 + // mir::Constant + // + span: $DIR/borrowed_local.rs:27:28: 27:34 + // + literal: Const { ty: fn(u8) -> bool {opaque::}, val: Value() } + } + + bb2: { + return; // scope 0 at $DIR/borrowed_local.rs:+15:13: +15:21 + } + } + diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs new file mode 100644 index 000000000..c4b980e2b --- /dev/null +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -0,0 +1,39 @@ +// unit-test: CopyProp + +#![feature(custom_mir, core_intrinsics)] +#![allow(unused_assignments)] +extern crate core; +use core::intrinsics::mir::*; + +fn opaque(_: impl Sized) -> bool { true } + +fn cmp_ref(a: &u8, b: &u8) -> bool { + std::ptr::eq(a as *const u8, b as *const u8) +} + +#[custom_mir(dialect = "analysis", phase = "post-cleanup")] +fn f() -> bool { + mir!( + { + let a = 5_u8; + let r1 = &a; + let b = a; + // We cannot propagate the place `a`. + let r2 = &b; + Call(RET, next, cmp_ref(r1, r2)) + } + next = { + // But we can propagate the value `a`. + Call(RET, ret, opaque(b)) + } + ret = { + Return() + } + ) +} + +fn main() { + assert!(!f()); +} + +// EMIT_MIR borrowed_local.f.CopyProp.diff diff --git a/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff b/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff new file mode 100644 index 000000000..8b116532d --- /dev/null +++ b/tests/mir-opt/copy-prop/branch.foo.CopyProp.diff @@ -0,0 +1,65 @@ +- // MIR for `foo` before CopyProp ++ // MIR for `foo` after CopyProp + + fn foo() -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/branch.rs:+0:13: +0:16 + let _1: i32; // in scope 0 at $DIR/branch.rs:+1:9: +1:10 + let mut _3: bool; // in scope 0 at $DIR/branch.rs:+3:16: +3:22 + let _4: i32; // in scope 0 at $DIR/branch.rs:+6:9: +6:14 + scope 1 { + debug x => _1; // in scope 1 at $DIR/branch.rs:+1:9: +1:10 + let _2: i32; // in scope 1 at $DIR/branch.rs:+3:9: +3:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/branch.rs:+3:9: +3:10 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/branch.rs:+1:9: +1:10 + _1 = val() -> bb1; // scope 0 at $DIR/branch.rs:+1:13: +1:18 + // mir::Constant + // + span: $DIR/branch.rs:13:13: 13:16 + // + literal: Const { ty: fn() -> i32 {val}, val: Value() } + } + + bb1: { + StorageLive(_2); // scope 1 at $DIR/branch.rs:+3:9: +3:10 + StorageLive(_3); // scope 1 at $DIR/branch.rs:+3:16: +3:22 + _3 = cond() -> bb2; // scope 1 at $DIR/branch.rs:+3:16: +3:22 + // mir::Constant + // + span: $DIR/branch.rs:15:16: 15:20 + // + literal: Const { ty: fn() -> bool {cond}, val: Value() } + } + + bb2: { + switchInt(move _3) -> [0: bb4, otherwise: bb3]; // scope 1 at $DIR/branch.rs:+3:16: +3:22 + } + + bb3: { + _2 = _1; // scope 1 at $DIR/branch.rs:+4:9: +4:10 + goto -> bb6; // scope 1 at $DIR/branch.rs:+3:13: +8:6 + } + + bb4: { + StorageLive(_4); // scope 1 at $DIR/branch.rs:+6:9: +6:14 + _4 = val() -> bb5; // scope 1 at $DIR/branch.rs:+6:9: +6:14 + // mir::Constant + // + span: $DIR/branch.rs:18:9: 18:12 + // + literal: Const { ty: fn() -> i32 {val}, val: Value() } + } + + bb5: { + StorageDead(_4); // scope 1 at $DIR/branch.rs:+6:14: +6:15 + _2 = _1; // scope 1 at $DIR/branch.rs:+7:9: +7:10 + goto -> bb6; // scope 1 at $DIR/branch.rs:+3:13: +8:6 + } + + bb6: { + StorageDead(_3); // scope 1 at $DIR/branch.rs:+8:5: +8:6 + _0 = _2; // scope 2 at $DIR/branch.rs:+10:5: +10:6 + StorageDead(_2); // scope 1 at $DIR/branch.rs:+11:1: +11:2 + StorageDead(_1); // scope 0 at $DIR/branch.rs:+11:1: +11:2 + return; // scope 0 at $DIR/branch.rs:+11:2: +11:2 + } + } + diff --git a/tests/mir-opt/copy-prop/branch.rs b/tests/mir-opt/copy-prop/branch.rs new file mode 100644 index 000000000..50b1e00fa --- /dev/null +++ b/tests/mir-opt/copy-prop/branch.rs @@ -0,0 +1,27 @@ +//! Tests that we bail out when there are multiple assignments to the same local. +// unit-test: CopyProp +fn val() -> i32 { + 1 +} + +fn cond() -> bool { + true +} + +// EMIT_MIR branch.foo.CopyProp.diff +fn foo() -> i32 { + let x = val(); + + let y = if cond() { + x + } else { + val(); + x + }; + + y +} + +fn main() { + foo(); +} diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff new file mode 100644 index 000000000..69acebf76 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.arg_src.CopyProp.diff @@ -0,0 +1,21 @@ +- // MIR for `arg_src` before CopyProp ++ // MIR for `arg_src` after CopyProp + + fn arg_src(_1: i32) -> i32 { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:12: +0:17 + let mut _0: i32; // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:27: +0:30 + let _2: i32; // in scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 + scope 1 { + debug y => _2; // in scope 1 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 + _2 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 + _1 = const 123_i32; // scope 1 at $DIR/copy_propagation_arg.rs:+2:5: +2:12 + _0 = _2; // scope 1 at $DIR/copy_propagation_arg.rs:+3:5: +3:6 + StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+4:1: +4:2 + return; // scope 0 at $DIR/copy_propagation_arg.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff new file mode 100644 index 000000000..ac4e9a2bf --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.bar.CopyProp.diff @@ -0,0 +1,28 @@ +- // MIR for `bar` before CopyProp ++ // MIR for `bar` after CopyProp + + fn bar(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:8: +0:13 + let mut _0: (); // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +0:19 + let _2: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 + let mut _3: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 + StorageLive(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 + _3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 + _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:5: +1:13 + // mir::Constant + // + span: $DIR/copy_propagation_arg.rs:16:5: 16:10 + // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value() } + } + + bb1: { + StorageDead(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+1:12: +1:13 + StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 + _1 = const 5_u8; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:10 + _0 = const (); // scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +3:2 + return; // scope 0 at $DIR/copy_propagation_arg.rs:+3:2: +3:2 + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.diff new file mode 100644 index 000000000..7ab6ebb7d --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.baz.CopyProp.diff @@ -0,0 +1,18 @@ +- // MIR for `baz` before CopyProp ++ // MIR for `baz` after CopyProp + + fn baz(_1: i32) -> i32 { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:8: +0:13 + let mut _0: i32; // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:23: +0:26 + let mut _2: i32; // in scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 + _2 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 + _1 = move _2; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:10 + StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 + _0 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+3:5: +3:6 + return; // scope 0 at $DIR/copy_propagation_arg.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff new file mode 100644 index 000000000..0a3e985e7 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.foo.CopyProp.diff @@ -0,0 +1,28 @@ +- // MIR for `foo` before CopyProp ++ // MIR for `foo` after CopyProp + + fn foo(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:8: +0:13 + let mut _0: (); // return place in scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +0:19 + let mut _2: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 + let mut _3: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 + StorageLive(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16 + _3 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:15: +2:16 + _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 + // mir::Constant + // + span: $DIR/copy_propagation_arg.rs:11:9: 11:14 + // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value() } + } + + bb1: { + StorageDead(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+2:16: +2:17 + _1 = move _2; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:17 + StorageDead(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:16: +2:17 + _0 = const (); // scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +3:2 + return; // scope 0 at $DIR/copy_propagation_arg.rs:+3:2: +3:2 + } + } + diff --git a/tests/mir-opt/copy-prop/copy_propagation_arg.rs b/tests/mir-opt/copy-prop/copy_propagation_arg.rs new file mode 100644 index 000000000..cc98985f1 --- /dev/null +++ b/tests/mir-opt/copy-prop/copy_propagation_arg.rs @@ -0,0 +1,40 @@ +// Check that CopyProp does not propagate an assignment to a function argument +// (doing so can break usages of the original argument value) +// unit-test: CopyProp +fn dummy(x: u8) -> u8 { + x +} + +// EMIT_MIR copy_propagation_arg.foo.CopyProp.diff +fn foo(mut x: u8) { + // calling `dummy` to make a use of `x` that copyprop cannot eliminate + x = dummy(x); // this will assign a local to `x` +} + +// EMIT_MIR copy_propagation_arg.bar.CopyProp.diff +fn bar(mut x: u8) { + dummy(x); + x = 5; +} + +// EMIT_MIR copy_propagation_arg.baz.CopyProp.diff +fn baz(mut x: i32) -> i32 { + // self-assignment to a function argument should be eliminated + x = x; + x +} + +// EMIT_MIR copy_propagation_arg.arg_src.CopyProp.diff +fn arg_src(mut x: i32) -> i32 { + let y = x; + x = 123; // Don't propagate this assignment to `y` + y +} + +fn main() { + // Make sure the function actually gets instantiated. + foo(0); + bar(0); + baz(0); + arg_src(0); +} diff --git a/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff new file mode 100644 index 000000000..6ca73ffdd --- /dev/null +++ b/tests/mir-opt/copy-prop/custom_move_arg.f.CopyProp.diff @@ -0,0 +1,31 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: NotCopy) -> () { + let mut _0: (); // return place in scope 0 at $DIR/custom_move_arg.rs:+0:19: +0:19 + let mut _2: NotCopy; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: NotCopy; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { +- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _0 = opaque::(move _1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41 ++ _0 = opaque::(_1) -> bb1; // scope 0 at $DIR/custom_move_arg.rs:+3:9: +3:41 + // mir::Constant + // + span: $DIR/custom_move_arg.rs:15:24: 15:30 + // + literal: Const { ty: fn(NotCopy) {opaque::}, val: Value() } + } + + bb1: { +- _3 = move _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _0 = opaque::(_3) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35 ++ _0 = opaque::(_1) -> bb2; // scope 0 at $DIR/custom_move_arg.rs:+7:9: +7:35 + // mir::Constant + // + span: $DIR/custom_move_arg.rs:19:24: 19:30 + // + literal: Const { ty: fn(NotCopy) {opaque::}, val: Value() } + } + + bb2: { + return; // scope 0 at $DIR/custom_move_arg.rs:+10:9: +10:17 + } + } + diff --git a/tests/mir-opt/copy-prop/custom_move_arg.rs b/tests/mir-opt/copy-prop/custom_move_arg.rs new file mode 100644 index 000000000..4a591146e --- /dev/null +++ b/tests/mir-opt/copy-prop/custom_move_arg.rs @@ -0,0 +1,32 @@ +// unit-test: CopyProp + +#![feature(custom_mir, core_intrinsics)] +#![allow(unused_assignments)] +extern crate core; +use core::intrinsics::mir::*; + +struct NotCopy(bool); + +// EMIT_MIR custom_move_arg.f.CopyProp.diff +#[custom_mir(dialect = "analysis", phase = "post-cleanup")] +fn f(_1: NotCopy) { + mir!({ + let _2 = _1; + Call(RET, bb1, opaque(Move(_1))) + } + bb1 = { + let _3 = Move(_2); + Call(RET, bb2, opaque(_3)) + } + bb2 = { + Return() + }) +} + +#[inline(never)] +fn opaque(_t: T) {} + +fn main() { + f(NotCopy(true)); + println!("hi"); +} diff --git a/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff b/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff new file mode 100644 index 000000000..3e61869e8 --- /dev/null +++ b/tests/mir-opt/copy-prop/cycle.main.CopyProp.diff @@ -0,0 +1,60 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:11: +0:11 + let mut _1: i32; // in scope 0 at $DIR/cycle.rs:+1:9: +1:14 + let mut _4: i32; // in scope 0 at $DIR/cycle.rs:+4:9: +4:10 + let _5: (); // in scope 0 at $DIR/cycle.rs:+6:5: +6:12 + let mut _6: i32; // in scope 0 at $DIR/cycle.rs:+6:10: +6:11 + scope 1 { + debug x => _1; // in scope 1 at $DIR/cycle.rs:+1:9: +1:14 + let _2: i32; // in scope 1 at $DIR/cycle.rs:+2:9: +2:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/cycle.rs:+2:9: +2:10 + let _3: i32; // in scope 2 at $DIR/cycle.rs:+3:9: +3:10 + scope 3 { +- debug z => _3; // in scope 3 at $DIR/cycle.rs:+3:9: +3:10 ++ debug z => _2; // in scope 3 at $DIR/cycle.rs:+3:9: +3:10 + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:14 + _1 = val() -> bb1; // scope 0 at $DIR/cycle.rs:+1:17: +1:22 + // mir::Constant + // + span: $DIR/cycle.rs:9:17: 9:20 + // + literal: Const { ty: fn() -> i32 {val}, val: Value() } + } + + bb1: { +- StorageLive(_2); // scope 1 at $DIR/cycle.rs:+2:9: +2:10 + _2 = _1; // scope 1 at $DIR/cycle.rs:+2:13: +2:14 +- StorageLive(_3); // scope 2 at $DIR/cycle.rs:+3:9: +3:10 +- _3 = _2; // scope 2 at $DIR/cycle.rs:+3:13: +3:14 +- StorageLive(_4); // scope 3 at $DIR/cycle.rs:+4:9: +4:10 +- _4 = _3; // scope 3 at $DIR/cycle.rs:+4:9: +4:10 +- _1 = move _4; // scope 3 at $DIR/cycle.rs:+4:5: +4:10 +- StorageDead(_4); // scope 3 at $DIR/cycle.rs:+4:9: +4:10 ++ _1 = _2; // scope 3 at $DIR/cycle.rs:+4:5: +4:10 + StorageLive(_5); // scope 3 at $DIR/cycle.rs:+6:5: +6:12 + StorageLive(_6); // scope 3 at $DIR/cycle.rs:+6:10: +6:11 + _6 = _1; // scope 3 at $DIR/cycle.rs:+6:10: +6:11 + _5 = std::mem::drop::(move _6) -> bb2; // scope 3 at $DIR/cycle.rs:+6:5: +6:12 + // mir::Constant + // + span: $DIR/cycle.rs:14:5: 14:9 + // + literal: Const { ty: fn(i32) {std::mem::drop::}, val: Value() } + } + + bb2: { + StorageDead(_6); // scope 3 at $DIR/cycle.rs:+6:11: +6:12 + StorageDead(_5); // scope 3 at $DIR/cycle.rs:+6:12: +6:13 + _0 = const (); // scope 0 at $DIR/cycle.rs:+0:11: +7:2 +- StorageDead(_3); // scope 2 at $DIR/cycle.rs:+7:1: +7:2 +- StorageDead(_2); // scope 1 at $DIR/cycle.rs:+7:1: +7:2 + StorageDead(_1); // scope 0 at $DIR/cycle.rs:+7:1: +7:2 + return; // scope 0 at $DIR/cycle.rs:+7:2: +7:2 + } + } + diff --git a/tests/mir-opt/copy-prop/cycle.rs b/tests/mir-opt/copy-prop/cycle.rs new file mode 100644 index 000000000..b74c39726 --- /dev/null +++ b/tests/mir-opt/copy-prop/cycle.rs @@ -0,0 +1,15 @@ +//! Tests that cyclic assignments don't hang CopyProp, and result in reasonable code. +// unit-test: CopyProp +fn val() -> i32 { + 1 +} + +// EMIT_MIR cycle.main.CopyProp.diff +fn main() { + let mut x = val(); + let y = x; + let z = y; + x = z; + + drop(x); +} diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir new file mode 100644 index 000000000..d48b04e2d --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_79191.f.CopyProp.after.mir @@ -0,0 +1,29 @@ +// MIR for `f` after CopyProp + +fn f(_1: usize) -> usize { + debug a => _1; // in scope 0 at $DIR/dead_stores_79191.rs:+0:6: +0:11 + let mut _0: usize; // return place in scope 0 at $DIR/dead_stores_79191.rs:+0:23: +0:28 + let _2: usize; // in scope 0 at $DIR/dead_stores_79191.rs:+1:9: +1:10 + let mut _3: usize; // in scope 0 at $DIR/dead_stores_79191.rs:+3:9: +3:10 + let mut _4: usize; // in scope 0 at $DIR/dead_stores_79191.rs:+4:8: +4:9 + scope 1 { + debug b => _2; // in scope 1 at $DIR/dead_stores_79191.rs:+1:9: +1:10 + } + + bb0: { + _2 = _1; // scope 0 at $DIR/dead_stores_79191.rs:+1:13: +1:14 + _1 = const 5_usize; // scope 1 at $DIR/dead_stores_79191.rs:+2:5: +2:10 + _1 = _2; // scope 1 at $DIR/dead_stores_79191.rs:+3:5: +3:10 + StorageLive(_4); // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 + _4 = _1; // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 + _0 = id::(move _4) -> bb1; // scope 1 at $DIR/dead_stores_79191.rs:+4:5: +4:10 + // mir::Constant + // + span: $DIR/dead_stores_79191.rs:12:5: 12:7 + // + literal: Const { ty: fn(usize) -> usize {id::}, val: Value() } + } + + bb1: { + StorageDead(_4); // scope 1 at $DIR/dead_stores_79191.rs:+4:9: +4:10 + return; // scope 0 at $DIR/dead_stores_79191.rs:+5:2: +5:2 + } +} diff --git a/tests/mir-opt/copy-prop/dead_stores_79191.rs b/tests/mir-opt/copy-prop/dead_stores_79191.rs new file mode 100644 index 000000000..e3493b8b7 --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_79191.rs @@ -0,0 +1,17 @@ +// unit-test: CopyProp + +fn id(x: T) -> T { + x +} + +// EMIT_MIR dead_stores_79191.f.CopyProp.after.mir +fn f(mut a: usize) -> usize { + let b = a; + a = 5; + a = b; + id(a) +} + +fn main() { + f(0); +} diff --git a/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir new file mode 100644 index 000000000..727791f50 --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_better.f.CopyProp.after.mir @@ -0,0 +1,29 @@ +// MIR for `f` after CopyProp + +fn f(_1: usize) -> usize { + debug a => _1; // in scope 0 at $DIR/dead_stores_better.rs:+0:10: +0:15 + let mut _0: usize; // return place in scope 0 at $DIR/dead_stores_better.rs:+0:27: +0:32 + let _2: usize; // in scope 0 at $DIR/dead_stores_better.rs:+1:9: +1:10 + let mut _3: usize; // in scope 0 at $DIR/dead_stores_better.rs:+3:9: +3:10 + let mut _4: usize; // in scope 0 at $DIR/dead_stores_better.rs:+4:8: +4:9 + scope 1 { + debug b => _2; // in scope 1 at $DIR/dead_stores_better.rs:+1:9: +1:10 + } + + bb0: { + _2 = _1; // scope 0 at $DIR/dead_stores_better.rs:+1:13: +1:14 + _1 = const 5_usize; // scope 1 at $DIR/dead_stores_better.rs:+2:5: +2:10 + _1 = _2; // scope 1 at $DIR/dead_stores_better.rs:+3:5: +3:10 + StorageLive(_4); // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 + _4 = _1; // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 + _0 = id::(move _4) -> bb1; // scope 1 at $DIR/dead_stores_better.rs:+4:5: +4:10 + // mir::Constant + // + span: $DIR/dead_stores_better.rs:16:5: 16:7 + // + literal: Const { ty: fn(usize) -> usize {id::}, val: Value() } + } + + bb1: { + StorageDead(_4); // scope 1 at $DIR/dead_stores_better.rs:+4:9: +4:10 + return; // scope 0 at $DIR/dead_stores_better.rs:+5:2: +5:2 + } +} diff --git a/tests/mir-opt/copy-prop/dead_stores_better.rs b/tests/mir-opt/copy-prop/dead_stores_better.rs new file mode 100644 index 000000000..8465b3c98 --- /dev/null +++ b/tests/mir-opt/copy-prop/dead_stores_better.rs @@ -0,0 +1,21 @@ +// This is a copy of the `dead_stores_79191` test, except that we turn on DSE. This demonstrates +// that that pass enables this one to do more optimizations. + +// unit-test: CopyProp +// compile-flags: -Zmir-enable-passes=+DeadStoreElimination + +fn id(x: T) -> T { + x +} + +// EMIT_MIR dead_stores_better.f.CopyProp.after.mir +pub fn f(mut a: usize) -> usize { + let b = a; + a = 5; + a = b; + id(a) +} + +fn main() { + f(0); +} diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff new file mode 100644 index 000000000..97d0a01e0 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.diff @@ -0,0 +1,138 @@ +- // MIR for `main` before CopyProp ++ // MIR for `main` after CopyProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_107511.rs:+0:11: +0:11 + let mut _1: i32; // in scope 0 at $DIR/issue_107511.rs:+1:9: +1:16 + let mut _3: std::ops::Range; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 + let mut _4: std::ops::Range; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 + let mut _5: usize; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24 + let mut _6: &[i32]; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24 + let mut _7: &[i32; 4]; // in scope 0 at $DIR/issue_107511.rs:+6:17: +6:24 + let mut _9: (); // in scope 0 at $DIR/issue_107511.rs:+0:1: +9:2 + let _10: (); // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 + let mut _11: std::option::Option; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 + let mut _12: &mut std::ops::Range; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 + let mut _13: &mut std::ops::Range; // in scope 0 at $DIR/issue_107511.rs:+6:14: +6:24 + let mut _14: isize; // in scope 0 at $DIR/issue_107511.rs:+6:5: +8:6 + let mut _15: !; // in scope 0 at $DIR/issue_107511.rs:+6:5: +8:6 + let mut _17: i32; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20 + let _18: usize; // in scope 0 at $DIR/issue_107511.rs:+7:18: +7:19 + let mut _19: usize; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20 + let mut _20: bool; // in scope 0 at $DIR/issue_107511.rs:+7:16: +7:20 + scope 1 { + debug sum => _1; // in scope 1 at $DIR/issue_107511.rs:+1:9: +1:16 + let _2: [i32; 4]; // in scope 1 at $DIR/issue_107511.rs:+2:9: +2:10 + scope 2 { + debug a => _2; // in scope 2 at $DIR/issue_107511.rs:+2:9: +2:10 + let mut _8: std::ops::Range; // in scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 + scope 3 { + debug iter => _8; // in scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + let _16: usize; // in scope 3 at $DIR/issue_107511.rs:+6:9: +6:10 + scope 4 { + debug i => _16; // in scope 4 at $DIR/issue_107511.rs:+6:9: +6:10 + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue_107511.rs:+1:9: +1:16 + _1 = const 0_i32; // scope 0 at $DIR/issue_107511.rs:+1:19: +1:20 + StorageLive(_2); // scope 1 at $DIR/issue_107511.rs:+2:9: +2:10 + _2 = [const 0_i32, const 10_i32, const 20_i32, const 30_i32]; // scope 1 at $DIR/issue_107511.rs:+2:13: +2:28 + StorageLive(_3); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 + StorageLive(_4); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 + StorageLive(_5); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 + StorageLive(_6); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 + StorageLive(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 + _7 = &_2; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 + _6 = move _7 as &[i32] (Pointer(Unsize)); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 + StorageDead(_7); // scope 2 at $DIR/issue_107511.rs:+6:17: +6:18 + _5 = core::slice::::len(move _6) -> bb1; // scope 2 at $DIR/issue_107511.rs:+6:17: +6:24 + // mir::Constant + // + span: $DIR/issue_107511.rs:10:19: 10:22 + // + literal: Const { ty: for<'a> fn(&'a [i32]) -> usize {core::slice::::len}, val: Value() } + } + + bb1: { + StorageDead(_6); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24 + _4 = std::ops::Range:: { start: const 0_usize, end: move _5 }; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 + StorageDead(_5); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24 + _3 = as IntoIterator>::into_iter(move _4) -> bb2; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 + // mir::Constant + // + span: $DIR/issue_107511.rs:10:14: 10:24 + // + literal: Const { ty: fn(std::ops::Range) -> as IntoIterator>::IntoIter { as IntoIterator>::into_iter}, val: Value() } + } + + bb2: { + StorageDead(_4); // scope 2 at $DIR/issue_107511.rs:+6:23: +6:24 + StorageLive(_8); // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 + _8 = move _3; // scope 2 at $DIR/issue_107511.rs:+6:14: +6:24 + goto -> bb3; // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 + } + + bb3: { +- StorageLive(_10); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + StorageLive(_11); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + StorageLive(_12); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + StorageLive(_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + _13 = &mut _8; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + _12 = &mut (*_13); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + _11 = as Iterator>::next(move _12) -> bb4; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + // mir::Constant + // + span: $DIR/issue_107511.rs:10:14: 10:24 + // + literal: Const { ty: for<'a> fn(&'a mut std::ops::Range) -> Option< as Iterator>::Item> { as Iterator>::next}, val: Value() } + } + + bb4: { + StorageDead(_12); // scope 3 at $DIR/issue_107511.rs:+6:23: +6:24 + _14 = discriminant(_11); // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + } + + bb5: { +- StorageLive(_16); // scope 3 at $DIR/issue_107511.rs:+6:9: +6:10 + _16 = ((_11 as Some).0: usize); // scope 3 at $DIR/issue_107511.rs:+6:9: +6:10 + StorageLive(_17); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 +- StorageLive(_18); // scope 4 at $DIR/issue_107511.rs:+7:18: +7:19 +- _18 = _16; // scope 4 at $DIR/issue_107511.rs:+7:18: +7:19 + _19 = Len(_2); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 +- _20 = Lt(_18, _19); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 +- assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _18) -> bb8; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 ++ _20 = Lt(_16, _19); // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 ++ assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> bb8; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 + } + + bb6: { + unreachable; // scope 3 at $DIR/issue_107511.rs:+6:14: +6:24 + } + + bb7: { + _0 = const (); // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 + StorageDead(_13); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 + StorageDead(_11); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 +- StorageDead(_10); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 + StorageDead(_8); // scope 2 at $DIR/issue_107511.rs:+8:5: +8:6 + StorageDead(_3); // scope 2 at $DIR/issue_107511.rs:+8:5: +8:6 + StorageDead(_2); // scope 1 at $DIR/issue_107511.rs:+9:1: +9:2 + StorageDead(_1); // scope 0 at $DIR/issue_107511.rs:+9:1: +9:2 + return; // scope 0 at $DIR/issue_107511.rs:+9:2: +9:2 + } + + bb8: { +- _17 = _2[_18]; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 ++ _17 = _2[_16]; // scope 4 at $DIR/issue_107511.rs:+7:16: +7:20 + _1 = Add(_1, move _17); // scope 4 at $DIR/issue_107511.rs:+7:9: +7:20 + StorageDead(_17); // scope 4 at $DIR/issue_107511.rs:+7:19: +7:20 +- StorageDead(_18); // scope 4 at $DIR/issue_107511.rs:+7:20: +7:21 +- _10 = const (); // scope 4 at $DIR/issue_107511.rs:+6:25: +8:6 +- StorageDead(_16); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 + StorageDead(_13); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 + StorageDead(_11); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 +- StorageDead(_10); // scope 3 at $DIR/issue_107511.rs:+8:5: +8:6 +- _9 = const (); // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 + goto -> bb3; // scope 3 at $DIR/issue_107511.rs:+6:5: +8:6 + } + } + diff --git a/tests/mir-opt/copy-prop/issue_107511.rs b/tests/mir-opt/copy-prop/issue_107511.rs new file mode 100644 index 000000000..d593f2872 --- /dev/null +++ b/tests/mir-opt/copy-prop/issue_107511.rs @@ -0,0 +1,13 @@ +// unit-test: CopyProp + +// EMIT_MIR issue_107511.main.CopyProp.diff +fn main() { + let mut sum = 0; + let a = [0, 10, 20, 30]; + + // `i` is assigned in a loop. Only removing its `StorageDead` would mean that + // execution sees repeated `StorageLive`. This would be UB. + for i in 0..a.len() { + sum += a[i]; + } +} diff --git a/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff new file mode 100644 index 000000000..d76bf1cfe --- /dev/null +++ b/tests/mir-opt/copy-prop/move_arg.f.CopyProp.diff @@ -0,0 +1,40 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: T) -> () { + debug a => _1; // in scope 0 at $DIR/move_arg.rs:+0:19: +0:20 + let mut _0: (); // return place in scope 0 at $DIR/move_arg.rs:+0:25: +0:25 + let _2: T; // in scope 0 at $DIR/move_arg.rs:+1:9: +1:10 + let _3: (); // in scope 0 at $DIR/move_arg.rs:+2:5: +2:12 + let mut _4: T; // in scope 0 at $DIR/move_arg.rs:+2:7: +2:8 + let mut _5: T; // in scope 0 at $DIR/move_arg.rs:+2:10: +2:11 + scope 1 { +- debug b => _2; // in scope 1 at $DIR/move_arg.rs:+1:9: +1:10 ++ debug b => _1; // in scope 1 at $DIR/move_arg.rs:+1:9: +1:10 + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/move_arg.rs:+1:9: +1:10 +- _2 = _1; // scope 0 at $DIR/move_arg.rs:+1:13: +1:14 + StorageLive(_3); // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 +- StorageLive(_4); // scope 1 at $DIR/move_arg.rs:+2:7: +2:8 +- _4 = _1; // scope 1 at $DIR/move_arg.rs:+2:7: +2:8 +- StorageLive(_5); // scope 1 at $DIR/move_arg.rs:+2:10: +2:11 +- _5 = _2; // scope 1 at $DIR/move_arg.rs:+2:10: +2:11 +- _3 = g::(move _4, move _5) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 ++ _3 = g::(_1, _1) -> bb1; // scope 1 at $DIR/move_arg.rs:+2:5: +2:12 + // mir::Constant + // + span: $DIR/move_arg.rs:7:5: 7:6 + // + literal: Const { ty: fn(T, T) {g::}, val: Value() } + } + + bb1: { +- StorageDead(_5); // scope 1 at $DIR/move_arg.rs:+2:11: +2:12 +- StorageDead(_4); // scope 1 at $DIR/move_arg.rs:+2:11: +2:12 + StorageDead(_3); // scope 1 at $DIR/move_arg.rs:+2:12: +2:13 + _0 = const (); // scope 0 at $DIR/move_arg.rs:+0:25: +3:2 +- StorageDead(_2); // scope 0 at $DIR/move_arg.rs:+3:1: +3:2 + return; // scope 0 at $DIR/move_arg.rs:+3:2: +3:2 + } + } + diff --git a/tests/mir-opt/copy-prop/move_arg.rs b/tests/mir-opt/copy-prop/move_arg.rs new file mode 100644 index 000000000..40ae1d8f4 --- /dev/null +++ b/tests/mir-opt/copy-prop/move_arg.rs @@ -0,0 +1,15 @@ +// Test that we do not move multiple times from the same local. +// unit-test: CopyProp + +// EMIT_MIR move_arg.f.CopyProp.diff +pub fn f(a: T) { + let b = a; + g(a, b); +} + +#[inline(never)] +pub fn g(_: T, _: T) {} + +fn main() { + f(5) +} diff --git a/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff new file mode 100644 index 000000000..02308beb8 --- /dev/null +++ b/tests/mir-opt/copy-prop/move_projection.f.CopyProp.diff @@ -0,0 +1,31 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: Foo) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/move_projection.rs:+0:17: +0:21 + let mut _2: Foo; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { +- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _3 = move (_2.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL +- _0 = opaque::(move _1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44 ++ _3 = (_1.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL ++ _0 = opaque::(_1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44 + // mir::Constant + // + span: $DIR/move_projection.rs:19:28: 19:34 + // + literal: Const { ty: fn(Foo) -> bool {opaque::}, val: Value() } + } + + bb1: { + _0 = opaque::(move _3) -> bb2; // scope 0 at $DIR/move_projection.rs:+9:13: +9:44 + // mir::Constant + // + span: $DIR/move_projection.rs:22:28: 22:34 + // + literal: Const { ty: fn(u8) -> bool {opaque::}, val: Value() } + } + + bb2: { + return; // scope 0 at $DIR/move_projection.rs:+12:13: +12:21 + } + } + diff --git a/tests/mir-opt/copy-prop/move_projection.rs b/tests/mir-opt/copy-prop/move_projection.rs new file mode 100644 index 000000000..2a1bbae99 --- /dev/null +++ b/tests/mir-opt/copy-prop/move_projection.rs @@ -0,0 +1,34 @@ +// unit-test: CopyProp + +#![feature(custom_mir, core_intrinsics)] +#![allow(unused_assignments)] +extern crate core; +use core::intrinsics::mir::*; + +fn opaque(_: impl Sized) -> bool { true } + +struct Foo(u8); + +#[custom_mir(dialect = "analysis", phase = "post-cleanup")] +fn f(a: Foo) -> bool { + mir!( + { + let b = a; + // This is a move out of a copy, so must become a copy of `a.0`. + let c = Move(b.0); + Call(RET, bb1, opaque(Move(a))) + } + bb1 = { + Call(RET, ret, opaque(Move(c))) + } + ret = { + Return() + } + ) +} + +fn main() { + assert!(f(Foo(0))); +} + +// EMIT_MIR move_projection.f.CopyProp.diff diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff b/tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff new file mode 100644 index 000000000..61fdd6f8c --- /dev/null +++ b/tests/mir-opt/copy-prop/mutate_through_pointer.f.CopyProp.diff @@ -0,0 +1,19 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: bool) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/mutate_through_pointer.rs:+0:18: +0:22 + let mut _2: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: *const bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: *mut bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _3 = &raw const _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _4 = &raw mut (*_3); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + (*_4) = const false; // scope 0 at $DIR/mutate_through_pointer.rs:+5:9: +5:20 + _0 = _1; // scope 0 at $DIR/mutate_through_pointer.rs:+6:9: +6:16 + return; // scope 0 at $DIR/mutate_through_pointer.rs:+7:9: +7:17 + } + } + diff --git a/tests/mir-opt/copy-prop/mutate_through_pointer.rs b/tests/mir-opt/copy-prop/mutate_through_pointer.rs new file mode 100644 index 000000000..da142e339 --- /dev/null +++ b/tests/mir-opt/copy-prop/mutate_through_pointer.rs @@ -0,0 +1,32 @@ +// This attempts to mutate `a` via a pointer derived from `addr_of!(a)`. That is UB +// according to Miri. However, the decision to make this UB - and to allow +// rustc to rely on that fact for the purpose of optimizations - has not been +// finalized. +// +// As such, we include this test to ensure that copy prop does not rely on that +// fact. Specifically, if `addr_of!(a)` could not be used to modify a, it would +// be correct for CopyProp to replace all occurrences of `a` with `c` - but that +// would cause `f(true)` to output `false` instead of `true`. + +#![feature(custom_mir, core_intrinsics)] +#![allow(unused_assignments)] +extern crate core; +use core::intrinsics::mir::*; + +#[custom_mir(dialect = "analysis", phase = "post-cleanup")] +fn f(c: bool) -> bool { + mir!({ + let a = c; + let p = core::ptr::addr_of!(a); + let p2 = core::ptr::addr_of_mut!(*p); + *p2 = false; + RET = c; + Return() + }) +} + +fn main() { + assert_eq!(true, f(true)); +} + +// EMIT_MIR mutate_through_pointer.f.CopyProp.diff diff --git a/tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff b/tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff new file mode 100644 index 000000000..9760fd374 --- /dev/null +++ b/tests/mir-opt/copy-prop/non_dominate.f.CopyProp.diff @@ -0,0 +1,29 @@ +- // MIR for `f` before CopyProp ++ // MIR for `f` after CopyProp + + fn f(_1: bool) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/non_dominate.rs:+0:18: +0:22 + let mut _2: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: bool; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + goto -> bb1; // scope 0 at $DIR/non_dominate.rs:+4:11: +4:20 + } + + bb1: { + _3 = _1; // scope 0 at $DIR/non_dominate.rs:+5:17: +5:22 + switchInt(_3) -> [0: bb3, otherwise: bb2]; // scope 0 at $DIR/non_dominate.rs:+5:24: +5:58 + } + + bb2: { + _2 = _3; // scope 0 at $DIR/non_dominate.rs:+8:17: +8:22 + _1 = const false; // scope 0 at $DIR/non_dominate.rs:+8:24: +8:33 + goto -> bb1; // scope 0 at $DIR/non_dominate.rs:+8:35: +8:44 + } + + bb3: { + _0 = _2; // scope 0 at $DIR/non_dominate.rs:+9:17: +9:24 + return; // scope 0 at $DIR/non_dominate.rs:+9:26: +9:34 + } + } + diff --git a/tests/mir-opt/copy-prop/non_dominate.rs b/tests/mir-opt/copy-prop/non_dominate.rs new file mode 100644 index 000000000..c0ea838e1 --- /dev/null +++ b/tests/mir-opt/copy-prop/non_dominate.rs @@ -0,0 +1,26 @@ +// unit-test: CopyProp + +#![feature(custom_mir, core_intrinsics)] +#![allow(unused_assignments)] +extern crate core; +use core::intrinsics::mir::*; + +#[custom_mir(dialect = "analysis", phase = "post-cleanup")] +fn f(c: bool) -> bool { + mir!( + let a: bool; + let b: bool; + { Goto(bb1) } + bb1 = { b = c; match b { false => bb3, _ => bb2 }} + // This assignment to `a` does not dominate the use in `bb3`. + // It should not be replaced by `b`. + bb2 = { a = b; c = false; Goto(bb1) } + bb3 = { RET = a; Return() } + ) +} + +fn main() { + assert_eq!(true, f(true)); +} + +// EMIT_MIR non_dominate.f.CopyProp.diff diff --git a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff index a4ebd0c8c..944afed8f 100644 --- a/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff @@ -61,7 +61,7 @@ - assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_i32) -> bb2; // scope 4 at $DIR/checked.rs:+6:13: +6:18 + _9 = const i32::MAX; // scope 4 at $DIR/checked.rs:+6:13: +6:14 + _10 = CheckedAdd(const i32::MAX, const 1_i32); // scope 4 at $DIR/checked.rs:+6:13: +6:18 -+ assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", const i32::MAX, const 1_i32) -> bb2; // scope 4 at $DIR/checked.rs:+6:13: +6:18 ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const i32::MAX, const 1_i32) -> bb2; // scope 4 at $DIR/checked.rs:+6:13: +6:18 } bb2: { diff --git a/tests/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff deleted file mode 100644 index fce18fae4..000000000 --- a/tests/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff +++ /dev/null @@ -1,61 +0,0 @@ -- // MIR for `main` before DataflowConstProp -+ // MIR for `main` after DataflowConstProp - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum.rs:+0:11: +0:11 - let _1: E; // in scope 0 at $DIR/enum.rs:+1:9: +1:10 - let mut _3: isize; // in scope 0 at $DIR/enum.rs:+2:23: +2:31 - scope 1 { - debug e => _1; // in scope 1 at $DIR/enum.rs:+1:9: +1:10 - let _2: i32; // in scope 1 at $DIR/enum.rs:+2:9: +2:10 - let _4: i32; // in scope 1 at $DIR/enum.rs:+2:29: +2:30 - let _5: i32; // in scope 1 at $DIR/enum.rs:+2:44: +2:45 - scope 2 { - debug x => _2; // in scope 2 at $DIR/enum.rs:+2:9: +2:10 - } - scope 3 { - debug x => _4; // in scope 3 at $DIR/enum.rs:+2:29: +2:30 - } - scope 4 { - debug x => _5; // in scope 4 at $DIR/enum.rs:+2:44: +2:45 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/enum.rs:+1:9: +1:10 - Deinit(_1); // scope 0 at $DIR/enum.rs:+1:13: +1:21 - ((_1 as V1).0: i32) = const 0_i32; // scope 0 at $DIR/enum.rs:+1:13: +1:21 - discriminant(_1) = 0; // scope 0 at $DIR/enum.rs:+1:13: +1:21 - StorageLive(_2); // scope 1 at $DIR/enum.rs:+2:9: +2:10 - _3 = discriminant(_1); // scope 1 at $DIR/enum.rs:+2:19: +2:20 - switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 1 at $DIR/enum.rs:+2:13: +2:20 - } - - bb1: { - StorageLive(_5); // scope 1 at $DIR/enum.rs:+2:44: +2:45 - _5 = ((_1 as V2).0: i32); // scope 1 at $DIR/enum.rs:+2:44: +2:45 - _2 = _5; // scope 4 at $DIR/enum.rs:+2:50: +2:51 - StorageDead(_5); // scope 1 at $DIR/enum.rs:+2:50: +2:51 - goto -> bb4; // scope 1 at $DIR/enum.rs:+2:50: +2:51 - } - - bb2: { - unreachable; // scope 1 at $DIR/enum.rs:+2:19: +2:20 - } - - bb3: { - StorageLive(_4); // scope 1 at $DIR/enum.rs:+2:29: +2:30 - _4 = ((_1 as V1).0: i32); // scope 1 at $DIR/enum.rs:+2:29: +2:30 - _2 = _4; // scope 3 at $DIR/enum.rs:+2:35: +2:36 - StorageDead(_4); // scope 1 at $DIR/enum.rs:+2:35: +2:36 - goto -> bb4; // scope 1 at $DIR/enum.rs:+2:35: +2:36 - } - - bb4: { - _0 = const (); // scope 0 at $DIR/enum.rs:+0:11: +3:2 - StorageDead(_2); // scope 1 at $DIR/enum.rs:+3:1: +3:2 - StorageDead(_1); // scope 0 at $DIR/enum.rs:+3:1: +3:2 - return; // scope 0 at $DIR/enum.rs:+3:2: +3:2 - } - } - diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff new file mode 100644 index 000000000..c4002d65e --- /dev/null +++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff @@ -0,0 +1,82 @@ +- // MIR for `multiple` before DataflowConstProp ++ // MIR for `multiple` after DataflowConstProp + + fn multiple(_1: bool, _2: u8) -> () { + debug x => _1; // in scope 0 at $DIR/enum.rs:+0:13: +0:14 + debug i => _2; // in scope 0 at $DIR/enum.rs:+0:22: +0:23 + let mut _0: (); // return place in scope 0 at $DIR/enum.rs:+0:29: +0:29 + let _3: std::option::Option; // in scope 0 at $DIR/enum.rs:+1:9: +1:10 + let mut _4: bool; // in scope 0 at $DIR/enum.rs:+1:16: +1:17 + let mut _5: u8; // in scope 0 at $DIR/enum.rs:+2:14: +2:15 + let mut _7: isize; // in scope 0 at $DIR/enum.rs:+9:23: +9:30 + scope 1 { + debug e => _3; // in scope 1 at $DIR/enum.rs:+1:9: +1:10 + let _6: u8; // in scope 1 at $DIR/enum.rs:+9:9: +9:10 + let _8: u8; // in scope 1 at $DIR/enum.rs:+9:28: +9:29 + scope 2 { + debug x => _6; // in scope 2 at $DIR/enum.rs:+9:9: +9:10 + let _9: u8; // in scope 2 at $DIR/enum.rs:+11:9: +11:10 + scope 4 { + debug y => _9; // in scope 4 at $DIR/enum.rs:+11:9: +11:10 + } + } + scope 3 { + debug i => _8; // in scope 3 at $DIR/enum.rs:+9:28: +9:29 + } + } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/enum.rs:+1:9: +1:10 + StorageLive(_4); // scope 0 at $DIR/enum.rs:+1:16: +1:17 + _4 = _1; // scope 0 at $DIR/enum.rs:+1:16: +1:17 + switchInt(move _4) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/enum.rs:+1:16: +1:17 + } + + bb1: { + StorageLive(_5); // scope 0 at $DIR/enum.rs:+2:14: +2:15 + _5 = _2; // scope 0 at $DIR/enum.rs:+2:14: +2:15 + _3 = Option::::Some(move _5); // scope 0 at $DIR/enum.rs:+2:9: +2:16 + StorageDead(_5); // scope 0 at $DIR/enum.rs:+2:15: +2:16 + goto -> bb3; // scope 0 at $DIR/enum.rs:+1:13: +5:6 + } + + bb2: { + _3 = Option::::None; // scope 0 at $DIR/enum.rs:+4:9: +4:13 + goto -> bb3; // scope 0 at $DIR/enum.rs:+1:13: +5:6 + } + + bb3: { + StorageDead(_4); // scope 0 at $DIR/enum.rs:+5:5: +5:6 + StorageLive(_6); // scope 1 at $DIR/enum.rs:+9:9: +9:10 + _7 = discriminant(_3); // scope 1 at $DIR/enum.rs:+9:19: +9:20 + switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5]; // scope 1 at $DIR/enum.rs:+9:13: +9:20 + } + + bb4: { + _6 = const 0_u8; // scope 1 at $DIR/enum.rs:+9:45: +9:46 + goto -> bb7; // scope 1 at $DIR/enum.rs:+9:45: +9:46 + } + + bb5: { + unreachable; // scope 1 at $DIR/enum.rs:+9:19: +9:20 + } + + bb6: { + StorageLive(_8); // scope 1 at $DIR/enum.rs:+9:28: +9:29 + _8 = ((_3 as Some).0: u8); // scope 1 at $DIR/enum.rs:+9:28: +9:29 + _6 = _8; // scope 3 at $DIR/enum.rs:+9:34: +9:35 + StorageDead(_8); // scope 1 at $DIR/enum.rs:+9:34: +9:35 + goto -> bb7; // scope 1 at $DIR/enum.rs:+9:34: +9:35 + } + + bb7: { + StorageLive(_9); // scope 2 at $DIR/enum.rs:+11:9: +11:10 + _9 = _6; // scope 2 at $DIR/enum.rs:+11:13: +11:14 + _0 = const (); // scope 0 at $DIR/enum.rs:+0:29: +12:2 + StorageDead(_9); // scope 2 at $DIR/enum.rs:+12:1: +12:2 + StorageDead(_6); // scope 1 at $DIR/enum.rs:+12:1: +12:2 + StorageDead(_3); // scope 0 at $DIR/enum.rs:+12:1: +12:2 + return; // scope 0 at $DIR/enum.rs:+12:2: +12:2 + } + } + diff --git a/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff new file mode 100644 index 000000000..038e6c6bd --- /dev/null +++ b/tests/mir-opt/dataflow-const-prop/enum.mutate_discriminant.DataflowConstProp.diff @@ -0,0 +1,26 @@ +- // MIR for `mutate_discriminant` before DataflowConstProp ++ // MIR for `mutate_discriminant` after DataflowConstProp + + fn mutate_discriminant() -> u8 { + let mut _0: u8; // return place in scope 0 at $DIR/enum.rs:+0:29: +0:31 + let mut _1: std::option::Option; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: isize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + discriminant(_1) = 1; // scope 0 at $DIR/enum.rs:+4:13: +4:34 + (((_1 as variant#1).0: NonZeroUsize).0: usize) = const 0_usize; // scope 0 at $DIR/enum.rs:+6:13: +6:64 + _2 = discriminant(_1); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + switchInt(_2) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/enum.rs:+9:13: +12:14 + } + + bb1: { + _0 = const 1_u8; // scope 0 at $DIR/enum.rs:+15:13: +15:20 + return; // scope 0 at $DIR/enum.rs:+16:13: +16:21 + } + + bb2: { + _0 = const 2_u8; // scope 0 at $DIR/enum.rs:+19:13: +19:20 + unreachable; // scope 0 at $DIR/enum.rs:+20:13: +20:26 + } + } + diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs index 13288577d..79a20d7ef 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.rs +++ b/tests/mir-opt/dataflow-const-prop/enum.rs @@ -1,13 +1,68 @@ // unit-test: DataflowConstProp -// Not trackable, because variants could be aliased. +#![feature(custom_mir, core_intrinsics, rustc_attrs)] + +use std::intrinsics::mir::*; + enum E { V1(i32), V2(i32) } -// EMIT_MIR enum.main.DataflowConstProp.diff -fn main() { +// EMIT_MIR enum.simple.DataflowConstProp.diff +fn simple() { let e = E::V1(0); let x = match e { E::V1(x) => x, E::V2(x) => x }; } + +#[rustc_layout_scalar_valid_range_start(1)] +#[rustc_nonnull_optimization_guaranteed] +struct NonZeroUsize(usize); + +// EMIT_MIR enum.mutate_discriminant.DataflowConstProp.diff +#[custom_mir(dialect = "runtime", phase = "post-cleanup")] +fn mutate_discriminant() -> u8 { + mir!( + let x: Option; + { + SetDiscriminant(x, 1); + // This assignment overwrites the niche in which the discriminant is stored. + place!(Field(Field(Variant(x, 1), 0), 0)) = 0_usize; + // So we cannot know the value of this discriminant. + let a = Discriminant(x); + match a { + 0 => bb1, + _ => bad, + } + } + bb1 = { + RET = 1; + Return() + } + bad = { + RET = 2; + Unreachable() + } + ) +} + +// EMIT_MIR enum.multiple.DataflowConstProp.diff +fn multiple(x: bool, i: u8) { + let e = if x { + Some(i) + } else { + None + }; + // The dataflow state must have: + // discriminant(e) => Top + // (e as Some).0 => Top + let x = match e { Some(i) => i, None => 0 }; + // Therefore, `x` should be `Top` here, and no replacement shall happen. + let y = x; +} + +fn main() { + simple(); + mutate_discriminant(); + multiple(false, 5); +} diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff new file mode 100644 index 000000000..22bdc35d6 --- /dev/null +++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.diff @@ -0,0 +1,63 @@ +- // MIR for `simple` before DataflowConstProp ++ // MIR for `simple` after DataflowConstProp + + fn simple() -> () { + let mut _0: (); // return place in scope 0 at $DIR/enum.rs:+0:13: +0:13 + let _1: E; // in scope 0 at $DIR/enum.rs:+1:9: +1:10 + let mut _3: isize; // in scope 0 at $DIR/enum.rs:+2:23: +2:31 + scope 1 { + debug e => _1; // in scope 1 at $DIR/enum.rs:+1:9: +1:10 + let _2: i32; // in scope 1 at $DIR/enum.rs:+2:9: +2:10 + let _4: i32; // in scope 1 at $DIR/enum.rs:+2:29: +2:30 + let _5: i32; // in scope 1 at $DIR/enum.rs:+2:44: +2:45 + scope 2 { + debug x => _2; // in scope 2 at $DIR/enum.rs:+2:9: +2:10 + } + scope 3 { + debug x => _4; // in scope 3 at $DIR/enum.rs:+2:29: +2:30 + } + scope 4 { + debug x => _5; // in scope 4 at $DIR/enum.rs:+2:44: +2:45 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum.rs:+1:9: +1:10 + _1 = E::V1(const 0_i32); // scope 0 at $DIR/enum.rs:+1:13: +1:21 + StorageLive(_2); // scope 1 at $DIR/enum.rs:+2:9: +2:10 +- _3 = discriminant(_1); // scope 1 at $DIR/enum.rs:+2:19: +2:20 +- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 1 at $DIR/enum.rs:+2:13: +2:20 ++ _3 = const 0_isize; // scope 1 at $DIR/enum.rs:+2:19: +2:20 ++ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; // scope 1 at $DIR/enum.rs:+2:13: +2:20 + } + + bb1: { + StorageLive(_5); // scope 1 at $DIR/enum.rs:+2:44: +2:45 + _5 = ((_1 as V2).0: i32); // scope 1 at $DIR/enum.rs:+2:44: +2:45 + _2 = _5; // scope 4 at $DIR/enum.rs:+2:50: +2:51 + StorageDead(_5); // scope 1 at $DIR/enum.rs:+2:50: +2:51 + goto -> bb4; // scope 1 at $DIR/enum.rs:+2:50: +2:51 + } + + bb2: { + unreachable; // scope 1 at $DIR/enum.rs:+2:19: +2:20 + } + + bb3: { + StorageLive(_4); // scope 1 at $DIR/enum.rs:+2:29: +2:30 +- _4 = ((_1 as V1).0: i32); // scope 1 at $DIR/enum.rs:+2:29: +2:30 +- _2 = _4; // scope 3 at $DIR/enum.rs:+2:35: +2:36 ++ _4 = const 0_i32; // scope 1 at $DIR/enum.rs:+2:29: +2:30 ++ _2 = const 0_i32; // scope 3 at $DIR/enum.rs:+2:35: +2:36 + StorageDead(_4); // scope 1 at $DIR/enum.rs:+2:35: +2:36 + goto -> bb4; // scope 1 at $DIR/enum.rs:+2:35: +2:36 + } + + bb4: { + _0 = const (); // scope 0 at $DIR/enum.rs:+0:13: +3:2 + StorageDead(_2); // scope 1 at $DIR/enum.rs:+3:1: +3:2 + StorageDead(_1); // scope 0 at $DIR/enum.rs:+3:1: +3:2 + return; // scope 0 at $DIR/enum.rs:+3:2: +3:2 + } + } + diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff index 02aafd7ac..29781e9ce 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff @@ -5,34 +5,34 @@ let mut _0: (); // return place in scope 0 at $DIR/inherit_overflow.rs:+0:11: +0:11 let mut _1: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 let mut _2: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + let mut _3: u8; // in scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 scope 1 { } - scope 2 (inlined ::add) { // at $DIR/inherit_overflow.rs:7:13: 7:47 - debug self => _1; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - debug other => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - let mut _3: u8; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - let mut _4: u8; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - let mut _5: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + scope 2 (inlined ::add) { // at $DIR/inherit_overflow.rs:8:13: 8:47 + debug self => _2; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + debug other => _3; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + let mut _4: (u8, bool); // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL } bb0: { StorageLive(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - _1 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 StorageLive(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - _2 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - _3 = const u8::MAX; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - _4 = const 1_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - _5 = CheckedAdd(const u8::MAX, const 1_u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + _2 = const u8::MAX; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageLive(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + _3 = const 1_u8; // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 +- _4 = CheckedAdd(_2, _3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL +- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL ++ _4 = CheckedAdd(const u8::MAX, const 1_u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL ++ assert(!const true, "attempt to compute `{} + {}`, which would overflow", const u8::MAX, const 1_u8) -> bb1; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL } bb1: { - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL +- _1 = move (_4.0: u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL ++ _1 = const 0_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 StorageDead(_2); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 - StorageDead(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:13: +3:47 + StorageDead(_1); // scope 0 at $DIR/inherit_overflow.rs:+3:47: +3:48 + _0 = const (); // scope 0 at $DIR/inherit_overflow.rs:+0:11: +4:2 return; // scope 0 at $DIR/inherit_overflow.rs:+4:2: +4:2 } } diff --git a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs index 2f2d9d010..f4aba60f0 100644 --- a/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs +++ b/tests/mir-opt/dataflow-const-prop/inherit_overflow.rs @@ -1,8 +1,9 @@ -// compile-flags: -Zunsound-mir-opts +// unit-test: DataflowConstProp +// compile-flags: -Zmir-enable-passes=+Inline // EMIT_MIR inherit_overflow.main.DataflowConstProp.diff fn main() { - // After inlining, this will contain a `CheckedBinaryOp`. The overflow - // must be ignored by the constant propagation to avoid triggering a panic. + // After inlining, this will contain a `CheckedBinaryOp`. + // Propagating the overflow is ok as codegen will just skip emitting the panic. let _ = ::add(255, 1); } diff --git a/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff index f66b00a9a..8f045eedf 100644 --- a/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff @@ -17,8 +17,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/repr_transparent.rs:+1:9: +1:10 - Deinit(_1); // scope 0 at $DIR/repr_transparent.rs:+1:13: +1:19 - (_1.0: i32) = const 0_i32; // scope 0 at $DIR/repr_transparent.rs:+1:13: +1:19 + _1 = I32(const 0_i32); // scope 0 at $DIR/repr_transparent.rs:+1:13: +1:19 StorageLive(_2); // scope 1 at $DIR/repr_transparent.rs:+2:9: +2:10 StorageLive(_3); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:26 StorageLive(_4); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:20 @@ -31,9 +30,8 @@ + _3 = const 0_i32; // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:26 StorageDead(_5); // scope 1 at $DIR/repr_transparent.rs:+2:25: +2:26 StorageDead(_4); // scope 1 at $DIR/repr_transparent.rs:+2:25: +2:26 - Deinit(_2); // scope 1 at $DIR/repr_transparent.rs:+2:13: +2:27 -- (_2.0: i32) = move _3; // scope 1 at $DIR/repr_transparent.rs:+2:13: +2:27 -+ (_2.0: i32) = const 0_i32; // scope 1 at $DIR/repr_transparent.rs:+2:13: +2:27 +- _2 = I32(move _3); // scope 1 at $DIR/repr_transparent.rs:+2:13: +2:27 ++ _2 = I32(const 0_i32); // scope 1 at $DIR/repr_transparent.rs:+2:13: +2:27 StorageDead(_3); // scope 1 at $DIR/repr_transparent.rs:+2:26: +2:27 _0 = const (); // scope 0 at $DIR/repr_transparent.rs:+0:11: +3:2 StorageDead(_2); // scope 1 at $DIR/repr_transparent.rs:+3:1: +3:2 diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff index 8126d4b85..004643e36 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff @@ -23,9 +23,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/sibling_ptr.rs:+1:9: +1:14 - Deinit(_1); // scope 0 at $DIR/sibling_ptr.rs:+1:27: +1:33 - (_1.0: u8) = const 0_u8; // scope 0 at $DIR/sibling_ptr.rs:+1:27: +1:33 - (_1.1: u8) = const 0_u8; // scope 0 at $DIR/sibling_ptr.rs:+1:27: +1:33 + _1 = (const 0_u8, const 0_u8); // scope 0 at $DIR/sibling_ptr.rs:+1:27: +1:33 StorageLive(_2); // scope 1 at $DIR/sibling_ptr.rs:+2:5: +5:6 StorageLive(_3); // scope 2 at $DIR/sibling_ptr.rs:+3:13: +3:14 _3 = &raw mut (_1.0: u8); // scope 2 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL @@ -34,7 +32,7 @@ _5 = _3; // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:11 _4 = ptr::mut_ptr::::add(move _5, const 1_usize) -> bb1; // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:18 // mir::Constant - // + span: $DIR/sibling_ptr.rs:8:12: 8:15 + // + span: $DIR/sibling_ptr.rs:15:12: 15:15 // + literal: Const { ty: unsafe fn(*mut u8, usize) -> *mut u8 {ptr::mut_ptr::::add}, val: Value() } } diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs index 87ef00d18..6dfb3a4ed 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs @@ -1,3 +1,10 @@ +// This attempts to modify `x.1` via a pointer derived from `addr_of_mut!(x.0)`. +// According to Miri, that is UB. However, T-opsem has not finalized that +// decision and as such we cannot rely on it in optimizations. Consequently, +// DataflowConstProp must treat the `addr_of_mut!(x.0)` as potentially being +// used to modify `x.1` - if it did not, then it might incorrectly assume that it +// can infer the value of `x.1` at the end of this function. + // unit-test: DataflowConstProp // EMIT_MIR sibling_ptr.main.DataflowConstProp.diff @@ -7,5 +14,5 @@ fn main() { let p = std::ptr::addr_of_mut!(x.0); *p.add(1) = 1; } - let x1 = x.1; // should not be propagated + let x1 = x.1; // should not be propagated } diff --git a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff index cfb2706c1..53c62c081 100644 --- a/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff @@ -21,8 +21,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/struct.rs:+1:9: +1:14 - Deinit(_1); // scope 0 at $DIR/struct.rs:+1:17: +1:21 - (_1.0: i32) = const 1_i32; // scope 0 at $DIR/struct.rs:+1:17: +1:21 + _1 = S(const 1_i32); // scope 0 at $DIR/struct.rs:+1:17: +1:21 StorageLive(_2); // scope 1 at $DIR/struct.rs:+2:9: +2:10 StorageLive(_3); // scope 1 at $DIR/struct.rs:+2:13: +2:16 - _3 = (_1.0: i32); // scope 1 at $DIR/struct.rs:+2:13: +2:16 diff --git a/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff index e028def00..8ce4ce4ba 100644 --- a/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff @@ -25,9 +25,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/tuple.rs:+1:9: +1:14 - Deinit(_1); // scope 0 at $DIR/tuple.rs:+1:17: +1:23 - (_1.0: i32) = const 1_i32; // scope 0 at $DIR/tuple.rs:+1:17: +1:23 - (_1.1: i32) = const 2_i32; // scope 0 at $DIR/tuple.rs:+1:17: +1:23 + _1 = (const 1_i32, const 2_i32); // scope 0 at $DIR/tuple.rs:+1:17: +1:23 StorageLive(_2); // scope 1 at $DIR/tuple.rs:+2:9: +2:10 StorageLive(_3); // scope 1 at $DIR/tuple.rs:+2:13: +2:22 StorageLive(_4); // scope 1 at $DIR/tuple.rs:+2:13: +2:16 @@ -43,9 +41,7 @@ - _2 = Add(move _3, const 3_i32); // scope 1 at $DIR/tuple.rs:+2:13: +2:26 + _2 = const 6_i32; // scope 1 at $DIR/tuple.rs:+2:13: +2:26 StorageDead(_3); // scope 1 at $DIR/tuple.rs:+2:25: +2:26 - Deinit(_1); // scope 2 at $DIR/tuple.rs:+3:5: +3:15 - (_1.0: i32) = const 2_i32; // scope 2 at $DIR/tuple.rs:+3:5: +3:15 - (_1.1: i32) = const 3_i32; // scope 2 at $DIR/tuple.rs:+3:5: +3:15 + _1 = (const 2_i32, const 3_i32); // scope 2 at $DIR/tuple.rs:+3:5: +3:15 StorageLive(_6); // scope 2 at $DIR/tuple.rs:+4:9: +4:10 StorageLive(_7); // scope 2 at $DIR/tuple.rs:+4:13: +4:22 StorageLive(_8); // scope 2 at $DIR/tuple.rs:+4:13: +4:16 diff --git a/tests/mir-opt/deaggregator_test.bar.Deaggregator.diff b/tests/mir-opt/deaggregator_test.bar.Deaggregator.diff deleted file mode 100644 index db136485a..000000000 --- a/tests/mir-opt/deaggregator_test.bar.Deaggregator.diff +++ /dev/null @@ -1,21 +0,0 @@ -- // MIR for `bar` before Deaggregator -+ // MIR for `bar` after Deaggregator - - fn bar(_1: usize) -> Baz { - debug a => _1; // in scope 0 at $DIR/deaggregator_test.rs:+0:8: +0:9 - let mut _0: Baz; // return place in scope 0 at $DIR/deaggregator_test.rs:+0:21: +0:24 - let mut _2: usize; // in scope 0 at $DIR/deaggregator_test.rs:+1:14: +1:15 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/deaggregator_test.rs:+1:14: +1:15 - _2 = _1; // scope 0 at $DIR/deaggregator_test.rs:+1:14: +1:15 -- _0 = Baz { x: move _2, y: const 0f32, z: const false }; // scope 0 at $DIR/deaggregator_test.rs:+1:5: +1:35 -+ Deinit(_0); // scope 0 at $DIR/deaggregator_test.rs:+1:5: +1:35 -+ (_0.0: usize) = move _2; // scope 0 at $DIR/deaggregator_test.rs:+1:5: +1:35 -+ (_0.1: f32) = const 0f32; // scope 0 at $DIR/deaggregator_test.rs:+1:5: +1:35 -+ (_0.2: bool) = const false; // scope 0 at $DIR/deaggregator_test.rs:+1:5: +1:35 - StorageDead(_2); // scope 0 at $DIR/deaggregator_test.rs:+1:34: +1:35 - return; // scope 0 at $DIR/deaggregator_test.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/deaggregator_test.rs b/tests/mir-opt/deaggregator_test.rs deleted file mode 100644 index ee59402af..000000000 --- a/tests/mir-opt/deaggregator_test.rs +++ /dev/null @@ -1,17 +0,0 @@ -// unit-test: Deaggregator - -struct Baz { - x: usize, - y: f32, - z: bool, -} - -// EMIT_MIR deaggregator_test.bar.Deaggregator.diff -fn bar(a: usize) -> Baz { - Baz { x: a, y: 0.0, z: false } -} - -fn main() { - // Make sure the function actually gets instantiated. - bar(0); -} diff --git a/tests/mir-opt/deaggregator_test_enum.bar.Deaggregator.diff b/tests/mir-opt/deaggregator_test_enum.bar.Deaggregator.diff deleted file mode 100644 index f28c2b482..000000000 --- a/tests/mir-opt/deaggregator_test_enum.bar.Deaggregator.diff +++ /dev/null @@ -1,20 +0,0 @@ -- // MIR for `bar` before Deaggregator -+ // MIR for `bar` after Deaggregator - - fn bar(_1: usize) -> Baz { - debug a => _1; // in scope 0 at $DIR/deaggregator_test_enum.rs:+0:8: +0:9 - let mut _0: Baz; // return place in scope 0 at $DIR/deaggregator_test_enum.rs:+0:21: +0:24 - let mut _2: usize; // in scope 0 at $DIR/deaggregator_test_enum.rs:+1:19: +1:20 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/deaggregator_test_enum.rs:+1:19: +1:20 - _2 = _1; // scope 0 at $DIR/deaggregator_test_enum.rs:+1:19: +1:20 -- _0 = Baz::Foo { x: move _2 }; // scope 0 at $DIR/deaggregator_test_enum.rs:+1:5: +1:22 -+ Deinit(_0); // scope 0 at $DIR/deaggregator_test_enum.rs:+1:5: +1:22 -+ ((_0 as Foo).0: usize) = move _2; // scope 0 at $DIR/deaggregator_test_enum.rs:+1:5: +1:22 -+ discriminant(_0) = 1; // scope 0 at $DIR/deaggregator_test_enum.rs:+1:5: +1:22 - StorageDead(_2); // scope 0 at $DIR/deaggregator_test_enum.rs:+1:21: +1:22 - return; // scope 0 at $DIR/deaggregator_test_enum.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/deaggregator_test_enum.rs b/tests/mir-opt/deaggregator_test_enum.rs deleted file mode 100644 index ea402dafd..000000000 --- a/tests/mir-opt/deaggregator_test_enum.rs +++ /dev/null @@ -1,19 +0,0 @@ -// unit-test: Deaggregator - -enum Baz { - Empty, - Foo { x: usize }, -} - -// EMIT_MIR deaggregator_test_enum.bar.Deaggregator.diff -fn bar(a: usize) -> Baz { - Baz::Foo { x: a } -} - -fn main() { - let x = bar(10); - match x { - Baz::Empty => println!("empty"), - Baz::Foo { x } => println!("{}", x), - }; -} diff --git a/tests/mir-opt/deaggregator_test_enum_2.rs b/tests/mir-opt/deaggregator_test_enum_2.rs deleted file mode 100644 index 955c31732..000000000 --- a/tests/mir-opt/deaggregator_test_enum_2.rs +++ /dev/null @@ -1,21 +0,0 @@ -// unit-test: Deaggregator -// Test that deaggregate fires in more than one basic block - -enum Foo { - A(i32), - B(i32), -} - -// EMIT_MIR deaggregator_test_enum_2.test1.Deaggregator.diff -fn test1(x: bool, y: i32) -> Foo { - if x { - Foo::A(y) - } else { - Foo::B(y) - } -} - -fn main() { - // Make sure the function actually gets instantiated. - test1(false, 0); -} diff --git a/tests/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff b/tests/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff deleted file mode 100644 index 210d3849e..000000000 --- a/tests/mir-opt/deaggregator_test_enum_2.test1.Deaggregator.diff +++ /dev/null @@ -1,45 +0,0 @@ -- // MIR for `test1` before Deaggregator -+ // MIR for `test1` after Deaggregator - - fn test1(_1: bool, _2: i32) -> Foo { - debug x => _1; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:+0:10: +0:11 - debug y => _2; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:+0:19: +0:20 - let mut _0: Foo; // return place in scope 0 at $DIR/deaggregator_test_enum_2.rs:+0:30: +0:33 - let mut _3: bool; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:+1:8: +1:9 - let mut _4: i32; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:16: +2:17 - let mut _5: i32; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:16: +4:17 - - bb0: { - StorageLive(_3); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+1:8: +1:9 - switchInt(move _3) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+1:8: +1:9 - } - - bb1: { - StorageLive(_4); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:16: +2:17 - _4 = _2; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:16: +2:17 -- _0 = Foo::A(move _4); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:9: +2:18 -+ Deinit(_0); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:9: +2:18 -+ ((_0 as A).0: i32) = move _4; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:9: +2:18 -+ discriminant(_0) = 0; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:9: +2:18 - StorageDead(_4); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+2:17: +2:18 - goto -> bb3; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+1:5: +5:6 - } - - bb2: { - StorageLive(_5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:16: +4:17 - _5 = _2; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:16: +4:17 -- _0 = Foo::B(move _5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:9: +4:18 -+ Deinit(_0); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:9: +4:18 -+ ((_0 as B).0: i32) = move _5; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:9: +4:18 -+ discriminant(_0) = 1; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:9: +4:18 - StorageDead(_5); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+4:17: +4:18 - goto -> bb3; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+1:5: +5:6 - } - - bb3: { - StorageDead(_3); // scope 0 at $DIR/deaggregator_test_enum_2.rs:+5:5: +5:6 - return; // scope 0 at $DIR/deaggregator_test_enum_2.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/deaggregator_test_multiple.rs b/tests/mir-opt/deaggregator_test_multiple.rs deleted file mode 100644 index 46305fe21..000000000 --- a/tests/mir-opt/deaggregator_test_multiple.rs +++ /dev/null @@ -1,17 +0,0 @@ -// unit-test: Deaggregator -// Test that deaggregate fires more than once per block - -enum Foo { - A(i32), - B, -} - -// EMIT_MIR deaggregator_test_multiple.test.Deaggregator.diff -fn test(x: i32) -> [Foo; 2] { - [Foo::A(x), Foo::A(x)] -} - -fn main() { - // Make sure the function actually gets instantiated. - test(0); -} diff --git a/tests/mir-opt/deaggregator_test_multiple.test.Deaggregator.diff b/tests/mir-opt/deaggregator_test_multiple.test.Deaggregator.diff deleted file mode 100644 index cf5da273c..000000000 --- a/tests/mir-opt/deaggregator_test_multiple.test.Deaggregator.diff +++ /dev/null @@ -1,35 +0,0 @@ -- // MIR for `test` before Deaggregator -+ // MIR for `test` after Deaggregator - - fn test(_1: i32) -> [Foo; 2] { - debug x => _1; // in scope 0 at $DIR/deaggregator_test_multiple.rs:+0:9: +0:10 - let mut _0: [Foo; 2]; // return place in scope 0 at $DIR/deaggregator_test_multiple.rs:+0:20: +0:28 - let mut _2: Foo; // in scope 0 at $DIR/deaggregator_test_multiple.rs:+1:6: +1:15 - let mut _3: i32; // in scope 0 at $DIR/deaggregator_test_multiple.rs:+1:13: +1:14 - let mut _4: Foo; // in scope 0 at $DIR/deaggregator_test_multiple.rs:+1:17: +1:26 - let mut _5: i32; // in scope 0 at $DIR/deaggregator_test_multiple.rs:+1:24: +1:25 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:6: +1:15 - StorageLive(_3); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:13: +1:14 - _3 = _1; // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:13: +1:14 -- _2 = Foo::A(move _3); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:6: +1:15 -+ Deinit(_2); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:6: +1:15 -+ ((_2 as A).0: i32) = move _3; // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:6: +1:15 -+ discriminant(_2) = 0; // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:6: +1:15 - StorageDead(_3); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:14: +1:15 - StorageLive(_4); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:17: +1:26 - StorageLive(_5); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:24: +1:25 - _5 = _1; // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:24: +1:25 -- _4 = Foo::A(move _5); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:17: +1:26 -+ Deinit(_4); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:17: +1:26 -+ ((_4 as A).0: i32) = move _5; // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:17: +1:26 -+ discriminant(_4) = 0; // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:17: +1:26 - StorageDead(_5); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:25: +1:26 - _0 = [move _2, move _4]; // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:5: +1:27 - StorageDead(_4); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:26: +1:27 - StorageDead(_2); // scope 0 at $DIR/deaggregator_test_multiple.rs:+1:26: +1:27 - return; // scope 0 at $DIR/deaggregator_test_multiple.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/div_overflow.const_dividend.PreCodegen.after.mir b/tests/mir-opt/div_overflow.const_dividend.PreCodegen.after.mir index d7f66a6bf..1a7fb916e 100644 --- a/tests/mir-opt/div_overflow.const_dividend.PreCodegen.after.mir +++ b/tests/mir-opt/div_overflow.const_dividend.PreCodegen.after.mir @@ -11,7 +11,7 @@ fn const_dividend(_1: i32) -> i32 { } bb1: { - _0 = Div(const 256_i32, move _1); // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 + _0 = Div(const 256_i32, _1); // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 return; // scope 0 at $DIR/div_overflow.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/div_overflow.const_divisor.PreCodegen.after.mir b/tests/mir-opt/div_overflow.const_divisor.PreCodegen.after.mir index 7b7ab1978..5526a194b 100644 --- a/tests/mir-opt/div_overflow.const_divisor.PreCodegen.after.mir +++ b/tests/mir-opt/div_overflow.const_divisor.PreCodegen.after.mir @@ -5,7 +5,7 @@ fn const_divisor(_1: i32) -> i32 { let mut _0: i32; // return place in scope 0 at $DIR/div_overflow.rs:+0:33: +0:36 bb0: { - _0 = Div(move _1, const 256_i32); // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 + _0 = Div(_1, const 256_i32); // scope 0 at $DIR/div_overflow.rs:+1:5: +1:12 return; // scope 0 at $DIR/div_overflow.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff b/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff new file mode 100644 index 000000000..c1a42a47e --- /dev/null +++ b/tests/mir-opt/dont_yeet_assert.generic.InstCombine.diff @@ -0,0 +1,23 @@ +- // MIR for `generic` before InstCombine ++ // MIR for `generic` after InstCombine + + fn generic() -> () { + let mut _0: (); // return place in scope 0 at $DIR/dont_yeet_assert.rs:+0:21: +0:21 + let _1: (); // in scope 0 at $DIR/dont_yeet_assert.rs:+1:5: +1:61 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/dont_yeet_assert.rs:+1:5: +1:61 + _1 = assert_mem_uninitialized_valid::<&T>() -> bb1; // scope 0 at $DIR/dont_yeet_assert.rs:+1:5: +1:61 + // mir::Constant + // + span: $DIR/dont_yeet_assert.rs:10:5: 10:59 + // + user_ty: UserType(0) + // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::<&T>}, val: Value() } + } + + bb1: { + StorageDead(_1); // scope 0 at $DIR/dont_yeet_assert.rs:+1:61: +1:62 + _0 = const (); // scope 0 at $DIR/dont_yeet_assert.rs:+0:21: +2:2 + return; // scope 0 at $DIR/dont_yeet_assert.rs:+2:2: +2:2 + } + } + diff --git a/tests/mir-opt/dont_yeet_assert.rs b/tests/mir-opt/dont_yeet_assert.rs new file mode 100644 index 000000000..7cec761ea --- /dev/null +++ b/tests/mir-opt/dont_yeet_assert.rs @@ -0,0 +1,11 @@ +// compile-flags: --crate-type=lib +// unit-test: InstCombine + +#![feature(core_intrinsics)] + +// Want to make sure this assertion isn't compiled away in generic code. + +// EMIT_MIR dont_yeet_assert.generic.InstCombine.diff +pub fn generic() { + core::intrinsics::assert_mem_uninitialized_valid::<&T>(); +} diff --git a/tests/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff index 98a02ee38..5383d1be1 100644 --- a/tests/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff @@ -25,9 +25,7 @@ _4 = _1; // scope 0 at $DIR/early_otherwise_branch.rs:+1:12: +1:13 StorageLive(_5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:15: +1:16 _5 = _2; // scope 0 at $DIR/early_otherwise_branch.rs:+1:15: +1:16 - Deinit(_3); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 - (_3.0: std::option::Option) = move _4; // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 - (_3.1: std::option::Option) = move _5; // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 + _3 = (move _4, move _5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:16: +1:17 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch.rs:+1:16: +1:17 _7 = discriminant((_3.0: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 diff --git a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff index aa75c44b8..b3e21ff49 100644 --- a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff @@ -26,9 +26,7 @@ _4 = _1; // scope 0 at $DIR/early_otherwise_branch.rs:+1:12: +1:13 StorageLive(_5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:15: +1:16 _5 = _2; // scope 0 at $DIR/early_otherwise_branch.rs:+1:15: +1:16 - Deinit(_3); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 - (_3.0: std::option::Option) = move _4; // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 - (_3.1: std::option::Option) = move _5; // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 + _3 = (move _4, move _5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:16: +1:17 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch.rs:+1:16: +1:17 _8 = discriminant((_3.0: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 diff --git a/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff index cea6ff7cd..e098a88eb 100644 --- a/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt3.EarlyOtherwiseBranch.diff @@ -25,9 +25,7 @@ _4 = _1; // scope 0 at $DIR/early_otherwise_branch.rs:+1:12: +1:13 StorageLive(_5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:15: +1:16 _5 = _2; // scope 0 at $DIR/early_otherwise_branch.rs:+1:15: +1:16 - Deinit(_3); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 - (_3.0: std::option::Option) = move _4; // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 - (_3.1: std::option::Option) = move _5; // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 + _3 = (move _4, move _5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch.rs:+1:16: +1:17 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch.rs:+1:16: +1:17 _7 = discriminant((_3.0: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch.rs:+1:11: +1:17 diff --git a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff index b90d70ce4..ec3b4bbdf 100644 --- a/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff @@ -34,10 +34,7 @@ _6 = _2; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:15: +1:16 StorageLive(_7); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:18: +1:19 _7 = _3; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:18: +1:19 - Deinit(_4); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:11: +1:20 - (_4.0: std::option::Option) = move _5; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:11: +1:20 - (_4.1: std::option::Option) = move _6; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:11: +1:20 - (_4.2: std::option::Option) = move _7; // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:11: +1:20 + _4 = (move _5, move _6, move _7); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:11: +1:20 StorageDead(_7); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:19: +1:20 StorageDead(_6); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:19: +1:20 StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_3_element_tuple.rs:+1:19: +1:20 diff --git a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index 9edd1a39f..a91d0d7cf 100644 --- a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -73,9 +73,7 @@ _5 = _1; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:15: +5:16 StorageLive(_6); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:18: +5:23 _6 = _2; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:18: +5:23 - Deinit(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:14: +5:24 - (_4.0: &ViewportPercentageLength) = move _5; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:14: +5:24 - (_4.1: &ViewportPercentageLength) = move _6; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:14: +5:24 + _4 = (move _5, move _6); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:14: +5:24 StorageDead(_6); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:23: +5:24 StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:23: +5:24 _34 = deref_copy (_4.0: &ViewportPercentageLength); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:14: +5:24 @@ -91,10 +89,8 @@ bb2: { StorageLive(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:25: +10:27 - Deinit(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:25: +10:27 - Deinit(_0); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28 - ((_0 as Err).0: ()) = move _33; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28 - discriminant(_0) = 1; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28 + _33 = (); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:25: +10:27 + _0 = Result::::Err(move _33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:21: +10:28 StorageDead(_33); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+10:27: +10:28 StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+11:6: +11:7 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:1: +12:2 @@ -134,9 +130,7 @@ _14 = Add(move _15, move _16); // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:38: +6:49 StorageDead(_16); // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:48: +6:49 StorageDead(_15); // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:48: +6:49 - Deinit(_3); // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:35: +6:50 - ((_3 as Vw).0: f32) = move _14; // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:35: +6:50 - discriminant(_3) = 0; // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:35: +6:50 + _3 = ViewportPercentageLength::Vw(move _14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:35: +6:50 StorageDead(_14); // scope 1 at $DIR/early_otherwise_branch_68867.rs:+6:49: +6:50 StorageDead(_13); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+6:49: +6:50 StorageDead(_12); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+6:49: +6:50 @@ -158,9 +152,7 @@ _19 = Add(move _20, move _21); // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:38: +7:49 StorageDead(_21); // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:48: +7:49 StorageDead(_20); // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:48: +7:49 - Deinit(_3); // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:35: +7:50 - ((_3 as Vh).0: f32) = move _19; // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:35: +7:50 - discriminant(_3) = 1; // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:35: +7:50 + _3 = ViewportPercentageLength::Vh(move _19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:35: +7:50 StorageDead(_19); // scope 2 at $DIR/early_otherwise_branch_68867.rs:+7:49: +7:50 StorageDead(_18); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+7:49: +7:50 StorageDead(_17); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+7:49: +7:50 @@ -182,9 +174,7 @@ _24 = Add(move _25, move _26); // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:44: +8:55 StorageDead(_26); // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:54: +8:55 StorageDead(_25); // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:54: +8:55 - Deinit(_3); // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:39: +8:56 - ((_3 as Vmin).0: f32) = move _24; // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:39: +8:56 - discriminant(_3) = 2; // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:39: +8:56 + _3 = ViewportPercentageLength::Vmin(move _24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:39: +8:56 StorageDead(_24); // scope 3 at $DIR/early_otherwise_branch_68867.rs:+8:55: +8:56 StorageDead(_23); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+8:55: +8:56 StorageDead(_22); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+8:55: +8:56 @@ -206,9 +196,7 @@ _29 = Add(move _30, move _31); // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:44: +9:55 StorageDead(_31); // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:54: +9:55 StorageDead(_30); // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:54: +9:55 - Deinit(_3); // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:39: +9:56 - ((_3 as Vmax).0: f32) = move _29; // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:39: +9:56 - discriminant(_3) = 3; // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:39: +9:56 + _3 = ViewportPercentageLength::Vmax(move _29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:39: +9:56 StorageDead(_29); // scope 4 at $DIR/early_otherwise_branch_68867.rs:+9:55: +9:56 StorageDead(_28); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+9:55: +9:56 StorageDead(_27); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+9:55: +9:56 @@ -216,9 +204,7 @@ } bb10: { - Deinit(_0); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:5: +11:7 - ((_0 as Ok).0: ViewportPercentageLength) = move _3; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:5: +11:7 - discriminant(_0) = 0; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:5: +11:7 + _0 = Result::::Ok(move _3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+5:5: +11:7 StorageDead(_3); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+11:6: +11:7 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:1: +12:2 goto -> bb11; // scope 0 at $DIR/early_otherwise_branch_68867.rs:+12:2: +12:2 diff --git a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff index 82d8b2fc5..6468eb5f8 100644 --- a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff @@ -32,9 +32,7 @@ _4 = _1; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:12: +1:13 StorageLive(_5); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:15: +1:16 _5 = _2; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:15: +1:16 - Deinit(_3); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:11: +1:17 - (_3.0: std::option::Option) = move _4; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:11: +1:17 - (_3.1: std::option::Option) = move _5; // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:11: +1:17 + _3 = (move _4, move _5); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:11: +1:17 StorageDead(_5); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:16: +1:17 StorageDead(_4); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:16: +1:17 _8 = discriminant((_3.0: std::option::Option)); // scope 0 at $DIR/early_otherwise_branch_noopt.rs:+1:11: +1:17 diff --git a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff new file mode 100644 index 000000000..b139deeee --- /dev/null +++ b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.32bit.diff @@ -0,0 +1,68 @@ +- // MIR for `cand` before EnumSizeOpt ++ // MIR for `cand` after EnumSizeOpt + + fn cand() -> Candidate { + let mut _0: Candidate; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:27 + let mut _1: Candidate; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 ++ let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _7: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _8: *mut Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _10: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = Candidate::Small(const 1_u8); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _2 = Candidate::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 +- _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _4 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _8 = &raw mut _1; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff new file mode 100644 index 000000000..b139deeee --- /dev/null +++ b/tests/mir-opt/enum_opt.cand.EnumSizeOpt.64bit.diff @@ -0,0 +1,68 @@ +- // MIR for `cand` before EnumSizeOpt ++ // MIR for `cand` after EnumSizeOpt + + fn cand() -> Candidate { + let mut _0: Candidate; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:27 + let mut _1: Candidate; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 ++ let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _7: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _8: *mut Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _10: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:34 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const Candidate; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = Candidate::Small(const 1_u8); // scope 0 at $DIR/enum_opt.rs:+1:15: +1:34 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _2 = Candidate::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 +- _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _4 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _8 = &raw mut _1; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 ++ StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [2_usize, 8197_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff new file mode 100644 index 000000000..a80001149 --- /dev/null +++ b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.32bit.diff @@ -0,0 +1,28 @@ +- // MIR for `invalid` before EnumSizeOpt ++ // MIR for `invalid` after EnumSizeOpt + + fn invalid() -> InvalidIdxs { + let mut _0: InvalidIdxs; // return place in scope 0 at $DIR/enum_opt.rs:+0:21: +0:32 + let mut _1: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:36 + let mut _3: [u64; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:26: +2:35 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = InvalidIdxs::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 + _3 = [const 0_u64; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 + _2 = InvalidIdxs::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 + _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:36 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff new file mode 100644 index 000000000..a80001149 --- /dev/null +++ b/tests/mir-opt/enum_opt.invalid.EnumSizeOpt.64bit.diff @@ -0,0 +1,28 @@ +- // MIR for `invalid` before EnumSizeOpt ++ // MIR for `invalid` after EnumSizeOpt + + fn invalid() -> InvalidIdxs { + let mut _0: InvalidIdxs; // return place in scope 0 at $DIR/enum_opt.rs:+0:21: +0:32 + let mut _1: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: InvalidIdxs; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:36 + let mut _3: [u64; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:26: +2:35 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = InvalidIdxs::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:29 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 + _3 = [const 0_u64; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:26: +2:35 + _2 = InvalidIdxs::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:36 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 + _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:36 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:35: +2:36 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/enum_opt.rs b/tests/mir-opt/enum_opt.rs new file mode 100644 index 000000000..2768d7080 --- /dev/null +++ b/tests/mir-opt/enum_opt.rs @@ -0,0 +1,86 @@ +// unit-test: EnumSizeOpt +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// compile-flags: -Zunsound-mir-opts + +#![feature(arbitrary_enum_discriminant, repr128)] + +// Tests that an enum with a variant with no data gets correctly transformed. +pub enum NoData { + Large([u8; 8196]), + None, +} + +// Tests that an enum with a variant with data that is a valid candidate gets transformed. +pub enum Candidate { + Small(u8), + Large([u8; 8196]), +} + +// Tests that an enum which has a discriminant much higher than the variant does not get +// tformed. +#[repr(u32)] +pub enum InvalidIdxs { + A = 302, + Large([u64; 1024]), +} + +// Tests that an enum with too high of a discriminant index (not in bounds of usize) does not +// get tformed. +#[repr(u128)] +pub enum NotTrunctable { + A = 0, + B([u8; 1024]) = 1, + C([u8; 4096]) = 0x10000000000000001, +} + +// Tests that an enum with discriminants in random order still gets tformed correctly. +#[repr(u32)] +pub enum RandOrderDiscr { + A = 13, + B([u8; 1024]) = 5, + C = 7, +} + +// EMIT_MIR enum_opt.unin.EnumSizeOpt.diff +pub fn unin() -> NoData { + let mut a = NoData::None; + a = NoData::Large([1; 8196]); + a +} + +// EMIT_MIR enum_opt.cand.EnumSizeOpt.diff +pub fn cand() -> Candidate { + let mut a = Candidate::Small(1); + a = Candidate::Large([1; 8196]); + a +} + +// EMIT_MIR enum_opt.invalid.EnumSizeOpt.diff +pub fn invalid() -> InvalidIdxs { + let mut a = InvalidIdxs::A; + a = InvalidIdxs::Large([0; 1024]); + a +} + +// EMIT_MIR enum_opt.trunc.EnumSizeOpt.diff +pub fn trunc() -> NotTrunctable { + let mut a = NotTrunctable::A; + a = NotTrunctable::B([0; 1024]); + a = NotTrunctable::C([0; 4096]); + a +} + +pub fn rand_order() -> RandOrderDiscr { + let mut a = RandOrderDiscr::A; + a = RandOrderDiscr::B([0; 1024]); + a = RandOrderDiscr::C; + a +} + +pub fn main() { + unin(); + cand(); + invalid(); + trunc(); + rand_order(); +} diff --git a/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff new file mode 100644 index 000000000..1ef79044d --- /dev/null +++ b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.32bit.diff @@ -0,0 +1,37 @@ +- // MIR for `trunc` before EnumSizeOpt ++ // MIR for `trunc` after EnumSizeOpt + + fn trunc() -> NotTrunctable { + let mut _0: NotTrunctable; // return place in scope 0 at $DIR/enum_opt.rs:+0:19: +0:32 + let mut _1: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 + let mut _3: [u8; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 + let mut _4: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+3:7: +3:34 + let mut _5: [u8; 4096]; // in scope 0 at $DIR/enum_opt.rs:+3:24: +3:33 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = NotTrunctable::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _3 = [const 0_u8; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _2 = NotTrunctable::B(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 + _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 + StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 + StorageLive(_5); // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 + _5 = [const 0_u8; 4096]; // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 + _4 = NotTrunctable::C(move _5); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 + StorageDead(_5); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 + _1 = move _4; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:34 + StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+4:3: +4:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+5:1: +5:2 + return; // scope 0 at $DIR/enum_opt.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff new file mode 100644 index 000000000..1ef79044d --- /dev/null +++ b/tests/mir-opt/enum_opt.trunc.EnumSizeOpt.64bit.diff @@ -0,0 +1,37 @@ +- // MIR for `trunc` before EnumSizeOpt ++ // MIR for `trunc` after EnumSizeOpt + + fn trunc() -> NotTrunctable { + let mut _0: NotTrunctable; // return place in scope 0 at $DIR/enum_opt.rs:+0:19: +0:32 + let mut _1: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:34 + let mut _3: [u8; 1024]; // in scope 0 at $DIR/enum_opt.rs:+2:24: +2:33 + let mut _4: NotTrunctable; // in scope 0 at $DIR/enum_opt.rs:+3:7: +3:34 + let mut _5: [u8; 4096]; // in scope 0 at $DIR/enum_opt.rs:+3:24: +3:33 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = NotTrunctable::A; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:31 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _3 = [const 0_u8; 1024]; // scope 1 at $DIR/enum_opt.rs:+2:24: +2:33 + _2 = NotTrunctable::B(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:34 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 + _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:34 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:33: +2:34 + StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 + StorageLive(_5); // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 + _5 = [const 0_u8; 4096]; // scope 1 at $DIR/enum_opt.rs:+3:24: +3:33 + _4 = NotTrunctable::C(move _5); // scope 1 at $DIR/enum_opt.rs:+3:7: +3:34 + StorageDead(_5); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 + _1 = move _4; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:34 + StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+3:33: +3:34 + _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+4:3: +4:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+5:1: +5:2 + return; // scope 0 at $DIR/enum_opt.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff new file mode 100644 index 000000000..ad9f12cf9 --- /dev/null +++ b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.32bit.diff @@ -0,0 +1,68 @@ +- // MIR for `unin` before EnumSizeOpt ++ // MIR for `unin` after EnumSizeOpt + + fn unin() -> NoData { + let mut _0: NoData; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:24 + let mut _1: NoData; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: NoData; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:31 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:21: +2:30 ++ let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _7: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _8: *mut NoData; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _10: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = NoData::None; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 + _2 = NoData::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 +- _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _4 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _8 = &raw mut _1; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff new file mode 100644 index 000000000..ad9f12cf9 --- /dev/null +++ b/tests/mir-opt/enum_opt.unin.EnumSizeOpt.64bit.diff @@ -0,0 +1,68 @@ +- // MIR for `unin` before EnumSizeOpt ++ // MIR for `unin` after EnumSizeOpt + + fn unin() -> NoData { + let mut _0: NoData; // return place in scope 0 at $DIR/enum_opt.rs:+0:18: +0:24 + let mut _1: NoData; // in scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + let mut _2: NoData; // in scope 0 at $DIR/enum_opt.rs:+2:7: +2:31 + let mut _3: [u8; 8196]; // in scope 0 at $DIR/enum_opt.rs:+2:21: +2:30 ++ let mut _4: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _5: isize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _6: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _7: usize; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _8: *mut NoData; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _9: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _10: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _11: *const u8; // in scope 0 at $DIR/enum_opt.rs:+2:3: +2:31 ++ let mut _12: [usize; 2]; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _13: isize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _14: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _15: usize; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _16: *mut NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _17: *mut u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _18: *const NoData; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 ++ let mut _19: *const u8; // in scope 0 at $DIR/enum_opt.rs:+3:3: +3:4 + scope 1 { + debug a => _1; // in scope 1 at $DIR/enum_opt.rs:+1:7: +1:12 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_opt.rs:+1:7: +1:12 + _1 = NoData::None; // scope 0 at $DIR/enum_opt.rs:+1:15: +1:27 + StorageLive(_2); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 + StorageLive(_3); // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 + _3 = [const 1_u8; 8196]; // scope 1 at $DIR/enum_opt.rs:+2:21: +2:30 + _2 = NoData::Large(move _3); // scope 1 at $DIR/enum_opt.rs:+2:7: +2:31 + StorageDead(_3); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 +- _1 = move _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ StorageLive(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _4 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _5 = discriminant(_2); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _6 = _5 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _7 = _4[_6]; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _8 = &raw mut _1; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _9 = _8 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _10 = &raw const _2; // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ _11 = _10 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ Deinit(_8); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ copy_nonoverlapping(dst = _9, src = _11, count = _7); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 ++ StorageDead(_4); // scope 1 at $DIR/enum_opt.rs:+2:3: +2:31 + StorageDead(_2); // scope 1 at $DIR/enum_opt.rs:+2:30: +2:31 +- _0 = move _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageLive(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _12 = const [8197_usize, 1_usize]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _13 = discriminant(_1); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _14 = _13 as usize (IntToInt); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _15 = _12[_14]; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _16 = &raw mut _0; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _17 = _16 as *mut u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _18 = &raw const _1; // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ _19 = _18 as *const u8 (PtrToPtr); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ Deinit(_16); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ copy_nonoverlapping(dst = _17, src = _19, count = _15); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 ++ StorageDead(_12); // scope 1 at $DIR/enum_opt.rs:+3:3: +3:4 + StorageDead(_1); // scope 0 at $DIR/enum_opt.rs:+4:1: +4:2 + return; // scope 0 at $DIR/enum_opt.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff index c1c2cde71..1f5c53381 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff @@ -51,14 +51,20 @@ } bb2: { - Deinit(_6); // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 - discriminant(_6) = 1; // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 +- _6 = MinusPlus; // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 ++ _6 = const MinusPlus; // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 ++ // mir::Constant ++ // + span: $DIR/funky_arms.rs:21:17: 21:41 ++ // + literal: Const { ty: Sign, val: Value(Scalar(0x01)) } goto -> bb4; // scope 1 at $DIR/funky_arms.rs:+10:17: +10:41 } bb3: { - Deinit(_6); // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 - discriminant(_6) = 0; // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 +- _6 = Minus; // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 ++ _6 = const Minus; // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 ++ // mir::Constant ++ // + span: $DIR/funky_arms.rs:20:18: 20:38 ++ // + literal: Const { ty: Sign, val: Value(Scalar(0x00)) } goto -> bb4; // scope 1 at $DIR/funky_arms.rs:+9:18: +9:38 } @@ -79,60 +85,37 @@ } bb6: { - StorageLive(_10); // scope 3 at $DIR/funky_arms.rs:+13:17: +13:26 _10 = ((_7 as Some).0: usize); // scope 3 at $DIR/funky_arms.rs:+13:17: +13:26 - StorageLive(_11); // scope 3 at $DIR/funky_arms.rs:+15:43: +15:46 - _11 = &mut (*_1); // scope 3 at $DIR/funky_arms.rs:+15:43: +15:46 - StorageLive(_12); // scope 3 at $DIR/funky_arms.rs:+15:48: +15:51 - _12 = _2; // scope 3 at $DIR/funky_arms.rs:+15:48: +15:51 StorageLive(_13); // scope 3 at $DIR/funky_arms.rs:+15:53: +15:57 _13 = _6; // scope 3 at $DIR/funky_arms.rs:+15:53: +15:57 StorageLive(_14); // scope 3 at $DIR/funky_arms.rs:+15:59: +15:79 StorageLive(_15); // scope 3 at $DIR/funky_arms.rs:+15:59: +15:75 - StorageLive(_16); // scope 3 at $DIR/funky_arms.rs:+15:59: +15:68 - _16 = _10; // scope 3 at $DIR/funky_arms.rs:+15:59: +15:68 - _15 = move _16 as u32 (IntToInt); // scope 3 at $DIR/funky_arms.rs:+15:59: +15:75 - StorageDead(_16); // scope 3 at $DIR/funky_arms.rs:+15:74: +15:75 + _15 = _10 as u32 (IntToInt); // scope 3 at $DIR/funky_arms.rs:+15:59: +15:75 _14 = Add(move _15, const 1_u32); // scope 3 at $DIR/funky_arms.rs:+15:59: +15:79 StorageDead(_15); // scope 3 at $DIR/funky_arms.rs:+15:78: +15:79 - StorageLive(_17); // scope 3 at $DIR/funky_arms.rs:+15:81: +15:86 - _17 = _3; // scope 3 at $DIR/funky_arms.rs:+15:81: +15:86 - _0 = float_to_exponential_common_exact::(move _11, move _12, move _13, move _14, move _17) -> bb7; // scope 3 at $DIR/funky_arms.rs:+15:9: +15:87 + _0 = float_to_exponential_common_exact::(_1, _2, move _13, move _14, _3) -> bb7; // scope 3 at $DIR/funky_arms.rs:+15:9: +15:87 // mir::Constant // + span: $DIR/funky_arms.rs:26:9: 26:42 // + literal: Const { ty: for<'a, 'b, 'c> fn(&'a mut Formatter<'b>, &'c T, Sign, u32, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_exact::}, val: Value() } } bb7: { - StorageDead(_17); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 StorageDead(_14); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 StorageDead(_13); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 - StorageDead(_12); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 - StorageDead(_11); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 - StorageDead(_10); // scope 2 at $DIR/funky_arms.rs:+16:5: +16:6 goto -> bb10; // scope 2 at $DIR/funky_arms.rs:+13:5: +18:6 } bb8: { - StorageLive(_18); // scope 2 at $DIR/funky_arms.rs:+17:46: +17:49 - _18 = &mut (*_1); // scope 2 at $DIR/funky_arms.rs:+17:46: +17:49 - StorageLive(_19); // scope 2 at $DIR/funky_arms.rs:+17:51: +17:54 - _19 = _2; // scope 2 at $DIR/funky_arms.rs:+17:51: +17:54 StorageLive(_20); // scope 2 at $DIR/funky_arms.rs:+17:56: +17:60 _20 = _6; // scope 2 at $DIR/funky_arms.rs:+17:56: +17:60 - StorageLive(_21); // scope 2 at $DIR/funky_arms.rs:+17:62: +17:67 - _21 = _3; // scope 2 at $DIR/funky_arms.rs:+17:62: +17:67 - _0 = float_to_exponential_common_shortest::(move _18, move _19, move _20, move _21) -> bb9; // scope 2 at $DIR/funky_arms.rs:+17:9: +17:68 + _0 = float_to_exponential_common_shortest::(_1, _2, move _20, _3) -> bb9; // scope 2 at $DIR/funky_arms.rs:+17:9: +17:68 // mir::Constant // + span: $DIR/funky_arms.rs:28:9: 28:45 // + literal: Const { ty: for<'a, 'b, 'c> fn(&'a mut Formatter<'b>, &'c T, Sign, bool) -> Result<(), std::fmt::Error> {float_to_exponential_common_shortest::}, val: Value() } } bb9: { - StorageDead(_21); // scope 2 at $DIR/funky_arms.rs:+17:67: +17:68 StorageDead(_20); // scope 2 at $DIR/funky_arms.rs:+17:67: +17:68 - StorageDead(_19); // scope 2 at $DIR/funky_arms.rs:+17:67: +17:68 - StorageDead(_18); // scope 2 at $DIR/funky_arms.rs:+17:67: +17:68 goto -> bb10; // scope 2 at $DIR/funky_arms.rs:+13:5: +18:6 } diff --git a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir index a8e090020..afe518642 100644 --- a/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir +++ b/tests/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir @@ -1,7 +1,14 @@ // MIR for `main::{closure#0}` 0 generator_drop /* generator_layout = GeneratorLayout { field_tys: { - _0: std::string::String, + _0: GeneratorSavedTy { + ty: std::string::String, + source_info: SourceInfo { + span: $DIR/generator_drop_cleanup.rs:11:13: 11:15 (#0), + scope: scope[0], + }, + ignore_for_traits: false, + }, }, variant_fields: { Unresumed(0): [], diff --git a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir index b3d3c768a..7efda05d2 100644 --- a/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir @@ -1,7 +1,14 @@ // MIR for `main::{closure#0}` 0 generator_resume /* generator_layout = GeneratorLayout { field_tys: { - _0: HasDrop, + _0: GeneratorSavedTy { + ty: HasDrop, + source_info: SourceInfo { + span: $DIR/generator_tiny.rs:20:13: 20:15 (#0), + scope: scope[0], + }, + ignore_for_traits: false, + }, }, variant_fields: { Unresumed(0): [], @@ -47,9 +54,7 @@ fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator_tiny.rs:19:16: 19:24 StorageLive(_6); // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 StorageLive(_7); // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 _7 = (); // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 - Deinit(_0); // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 - ((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 - discriminant(_0) = 0; // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 + _0 = GeneratorState::<(), ()>::Yielded(move _7); // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 discriminant((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24]))) = 3; // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 return; // scope 1 at $DIR/generator_tiny.rs:+3:13: +3:18 } diff --git a/tests/mir-opt/inline/cycle.f.Inline.diff b/tests/mir-opt/inline/cycle.f.Inline.diff index 75ea69a42..501390c3b 100644 --- a/tests/mir-opt/inline/cycle.f.Inline.diff +++ b/tests/mir-opt/inline/cycle.f.Inline.diff @@ -13,7 +13,7 @@ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:6 _3 = &_1; // scope 0 at $DIR/cycle.rs:+1:5: +1:6 StorageLive(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:8 - Deinit(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:8 + _4 = (); // scope 0 at $DIR/cycle.rs:+1:5: +1:8 _2 = >::call(move _3, move _4) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/cycle.rs:+1:5: +1:8 // mir::Constant // + span: $DIR/cycle.rs:6:5: 6:6 diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff index 8ea1a0757..64c3e47ff 100644 --- a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -35,8 +35,8 @@ _4 = &(*_2); // scope 1 at $DIR/dyn_trait.rs:+2:23: +2:24 - _0 = try_execute_query::<::C>(move _4) -> bb2; // scope 1 at $DIR/dyn_trait.rs:+2:5: +2:25 + StorageLive(_5); // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 -+ _5 = move _4 as &dyn Cache::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 -+ _0 = ::V> as Cache>::store_nocache(move _5) -> bb2; // scope 3 at $DIR/dyn_trait.rs:21:5: 21:22 ++ _5 = _4 as &dyn Cache::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 ++ _0 = ::V> as Cache>::store_nocache(_5) -> bb2; // scope 3 at $DIR/dyn_trait.rs:21:5: 21:22 // mir::Constant - // + span: $DIR/dyn_trait.rs:34:5: 34:22 - // + literal: Const { ty: for<'a> fn(&'a ::C) {try_execute_query::<::C>}, val: Value() } diff --git a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff index a71d73b74..3fa9c3e88 100644 --- a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -17,7 +17,7 @@ _2 = move _3 as &dyn Cache::V> (Pointer(Unsize)); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 StorageDead(_3); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 - _0 = mk_cycle::<::V>(move _2) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:16 -+ _0 = ::V> as Cache>::store_nocache(move _2) -> bb1; // scope 1 at $DIR/dyn_trait.rs:21:5: 21:22 ++ _0 = ::V> as Cache>::store_nocache(_2) -> bb1; // scope 1 at $DIR/dyn_trait.rs:21:5: 21:22 // mir::Constant - // + span: $DIR/dyn_trait.rs:27:5: 27:13 - // + literal: Const { ty: for<'a> fn(&'a (dyn Cache::V> + 'a)) {mk_cycle::<::V>}, val: Value() } diff --git a/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir b/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir index 3502c2586..20f737cc2 100644 --- a/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir +++ b/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir @@ -26,7 +26,7 @@ fn bar() -> bool { _3 = const 1_i32; // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 StorageLive(_4); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 _4 = const -1_i32; // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 - _0 = Eq(move _3, move _4); // scope 2 at $DIR/inline_any_operand.rs:17:5: 17:11 + _0 = Eq(_3, _4); // scope 2 at $DIR/inline_any_operand.rs:17:5: 17:11 StorageDead(_4); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 StorageDead(_3); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 StorageDead(_2); // scope 1 at $DIR/inline_any_operand.rs:+2:12: +2:13 diff --git a/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir index 9eb3a01ee..fff8d0171 100644 --- a/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -21,7 +21,15 @@ fn foo(_1: T, _2: i32) -> i32 { bb0: { StorageLive(_3); // scope 0 at $DIR/inline_closure.rs:+1:9: +1:10 - Deinit(_3); // scope 0 at $DIR/inline_closure.rs:+1:13: +1:24 + _3 = [closure@foo::::{closure#0}]; // scope 0 at $DIR/inline_closure.rs:+1:13: +1:24 + // closure + // + def_id: DefId(0:6 ~ inline_closure[92ba]::foo::{closure#0}) + // + substs: [ + // T, + // i8, + // extern "rust-call" fn((i32, i32)) -> i32, + // (), + // ] StorageLive(_4); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:6 _4 = &_3; // scope 1 at $DIR/inline_closure.rs:+2:5: +2:6 StorageLive(_5); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 @@ -29,9 +37,7 @@ fn foo(_1: T, _2: i32) -> i32 { _6 = _2; // scope 1 at $DIR/inline_closure.rs:+2:7: +2:8 StorageLive(_7); // scope 1 at $DIR/inline_closure.rs:+2:10: +2:11 _7 = _2; // scope 1 at $DIR/inline_closure.rs:+2:10: +2:11 - Deinit(_5); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - (_5.0: i32) = move _6; // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - (_5.1: i32) = move _7; // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 + _5 = (move _6, move _7); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 StorageLive(_8); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 _8 = move (_5.0: i32); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 StorageLive(_9); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index dd32eb2d8..dab204306 100644 --- a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -24,7 +24,15 @@ fn foo(_1: T, _2: &i32) -> i32 { bb0: { StorageLive(_3); // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10 - Deinit(_3); // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:13: +4:6 + _3 = [closure@foo::::{closure#0}]; // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:13: +4:6 + // closure + // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[96e9]::foo::{closure#0}) + // + substs: [ + // T, + // i8, + // for<'a, 'b> extern "rust-call" fn((&'a i32, &'b i32)) -> i32, + // (), + // ] StorageLive(_4); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6 _4 = &_3; // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6 StorageLive(_5); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 @@ -32,9 +40,7 @@ fn foo(_1: T, _2: &i32) -> i32 { _6 = &(*_2); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:7: +5:8 StorageLive(_7); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:10: +5:11 _7 = &(*_2); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:10: +5:11 - Deinit(_5); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - (_5.0: &i32) = move _6; // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - (_5.1: &i32) = move _7; // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 + _5 = (move _6, move _7); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 StorageLive(_8); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 _8 = move (_5.0: &i32); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 StorageLive(_9); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 diff --git a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index fd19c2886..84fd051e0 100644 --- a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -30,9 +30,15 @@ fn foo(_1: T, _2: i32) -> (i32, T) { _4 = &_2; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 StorageLive(_5); // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 _5 = &_1; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 - Deinit(_3); // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 - (_3.0: &i32) = move _4; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 - (_3.1: &T) = move _5; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 + _3 = [closure@foo::::{closure#0}] { q: move _4, t: move _5 }; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 + // closure + // + def_id: DefId(0:6 ~ inline_closure_captures[8bc0]::foo::{closure#0}) + // + substs: [ + // T, + // i8, + // extern "rust-call" fn((i32,)) -> (i32, T), + // (&i32, &T), + // ] StorageDead(_5); // scope 0 at $DIR/inline_closure_captures.rs:+1:16: +1:17 StorageDead(_4); // scope 0 at $DIR/inline_closure_captures.rs:+1:16: +1:17 StorageLive(_6); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:6 @@ -40,8 +46,7 @@ fn foo(_1: T, _2: i32) -> (i32, T) { StorageLive(_7); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 StorageLive(_8); // scope 1 at $DIR/inline_closure_captures.rs:+2:7: +2:8 _8 = _2; // scope 1 at $DIR/inline_closure_captures.rs:+2:7: +2:8 - Deinit(_7); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 - (_7.0: i32) = move _8; // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 + _7 = (move _8,); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 StorageLive(_9); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 _9 = move (_7.0: i32); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 StorageLive(_10); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 @@ -50,9 +55,7 @@ fn foo(_1: T, _2: i32) -> (i32, T) { StorageLive(_11); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 _13 = deref_copy ((*_6).1: &T); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 _11 = (*_13); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 - Deinit(_0); // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24 - (_0.0: i32) = move _10; // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24 - (_0.1: T) = move _11; // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24 + _0 = (move _10, move _11); // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24 StorageDead(_11); // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24 StorageDead(_10); // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24 StorageDead(_9); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.diff index f82fcf4c8..e1b2f7dbf 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.diff @@ -48,9 +48,7 @@ + StorageDead(_6); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 + StorageLive(_8); // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 + _8 = move _3; // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ Deinit(_1); // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 -+ (_1.0: !) = move _8; // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 -+ (_1.1: !) = move _9; // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 ++ _1 = (move _8, move _9); // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 + StorageDead(_8); // scope 3 at $DIR/inline_diverging.rs:29:10: 29:11 + StorageDead(_3); // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 + drop(_2) -> bb2; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.diff b/tests/mir-opt/inline/inline_generator.main.Inline.diff index f27b64c30..01f5052b6 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.diff @@ -7,7 +7,7 @@ let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>; // in scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 let mut _3: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 let mut _4: [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 0 at $DIR/inline_generator.rs:+1:28: +1:31 -+ let mut _7: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ let mut _5: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 scope 1 { debug _r => _1; // in scope 1 at $DIR/inline_generator.rs:+1:9: +1:11 } @@ -15,21 +15,19 @@ + } + scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new) { // at $DIR/inline_generator.rs:9:14: 9:32 + debug pointer => _3; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL -+ let mut _5: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL + scope 4 { + scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL -+ debug pointer => _5; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ let mut _6: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ debug pointer => _3; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL + } + } + } + scope 6 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:33: 9:46 -+ debug a => _7; // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7 -+ let mut _8: i32; // in scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ let mut _9: u32; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ debug a => _5; // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7 ++ let mut _6: i32; // in scope 6 at $DIR/inline_generator.rs:15:17: 15:39 ++ let mut _7: u32; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _8: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ let mut _9: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 + let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _11: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _12: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 + } bb0: { @@ -44,8 +42,17 @@ - } - - bb1: { -+ Deinit(_4); // scope 2 at $DIR/inline_generator.rs:15:5: 15:41 -+ discriminant(_4) = 0; // scope 2 at $DIR/inline_generator.rs:15:5: 15:41 ++ _4 = [generator@$DIR/inline_generator.rs:15:5: 15:8 (#0)]; // scope 2 at $DIR/inline_generator.rs:15:5: 15:41 ++ // generator ++ // + def_id: DefId(0:7 ~ inline_generator[ea31]::g::{closure#0}) ++ // + substs: [ ++ // bool, ++ // i32, ++ // bool, ++ // {bool, i32}, ++ // (), ++ // ] ++ // + movability: Movable _3 = &mut _4; // scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 - _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 - // mir::Constant @@ -55,29 +62,22 @@ - } - - bb2: { -+ StorageLive(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL -+ _5 = move _3; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL -+ StorageLive(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ _6 = move _5; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ Deinit(_2); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ StorageDead(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ StorageDead(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> { pointer: move _3 }; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 - _1 = <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46 - // mir::Constant - // + span: $DIR/inline_generator.rs:9:33: 9:39 - // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Yield, <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::Return> {<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator>::resume}, val: Value() } -+ StorageLive(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _7 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ _9 = discriminant((*_10)); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ switchInt(move _9) -> [0: bb3, 1: bb8, 3: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ StorageLive(_5); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ _5 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ _8 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ _7 = discriminant((*_8)); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ switchInt(move _7) -> [0: bb3, 1: bb8, 3: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 } - bb3: { + bb1: { -+ StorageDead(_7); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 ++ StorageDead(_5); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 StorageDead(_2); // scope 0 at $DIR/inline_generator.rs:+1:45: +1:46 StorageDead(_4); // scope 0 at $DIR/inline_generator.rs:+1:46: +1:47 _0 = const (); // scope 0 at $DIR/inline_generator.rs:+0:11: +2:2 @@ -91,37 +91,33 @@ + } + + bb3: { -+ StorageLive(_8); // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ switchInt(move _7) -> [0: bb5, otherwise: bb4]; // scope 6 at $DIR/inline_generator.rs:15:20: 15:21 ++ StorageLive(_6); // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 ++ switchInt(_5) -> [0: bb5, otherwise: bb4]; // scope 6 at $DIR/inline_generator.rs:15:20: 15:21 + } + + bb4: { -+ _8 = const 7_i32; // scope 6 at $DIR/inline_generator.rs:15:24: 15:25 ++ _6 = const 7_i32; // scope 6 at $DIR/inline_generator.rs:15:24: 15:25 + goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 + } + + bb5: { -+ _8 = const 13_i32; // scope 6 at $DIR/inline_generator.rs:15:35: 15:37 ++ _6 = const 13_i32; // scope 6 at $DIR/inline_generator.rs:15:35: 15:37 + goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 + } + + bb6: { -+ Deinit(_1); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ discriminant(_1) = 0; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ _11 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ discriminant((*_11)) = 3; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ _1 = GeneratorState::::Yielded(move _6); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 ++ discriminant((*_9)) = 3; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 + goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:11: 15:39 + } + + bb7: { -+ StorageLive(_8); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ StorageDead(_8); // scope 6 at $DIR/inline_generator.rs:15:38: 15:39 -+ Deinit(_1); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ ((_1 as Complete).0: bool) = move _7; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ discriminant(_1) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ _12 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ discriminant((*_12)) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ StorageLive(_6); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 ++ StorageDead(_6); // scope 6 at $DIR/inline_generator.rs:15:38: 15:39 ++ _1 = GeneratorState::::Complete(_5); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 ++ discriminant((*_10)) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 + goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:41: 15:41 + } + diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff index a28da146e..a1cbf0d3e 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff @@ -51,9 +51,7 @@ + // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + // + user_ty: UserType(0) + // + literal: Const { ty: alloc::raw_vec::RawVec, val: Unevaluated(alloc::raw_vec::RawVec::::NEW, [u32], None) } -+ Deinit(_9); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ (_9.0: alloc::raw_vec::RawVec) = move _10; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ (_9.1: usize) = const 0_usize; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ _9 = Vec:: { buf: move _10, len: const 0_usize }; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + StorageDead(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + (*_8) = move _9; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 + StorageDead(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 diff --git a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir index 73aea719e..b7c5bbecb 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -15,7 +15,7 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 _2 = move _3 as &dyn X (Pointer(Unsize)); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 StorageDead(_3); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 - _0 = ::y(move _2) -> bb1; // scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10 + _0 = ::y(_2) -> bb1; // scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10 // mir::Constant // + span: $DIR/inline_trait_method_2.rs:10:7: 10:8 // + literal: Const { ty: for<'a> fn(&'a dyn X) -> bool {::y}, val: Value() } diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir index dc0c32350..6441a9668 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir @@ -8,7 +8,6 @@ fn a(_1: &mut [T]) -> &mut [T] { let mut _4: &mut [T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:3:7: 3:15 debug self => _4; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - let mut _5: &mut [T]; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL } bb0: { @@ -16,10 +15,7 @@ fn a(_1: &mut [T]) -> &mut [T] { StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 StorageLive(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 _4 = &mut (*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageLive(_5); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - _5 = &mut (*_4); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - _3 = &mut (*_5); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_5); // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + _3 = _4; // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL _2 = &mut (*_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 StorageDead(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15 _0 = &mut (*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index b6aff3014..21570a88a 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -8,10 +8,8 @@ fn b(_1: &mut Box) -> &mut T { let mut _4: &mut std::boxed::Box; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 scope 1 (inlined as AsMut>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:8:7: 8:15 debug self => _4; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _5: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _6: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _7: std::boxed::Box; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _8: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + let mut _5: std::boxed::Box; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + let mut _6: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL } bb0: { @@ -19,15 +17,9 @@ fn b(_1: &mut Box) -> &mut T { StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 StorageLive(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 _4 = &mut (*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageLive(_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - StorageLive(_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _7 = deref_copy (*_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _8 = (((_7.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _6 = &mut (*_8); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _5 = &mut (*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _3 = &mut (*_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - StorageDead(_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - StorageDead(_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _5 = deref_copy (*_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _6 = (((_5.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _3 = &mut (*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL _2 = &mut (*_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 StorageDead(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15 _0 = &mut (*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index d99ae1a6c..4dd1aad48 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -20,14 +20,20 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 - Deinit(_1); // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:13: +1:33 + _1 = [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:13: +1:33 + // closure + // + def_id: DefId(0:4 ~ issue_76997_inline_scopes_parenting[bc59]::main::{closure#0}) + // + substs: [ + // i8, + // extern "rust-call" fn(((),)), + // (), + // ] StorageLive(_2); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6 _2 = &_1; // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6 StorageLive(_3); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 StorageLive(_4); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9 - Deinit(_4); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9 - Deinit(_3); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - (_3.0: ()) = move _4; // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 + _4 = (); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9 + _3 = (move _4,); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 StorageLive(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 _5 = move (_3.0: ()); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 StorageLive(_6); // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.diff index 51a98465f..aa62e4a16 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.diff @@ -25,7 +25,7 @@ bb1: { _3 = &_4; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 StorageLive(_5); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 - Deinit(_5); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 + _5 = (); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 - _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 - // mir::Constant - // + span: $DIR/issue_78442.rs:11:5: 11:15 diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff index e47466c5e..21055c6bf 100644 --- a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff @@ -24,7 +24,7 @@ bb1: { _3 = &_4; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 StorageLive(_5); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 - Deinit(_5); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 + _5 = (); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 - _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 + _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 // mir::Constant diff --git a/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff new file mode 100644 index 000000000..8ff64c1ea --- /dev/null +++ b/tests/mir-opt/intrinsic_asserts.generic.InstCombine.diff @@ -0,0 +1,42 @@ +- // MIR for `generic` before InstCombine ++ // MIR for `generic` after InstCombine + + fn generic() -> () { + let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:21: +0:21 + let _1: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 + let _2: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 + let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 + _1 = assert_inhabited::() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:46 + // mir::Constant + // + span: $DIR/intrinsic_asserts.rs:25:5: 25:44 + // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::}, val: Value() } + } + + bb1: { + StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:46: +1:47 + StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 + _2 = assert_zero_valid::() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:47 + // mir::Constant + // + span: $DIR/intrinsic_asserts.rs:26:5: 26:45 + // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::}, val: Value() } + } + + bb2: { + StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:47: +2:48 + StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 + _3 = assert_mem_uninitialized_valid::() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:60 + // mir::Constant + // + span: $DIR/intrinsic_asserts.rs:27:5: 27:58 + // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::}, val: Value() } + } + + bb3: { + StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:60: +3:61 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:21: +4:2 + return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff new file mode 100644 index 000000000..ddc015903 --- /dev/null +++ b/tests/mir-opt/intrinsic_asserts.panics.InstCombine.diff @@ -0,0 +1,47 @@ +- // MIR for `panics` before InstCombine ++ // MIR for `panics` after InstCombine + + fn panics() -> () { + let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:17: +0:17 + let _1: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 + let _2: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 + let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 +- _1 = assert_inhabited::() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 ++ _1 = assert_inhabited::(); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:50 + // mir::Constant + // + span: $DIR/intrinsic_asserts.rs:17:5: 17:48 + // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::}, val: Value() } + } + + bb1: { + StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:50: +1:51 + StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 +- _2 = assert_zero_valid::<&u8>() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 ++ _2 = assert_zero_valid::<&u8>(); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:49 + // mir::Constant + // + span: $DIR/intrinsic_asserts.rs:18:5: 18:47 + // + user_ty: UserType(0) + // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::<&u8>}, val: Value() } + } + + bb2: { + StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:49: +2:50 + StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 +- _3 = assert_mem_uninitialized_valid::<&u8>() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 ++ _3 = assert_mem_uninitialized_valid::<&u8>(); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:62 + // mir::Constant + // + span: $DIR/intrinsic_asserts.rs:19:5: 19:60 + // + user_ty: UserType(1) + // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::<&u8>}, val: Value() } + } + + bb3: { + StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:62: +3:63 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:17: +4:2 + return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff b/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff new file mode 100644 index 000000000..568fbf1a0 --- /dev/null +++ b/tests/mir-opt/intrinsic_asserts.removable.InstCombine.diff @@ -0,0 +1,45 @@ +- // MIR for `removable` before InstCombine ++ // MIR for `removable` after InstCombine + + fn removable() -> () { + let mut _0: (); // return place in scope 0 at $DIR/intrinsic_asserts.rs:+0:20: +0:20 + let _1: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 + let _2: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 + let _3: (); // in scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 +- _1 = assert_inhabited::<()>() -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 +- // mir::Constant +- // + span: $DIR/intrinsic_asserts.rs:7:5: 7:45 +- // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_inhabited::<()>}, val: Value() } ++ goto -> bb1; // scope 0 at $DIR/intrinsic_asserts.rs:+1:5: +1:47 + } + + bb1: { + StorageDead(_1); // scope 0 at $DIR/intrinsic_asserts.rs:+1:47: +1:48 + StorageLive(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 +- _2 = assert_zero_valid::() -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 +- // mir::Constant +- // + span: $DIR/intrinsic_asserts.rs:8:5: 8:46 +- // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_zero_valid::}, val: Value() } ++ goto -> bb2; // scope 0 at $DIR/intrinsic_asserts.rs:+2:5: +2:48 + } + + bb2: { + StorageDead(_2); // scope 0 at $DIR/intrinsic_asserts.rs:+2:48: +2:49 + StorageLive(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 +- _3 = assert_mem_uninitialized_valid::() -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 +- // mir::Constant +- // + span: $DIR/intrinsic_asserts.rs:9:5: 9:59 +- // + literal: Const { ty: extern "rust-intrinsic" fn() {assert_mem_uninitialized_valid::}, val: Value() } ++ goto -> bb3; // scope 0 at $DIR/intrinsic_asserts.rs:+3:5: +3:61 + } + + bb3: { + StorageDead(_3); // scope 0 at $DIR/intrinsic_asserts.rs:+3:61: +3:62 + nop; // scope 0 at $DIR/intrinsic_asserts.rs:+0:20: +4:2 + return; // scope 0 at $DIR/intrinsic_asserts.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/intrinsic_asserts.rs b/tests/mir-opt/intrinsic_asserts.rs new file mode 100644 index 000000000..8fb99cdf6 --- /dev/null +++ b/tests/mir-opt/intrinsic_asserts.rs @@ -0,0 +1,28 @@ +#![crate_type = "lib"] +#![feature(core_intrinsics)] + +// All these assertions pass, so all the intrinsic calls should be deleted. +// EMIT_MIR intrinsic_asserts.removable.InstCombine.diff +pub fn removable() { + core::intrinsics::assert_inhabited::<()>(); + core::intrinsics::assert_zero_valid::(); + core::intrinsics::assert_mem_uninitialized_valid::(); +} + +enum Never {} + +// These assertions all diverge, so their target blocks should become None. +// EMIT_MIR intrinsic_asserts.panics.InstCombine.diff +pub fn panics() { + core::intrinsics::assert_inhabited::(); + core::intrinsics::assert_zero_valid::<&u8>(); + core::intrinsics::assert_mem_uninitialized_valid::<&u8>(); +} + +// Whether or not these asserts pass isn't known, so they shouldn't be modified. +// EMIT_MIR intrinsic_asserts.generic.InstCombine.diff +pub fn generic() { + core::intrinsics::assert_inhabited::(); + core::intrinsics::assert_zero_valid::(); + core::intrinsics::assert_mem_uninitialized_valid::(); +} diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.diff b/tests/mir-opt/issue_101973.inner.ConstProp.diff index b2706e5a4..6db8e4d26 100644 --- a/tests/mir-opt/issue_101973.inner.ConstProp.diff +++ b/tests/mir-opt/issue_101973.inner.ConstProp.diff @@ -15,7 +15,7 @@ let mut _10: (u32, bool); // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 let mut _11: (u32, bool); // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 scope 1 (inlined imm8) { // at $DIR/issue_101973.rs:14:5: 14:17 - debug x => _5; // in scope 1 at $DIR/issue_101973.rs:5:13: 5:14 + debug x => _1; // in scope 1 at $DIR/issue_101973.rs:5:13: 5:14 let mut _12: u32; // in scope 1 at $DIR/issue_101973.rs:7:12: 7:27 let mut _13: u32; // in scope 1 at $DIR/issue_101973.rs:7:12: 7:20 let mut _14: (u32, bool); // in scope 1 at $DIR/issue_101973.rs:7:12: 7:20 @@ -26,25 +26,20 @@ scope 3 (inlined core::num::::rotate_right) { // at $DIR/issue_101973.rs:14:18: 14:58 debug self => _4; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL debug n => _6; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _15: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _16: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL } bb0: { StorageLive(_2); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:65 StorageLive(_3); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:58 StorageLive(_4); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:17 - StorageLive(_5); // scope 0 at $DIR/issue_101973.rs:+1:10: +1:16 - _5 = _1; // scope 0 at $DIR/issue_101973.rs:+1:10: +1:16 StorageLive(_12); // scope 2 at $DIR/issue_101973.rs:7:12: 7:27 StorageLive(_13); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 - _14 = CheckedShr(_5, const 0_i32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 + _14 = CheckedShr(_1, const 0_i32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 assert(!move (_14.1: bool), "attempt to shift right by `{}`, which would overflow", const 0_i32) -> bb3; // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 } bb1: { _8 = move (_10.0: u32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 - StorageDead(_9); // scope 0 at $DIR/issue_101973.rs:+1:44: +1:45 _7 = BitAnd(move _8, const 15_u32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52 StorageDead(_8); // scope 0 at $DIR/issue_101973.rs:+1:51: +1:52 _11 = CheckedShl(_7, const 1_i32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 @@ -54,11 +49,7 @@ bb2: { _6 = move (_11.0: u32); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 StorageDead(_7); // scope 0 at $DIR/issue_101973.rs:+1:56: +1:57 - StorageLive(_15); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _15 = _4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageLive(_16); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _16 = _6; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _3 = rotate_right::(move _15, move _16) -> bb4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _3 = rotate_right::(_4, _6) -> bb4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // + literal: Const { ty: extern "rust-intrinsic" fn(u32, u32) -> u32 {rotate_right::}, val: Value() } @@ -70,19 +61,14 @@ StorageDead(_13); // scope 2 at $DIR/issue_101973.rs:7:26: 7:27 _4 = BitOr(const 0_u32, move _12); // scope 2 at $DIR/issue_101973.rs:7:5: 7:27 StorageDead(_12); // scope 2 at $DIR/issue_101973.rs:7:26: 7:27 - StorageDead(_5); // scope 0 at $DIR/issue_101973.rs:+1:16: +1:17 StorageLive(_6); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 StorageLive(_7); // scope 0 at $DIR/issue_101973.rs:+1:31: +1:52 StorageLive(_8); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 - StorageLive(_9); // scope 0 at $DIR/issue_101973.rs:+1:33: +1:39 - _9 = _1; // scope 0 at $DIR/issue_101973.rs:+1:33: +1:39 - _10 = CheckedShr(_9, const 8_i32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 + _10 = CheckedShr(_1, const 8_i32); // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 assert(!move (_10.1: bool), "attempt to shift right by `{}`, which would overflow", const 8_i32) -> bb1; // scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 } bb4: { - StorageDead(_16); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageDead(_15); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL StorageDead(_6); // scope 0 at $DIR/issue_101973.rs:+1:57: +1:58 StorageDead(_4); // scope 0 at $DIR/issue_101973.rs:+1:57: +1:58 _2 = move _3 as i32 (IntToInt); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:65 diff --git a/tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir b/tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir deleted file mode 100644 index c2ea3ac50..000000000 --- a/tests/mir-opt/issue_41110.main.ElaborateDrops.after.mir +++ /dev/null @@ -1,70 +0,0 @@ -// MIR for `main` after ElaborateDrops - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_41110.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 - let mut _2: S; // in scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 - let mut _3: S; // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:27 - let mut _4: S; // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:22 - let mut _5: bool; // in scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - scope 1 { - debug x => _1; // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10 - } - - bb0: { - _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 - StorageLive(_1); // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 - _5 = const true; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 - _2 = S; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 - StorageLive(_3); // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27 - StorageLive(_4); // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22 - _4 = S; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22 - _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27 - // mir::Constant - // + span: $DIR/issue_41110.rs:8:23: 8:25 - // + literal: Const { ty: fn(S) -> S {S::id}, val: Value() } - } - - bb1: { - StorageDead(_4); // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 - _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28 - _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28 - // mir::Constant - // + span: $DIR/issue_41110.rs:8:15: 8:20 - // + literal: Const { ty: fn(S, S) {S::other}, val: Value() } - } - - bb2: { - StorageDead(_3); // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - StorageDead(_2); // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - _0 = const (); // scope 0 at $DIR/issue_41110.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/issue_41110.rs:+2:1: +2:2 - return; // scope 0 at $DIR/issue_41110.rs:+2:2: +2:2 - } - - bb3 (cleanup): { - goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - } - - bb4 (cleanup): { - goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 - } - - bb5 (cleanup): { - goto -> bb8; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - } - - bb6 (cleanup): { - resume; // scope 0 at $DIR/issue_41110.rs:+0:1: +2:2 - } - - bb7 (cleanup): { - drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - } - - bb8 (cleanup): { - switchInt(_5) -> [0: bb6, otherwise: bb7]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 - } -} diff --git a/tests/mir-opt/issue_41110.main.ElaborateDrops.diff b/tests/mir-opt/issue_41110.main.ElaborateDrops.diff new file mode 100644 index 000000000..7ac75b51a --- /dev/null +++ b/tests/mir-opt/issue_41110.main.ElaborateDrops.diff @@ -0,0 +1,75 @@ +- // MIR for `main` before ElaborateDrops ++ // MIR for `main` after ElaborateDrops + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_41110.rs:+0:11: +0:11 + let _1: (); // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 + let mut _2: S; // in scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 + let mut _3: S; // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:27 + let mut _4: S; // in scope 0 at $DIR/issue_41110.rs:+1:21: +1:22 ++ let mut _5: bool; // in scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + scope 1 { + debug x => _1; // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10 + } + + bb0: { ++ _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 + StorageLive(_1); // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 ++ _5 = const true; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 + _2 = S; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 + StorageLive(_3); // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27 + StorageLive(_4); // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22 + _4 = S; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:22 + _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_41110.rs:+1:21: +1:27 + // mir::Constant + // + span: $DIR/issue_41110.rs:8:23: 8:25 + // + literal: Const { ty: fn(S) -> S {S::id}, val: Value() } + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 ++ _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28 + _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:28 + // mir::Constant + // + span: $DIR/issue_41110.rs:8:15: 8:20 + // + literal: Const { ty: fn(S, S) {S::other}, val: Value() } + } + + bb2: { + StorageDead(_3); // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 ++ _5 = const false; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + StorageDead(_2); // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + _0 = const (); // scope 0 at $DIR/issue_41110.rs:+0:11: +2:2 + StorageDead(_1); // scope 0 at $DIR/issue_41110.rs:+2:1: +2:2 + return; // scope 0 at $DIR/issue_41110.rs:+2:2: +2:2 + } + + bb3 (cleanup): { +- drop(_3) -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 ++ goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + } + + bb4 (cleanup): { +- drop(_4) -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 ++ goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+1:26: +1:27 + } + + bb5 (cleanup): { +- drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 ++ goto -> bb8; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + } + + bb6 (cleanup): { + resume; // scope 0 at $DIR/issue_41110.rs:+0:1: +2:2 ++ } ++ ++ bb7 (cleanup): { ++ drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 ++ } ++ ++ bb8 (cleanup): { ++ switchInt(_5) -> [0: bb6, otherwise: bb7]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 + } + } + diff --git a/tests/mir-opt/issue_41110.rs b/tests/mir-opt/issue_41110.rs index 638dc601e..e1067ce53 100644 --- a/tests/mir-opt/issue_41110.rs +++ b/tests/mir-opt/issue_41110.rs @@ -3,14 +3,14 @@ // check that we don't emit multiple drop flags when they are not needed. -// EMIT_MIR issue_41110.main.ElaborateDrops.after.mir +// EMIT_MIR issue_41110.main.ElaborateDrops.diff fn main() { let x = S.other(S.id()); } // no_mangle to make sure this gets instantiated even in an executable. #[no_mangle] -// EMIT_MIR issue_41110.test.ElaborateDrops.after.mir +// EMIT_MIR issue_41110.test.ElaborateDrops.diff pub fn test() { let u = S; let mut v = S; diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir b/tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir deleted file mode 100644 index 82989c3f0..000000000 --- a/tests/mir-opt/issue_41110.test.ElaborateDrops.after.mir +++ /dev/null @@ -1,101 +0,0 @@ -// MIR for `test` after ElaborateDrops - -fn test() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_41110.rs:+0:15: +0:15 - let _1: S; // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 - let _3: (); // in scope 0 at $DIR/issue_41110.rs:+3:5: +3:12 - let mut _4: S; // in scope 0 at $DIR/issue_41110.rs:+3:10: +3:11 - let mut _5: S; // in scope 0 at $DIR/issue_41110.rs:+4:9: +4:10 - let mut _6: bool; // in scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 - scope 1 { - debug u => _1; // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10 - let mut _2: S; // in scope 1 at $DIR/issue_41110.rs:+2:9: +2:14 - scope 2 { - debug v => _2; // in scope 2 at $DIR/issue_41110.rs:+2:9: +2:14 - } - } - - bb0: { - _6 = const false; // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 - StorageLive(_1); // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 - _6 = const true; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 - _1 = S; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 - StorageLive(_2); // scope 1 at $DIR/issue_41110.rs:+2:9: +2:14 - _2 = S; // scope 1 at $DIR/issue_41110.rs:+2:17: +2:18 - StorageLive(_3); // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12 - StorageLive(_4); // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11 - _4 = move _2; // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11 - _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12 - // mir::Constant - // + span: $DIR/issue_41110.rs:17:5: 17:9 - // + literal: Const { ty: fn(S) {std::mem::drop::}, val: Value() } - } - - bb1: { - StorageDead(_4); // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 - StorageDead(_3); // scope 2 at $DIR/issue_41110.rs:+3:12: +3:13 - StorageLive(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 - _6 = const false; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 - _5 = move _1; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 - goto -> bb12; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 - } - - bb2: { - goto -> bb3; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 - } - - bb3: { - StorageDead(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 - _0 = const (); // scope 0 at $DIR/issue_41110.rs:+0:15: +5:2 - drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 - } - - bb4: { - StorageDead(_2); // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 - goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 - } - - bb5: { - _6 = const false; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 - StorageDead(_1); // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 - return; // scope 0 at $DIR/issue_41110.rs:+5:2: +5:2 - } - - bb6 (cleanup): { - goto -> bb8; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 - } - - bb7 (cleanup): { - goto -> bb8; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 - } - - bb8 (cleanup): { - goto -> bb9; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 - } - - bb9 (cleanup): { - goto -> bb14; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 - } - - bb10 (cleanup): { - resume; // scope 0 at $DIR/issue_41110.rs:+0:1: +5:2 - } - - bb11 (cleanup): { - _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 - goto -> bb6; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 - } - - bb12: { - _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 - goto -> bb2; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 - } - - bb13 (cleanup): { - drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 - } - - bb14 (cleanup): { - switchInt(_6) -> [0: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 - } -} diff --git a/tests/mir-opt/issue_41110.test.ElaborateDrops.diff b/tests/mir-opt/issue_41110.test.ElaborateDrops.diff new file mode 100644 index 000000000..79e3d073b --- /dev/null +++ b/tests/mir-opt/issue_41110.test.ElaborateDrops.diff @@ -0,0 +1,109 @@ +- // MIR for `test` before ElaborateDrops ++ // MIR for `test` after ElaborateDrops + + fn test() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_41110.rs:+0:15: +0:15 + let _1: S; // in scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 + let _3: (); // in scope 0 at $DIR/issue_41110.rs:+3:5: +3:12 + let mut _4: S; // in scope 0 at $DIR/issue_41110.rs:+3:10: +3:11 + let mut _5: S; // in scope 0 at $DIR/issue_41110.rs:+4:9: +4:10 ++ let mut _6: bool; // in scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 + scope 1 { + debug u => _1; // in scope 1 at $DIR/issue_41110.rs:+1:9: +1:10 + let mut _2: S; // in scope 1 at $DIR/issue_41110.rs:+2:9: +2:14 + scope 2 { + debug v => _2; // in scope 2 at $DIR/issue_41110.rs:+2:9: +2:14 + } + } + + bb0: { ++ _6 = const false; // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 + StorageLive(_1); // scope 0 at $DIR/issue_41110.rs:+1:9: +1:10 ++ _6 = const true; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 + _1 = S; // scope 0 at $DIR/issue_41110.rs:+1:13: +1:14 + StorageLive(_2); // scope 1 at $DIR/issue_41110.rs:+2:9: +2:14 + _2 = S; // scope 1 at $DIR/issue_41110.rs:+2:17: +2:18 + StorageLive(_3); // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12 + StorageLive(_4); // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11 + _4 = move _2; // scope 2 at $DIR/issue_41110.rs:+3:10: +3:11 + _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue_41110.rs:+3:5: +3:12 + // mir::Constant + // + span: $DIR/issue_41110.rs:17:5: 17:9 + // + literal: Const { ty: fn(S) {std::mem::drop::}, val: Value() } + } + + bb1: { + StorageDead(_4); // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 + StorageDead(_3); // scope 2 at $DIR/issue_41110.rs:+3:12: +3:13 + StorageLive(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 ++ _6 = const false; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 + _5 = move _1; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 +- replace(_2 <- move _5) -> [return: bb2, unwind: bb6]; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ goto -> bb12; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 + } + + bb2: { +- drop(_5) -> [return: bb3, unwind: bb8]; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 ++ goto -> bb3; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 + } + + bb3: { + StorageDead(_5); // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 + _0 = const (); // scope 0 at $DIR/issue_41110.rs:+0:15: +5:2 + drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 + } + + bb4: { + StorageDead(_2); // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 +- drop(_1) -> bb5; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 ++ goto -> bb5; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 + } + + bb5: { ++ _6 = const false; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 + return; // scope 0 at $DIR/issue_41110.rs:+5:2: +5:2 + } + + bb6 (cleanup): { + drop(_5) -> bb8; // scope 2 at $DIR/issue_41110.rs:+4:9: +4:10 + } + + bb7 (cleanup): { +- drop(_4) -> bb8; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 ++ goto -> bb8; // scope 2 at $DIR/issue_41110.rs:+3:11: +3:12 + } + + bb8 (cleanup): { +- drop(_2) -> bb9; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 ++ goto -> bb9; // scope 1 at $DIR/issue_41110.rs:+5:1: +5:2 + } + + bb9 (cleanup): { +- drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 ++ goto -> bb14; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 + } + + bb10 (cleanup): { + resume; // scope 0 at $DIR/issue_41110.rs:+0:1: +5:2 ++ } ++ ++ bb11 (cleanup): { ++ _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ goto -> bb10; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ } ++ ++ bb12: { ++ _2 = move _5; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ goto -> bb2; // scope 2 at $DIR/issue_41110.rs:+4:5: +4:6 ++ } ++ ++ bb13 (cleanup): { ++ drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 ++ } ++ ++ bb14 (cleanup): { ++ switchInt(_6) -> [0: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 + } + } + diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir b/tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir deleted file mode 100644 index 005042732..000000000 --- a/tests/mir-opt/issue_41888.main.ElaborateDrops.after.mir +++ /dev/null @@ -1,152 +0,0 @@ -// MIR for `main` after ElaborateDrops - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_41888.rs:+0:11: +0:11 - let _1: E; // in scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 - let mut _2: bool; // in scope 0 at $DIR/issue_41888.rs:+2:8: +2:14 - let mut _3: E; // in scope 0 at $DIR/issue_41888.rs:+3:13: +3:20 - let mut _4: K; // in scope 0 at $DIR/issue_41888.rs:+3:18: +3:19 - let mut _5: isize; // in scope 0 at $DIR/issue_41888.rs:+4:16: +4:24 - let mut _7: bool; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - let mut _8: bool; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - let mut _9: bool; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - let mut _10: isize; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - let mut _11: isize; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - scope 1 { - debug e => _1; // in scope 1 at $DIR/issue_41888.rs:+1:9: +1:10 - scope 2 { - debug _k => _6; // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 - let _6: K; // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 - } - } - - bb0: { - _9 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 - _7 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 - _8 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 - StorageLive(_1); // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 - StorageLive(_2); // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 - _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 - // mir::Constant - // + span: $DIR/issue_41888.rs:8:8: 8:12 - // + literal: Const { ty: fn() -> bool {cond}, val: Value() } - } - - bb1: { - switchInt(move _2) -> [0: bb7, otherwise: bb2]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 - } - - bb2: { - StorageLive(_3); // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20 - StorageLive(_4); // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19 - _4 = K; // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19 - _3 = E::F(move _4); // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20 - StorageDead(_4); // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 - goto -> bb14; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - } - - bb3: { - goto -> bb4; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 - } - - bb4: { - StorageDead(_3); // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 - _5 = discriminant(_1); // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24 - switchInt(move _5) -> [0: bb5, otherwise: bb6]; // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24 - } - - bb5: { - StorageLive(_6); // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 - _9 = const false; // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 - _6 = move ((_1 as F).0: K); // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 - _0 = const (); // scope 2 at $DIR/issue_41888.rs:+4:29: +7:10 - StorageDead(_6); // scope 1 at $DIR/issue_41888.rs:+7:9: +7:10 - goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 - } - - bb6: { - _0 = const (); // scope 1 at $DIR/issue_41888.rs:+7:10: +7:10 - goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 - } - - bb7: { - _0 = const (); // scope 1 at $DIR/issue_41888.rs:+8:6: +8:6 - goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+2:5: +8:6 - } - - bb8: { - StorageDead(_2); // scope 1 at $DIR/issue_41888.rs:+8:5: +8:6 - goto -> bb20; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb9: { - _7 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - _8 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - _9 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - StorageDead(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - return; // scope 0 at $DIR/issue_41888.rs:+9:2: +9:2 - } - - bb10 (cleanup): { - goto -> bb11; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 - } - - bb11 (cleanup): { - goto -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb12 (cleanup): { - resume; // scope 0 at $DIR/issue_41888.rs:+0:1: +9:2 - } - - bb13 (cleanup): { - _7 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - _8 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - _9 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - goto -> bb10; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - } - - bb14: { - _7 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - _8 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - _9 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - goto -> bb3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 - } - - bb15: { - _7 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - goto -> bb9; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb16 (cleanup): { - goto -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb17: { - drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb18 (cleanup): { - drop(_1) -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb19: { - _10 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - switchInt(move _10) -> [0: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb20: { - switchInt(_7) -> [0: bb15, otherwise: bb19]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb21 (cleanup): { - _11 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - switchInt(move _11) -> [0: bb16, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } - - bb22 (cleanup): { - switchInt(_7) -> [0: bb12, otherwise: bb21]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 - } -} diff --git a/tests/mir-opt/issue_41888.main.ElaborateDrops.diff b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff new file mode 100644 index 000000000..257f0b1e6 --- /dev/null +++ b/tests/mir-opt/issue_41888.main.ElaborateDrops.diff @@ -0,0 +1,158 @@ +- // MIR for `main` before ElaborateDrops ++ // MIR for `main` after ElaborateDrops + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_41888.rs:+0:11: +0:11 + let _1: E; // in scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 + let mut _2: bool; // in scope 0 at $DIR/issue_41888.rs:+2:8: +2:14 + let mut _3: E; // in scope 0 at $DIR/issue_41888.rs:+3:13: +3:20 + let mut _4: K; // in scope 0 at $DIR/issue_41888.rs:+3:18: +3:19 + let mut _5: isize; // in scope 0 at $DIR/issue_41888.rs:+4:16: +4:24 ++ let mut _7: bool; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ let mut _8: bool; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ let mut _9: bool; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ let mut _10: isize; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ let mut _11: isize; // in scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + scope 1 { + debug e => _1; // in scope 1 at $DIR/issue_41888.rs:+1:9: +1:10 + scope 2 { + debug _k => _6; // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 + let _6: K; // in scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 + } + } + + bb0: { ++ _9 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 ++ _7 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 ++ _8 = const false; // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 + StorageLive(_1); // scope 0 at $DIR/issue_41888.rs:+1:9: +1:10 + StorageLive(_2); // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 + _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 + // mir::Constant + // + span: $DIR/issue_41888.rs:8:8: 8:12 + // + literal: Const { ty: fn() -> bool {cond}, val: Value() } + } + + bb1: { + switchInt(move _2) -> [0: bb7, otherwise: bb2]; // scope 1 at $DIR/issue_41888.rs:+2:8: +2:14 + } + + bb2: { + StorageLive(_3); // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20 + StorageLive(_4); // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19 + _4 = K; // scope 1 at $DIR/issue_41888.rs:+3:18: +3:19 + _3 = E::F(move _4); // scope 1 at $DIR/issue_41888.rs:+3:13: +3:20 + StorageDead(_4); // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 +- replace(_1 <- move _3) -> [return: bb3, unwind: bb10]; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ goto -> bb14; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 + } + + bb3: { +- drop(_3) -> [return: bb4, unwind: bb11]; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 ++ goto -> bb4; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 + } + + bb4: { + StorageDead(_3); // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 + _5 = discriminant(_1); // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24 + switchInt(move _5) -> [0: bb5, otherwise: bb6]; // scope 2 at $DIR/issue_41888.rs:+4:16: +4:24 + } + + bb5: { + StorageLive(_6); // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 ++ _9 = const false; // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 + _6 = move ((_1 as F).0: K); // scope 2 at $DIR/issue_41888.rs:+4:21: +4:23 + _0 = const (); // scope 2 at $DIR/issue_41888.rs:+4:29: +7:10 + StorageDead(_6); // scope 1 at $DIR/issue_41888.rs:+7:9: +7:10 + goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 + } + + bb6: { + _0 = const (); // scope 1 at $DIR/issue_41888.rs:+7:10: +7:10 + goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+4:9: +7:10 + } + + bb7: { + _0 = const (); // scope 1 at $DIR/issue_41888.rs:+8:6: +8:6 + goto -> bb8; // scope 1 at $DIR/issue_41888.rs:+2:5: +8:6 + } + + bb8: { + StorageDead(_2); // scope 1 at $DIR/issue_41888.rs:+8:5: +8:6 +- drop(_1) -> bb9; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ goto -> bb20; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + + bb9: { ++ _7 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ _8 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ _9 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + StorageDead(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + return; // scope 0 at $DIR/issue_41888.rs:+9:2: +9:2 + } + + bb10 (cleanup): { + drop(_3) -> bb11; // scope 1 at $DIR/issue_41888.rs:+3:19: +3:20 + } + + bb11 (cleanup): { +- drop(_1) -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ goto -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + + bb12 (cleanup): { + resume; // scope 0 at $DIR/issue_41888.rs:+0:1: +9:2 ++ } ++ ++ bb13 (cleanup): { ++ _7 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _8 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _9 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ goto -> bb12; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ } ++ ++ bb14: { ++ _7 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _8 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _9 = const true; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ _1 = move _3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ goto -> bb3; // scope 1 at $DIR/issue_41888.rs:+3:9: +3:10 ++ } ++ ++ bb15: { ++ _7 = const false; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ goto -> bb9; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ } ++ ++ bb16 (cleanup): { ++ goto -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ } ++ ++ bb17: { ++ drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ } ++ ++ bb18 (cleanup): { ++ drop(_1) -> bb12; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ } ++ ++ bb19: { ++ _10 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ switchInt(move _10) -> [0: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ } ++ ++ bb20: { ++ switchInt(_7) -> [0: bb15, otherwise: bb19]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ } ++ ++ bb21 (cleanup): { ++ _11 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ switchInt(move _11) -> [0: bb16, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 ++ } ++ ++ bb22 (cleanup): { ++ switchInt(_7) -> [0: bb12, otherwise: bb21]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + } + } + diff --git a/tests/mir-opt/issue_41888.rs b/tests/mir-opt/issue_41888.rs index c1046c14d..0f10c0a1d 100644 --- a/tests/mir-opt/issue_41888.rs +++ b/tests/mir-opt/issue_41888.rs @@ -2,7 +2,7 @@ // check that we clear the "ADT master drop flag" even when there are // no fields to be dropped. -// EMIT_MIR issue_41888.main.ElaborateDrops.after.mir +// EMIT_MIR issue_41888.main.ElaborateDrops.diff fn main() { let e; if cond() { diff --git a/tests/mir-opt/issue_73223.main.SimplifyArmIdentity.diff b/tests/mir-opt/issue_73223.main.SimplifyArmIdentity.diff deleted file mode 100644 index bf3bcfdb5..000000000 --- a/tests/mir-opt/issue_73223.main.SimplifyArmIdentity.diff +++ /dev/null @@ -1,156 +0,0 @@ -- // MIR for `main` before SimplifyArmIdentity -+ // MIR for `main` after SimplifyArmIdentity - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_73223.rs:+0:11: +0:11 - let _1: i32; // in scope 0 at $DIR/issue_73223.rs:+1:9: +1:14 - let mut _2: std::option::Option; // in scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 - let mut _3: isize; // in scope 0 at $DIR/issue_73223.rs:+2:9: +2:16 - let _4: i32; // in scope 0 at $DIR/issue_73223.rs:+2:14: +2:15 - let mut _6: i32; // in scope 0 at $DIR/issue_73223.rs:+6:22: +6:27 - let mut _7: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _8: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _11: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _12: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _13: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _14: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _16: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _17: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _18: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _19: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _20: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _21: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _22: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _24: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 1 { - debug split => _1; // in scope 1 at $DIR/issue_73223.rs:+1:9: +1:14 - let _5: std::option::Option; // in scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 - scope 3 { - debug _prev => _5; // in scope 3 at $DIR/issue_73223.rs:+6:9: +6:14 - let _9: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _10: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _23: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 4 { - debug left_val => _9; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _10; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _15: core::panicking::AssertKind; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 5 { - debug kind => _15; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - } - } - } - scope 2 { - debug v => _4; // in scope 2 at $DIR/issue_73223.rs:+2:14: +2:15 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_73223.rs:+1:9: +1:14 - StorageLive(_2); // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 - Deinit(_2); // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 - ((_2 as Some).0: i32) = const 1_i32; // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 - discriminant(_2) = 1; // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 - _3 = const 1_isize; // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 - goto -> bb3; // scope 0 at $DIR/issue_73223.rs:+1:17: +1:30 - } - - bb1: { - StorageDead(_2); // scope 0 at $DIR/issue_73223.rs:+4:6: +4:7 - StorageDead(_1); // scope 0 at $DIR/issue_73223.rs:+8:1: +8:2 - return; // scope 0 at $DIR/issue_73223.rs:+8:2: +8:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/issue_73223.rs:+1:23: +1:30 - } - - bb3: { - StorageLive(_4); // scope 0 at $DIR/issue_73223.rs:+2:14: +2:15 - _4 = ((_2 as Some).0: i32); // scope 0 at $DIR/issue_73223.rs:+2:14: +2:15 - _1 = _4; // scope 2 at $DIR/issue_73223.rs:+2:20: +2:21 - StorageDead(_4); // scope 0 at $DIR/issue_73223.rs:+2:20: +2:21 - StorageDead(_2); // scope 0 at $DIR/issue_73223.rs:+4:6: +4:7 - StorageLive(_5); // scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 - StorageLive(_6); // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 - _6 = _1; // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 - Deinit(_5); // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 - ((_5 as Some).0: i32) = move _6; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 - discriminant(_5) = 1; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 - StorageDead(_6); // scope 1 at $DIR/issue_73223.rs:+6:27: +6:28 - StorageLive(_24); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _7 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _23 = const _; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } - _8 = _23; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_24); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_25); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = move _7; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _25 = move _8; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_7); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _9 = _24; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _10 = _25; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = (*_9); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _14 = const 1_i32; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = Eq(move _13, const 1_i32); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_14); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_13); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _11 = Not(move _12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_12); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _11) -> [0: bb5, otherwise: bb4]; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb4: { - StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_15) = 0; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_16); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_17); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = const core::panicking::AssertKind::Eq; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } - StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_19); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _19 = _9; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = _19; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_20); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_21); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _21 = _10; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _20 = _21; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_22) = 0; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = core::panicking::assert_failed::(const core::panicking::AssertKind::Eq, move _18, move _20, move _22); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: for<'a, 'b, 'c> fn(core::panicking::AssertKind, &'a i32, &'b i32, Option>) -> ! {core::panicking::assert_failed::}, val: Value() } - // mir::Constant - // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL - // + literal: Const { ty: core::panicking::AssertKind, val: Value(Scalar(0x00)) } - } - - bb5: { - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_24); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_25); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_5); // scope 1 at $DIR/issue_73223.rs:+8:1: +8:2 - StorageDead(_1); // scope 0 at $DIR/issue_73223.rs:+8:1: +8:2 - return; // scope 0 at $DIR/issue_73223.rs:+8:2: +8:2 - } - } - diff --git a/tests/mir-opt/issue_73223.rs b/tests/mir-opt/issue_73223.rs deleted file mode 100644 index be114cab7..000000000 --- a/tests/mir-opt/issue_73223.rs +++ /dev/null @@ -1,12 +0,0 @@ -fn main() { - let split = match Some(1) { - Some(v) => v, - None => return, - }; - - let _prev = Some(split); - assert_eq!(split, 1); -} - - -// EMIT_MIR issue_73223.main.SimplifyArmIdentity.diff diff --git a/tests/mir-opt/issue_76432.rs b/tests/mir-opt/issue_76432.rs index c8b405ca8..fbbfd4ceb 100644 --- a/tests/mir-opt/issue_76432.rs +++ b/tests/mir-opt/issue_76432.rs @@ -1,3 +1,4 @@ +// compile-flags: -Zmir-enable-passes=-NormalizeArrayLen // Check that we do not insert StorageDead at each target if StorageDead was never seen // EMIT_MIR issue_76432.test.SimplifyComparisonIntegral.diff diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index c24543dae..cc4f7cc06 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -29,24 +29,10 @@ bb0: { StorageLive(_2); // scope 0 at $DIR/issue_76432.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29 - StorageLive(_4); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29 StorageLive(_5); // scope 0 at $DIR/issue_76432.rs:+1:20: +1:29 - StorageLive(_6); // scope 0 at $DIR/issue_76432.rs:+1:21: +1:22 - _6 = _1; // scope 0 at $DIR/issue_76432.rs:+1:21: +1:22 - StorageLive(_7); // scope 0 at $DIR/issue_76432.rs:+1:24: +1:25 - _7 = _1; // scope 0 at $DIR/issue_76432.rs:+1:24: +1:25 - StorageLive(_8); // scope 0 at $DIR/issue_76432.rs:+1:27: +1:28 - _8 = _1; // scope 0 at $DIR/issue_76432.rs:+1:27: +1:28 - _5 = [move _6, move _7, move _8]; // scope 0 at $DIR/issue_76432.rs:+1:20: +1:29 - StorageDead(_8); // scope 0 at $DIR/issue_76432.rs:+1:28: +1:29 - StorageDead(_7); // scope 0 at $DIR/issue_76432.rs:+1:28: +1:29 - StorageDead(_6); // scope 0 at $DIR/issue_76432.rs:+1:28: +1:29 + _5 = [_1, _1, _1]; // scope 0 at $DIR/issue_76432.rs:+1:20: +1:29 _4 = &_5; // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29 - _3 = _4; // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29 - _2 = move _3 as &[T] (Pointer(Unsize)); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29 - StorageDead(_3); // scope 0 at $DIR/issue_76432.rs:+1:28: +1:29 - StorageDead(_4); // scope 0 at $DIR/issue_76432.rs:+1:29: +1:30 + _2 = _4 as &[T] (Pointer(Unsize)); // scope 0 at $DIR/issue_76432.rs:+1:19: +1:29 _9 = Len((*_2)); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 _10 = const 3_usize; // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 - _11 = Eq(move _9, const 3_usize); // scope 1 at $DIR/issue_76432.rs:+3:9: +3:33 diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index c17d221f8..291fc5063 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -5,15 +5,14 @@ fn num_to_digit(_1: char) -> u32 { let mut _0: u32; // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38 let mut _2: std::option::Option; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - let mut _9: isize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL scope 1 (inlined char::methods::::is_digit) { // at $DIR/issue_59352.rs:14:12: 14:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL let mut _4: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL let _5: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _6: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL scope 2 (inlined Option::::is_some) { // at $SRC_DIR/core/src/char/methods.rs:LL:COL debug self => _4; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _6: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL } } scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:42: 14:50 @@ -29,9 +28,7 @@ fn num_to_digit(_1: char) -> u32 { StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 StorageLive(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageLive(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageLive(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _6 = _1; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _5 = char::methods::::to_digit(move _6, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _5 = char::methods::::to_digit(_1, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/char/methods.rs:LL:COL // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } @@ -39,7 +36,7 @@ fn num_to_digit(_1: char) -> u32 { bb1: { StorageLive(_2); // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 - _2 = char::methods::::to_digit(move _1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + _2 = char::methods::::to_digit(_1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 // mir::Constant // + span: $DIR/issue_59352.rs:14:30: 14:38 // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } @@ -61,12 +58,11 @@ fn num_to_digit(_1: char) -> u32 { bb5: { _4 = &_5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _9 = discriminant((*_4)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + _6 = discriminant((*_4)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL StorageDead(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:12: +2:23 - switchInt(move _9) -> [1: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + switchInt(move _6) -> [1: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 } bb6: { diff --git a/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff b/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff index 938047803..bcda12880 100644 --- a/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff +++ b/tests/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff @@ -67,17 +67,14 @@ bb7: { StorageDead(_6); // scope 4 at $DIR/issue_75439.rs:+5:35: +5:36 - Deinit(_0); // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 - ((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 - discriminant(_0) = 1; // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 + _0 = Option::<[u8; 4]>::Some(move _5); // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 StorageDead(_5); // scope 3 at $DIR/issue_75439.rs:+5:38: +5:39 StorageDead(_4); // scope 1 at $DIR/issue_75439.rs:+6:5: +6:6 goto -> bb9; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 } bb8: { - Deinit(_0); // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13 - discriminant(_0) = 0; // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13 + _0 = Option::<[u8; 4]>::None; // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13 goto -> bb9; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 } diff --git a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.diff b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.diff index 9bc7060e9..59de067f4 100644 --- a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.diff +++ b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.diff @@ -13,7 +13,6 @@ let _8: usize; // in scope 0 at $DIR/lower_array_len.rs:+2:15: +2:20 let mut _9: usize; // in scope 0 at $DIR/lower_array_len.rs:+2:9: +2:21 let mut _10: bool; // in scope 0 at $DIR/lower_array_len.rs:+2:9: +2:21 -+ let mut _11: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 bb0: { StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:+1:8: +1:27 @@ -23,13 +22,10 @@ StorageLive(_6); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 StorageLive(_7); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 _7 = &(*_2); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ StorageLive(_11); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ _11 = _7; // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 _6 = move _7 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 StorageDead(_7); // scope 0 at $DIR/lower_array_len.rs:+1:20: +1:21 - _5 = Len((*_6)); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ _5 = Len((*_11)); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ StorageDead(_11); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 ++ _5 = const N; // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 goto -> bb1; // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 } diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.diff b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.diff index cf427cfd1..17574b1b6 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.diff @@ -16,7 +16,6 @@ let _11: usize; // in scope 0 at $DIR/lower_array_len.rs:+4:15: +4:16 let mut _12: usize; // in scope 0 at $DIR/lower_array_len.rs:+4:9: +4:17 let mut _13: bool; // in scope 0 at $DIR/lower_array_len.rs:+4:9: +4:17 -+ let mut _14: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 bb0: { StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:+1:8: +1:27 @@ -26,13 +25,10 @@ StorageLive(_6); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 StorageLive(_7); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 _7 = &(*_2); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ StorageLive(_14); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ _14 = _7; // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 _6 = move _7 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 StorageDead(_7); // scope 0 at $DIR/lower_array_len.rs:+1:20: +1:21 - _5 = Len((*_6)); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ _5 = Len((*_14)); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 -+ StorageDead(_14); // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 ++ _5 = const N; // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 goto -> bb1; // scope 0 at $DIR/lower_array_len.rs:+1:16: +1:27 } diff --git a/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff b/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff index 3ed68f5f7..66feff62f 100644 --- a/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff +++ b/tests/mir-opt/lower_array_len.array_len.NormalizeArrayLen.diff @@ -6,19 +6,15 @@ let mut _0: usize; // return place in scope 0 at $DIR/lower_array_len.rs:+0:52: +0:57 let mut _2: &[u8]; // in scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 let mut _3: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ let mut _4: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 bb0: { StorageLive(_2); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 _3 = &(*_1); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ StorageLive(_4); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ _4 = _3; // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 StorageDead(_3); // scope 0 at $DIR/lower_array_len.rs:+1:7: +1:8 - _0 = Len((*_2)); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ _0 = Len((*_4)); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ StorageDead(_4); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 ++ _0 = const N; // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 goto -> bb1; // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 } diff --git a/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.diff b/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.diff index f0e0cdcfd..c0a277edc 100644 --- a/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.diff +++ b/tests/mir-opt/lower_array_len.array_len_by_value.NormalizeArrayLen.diff @@ -6,19 +6,15 @@ let mut _0: usize; // return place in scope 0 at $DIR/lower_array_len.rs:+0:60: +0:65 let mut _2: &[u8]; // in scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 let mut _3: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ let mut _4: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 bb0: { StorageLive(_2); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 _3 = &_1; // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ StorageLive(_4); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ _4 = _3; // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 StorageDead(_3); // scope 0 at $DIR/lower_array_len.rs:+1:7: +1:8 - _0 = Len((*_2)); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ _0 = Len((*_4)); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 -+ StorageDead(_4); // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 ++ _0 = const N; // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 goto -> bb1; // scope 0 at $DIR/lower_array_len.rs:+1:5: +1:14 } diff --git a/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.diff b/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.diff new file mode 100644 index 000000000..8b35fd57f --- /dev/null +++ b/tests/mir-opt/lower_array_len.array_len_raw.NormalizeArrayLen.diff @@ -0,0 +1,50 @@ +- // MIR for `array_len_raw` before NormalizeArrayLen ++ // MIR for `array_len_raw` after NormalizeArrayLen + + fn array_len_raw(_1: [u8; N]) -> usize { + debug arr => _1; // in scope 0 at $DIR/lower_array_len.rs:+0:38: +0:41 + let mut _0: usize; // return place in scope 0 at $DIR/lower_array_len.rs:+0:55: +0:60 + let _2: &[u8]; // in scope 0 at $DIR/lower_array_len.rs:+1:9: +1:12 + let mut _3: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:21: +1:25 + let _4: &[u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:21: +1:25 + let mut _6: &[u8]; // in scope 0 at $DIR/lower_array_len.rs:+3:5: +3:27 + let _7: &[u8]; // in scope 0 at $DIR/lower_array_len.rs:+3:14: +3:19 + scope 1 { + debug arr => _2; // in scope 1 at $DIR/lower_array_len.rs:+1:9: +1:12 + let _5: *const [u8]; // in scope 1 at $DIR/lower_array_len.rs:+2:9: +2:12 + scope 2 { + debug arr => _5; // in scope 2 at $DIR/lower_array_len.rs:+2:9: +2:12 + scope 3 { + } + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/lower_array_len.rs:+1:9: +1:12 + StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:+1:21: +1:25 + StorageLive(_4); // scope 0 at $DIR/lower_array_len.rs:+1:21: +1:25 + _4 = &_1; // scope 0 at $DIR/lower_array_len.rs:+1:21: +1:25 + _3 = &(*_4); // scope 0 at $DIR/lower_array_len.rs:+1:21: +1:25 + _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:+1:21: +1:25 + StorageDead(_3); // scope 0 at $DIR/lower_array_len.rs:+1:24: +1:25 + StorageDead(_4); // scope 0 at $DIR/lower_array_len.rs:+1:25: +1:26 + StorageLive(_5); // scope 1 at $DIR/lower_array_len.rs:+2:9: +2:12 + _5 = &raw const (*_2); // scope 1 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageLive(_6); // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:27 + StorageLive(_7); // scope 2 at $DIR/lower_array_len.rs:+3:14: +3:19 + _7 = &(*_5); // scope 3 at $DIR/lower_array_len.rs:+3:14: +3:19 + _6 = &(*_7); // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:27 +- _0 = Len((*_6)); // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:27 ++ _0 = const N; // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:27 + goto -> bb1; // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:27 + } + + bb1: { + StorageDead(_6); // scope 2 at $DIR/lower_array_len.rs:+3:26: +3:27 + StorageDead(_5); // scope 1 at $DIR/lower_array_len.rs:+4:1: +4:2 + StorageDead(_2); // scope 0 at $DIR/lower_array_len.rs:+4:1: +4:2 + StorageDead(_7); // scope 0 at $DIR/lower_array_len.rs:+4:1: +4:2 + return; // scope 0 at $DIR/lower_array_len.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.diff b/tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.diff new file mode 100644 index 000000000..8bdd2ede6 --- /dev/null +++ b/tests/mir-opt/lower_array_len.array_len_reborrow.NormalizeArrayLen.diff @@ -0,0 +1,44 @@ +- // MIR for `array_len_reborrow` before NormalizeArrayLen ++ // MIR for `array_len_reborrow` after NormalizeArrayLen + + fn array_len_reborrow(_1: [u8; N]) -> usize { + debug arr => _1; // in scope 0 at $DIR/lower_array_len.rs:+0:43: +0:50 + let mut _0: usize; // return place in scope 0 at $DIR/lower_array_len.rs:+0:64: +0:69 + let _2: &mut [u8]; // in scope 0 at $DIR/lower_array_len.rs:+1:9: +1:12 + let mut _3: &mut [u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:25: +1:33 + let mut _4: &mut [u8; N]; // in scope 0 at $DIR/lower_array_len.rs:+1:25: +1:33 + let mut _6: &[u8]; // in scope 0 at $DIR/lower_array_len.rs:+3:5: +3:14 + scope 1 { + debug arr => _2; // in scope 1 at $DIR/lower_array_len.rs:+1:9: +1:12 + let _5: &[u8]; // in scope 1 at $DIR/lower_array_len.rs:+2:9: +2:12 + scope 2 { + debug arr => _5; // in scope 2 at $DIR/lower_array_len.rs:+2:9: +2:12 + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/lower_array_len.rs:+1:9: +1:12 + StorageLive(_3); // scope 0 at $DIR/lower_array_len.rs:+1:25: +1:33 + StorageLive(_4); // scope 0 at $DIR/lower_array_len.rs:+1:25: +1:33 + _4 = &mut _1; // scope 0 at $DIR/lower_array_len.rs:+1:25: +1:33 + _3 = &mut (*_4); // scope 0 at $DIR/lower_array_len.rs:+1:25: +1:33 + _2 = move _3 as &mut [u8] (Pointer(Unsize)); // scope 0 at $DIR/lower_array_len.rs:+1:25: +1:33 + StorageDead(_3); // scope 0 at $DIR/lower_array_len.rs:+1:32: +1:33 + StorageDead(_4); // scope 0 at $DIR/lower_array_len.rs:+1:33: +1:34 + StorageLive(_5); // scope 1 at $DIR/lower_array_len.rs:+2:9: +2:12 + _5 = &(*_2); // scope 1 at $DIR/lower_array_len.rs:+2:15: +2:20 + StorageLive(_6); // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:14 + _6 = &(*_5); // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:14 +- _0 = Len((*_6)); // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:14 ++ _0 = const N; // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:14 + goto -> bb1; // scope 2 at $DIR/lower_array_len.rs:+3:5: +3:14 + } + + bb1: { + StorageDead(_6); // scope 2 at $DIR/lower_array_len.rs:+3:13: +3:14 + StorageDead(_5); // scope 1 at $DIR/lower_array_len.rs:+4:1: +4:2 + StorageDead(_2); // scope 0 at $DIR/lower_array_len.rs:+4:1: +4:2 + return; // scope 0 at $DIR/lower_array_len.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/lower_array_len.rs b/tests/mir-opt/lower_array_len.rs index ea0224b21..972d46cb8 100644 --- a/tests/mir-opt/lower_array_len.rs +++ b/tests/mir-opt/lower_array_len.rs @@ -31,10 +31,26 @@ pub fn array_len_by_value(arr: [u8; N]) -> usize { arr.len() } +// EMIT_MIR lower_array_len.array_len_reborrow.NormalizeArrayLen.diff +pub fn array_len_reborrow(mut arr: [u8; N]) -> usize { + let arr: &mut [_] = &mut arr; + let arr = &*arr; + arr.len() +} + +// EMIT_MIR lower_array_len.array_len_raw.NormalizeArrayLen.diff +pub fn array_len_raw(arr: [u8; N]) -> usize { + let arr: &[_] = &arr; + let arr = std::ptr::addr_of!(*arr); + unsafe { &*arr }.len() +} + fn main() { let _ = array_bound(3, &[0, 1, 2, 3]); let mut tmp = [0, 1, 2, 3, 4]; let _ = array_bound_mut(3, &mut [0, 1, 2, 3]); let _ = array_len(&[0]); let _ = array_len_by_value([0, 2]); + let _ = array_len_reborrow([0, 2]); + let _ = array_len_raw([0, 2]); } diff --git a/tests/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir b/tests/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir deleted file mode 100644 index 701c2ad70..000000000 --- a/tests/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir +++ /dev/null @@ -1,45 +0,0 @@ -// MIR for `array_bound` after PreCodegen - -fn array_bound(_1: usize, _2: &[u8; N]) -> u8 { - debug index => _1; // in scope 0 at $DIR/lower_array_len_e2e.rs:+0:36: +0:41 - debug slice => _2; // in scope 0 at $DIR/lower_array_len_e2e.rs:+0:50: +0:55 - let mut _0: u8; // return place in scope 0 at $DIR/lower_array_len_e2e.rs:+0:70: +0:72 - let mut _3: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - let mut _4: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:13 - let mut _5: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+1:16: +1:27 - let mut _6: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - let mut _7: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - - bb0: { - StorageLive(_3); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - StorageLive(_4); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:13 - _4 = _1; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:13 - StorageLive(_5); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:16: +1:27 - _5 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:16: +1:27 - _3 = Lt(move _4, move _5); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - StorageDead(_5); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:26: +1:27 - StorageDead(_4); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:26: +1:27 - switchInt(move _3) -> [0: bb3, otherwise: bb1]; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - } - - bb1: { - _6 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - _7 = Lt(_1, _6); // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _1) -> bb2; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - } - - bb2: { - _0 = (*_2)[_1]; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - goto -> bb4; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:5: +5:6 - } - - bb3: { - _0 = const 42_u8; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:11 - goto -> bb4; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:5: +5:6 - } - - bb4: { - StorageDead(_3); // scope 0 at $DIR/lower_array_len_e2e.rs:+5:5: +5:6 - return; // scope 0 at $DIR/lower_array_len_e2e.rs:+6:2: +6:2 - } -} diff --git a/tests/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir b/tests/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir deleted file mode 100644 index 0440cfce2..000000000 --- a/tests/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir +++ /dev/null @@ -1,58 +0,0 @@ -// MIR for `array_bound_mut` after PreCodegen - -fn array_bound_mut(_1: usize, _2: &mut [u8; N]) -> u8 { - debug index => _1; // in scope 0 at $DIR/lower_array_len_e2e.rs:+0:40: +0:45 - debug slice => _2; // in scope 0 at $DIR/lower_array_len_e2e.rs:+0:54: +0:59 - let mut _0: u8; // return place in scope 0 at $DIR/lower_array_len_e2e.rs:+0:78: +0:80 - let mut _3: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - let mut _4: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:13 - let mut _5: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+1:16: +1:27 - let mut _6: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - let mut _7: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - let _8: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+4:15: +4:16 - let mut _9: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - let mut _10: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - - bb0: { - StorageLive(_3); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - StorageLive(_4); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:13 - _4 = _1; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:13 - StorageLive(_5); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:16: +1:27 - _5 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:16: +1:27 - _3 = Lt(move _4, move _5); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - StorageDead(_5); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:26: +1:27 - StorageDead(_4); // scope 0 at $DIR/lower_array_len_e2e.rs:+1:26: +1:27 - switchInt(move _3) -> [0: bb3, otherwise: bb1]; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:8: +1:27 - } - - bb1: { - _6 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - _7 = Lt(_1, _6); // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _1) -> bb2; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - } - - bb2: { - _0 = (*_2)[_1]; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - goto -> bb5; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:5: +7:6 - } - - bb3: { - StorageLive(_8); // scope 0 at $DIR/lower_array_len_e2e.rs:+4:15: +4:16 - _8 = const 0_usize; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:15: +4:16 - _9 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - _10 = Lt(const 0_usize, _9); // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, const 0_usize) -> bb4; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - } - - bb4: { - (*_2)[_8] = const 42_u8; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:22 - StorageDead(_8); // scope 0 at $DIR/lower_array_len_e2e.rs:+4:22: +4:23 - _0 = const 42_u8; // scope 0 at $DIR/lower_array_len_e2e.rs:+6:9: +6:11 - goto -> bb5; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:5: +7:6 - } - - bb5: { - StorageDead(_3); // scope 0 at $DIR/lower_array_len_e2e.rs:+7:5: +7:6 - return; // scope 0 at $DIR/lower_array_len_e2e.rs:+8:2: +8:2 - } -} diff --git a/tests/mir-opt/lower_array_len_e2e.array_len.PreCodegen.after.mir b/tests/mir-opt/lower_array_len_e2e.array_len.PreCodegen.after.mir deleted file mode 100644 index 4b19f6795..000000000 --- a/tests/mir-opt/lower_array_len_e2e.array_len.PreCodegen.after.mir +++ /dev/null @@ -1,11 +0,0 @@ -// MIR for `array_len` after PreCodegen - -fn array_len(_1: &[u8; N]) -> usize { - debug arr => _1; // in scope 0 at $DIR/lower_array_len_e2e.rs:+0:34: +0:37 - let mut _0: usize; // return place in scope 0 at $DIR/lower_array_len_e2e.rs:+0:52: +0:57 - - bb0: { - _0 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:5: +1:14 - return; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/lower_array_len_e2e.array_len_by_value.PreCodegen.after.mir b/tests/mir-opt/lower_array_len_e2e.array_len_by_value.PreCodegen.after.mir deleted file mode 100644 index 4dc0ba9a2..000000000 --- a/tests/mir-opt/lower_array_len_e2e.array_len_by_value.PreCodegen.after.mir +++ /dev/null @@ -1,11 +0,0 @@ -// MIR for `array_len_by_value` after PreCodegen - -fn array_len_by_value(_1: [u8; N]) -> usize { - debug arr => _1; // in scope 0 at $DIR/lower_array_len_e2e.rs:+0:43: +0:46 - let mut _0: usize; // return place in scope 0 at $DIR/lower_array_len_e2e.rs:+0:60: +0:65 - - bb0: { - _0 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+1:5: +1:14 - return; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/lower_array_len_e2e.rs b/tests/mir-opt/lower_array_len_e2e.rs deleted file mode 100644 index d8e4e521e..000000000 --- a/tests/mir-opt/lower_array_len_e2e.rs +++ /dev/null @@ -1,39 +0,0 @@ -// compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts - -// EMIT_MIR lower_array_len_e2e.array_bound.PreCodegen.after.mir -pub fn array_bound(index: usize, slice: &[u8; N]) -> u8 { - if index < slice.len() { - slice[index] - } else { - 42 - } -} - -// EMIT_MIR lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir -pub fn array_bound_mut(index: usize, slice: &mut [u8; N]) -> u8 { - if index < slice.len() { - slice[index] - } else { - slice[0] = 42; - - 42 - } -} - -// EMIT_MIR lower_array_len_e2e.array_len.PreCodegen.after.mir -pub fn array_len(arr: &[u8; N]) -> usize { - arr.len() -} - -// EMIT_MIR lower_array_len_e2e.array_len_by_value.PreCodegen.after.mir -pub fn array_len_by_value(arr: [u8; N]) -> usize { - arr.len() -} - -fn main() { - let _ = array_bound(3, &[0, 1, 2, 3]); - let mut tmp = [0, 1, 2, 3, 4]; - let _ = array_bound_mut(3, &mut [0, 1, 2, 3]); - let _ = array_len(&[0]); - let _ = array_len_by_value([0, 2]); -} diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff index ec15fd1ef..5c972a00e 100644 --- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff @@ -25,9 +25,9 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:12 - Deinit(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:15: +1:17 + _1 = (); // scope 0 at $DIR/lower_intrinsics.rs:+1:15: +1:17 StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:16 - Deinit(_2); // scope 1 at $DIR/lower_intrinsics.rs:+2:19: +2:21 + _2 = (); // scope 1 at $DIR/lower_intrinsics.rs:+2:19: +2:21 StorageLive(_3); // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 StorageLive(_4); // scope 3 at $DIR/lower_intrinsics.rs:+4:29: +4:59 StorageLive(_5); // scope 3 at $DIR/lower_intrinsics.rs:+4:29: +4:45 diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 66dae0e46..7147be43c 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -72,3 +72,10 @@ pub fn assume() { std::intrinsics::assume(true); } } + +// EMIT_MIR lower_intrinsics.with_overflow.LowerIntrinsics.diff +pub fn with_overflow(a: i32, b: i32) { + let _x = core::intrinsics::add_with_overflow(a, b); + let _y = core::intrinsics::sub_with_overflow(a, b); + let _z = core::intrinsics::mul_with_overflow(a, b); +} diff --git a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff new file mode 100644 index 000000000..9870a70de --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff @@ -0,0 +1,83 @@ +- // MIR for `with_overflow` before LowerIntrinsics ++ // MIR for `with_overflow` after LowerIntrinsics + + fn with_overflow(_1: i32, _2: i32) -> () { + debug a => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:22: +0:23 + debug b => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:30: +0:31 + let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:38: +0:38 + let _3: (i32, bool); // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:11 + let mut _4: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + let mut _5: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54 + let mut _7: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+2:50: +2:51 + let mut _8: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+2:53: +2:54 + let mut _10: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+3:50: +3:51 + let mut _11: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+3:53: +3:54 + scope 1 { + debug _x => _3; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:11 + let _6: (i32, bool); // in scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:11 + scope 2 { + debug _y => _6; // in scope 2 at $DIR/lower_intrinsics.rs:+2:9: +2:11 + let _9: (i32, bool); // in scope 2 at $DIR/lower_intrinsics.rs:+3:9: +3:11 + scope 3 { + debug _z => _9; // in scope 3 at $DIR/lower_intrinsics.rs:+3:9: +3:11 + } + } + } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:11 + StorageLive(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + _4 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + StorageLive(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54 + _5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54 +- _3 = add_with_overflow::(move _4, move _5) -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:78:14: 78:49 +- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {add_with_overflow::}, val: Value() } ++ _3 = CheckedAdd(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 + } + + bb1: { + StorageDead(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:54: +1:55 + StorageDead(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:54: +1:55 + StorageLive(_6); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:11 + StorageLive(_7); // scope 1 at $DIR/lower_intrinsics.rs:+2:50: +2:51 + _7 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+2:50: +2:51 + StorageLive(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:53: +2:54 + _8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:53: +2:54 +- _6 = sub_with_overflow::(move _7, move _8) -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:79:14: 79:49 +- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {sub_with_overflow::}, val: Value() } ++ _6 = CheckedSub(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 ++ goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 + } + + bb2: { + StorageDead(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:54: +2:55 + StorageDead(_7); // scope 1 at $DIR/lower_intrinsics.rs:+2:54: +2:55 + StorageLive(_9); // scope 2 at $DIR/lower_intrinsics.rs:+3:9: +3:11 + StorageLive(_10); // scope 2 at $DIR/lower_intrinsics.rs:+3:50: +3:51 + _10 = _1; // scope 2 at $DIR/lower_intrinsics.rs:+3:50: +3:51 + StorageLive(_11); // scope 2 at $DIR/lower_intrinsics.rs:+3:53: +3:54 + _11 = _2; // scope 2 at $DIR/lower_intrinsics.rs:+3:53: +3:54 +- _9 = mul_with_overflow::(move _10, move _11) -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:80:14: 80:49 +- // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {mul_with_overflow::}, val: Value() } ++ _9 = CheckedMul(move _10, move _11); // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 ++ goto -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 + } + + bb3: { + StorageDead(_11); // scope 2 at $DIR/lower_intrinsics.rs:+3:54: +3:55 + StorageDead(_10); // scope 2 at $DIR/lower_intrinsics.rs:+3:54: +3:55 + _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:+0:38: +4:2 + StorageDead(_9); // scope 2 at $DIR/lower_intrinsics.rs:+4:1: +4:2 + StorageDead(_6); // scope 1 at $DIR/lower_intrinsics.rs:+4:1: +4:2 + StorageDead(_3); // scope 0 at $DIR/lower_intrinsics.rs:+4:1: +4:2 + return; // scope 0 at $DIR/lower_intrinsics.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/matches_reduce_branches.bar.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.bar.MatchBranchSimplification.diff index be91b0bfe..92f8d4e14 100644 --- a/tests/mir-opt/matches_reduce_branches.bar.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_reduce_branches.bar.MatchBranchSimplification.diff @@ -41,7 +41,7 @@ - _3 = const false; // scope 4 at $DIR/matches_reduce_branches.rs:+16:13: +16:22 - _4 = const false; // scope 4 at $DIR/matches_reduce_branches.rs:+17:13: +17:22 - _5 = const true; // scope 4 at $DIR/matches_reduce_branches.rs:+18:13: +18:21 -- Deinit(_6); // scope 4 at $DIR/matches_reduce_branches.rs:+19:13: +19:15 +- _6 = (); // scope 4 at $DIR/matches_reduce_branches.rs:+19:13: +19:15 - goto -> bb3; // scope 4 at $DIR/matches_reduce_branches.rs:+19:13: +19:15 - } - @@ -54,7 +54,7 @@ + _3 = Eq(_11, const 7_i32); // scope 4 at $DIR/matches_reduce_branches.rs:+9:13: +9:21 _4 = const false; // scope 4 at $DIR/matches_reduce_branches.rs:+10:13: +10:22 _5 = const true; // scope 4 at $DIR/matches_reduce_branches.rs:+11:13: +11:21 - Deinit(_6); // scope 4 at $DIR/matches_reduce_branches.rs:+12:13: +12:15 + _6 = (); // scope 4 at $DIR/matches_reduce_branches.rs:+12:13: +12:15 - goto -> bb3; // scope 4 at $DIR/matches_reduce_branches.rs:+12:13: +12:15 - } - @@ -69,11 +69,7 @@ _9 = _4; // scope 4 at $DIR/matches_reduce_branches.rs:+23:12: +23:13 StorageLive(_10); // scope 4 at $DIR/matches_reduce_branches.rs:+23:15: +23:16 _10 = _5; // scope 4 at $DIR/matches_reduce_branches.rs:+23:15: +23:16 - Deinit(_0); // scope 4 at $DIR/matches_reduce_branches.rs:+23:5: +23:17 - (_0.0: bool) = move _7; // scope 4 at $DIR/matches_reduce_branches.rs:+23:5: +23:17 - (_0.1: bool) = move _8; // scope 4 at $DIR/matches_reduce_branches.rs:+23:5: +23:17 - (_0.2: bool) = move _9; // scope 4 at $DIR/matches_reduce_branches.rs:+23:5: +23:17 - (_0.3: bool) = move _10; // scope 4 at $DIR/matches_reduce_branches.rs:+23:5: +23:17 + _0 = (move _7, move _8, move _9, move _10); // scope 4 at $DIR/matches_reduce_branches.rs:+23:5: +23:17 StorageDead(_10); // scope 4 at $DIR/matches_reduce_branches.rs:+23:16: +23:17 StorageDead(_9); // scope 4 at $DIR/matches_reduce_branches.rs:+23:16: +23:17 StorageDead(_8); // scope 4 at $DIR/matches_reduce_branches.rs:+23:16: +23:17 diff --git a/tests/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.diff index aa8092ece..0580f7334 100644 --- a/tests/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.diff @@ -34,7 +34,7 @@ - } - - bb4: { - Deinit(_0); // scope 0 at $DIR/matches_reduce_branches.rs:+2:9: +2:11 + _0 = (); // scope 0 at $DIR/matches_reduce_branches.rs:+2:9: +2:11 - goto -> bb6; // scope 0 at $DIR/matches_reduce_branches.rs:+1:5: +3:6 + goto -> bb3; // scope 0 at $DIR/matches_reduce_branches.rs:+1:5: +3:6 } diff --git a/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff index 193104dd3..20e8ef2f7 100644 --- a/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff @@ -20,7 +20,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/matches_reduce_branches.rs:+1:9: +1:12 StorageLive(_2); // scope 0 at $DIR/matches_reduce_branches.rs:+1:21: +1:23 - Deinit(_2); // scope 0 at $DIR/matches_reduce_branches.rs:+1:21: +1:23 + _2 = (); // scope 0 at $DIR/matches_reduce_branches.rs:+1:21: +1:23 StorageLive(_3); // scope 0 at $DIR/matches_reduce_branches.rs:+2:15: +6:10 StorageLive(_4); // scope 0 at $DIR/matches_reduce_branches.rs:+2:18: +2:76 StorageLive(_5); // scope 0 at $DIR/matches_reduce_branches.rs:+2:21: +2:52 diff --git a/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir index e52253486..210f178a0 100644 --- a/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir @@ -16,20 +16,15 @@ fn main() -> () { StorageLive(_1); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:9: +1:14 StorageLive(_2); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42 StorageLive(_3); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41 - Deinit(_3); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41 - (_3.0: usize) = const 0_usize; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41 - Deinit(_2); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42 - (_2.0: Droppy) = move _3; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42 + _3 = Droppy(const 0_usize); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41 + _2 = Aligned(move _3); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42 StorageDead(_3); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:41: +1:42 - Deinit(_1); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:17: +1:43 - (_1.0: Aligned) = move _2; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:17: +1:43 + _1 = Packed(move _2); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:17: +1:43 StorageDead(_2); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:42: +1:43 StorageLive(_4); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29 StorageLive(_5); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28 - Deinit(_5); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28 - (_5.0: usize) = const 0_usize; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28 - Deinit(_4); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29 - (_4.0: Droppy) = move _5; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29 + _5 = Droppy(const 0_usize); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28 + _4 = Aligned(move _5); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29 StorageDead(_5); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:28: +2:29 StorageLive(_6); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 _6 = move (_1.0: Aligned); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 diff --git a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff index ed1d0b87f..a8dd91efc 100644 --- a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff +++ b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.diff @@ -31,9 +31,7 @@ _1 = const 0_i32; // scope 0 at $DIR/remove_storage_markers.rs:+1:19: +1:20 - StorageLive(_2); // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 - StorageLive(_3); // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 - Deinit(_3); // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 - (_3.0: i32) = const 0_i32; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 - (_3.1: i32) = const 10_i32; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 + _3 = std::ops::Range:: { start: const 0_i32, end: const 10_i32 }; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 _2 = as IntoIterator>::into_iter(move _3) -> bb1; // scope 1 at $DIR/remove_storage_markers.rs:+2:14: +2:19 // mir::Constant // + span: $DIR/remove_storage_markers.rs:10:14: 10:19 diff --git a/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir b/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir index 12e914e25..af34bc5ed 100644 --- a/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir +++ b/tests/mir-opt/remove_zsts.get_union.PreCodegen.after.mir @@ -2,9 +2,12 @@ fn get_union() -> Foo { let mut _0: Foo; // return place in scope 0 at $DIR/remove_zsts.rs:+0:19: +0:22 + let mut _1: (); // in scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 bb0: { - Deinit(_0); // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 + StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 + _0 = Foo { x: move _1 }; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 + StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff index 169b7b105..0af29b2ba 100644 --- a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff +++ b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff @@ -7,11 +7,9 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 -- Deinit(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 +- _1 = (); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 + nop; // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 - Deinit(_0); // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 -- (_0.0: ()) = move _1; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 -+ nop; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 + _0 = Foo { x: move _1 }; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir index 19b726e74..3b479710b 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir @@ -122,9 +122,7 @@ fn array_casts() -> () { // + literal: Const { ty: &usize, val: Unevaluated(array_casts, [], Some(promoted[0])) } Retag(_35); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _18 = &(*_35); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_13.0: &usize) = move _14; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_13.1: &usize) = move _18; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = (move _14, move _18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL Retag(_13); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_14); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -150,8 +148,7 @@ fn array_casts() -> () { bb3: { StorageLive(_27); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_27); // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_27) = 0; // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _27 = core::panicking::AssertKind::Eq; // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_28); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_29); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _29 = move _27; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -164,8 +161,7 @@ fn array_casts() -> () { _33 = &(*_21); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _32 = &(*_33); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - discriminant(_34) = 0; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _34 = Option::>::None; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL Retag(_34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _28 = core::panicking::assert_failed::(move _29, move _30, move _32, move _34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant diff --git a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir index b853e4505..d7b6d64b6 100644 --- a/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir +++ b/tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir @@ -62,8 +62,7 @@ fn main() -> () { StorageLive(_3); // scope 1 at $DIR/retag.rs:+3:13: +3:14 StorageLive(_4); // scope 1 at $DIR/retag.rs:+3:17: +3:36 StorageLive(_5); // scope 1 at $DIR/retag.rs:+3:17: +3:24 - Deinit(_5); // scope 1 at $DIR/retag.rs:+3:17: +3:24 - (_5.0: i32) = const 0_i32; // scope 1 at $DIR/retag.rs:+3:17: +3:24 + _5 = Test(const 0_i32); // scope 1 at $DIR/retag.rs:+3:17: +3:24 _4 = &_5; // scope 1 at $DIR/retag.rs:+3:17: +3:36 StorageLive(_6); // scope 1 at $DIR/retag.rs:+3:29: +3:35 StorageLive(_7); // scope 1 at $DIR/retag.rs:+3:29: +3:35 @@ -107,7 +106,14 @@ fn main() -> () { StorageDead(_2); // scope 1 at $DIR/retag.rs:+8:5: +8:6 StorageLive(_13); // scope 1 at $DIR/retag.rs:+11:9: +11:10 StorageLive(_14); // scope 1 at $DIR/retag.rs:+11:31: +14:6 - Deinit(_14); // scope 1 at $DIR/retag.rs:+11:31: +14:6 + _14 = [closure@main::{closure#0}]; // scope 1 at $DIR/retag.rs:+11:31: +14:6 + // closure + // + def_id: DefId(0:14 ~ retag[4622]::main::{closure#0}) + // + substs: [ + // i8, + // for<'a> extern "rust-call" fn((&'a i32,)) -> &'a i32, + // (), + // ] Retag(_14); // scope 1 at $DIR/retag.rs:+11:31: +14:6 _13 = move _14 as for<'a> fn(&'a i32) -> &'a i32 (Pointer(ClosureFnPointer(Normal))); // scope 1 at $DIR/retag.rs:+11:31: +14:6 StorageDead(_14); // scope 1 at $DIR/retag.rs:+11:47: +11:48 @@ -129,8 +135,7 @@ fn main() -> () { StorageLive(_19); // scope 7 at $DIR/retag.rs:+18:5: +18:24 StorageLive(_20); // scope 7 at $DIR/retag.rs:+18:5: +18:24 StorageLive(_21); // scope 7 at $DIR/retag.rs:+18:5: +18:12 - Deinit(_21); // scope 7 at $DIR/retag.rs:+18:5: +18:12 - (_21.0: i32) = const 0_i32; // scope 7 at $DIR/retag.rs:+18:5: +18:12 + _21 = Test(const 0_i32); // scope 7 at $DIR/retag.rs:+18:5: +18:12 _20 = &_21; // scope 7 at $DIR/retag.rs:+18:5: +18:24 StorageLive(_22); // scope 7 at $DIR/retag.rs:+18:21: +18:23 StorageLive(_23); // scope 7 at $DIR/retag.rs:+18:21: +18:23 diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index e57544e09..cfcd43093 100644 --- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -12,18 +12,18 @@ let mut _7: !; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 let mut _8: std::result::Result; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 let _9: i32; // in scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + let mut _16: i32; // in scope 0 at $SRC_DIR/core/src/result.rs:LL:COL scope 1 { debug residual => _6; // in scope 1 at $DIR/separate_const_switch.rs:+1:9: +1:10 scope 2 { scope 8 (inlined #[track_caller] as FromResidual>>::from_residual) { // at $DIR/separate_const_switch.rs:25:8: 25:10 debug residual => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let _16: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _17: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _18: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + let _14: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _15: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL scope 9 { - debug e => _16; // in scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + debug e => _14; // in scope 9 at $SRC_DIR/core/src/result.rs:LL:COL scope 10 (inlined >::from) { // at $SRC_DIR/core/src/result.rs:LL:COL - debug t => _18; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => _16; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL } } } @@ -38,15 +38,13 @@ debug self => _4; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL let mut _10: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL let _11: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _12: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let _13: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _14: std::result::Result; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _15: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _12: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _13: std::result::Result; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL scope 6 { debug v => _11; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL } scope 7 { - debug e => _13; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + debug e => _12; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } } @@ -55,53 +53,50 @@ StorageLive(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:9 _4 = _1; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:9 + StorageLive(_11); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + StorageLive(_12); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 _10 = discriminant(_4); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -- switchInt(move _10) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _10) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } bb1: { -- StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 -- _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 -- switchInt(move _5) -> [0: bb2, 1: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 -- } -- -- bb2: { + StorageDead(_12); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + StorageDead(_11); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 + _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + switchInt(move _5) -> [0: bb2, 1: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + } + + bb2: { StorageLive(_9); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 _9 = ((_3 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 _2 = _9; // scope 4 at $DIR/separate_const_switch.rs:+1:8: +1:10 StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 - Deinit(_0); // scope 0 at $DIR/separate_const_switch.rs:+1:5: +1:11 - ((_0 as Ok).0: i32) = move _2; // scope 0 at $DIR/separate_const_switch.rs:+1:5: +1:11 - discriminant(_0) = 0; // scope 0 at $DIR/separate_const_switch.rs:+1:5: +1:11 + _0 = Result::::Ok(move _2); // scope 0 at $DIR/separate_const_switch.rs:+1:5: +1:11 StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+1:10: +1:11 StorageDead(_3); // scope 0 at $DIR/separate_const_switch.rs:+2:1: +2:2 return; // scope 0 at $DIR/separate_const_switch.rs:+2:2: +2:2 } -- bb3: { -+ bb2: { + bb3: { unreachable; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 } -- bb4: { -+ bb3: { + bb4: { StorageLive(_6); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 _6 = ((_3 as Break).0: std::result::Result); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 StorageLive(_8); // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10 _8 = _6; // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10 - StorageLive(_16); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - _16 = move ((_8 as Err).0: i32); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_17); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_18); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - _18 = move _16; // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - _17 = move _18; // scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_18); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - Deinit(_0); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - ((_0 as Err).0: i32) = move _17; // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - discriminant(_0) = 1; // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_17); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_16); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + StorageLive(_14); // scope 2 at $DIR/separate_const_switch.rs:+1:8: +1:10 + _14 = move ((_8 as Err).0: i32); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + StorageLive(_15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + StorageLive(_16); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + _16 = move _14; // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + _15 = move _16; // scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + StorageDead(_16); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + _0 = Result::::Err(move _15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_14); // scope 2 at $DIR/separate_const_switch.rs:+1:8: +1:10 StorageDead(_8); // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10 StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+1:10: +1:11 @@ -109,48 +104,23 @@ return; // scope 0 at $DIR/separate_const_switch.rs:+2:2: +2:2 } -- bb5: { -+ bb4: { - StorageLive(_13); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - _13 = move ((_4 as Err).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_14); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_15); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _15 = move _13; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - Deinit(_14); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - ((_14 as Err).0: i32) = move _15; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - discriminant(_14) = 1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_15); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - Deinit(_3); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - ((_3 as Break).0: std::result::Result) = move _14; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - discriminant(_3) = 1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_14); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_13); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -- goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 -+ _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 -+ switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + bb5: { + _12 = move ((_4 as Err).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + StorageLive(_13); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _13 = Result::::Err(move _12); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = ControlFlow::, i32>::Break(move _13); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_13); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } -- bb6: { -+ bb5: { + bb6: { unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } -- bb7: { -+ bb6: { - StorageLive(_11); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + bb7: { _11 = move ((_4 as Ok).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - _12 = move _11; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - Deinit(_3); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - ((_3 as Continue).0: i32) = move _12; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - discriminant(_3) = 0; // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_11); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -- goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL -+ StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 -+ _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 -+ switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + _3 = ControlFlow::, i32>::Continue(move _11); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } } diff --git a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff index 8cc0c6a18..3c7e9dc61 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff @@ -38,14 +38,10 @@ _6 = ((_1 as Err).0: usize); // scope 0 at $DIR/separate_const_switch.rs:+8:17: +8:18 StorageLive(_7); // scope 2 at $DIR/separate_const_switch.rs:+8:42: +8:43 _7 = _6; // scope 2 at $DIR/separate_const_switch.rs:+8:42: +8:43 - Deinit(_2); // scope 2 at $DIR/separate_const_switch.rs:+8:23: +8:44 - ((_2 as Break).0: usize) = move _7; // scope 2 at $DIR/separate_const_switch.rs:+8:23: +8:44 - discriminant(_2) = 1; // scope 2 at $DIR/separate_const_switch.rs:+8:23: +8:44 + _2 = ControlFlow::::Break(move _7); // scope 2 at $DIR/separate_const_switch.rs:+8:23: +8:44 StorageDead(_7); // scope 2 at $DIR/separate_const_switch.rs:+8:43: +8:44 StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44 -- goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44 -+ _8 = discriminant(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6 -+ switchInt(move _8) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6 + goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44 } bb2: { @@ -57,53 +53,41 @@ _4 = ((_1 as Ok).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17 StorageLive(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:44: +7:45 _5 = _4; // scope 1 at $DIR/separate_const_switch.rs:+7:44: +7:45 - Deinit(_2); // scope 1 at $DIR/separate_const_switch.rs:+7:22: +7:46 - ((_2 as Continue).0: i32) = move _5; // scope 1 at $DIR/separate_const_switch.rs:+7:22: +7:46 - discriminant(_2) = 0; // scope 1 at $DIR/separate_const_switch.rs:+7:22: +7:46 + _2 = ControlFlow::::Continue(move _5); // scope 1 at $DIR/separate_const_switch.rs:+7:22: +7:46 StorageDead(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:45: +7:46 StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46 -- goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46 -- } -- -- bb4: { + goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46 + } + + bb4: { _8 = discriminant(_2); // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6 -- switchInt(move _8) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6 -+ switchInt(move _8) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6 + switchInt(move _8) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 0 at $DIR/separate_const_switch.rs:+5:5: +10:6 } -- bb5: { -+ bb4: { + bb5: { StorageLive(_11); // scope 0 at $DIR/separate_const_switch.rs:+12:28: +12:29 _11 = ((_2 as Break).0: usize); // scope 0 at $DIR/separate_const_switch.rs:+12:28: +12:29 - Deinit(_0); // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38 - discriminant(_0) = 0; // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38 + _0 = Option::::None; // scope 4 at $DIR/separate_const_switch.rs:+12:34: +12:38 StorageDead(_11); // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38 -- goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38 -+ goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38 + goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+12:37: +12:38 } -- bb6: { -+ bb5: { + bb6: { unreachable; // scope 0 at $DIR/separate_const_switch.rs:+5:11: +10:6 } -- bb7: { -+ bb6: { + bb7: { StorageLive(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32 _9 = ((_2 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32 StorageLive(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:42: +11:43 _10 = _9; // scope 3 at $DIR/separate_const_switch.rs:+11:42: +11:43 - Deinit(_0); // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44 - ((_0 as Some).0: i32) = move _10; // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44 - discriminant(_0) = 1; // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44 + _0 = Option::::Some(move _10); // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44 StorageDead(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:43: +11:44 StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 -- goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 -+ goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 + goto -> bb8; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 } -- bb8: { -+ bb7: { + bb8: { StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+14:1: +14:2 return; // scope 0 at $DIR/separate_const_switch.rs:+14:2: +14:2 } diff --git a/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir b/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir index 916f99049..66ba4df76 100644 --- a/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/simple_option_map_e2e.ezmap.PreCodegen.after.mir @@ -8,12 +8,12 @@ fn ezmap(_1: Option) -> Option { debug slf => _1; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:17: 2:20 debug f => _2; // in scope 1 at $DIR/simple_option_map_e2e.rs:2:33: 2:34 let mut _3: isize; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:9: 7:16 - let mut _4: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 + let _4: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 let mut _5: i32; // in scope 1 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 scope 2 { - debug x => _5; // in scope 2 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 + debug x => _4; // in scope 2 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map_e2e.rs:7:25: 7:29 - debug n => _5; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14 + debug n => _4; // in scope 3 at $DIR/simple_option_map_e2e.rs:+1:13: +1:14 } } } @@ -25,8 +25,7 @@ fn ezmap(_1: Option) -> Option { } bb1: { - Deinit(_0); // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 - discriminant(_0) = 0; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 + _0 = Option::::None; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 goto -> bb4; // scope 1 at $DIR/simple_option_map_e2e.rs:8:17: 8:21 } @@ -35,13 +34,11 @@ fn ezmap(_1: Option) -> Option { } bb3: { - _5 = move ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 - StorageLive(_4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 - _4 = Add(move _5, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21 - Deinit(_0); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30 - ((_0 as Some).0: i32) = move _4; // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30 - discriminant(_0) = 1; // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30 - StorageDead(_4); // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30 + _4 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map_e2e.rs:7:14: 7:15 + StorageLive(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:25: 7:29 + _5 = Add(_4, const 1_i32); // scope 3 at $DIR/simple_option_map_e2e.rs:+1:16: +1:21 + _0 = Option::::Some(move _5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:20: 7:30 + StorageDead(_5); // scope 2 at $DIR/simple_option_map_e2e.rs:7:29: 7:30 goto -> bb4; // scope 1 at $DIR/simple_option_map_e2e.rs:10:1: 10:2 } diff --git a/tests/mir-opt/simplify_locals.d1.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals.d1.SimplifyLocals-before-const-prop.diff index 981738030..946595e32 100644 --- a/tests/mir-opt/simplify_locals.d1.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals.d1.SimplifyLocals-before-const-prop.diff @@ -9,8 +9,7 @@ bb0: { - StorageLive(_1); // scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17 -- Deinit(_1); // scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17 -- discriminant(_1) = 0; // scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17 +- _1 = E::A; // scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17 - StorageDead(_1); // scope 0 at $DIR/simplify_locals.rs:+2:17: +2:18 _0 = const (); // scope 0 at $DIR/simplify_locals.rs:+0:9: +3:2 return; // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2 diff --git a/tests/mir-opt/simplify_locals.d2.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals.d2.SimplifyLocals-before-const-prop.diff index b152dc8cc..6a5dc56e2 100644 --- a/tests/mir-opt/simplify_locals.d2.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals.d2.SimplifyLocals-before-const-prop.diff @@ -9,15 +9,11 @@ bb0: { - StorageLive(_1); // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26 -- Deinit(_1); // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26 -- discriminant(_1) = 1; // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26 +- _1 = E::B; // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26 - StorageLive(_2); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:17 - StorageLive(_3); // scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15 -- Deinit(_3); // scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15 -- discriminant(_3) = 0; // scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15 -- Deinit(_2); // scope 0 at $DIR/simplify_locals.rs:+2:6: +2:16 -- (_2.0: i32) = const 10_i32; // scope 0 at $DIR/simplify_locals.rs:+2:6: +2:16 -- (_2.1: E) = move _3; // scope 0 at $DIR/simplify_locals.rs:+2:6: +2:16 +- _3 = E::A; // scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15 +- _2 = (const 10_i32, move _3); // scope 0 at $DIR/simplify_locals.rs:+2:6: +2:16 - StorageDead(_3); // scope 0 at $DIR/simplify_locals.rs:+2:15: +2:16 - (_2.1: E) = move _1; // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:26 - StorageDead(_1); // scope 0 at $DIR/simplify_locals.rs:+2:25: +2:26 diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff index f888c622d..f908e8dd0 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff @@ -18,14 +18,10 @@ bb0: { StorageLive(_1); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69 StorageLive(_2); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49 - Deinit(_2); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49 - discriminant(_2) = 0; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49 + _2 = Option::::None; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49 StorageLive(_3); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68 - Deinit(_3); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68 - discriminant(_3) = 0; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68 - Deinit(_1); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69 - (_1.0: std::option::Option) = move _2; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69 - (_1.1: std::option::Option) = move _3; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69 + _3 = Option::::None; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68 + _1 = (move _2, move _3); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69 StorageDead(_3); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:68: +1:69 StorageDead(_2); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:68: +1:69 _5 = discriminant((_1.0: std::option::Option)); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27 @@ -38,15 +34,10 @@ } bb2: { - StorageLive(_6); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19 _6 = (((_1.0: std::option::Option) as Some).0: u8); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19 - StorageLive(_7); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:20 -- StorageLive(_8); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:13 -- _8 = _6; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:13 -- _7 = Gt(move _8, const 42_u8); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:20 -- StorageDead(_8); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:19: +2:20 +- _7 = Gt(_6, const 42_u8); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:20 - StorageDead(_7); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+4:9: +4:10 - StorageDead(_6); // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+5:5: +5:6 goto -> bb3; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:5: +5:6 } diff --git a/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff index efb2b0961..0f8866f9c 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals-before-const-prop.diff @@ -28,36 +28,30 @@ bb0: { - StorageLive(_1); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28 - StorageLive(_2); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:21: +1:23 -- Deinit(_2); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:21: +1:23 +- _2 = (); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:21: +1:23 - StorageLive(_3); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:25: +1:27 -- Deinit(_3); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:25: +1:27 -- Deinit(_1); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28 -- (_1.0: ()) = move _2; // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28 -- (_1.1: ()) = move _3; // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28 +- _3 = (); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:25: +1:27 +- _1 = (move _2, move _3); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28 - StorageDead(_3); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:27: +1:28 - StorageDead(_2); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:27: +1:28 - StorageDead(_1); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:28: +1:29 - StorageLive(_4); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22 - StorageLive(_5); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 - StorageLive(_6); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 -- Deinit(_6); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 +- _6 = (); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 - StorageLive(_7); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 -- Deinit(_7); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 -- Deinit(_5); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 -- (_5.0: ()) = move _6; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 -- (_5.1: ()) = move _7; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 +- _7 = (); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 +- _5 = (move _6, move _7); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 - StorageDead(_7); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21 - StorageDead(_6); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21 - _4 = use_zst(move _5) -> bb1; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22 + StorageLive(_1); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22 + StorageLive(_2); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 + StorageLive(_3); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 -+ Deinit(_3); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 ++ _3 = (); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 + StorageLive(_4); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 -+ Deinit(_4); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 -+ Deinit(_2); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 -+ (_2.0: ()) = move _3; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 -+ (_2.1: ()) = move _4; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 ++ _4 = (); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 ++ _2 = (move _3, move _4); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 + StorageDead(_4); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21 + StorageDead(_3); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:20: +2:21 + _1 = use_zst(move _2) -> bb1; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22 @@ -73,8 +67,7 @@ - StorageLive(_9); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34 - StorageLive(_10); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30 - StorageLive(_11); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 -- Deinit(_11); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 -- (_11.0: u8) = const 40_u8; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 +- _11 = Temp { x: const 40_u8 }; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 - _10 = (_11.0: u8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30 - _9 = Add(move _10, const 2_u8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34 - StorageDead(_10); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:33: +4:34 @@ -85,8 +78,7 @@ + StorageLive(_6); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34 + StorageLive(_7); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30 + StorageLive(_8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 -+ Deinit(_8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 -+ (_8.0: u8) = const 40_u8; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 ++ _8 = Temp { x: const 40_u8 }; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 + _7 = (_8.0: u8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30 + _6 = Add(move _7, const 2_u8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34 + StorageDead(_7); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:33: +4:34 diff --git a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff index 027c983e6..3f9af31d8 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff @@ -26,9 +26,7 @@ _3 = move ((_1 as Some).0: std::boxed::Box<()>); // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15 StorageLive(_4); // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:25: +3:26 _4 = move _3; // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:25: +3:26 - Deinit(_0); // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:20: +3:27 - ((_0 as Some).0: std::boxed::Box<()>) = move _4; // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:20: +3:27 - discriminant(_0) = 1; // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:20: +3:27 + _0 = Option::>::Some(move _4); // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:20: +3:27 StorageDead(_4); // scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:26: +3:27 StorageDead(_3); // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:26: +3:27 goto -> bb4; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:26: +3:27 @@ -39,8 +37,7 @@ } bb3: { - Deinit(_0); // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21 - discriminant(_0) = 0; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21 + _0 = Option::>::None; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21 goto -> bb4; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21 } diff --git a/tests/mir-opt/simplify_match.main.ConstProp.diff b/tests/mir-opt/simplify_match.main.ConstProp.diff index 70bfbf1b3..b700adfb1 100644 --- a/tests/mir-opt/simplify_match.main.ConstProp.diff +++ b/tests/mir-opt/simplify_match.main.ConstProp.diff @@ -10,13 +10,8 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/simplify_match.rs:+1:11: +1:31 - StorageLive(_2); // scope 0 at $DIR/simplify_match.rs:+1:17: +1:18 _2 = const false; // scope 0 at $DIR/simplify_match.rs:+1:21: +1:26 -- _1 = _2; // scope 1 at $DIR/simplify_match.rs:+1:28: +1:29 -+ _1 = const false; // scope 1 at $DIR/simplify_match.rs:+1:28: +1:29 - StorageDead(_2); // scope 0 at $DIR/simplify_match.rs:+1:30: +1:31 -- switchInt(_1) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_match.rs:+1:5: +1:31 +- switchInt(_2) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_match.rs:+1:5: +1:31 + switchInt(const false) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_match.rs:+1:5: +1:31 } @@ -32,7 +27,6 @@ } bb3: { - StorageDead(_1); // scope 0 at $DIR/simplify_match.rs:+5:1: +5:2 return; // scope 0 at $DIR/simplify_match.rs:+5:2: +5:2 } } diff --git a/tests/mir-opt/slice_filter.rs b/tests/mir-opt/slice_filter.rs new file mode 100644 index 000000000..97c18af31 --- /dev/null +++ b/tests/mir-opt/slice_filter.rs @@ -0,0 +1,18 @@ +fn main() { + let input = vec![]; + let _variant_a_result = variant_a(&input); + let _variant_b_result = variant_b(&input); +} + +pub fn variant_a(input: &[(usize, usize, usize, usize)]) -> usize { + input.iter().filter(|(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count() +} + +pub fn variant_b(input: &[(usize, usize, usize, usize)]) -> usize { + input.iter().filter(|&&(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count() +} + +// EMIT_MIR slice_filter.variant_a-{closure#0}.CopyProp.diff +// EMIT_MIR slice_filter.variant_a-{closure#0}.DestinationPropagation.diff +// EMIT_MIR slice_filter.variant_b-{closure#0}.CopyProp.diff +// EMIT_MIR slice_filter.variant_b-{closure#0}.DestinationPropagation.diff diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff new file mode 100644 index 000000000..3bb0358ff --- /dev/null +++ b/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff @@ -0,0 +1,279 @@ +- // MIR for `variant_a::{closure#0}` before CopyProp ++ // MIR for `variant_a::{closure#0}` after CopyProp + + fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:8:25: 8:39], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 + let _3: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + let _4: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + let _5: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + let _6: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 + let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 + let mut _9: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:41 + let mut _10: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let _11: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 + let mut _13: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51 + let mut _14: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let _15: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 + let mut _17: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 + let mut _18: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61 + let mut _19: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let _20: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let mut _21: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 + let mut _22: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:71 + let mut _23: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let _24: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let mut _25: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _26: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _27: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _28: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _31: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _32: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _37: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _38: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _43: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _44: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _49: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _50: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 1 { + debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 + debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 + debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 + debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 + scope 2 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:40: 8:46 + debug self => _9; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _10; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _29: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _30: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 3 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _31; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _32; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => _29; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => _30; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _33: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _34: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 4 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:60: 8:66 + debug self => _18; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _19; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _35: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _36: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 5 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _37; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _38; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => _35; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => _36; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _39: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _40: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 6 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:50: 8:56 + debug self => _13; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _14; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _41: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _42: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 7 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _43; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _44; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => _41; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => _42; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _45: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _46: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 8 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:70: 8:76 + debug self => _22; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _23; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _47: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _48: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 9 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug self => _49; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- debug other => _50; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug self => _47; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ debug other => _48; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _51: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _52: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + } + + bb0: { +- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 +- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 +- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 +- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + _28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + _6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 + StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 + _9 = &_3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 + StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _11 = _5; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _10 = &_11; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _29 = deref_copy (*_9); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + _30 = deref_copy (*_10); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_31); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _31 = _29; // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_32); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _32 = _30; // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _33 = (*_31); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _33 = (*_29); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _34 = (*_32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _34 = (*_30); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _8 = Le(move _33, move _34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_32); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_31); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb1: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb2: { + StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 + StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 + _18 = &_5; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 + StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _20 = _3; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _19 = &_20; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _35 = deref_copy (*_18); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + _36 = deref_copy (*_19); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_37); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _37 = _35; // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_38); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _38 = _36; // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _39 = (*_37); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _39 = (*_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _40 = (*_38); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _40 = (*_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _17 = Le(move _39, move _40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_38); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_37); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + switchInt(move _17) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb3: { + StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 + } + + bb4: { + _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb5: { + StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 + StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 + _13 = &_6; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 + StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _15 = _4; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _14 = &_15; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _41 = deref_copy (*_13); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + _42 = deref_copy (*_14); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_43); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _43 = _41; // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_44); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _44 = _42; // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _45 = (*_43); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _45 = (*_41); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _46 = (*_44); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _46 = (*_42); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _12 = Le(move _45, move _46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_44); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_43); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _7 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb6: { + _16 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb7: { + StorageLive(_21); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 + StorageLive(_22); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 + _22 = &_4; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 + StorageLive(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageLive(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _24 = _6; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _23 = &_24; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _47 = deref_copy (*_22); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _48 = deref_copy (*_23); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_49); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _49 = _47; // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageLive(_50); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _50 = _48; // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _51 = (*_49); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _51 = (*_47); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _52 = (*_50); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _52 = (*_48); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _21 = Le(move _51, move _52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_50); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL +- StorageDead(_49); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_22); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _16 = move _21; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb8: { + StorageDead(_21); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _0 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + } + diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff new file mode 100644 index 000000000..294c3272f --- /dev/null +++ b/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff @@ -0,0 +1,237 @@ +- // MIR for `variant_a::{closure#0}` before DestinationPropagation ++ // MIR for `variant_a::{closure#0}` after DestinationPropagation + + fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:8:25: 8:39], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 + let _3: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + let _4: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + let _5: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + let _6: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 + let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 + let mut _9: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:41 + let mut _10: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let _11: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 + let mut _13: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51 + let mut _14: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let _15: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 + let mut _17: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 + let mut _18: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61 + let mut _19: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let _20: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let mut _21: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 + let mut _22: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:71 + let mut _23: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let _24: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let mut _25: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _26: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _27: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let mut _28: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + scope 1 { + debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 + debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 + debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 + debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 + scope 2 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:40: 8:46 + debug self => _9; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _10; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _29: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _30: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 3 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _29; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _30; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _31: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _32: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 4 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:60: 8:66 + debug self => _18; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _19; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _33: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _34: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 5 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _33; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _34; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _35: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _36: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 6 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:50: 8:56 + debug self => _13; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _14; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _37: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _38: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 7 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _37; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _38; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _39: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _40: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 8 (inlined cmp::impls::::le) { // at $DIR/slice_filter.rs:8:70: 8:76 + debug self => _22; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _23; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _41: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _42: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 9 (inlined cmp::impls::::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _41; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _42; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _43: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _44: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + } + + bb0: { + _25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + _6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 +- StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 + StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 + _9 = &_3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 + StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _11 = _5; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _10 = &_11; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _29 = deref_copy (*_9); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + _30 = deref_copy (*_10); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_31); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _31 = (*_29); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _32 = (*_30); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _8 = Le(move _31, move _32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_31); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb1: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb2: { +- StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 + StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 + _18 = &_5; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 + StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _20 = _3; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _19 = &_20; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _33 = deref_copy (*_18); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + _34 = deref_copy (*_19); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _35 = (*_33); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _36 = (*_34); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _17 = Le(move _35, move _36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + switchInt(move _17) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb3: { +- StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 + } + + bb4: { +- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb5: { +- StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 + StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 + _13 = &_6; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 + StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _15 = _4; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _14 = &_15; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _37 = deref_copy (*_13); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + _38 = deref_copy (*_14); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_39); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _39 = (*_37); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_40); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _40 = (*_38); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _12 = Le(move _39, move _40); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_40); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_39); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- _7 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 +- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 +- switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 ++ switchInt(move _12) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb6: { +- _16 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 ++ _0 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb7: { +- StorageLive(_21); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 + StorageLive(_22); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 + _22 = &_4; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 + StorageLive(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageLive(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _24 = _6; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _23 = &_24; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _41 = deref_copy (*_22); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _42 = deref_copy (*_23); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_43); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _43 = (*_41); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _44 = (*_42); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL +- _21 = Le(move _43, move _44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL ++ _0 = Le(move _43, move _44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_44); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_43); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_22); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- _16 = move _21; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb8: { +- StorageDead(_21); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 +- _0 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + } + diff --git a/tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff b/tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff new file mode 100644 index 000000000..5e4bdbdfa --- /dev/null +++ b/tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff @@ -0,0 +1,139 @@ +- // MIR for `variant_b::{closure#0}` before CopyProp ++ // MIR for `variant_b::{closure#0}` after CopyProp + + fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:12:25: 12:41], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42 + let _3: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + let _5: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58 + let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48 + let mut _9: usize; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:43 + let mut _10: usize; // in scope 0 at $DIR/slice_filter.rs:+0:47: +0:48 + let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58 + let mut _12: usize; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:53 + let mut _13: usize; // in scope 0 at $DIR/slice_filter.rs:+0:57: +0:58 + let mut _14: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78 + let mut _15: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68 + let mut _16: usize; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:63 + let mut _17: usize; // in scope 0 at $DIR/slice_filter.rs:+0:67: +0:68 + let mut _18: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78 + let mut _19: usize; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:73 + let mut _20: usize; // in scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 + let mut _21: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _22: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _23: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _24: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + scope 1 { + debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30 + debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33 + debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36 + debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39 + } + + bb0: { +- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _21 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _3 = ((*_21).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 +- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _22 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _4 = ((*_22).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 +- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _23 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _5 = ((*_23).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 +- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + _24 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + _6 = ((*_24).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 +- StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:43 +- _9 = _3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:43 +- StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 +- _10 = _5; // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 +- _8 = Le(move _9, move _10); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 +- StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 +- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 ++ _8 = Le(_3, _5); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 + switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb1: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb2: { + StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 +- StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:63 +- _16 = _5; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:63 +- StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 +- _17 = _3; // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 +- _15 = Le(move _16, move _17); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 +- StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 +- StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 ++ _15 = Le(_5, _3); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 + switchInt(move _15) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb3: { + StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 +- StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 +- StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 +- StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 +- StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 + return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78 + } + + bb4: { + _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb5: { + StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 +- StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:53 +- _12 = _6; // scope 1 at $DIR/slice_filter.rs:+0:52: +0:53 +- StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 +- _13 = _4; // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 +- _11 = Le(move _12, move _13); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 +- StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 +- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 ++ _11 = Le(_6, _4); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 + _7 = move _11; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb6: { + _14 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb7: { + StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 +- StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:73 +- _19 = _4; // scope 1 at $DIR/slice_filter.rs:+0:72: +0:73 +- StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 +- _20 = _6; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 +- _18 = Le(move _19, move _20); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 +- StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 +- StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 ++ _18 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 + _14 = move _18; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb8: { + StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + _0 = move _14; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + } + diff --git a/tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff b/tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff new file mode 100644 index 000000000..45af6600c --- /dev/null +++ b/tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff @@ -0,0 +1,109 @@ +- // MIR for `variant_b::{closure#0}` before DestinationPropagation ++ // MIR for `variant_b::{closure#0}` after DestinationPropagation + + fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:12:25: 12:41], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42 + let _3: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + let _5: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58 + let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48 + let mut _9: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58 + let mut _10: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78 + let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68 + let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78 + let mut _13: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _14: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _15: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let mut _16: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + scope 1 { + debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30 + debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33 + debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36 + debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39 + } + + bb0: { + _13 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _3 = ((*_13).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _14 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _4 = ((*_14).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _15 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _5 = ((*_15).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _16 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + _6 = ((*_16).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 +- StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 + _8 = Le(_3, _5); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 + switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb1: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb2: { +- StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 + _11 = Le(_5, _3); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 + switchInt(move _11) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb3: { +- StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 +- StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78 + } + + bb4: { +- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb5: { +- StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 + _9 = Le(_6, _4); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 +- _7 = move _9; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 +- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 +- switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 ++ switchInt(move _9) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb6: { +- _10 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 ++ _0 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb7: { +- StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 +- _12 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 +- _10 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 ++ _0 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb8: { +- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 +- _0 = move _10; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 ++ nop; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + } + diff --git a/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..9e33215f2 --- /dev/null +++ b/tests/mir-opt/sroa.constant.ScalarReplacementOfAggregates.diff @@ -0,0 +1,46 @@ +- // MIR for `constant` before ScalarReplacementOfAggregates ++ // MIR for `constant` after ScalarReplacementOfAggregates + + fn constant() -> () { + let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:15: +0:15 + let _1: (usize, u8); // in scope 0 at $DIR/sroa.rs:+2:9: +2:10 ++ let _4: usize; // in scope 0 at $DIR/sroa.rs:+2:9: +2:10 ++ let _5: u8; // in scope 0 at $DIR/sroa.rs:+2:9: +2:10 + scope 1 { +- debug y => _1; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 ++ debug y => (usize, u8){ .0 => _4, .1 => _5, }; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 + let _2: usize; // in scope 1 at $DIR/sroa.rs:+3:9: +3:10 + scope 2 { + debug t => _2; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10 + let _3: u8; // in scope 2 at $DIR/sroa.rs:+4:9: +4:10 + scope 3 { + debug u => _3; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 + } + } + } + + bb0: { +- StorageLive(_1); // scope 0 at $DIR/sroa.rs:+2:9: +2:10 ++ StorageLive(_4); // scope 0 at $DIR/sroa.rs:+2:9: +2:10 ++ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+2:9: +2:10 ++ nop; // scope 0 at $DIR/sroa.rs:+2:9: +2:10 + _1 = const _; // scope 0 at $DIR/sroa.rs:+2:13: +2:14 ++ _4 = move (_1.0: usize); // scope 1 at $DIR/sroa.rs:+3:9: +3:10 ++ _5 = move (_1.1: u8); // scope 1 at $DIR/sroa.rs:+3:9: +3:10 + StorageLive(_2); // scope 1 at $DIR/sroa.rs:+3:9: +3:10 +- _2 = (_1.0: usize); // scope 1 at $DIR/sroa.rs:+3:13: +3:16 ++ _2 = _4; // scope 1 at $DIR/sroa.rs:+3:13: +3:16 + StorageLive(_3); // scope 2 at $DIR/sroa.rs:+4:9: +4:10 +- _3 = (_1.1: u8); // scope 2 at $DIR/sroa.rs:+4:13: +4:16 ++ _3 = _5; // scope 2 at $DIR/sroa.rs:+4:13: +4:16 + _0 = const (); // scope 0 at $DIR/sroa.rs:+0:15: +5:2 + StorageDead(_3); // scope 2 at $DIR/sroa.rs:+5:1: +5:2 + StorageDead(_2); // scope 1 at $DIR/sroa.rs:+5:1: +5:2 +- StorageDead(_1); // scope 0 at $DIR/sroa.rs:+5:1: +5:2 ++ StorageDead(_4); // scope 0 at $DIR/sroa.rs:+5:1: +5:2 ++ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+5:1: +5:2 ++ nop; // scope 0 at $DIR/sroa.rs:+5:1: +5:2 + return; // scope 0 at $DIR/sroa.rs:+5:2: +5:2 + } + } + diff --git a/tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..976f6d44b --- /dev/null +++ b/tests/mir-opt/sroa.copies.ScalarReplacementOfAggregates.diff @@ -0,0 +1,91 @@ +- // MIR for `copies` before ScalarReplacementOfAggregates ++ // MIR for `copies` after ScalarReplacementOfAggregates + + fn copies(_1: Foo) -> () { + debug x => _1; // in scope 0 at $DIR/sroa.rs:+0:11: +0:12 + let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19 + let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _11: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _12: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _13: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _14: std::option::Option; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 + scope 1 { +- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 ++ debug y => Foo{ .0 => _11, .1 => _12, .2 => _13, .3 => _14, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 + let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 + scope 2 { + debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10 + let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10 + scope 3 { + debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10 + let _5: Foo; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ let _7: u8; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ let _8: (); // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ let _9: &str; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ let _10: std::option::Option; // in scope 3 at $DIR/sroa.rs:+4:9: +4:10 + scope 4 { +- debug z => _5; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10 ++ debug z => Foo{ .0 => _7, .1 => _8, .2 => _9, .3 => _10, }; // in scope 4 at $DIR/sroa.rs:+4:9: +4:10 + let _6: (); // in scope 4 at $DIR/sroa.rs:+5:9: +5:10 + scope 5 { + debug a => _6; // in scope 5 at $DIR/sroa.rs:+5:9: +5:10 + } + } + } + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 +- _2 = _1; // scope 0 at $DIR/sroa.rs:+1:13: +1:14 ++ StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ StorageLive(_12); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ StorageLive(_13); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ StorageLive(_14); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ _11 = (_1.0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 ++ _12 = (_1.1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 ++ _13 = (_1.2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 ++ _14 = (_1.3: std::option::Option); // scope 0 at $DIR/sroa.rs:+1:13: +1:14 ++ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:14 + StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10 +- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16 ++ _3 = _11; // scope 1 at $DIR/sroa.rs:+2:13: +2:16 + StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10 +- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16 +- StorageLive(_5); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 +- _5 = _2; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 ++ _4 = _13; // scope 2 at $DIR/sroa.rs:+3:13: +3:16 ++ StorageLive(_7); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ StorageLive(_8); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ StorageLive(_9); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ StorageLive(_10); // scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ nop; // scope 3 at $DIR/sroa.rs:+4:9: +4:10 ++ _7 = _11; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 ++ _8 = _12; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 ++ _9 = _13; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 ++ _10 = _14; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 ++ nop; // scope 3 at $DIR/sroa.rs:+4:13: +4:14 + StorageLive(_6); // scope 4 at $DIR/sroa.rs:+5:9: +5:10 +- _6 = (_5.1: ()); // scope 4 at $DIR/sroa.rs:+5:13: +5:16 ++ _6 = _8; // scope 4 at $DIR/sroa.rs:+5:13: +5:16 + _0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +6:2 + StorageDead(_6); // scope 4 at $DIR/sroa.rs:+6:1: +6:2 +- StorageDead(_5); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_7); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_8); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_9); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_10); // scope 3 at $DIR/sroa.rs:+6:1: +6:2 ++ nop; // scope 3 at $DIR/sroa.rs:+6:1: +6:2 + StorageDead(_4); // scope 2 at $DIR/sroa.rs:+6:1: +6:2 + StorageDead(_3); // scope 1 at $DIR/sroa.rs:+6:1: +6:2 +- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_11); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_12); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_13); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 ++ StorageDead(_14); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 ++ nop; // scope 0 at $DIR/sroa.rs:+6:1: +6:2 + return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2 + } + } + diff --git a/tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff index eb8830446..17a89e7d8 100644 --- a/tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff @@ -13,18 +13,12 @@ StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:5: +1:32 StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:5: +1:30 StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:7: +1:13 - Deinit(_3); // scope 0 at $DIR/sroa.rs:+1:7: +1:13 - (_3.0: usize) = const 0_usize; // scope 0 at $DIR/sroa.rs:+1:7: +1:13 + _3 = Tag(const 0_usize); // scope 0 at $DIR/sroa.rs:+1:7: +1:13 StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:15: +1:21 - Deinit(_4); // scope 0 at $DIR/sroa.rs:+1:15: +1:21 - (_4.0: usize) = const 1_usize; // scope 0 at $DIR/sroa.rs:+1:15: +1:21 + _4 = Tag(const 1_usize); // scope 0 at $DIR/sroa.rs:+1:15: +1:21 StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:23: +1:29 - Deinit(_5); // scope 0 at $DIR/sroa.rs:+1:23: +1:29 - (_5.0: usize) = const 2_usize; // scope 0 at $DIR/sroa.rs:+1:23: +1:29 - Deinit(_2); // scope 0 at $DIR/sroa.rs:+1:5: +1:30 - (_2.0: Tag) = move _3; // scope 0 at $DIR/sroa.rs:+1:5: +1:30 - (_2.1: Tag) = move _4; // scope 0 at $DIR/sroa.rs:+1:5: +1:30 - (_2.2: Tag) = move _5; // scope 0 at $DIR/sroa.rs:+1:5: +1:30 + _5 = Tag(const 2_usize); // scope 0 at $DIR/sroa.rs:+1:23: +1:29 + _2 = S(move _3, move _4, move _5); // scope 0 at $DIR/sroa.rs:+1:5: +1:30 StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:29: +1:30 StorageDead(_4); // scope 0 at $DIR/sroa.rs:+1:29: +1:30 StorageDead(_3); // scope 0 at $DIR/sroa.rs:+1:29: +1:30 diff --git a/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff index a5488c1ec..04d26162a 100644 --- a/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff @@ -16,9 +16,7 @@ StorageLive(_2); // scope 1 at $DIR/sroa.rs:+1:22: +1:29 StorageLive(_3); // scope 1 at $DIR/sroa.rs:+1:27: +1:28 _3 = _1; // scope 1 at $DIR/sroa.rs:+1:27: +1:28 - Deinit(_2); // scope 1 at $DIR/sroa.rs:+1:22: +1:29 - ((_2 as Some).0: usize) = move _3; // scope 1 at $DIR/sroa.rs:+1:22: +1:29 - discriminant(_2) = 1; // scope 1 at $DIR/sroa.rs:+1:22: +1:29 + _2 = Option::::Some(move _3); // scope 1 at $DIR/sroa.rs:+1:22: +1:29 StorageDead(_3); // scope 1 at $DIR/sroa.rs:+1:28: +1:29 _4 = discriminant(_2); // scope 1 at $DIR/sroa.rs:+1:12: +1:19 switchInt(move _4) -> [1: bb1, otherwise: bb2]; // scope 1 at $DIR/sroa.rs:+1:12: +1:19 diff --git a/tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff index 64559b58f..fd691fdd1 100644 --- a/tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff @@ -3,45 +3,42 @@ fn escaping() -> () { let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19 - let _1: (); // in scope 0 at $DIR/sroa.rs:+2:5: +2:42 - let mut _2: *const u32; // in scope 0 at $DIR/sroa.rs:+2:7: +2:41 - let _3: &u32; // in scope 0 at $DIR/sroa.rs:+2:7: +2:41 - let _4: Escaping; // in scope 0 at $DIR/sroa.rs:+2:8: +2:39 - let mut _5: u32; // in scope 0 at $DIR/sroa.rs:+2:34: +2:37 + let _1: (); // in scope 0 at $DIR/sroa.rs:+1:5: +1:42 + let mut _2: *const u32; // in scope 0 at $DIR/sroa.rs:+1:7: +1:41 + let _3: &u32; // in scope 0 at $DIR/sroa.rs:+1:7: +1:41 + let _4: Escaping; // in scope 0 at $DIR/sroa.rs:+1:8: +1:39 + let mut _5: u32; // in scope 0 at $DIR/sroa.rs:+1:34: +1:37 bb0: { - StorageLive(_1); // scope 0 at $DIR/sroa.rs:+2:5: +2:42 - StorageLive(_2); // scope 0 at $DIR/sroa.rs:+2:7: +2:41 - StorageLive(_3); // scope 0 at $DIR/sroa.rs:+2:7: +2:41 - StorageLive(_4); // scope 0 at $DIR/sroa.rs:+2:8: +2:39 - StorageLive(_5); // scope 0 at $DIR/sroa.rs:+2:34: +2:37 - _5 = g() -> bb1; // scope 0 at $DIR/sroa.rs:+2:34: +2:37 + StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:5: +1:42 + StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 + StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 + StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:8: +1:39 + StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:34: +1:37 + _5 = g() -> bb1; // scope 0 at $DIR/sroa.rs:+1:34: +1:37 // mir::Constant // + span: $DIR/sroa.rs:78:34: 78:35 // + literal: Const { ty: fn() -> u32 {g}, val: Value() } } bb1: { - Deinit(_4); // scope 0 at $DIR/sroa.rs:+2:8: +2:39 - (_4.0: u32) = const 1_u32; // scope 0 at $DIR/sroa.rs:+2:8: +2:39 - (_4.1: u32) = const 2_u32; // scope 0 at $DIR/sroa.rs:+2:8: +2:39 - (_4.2: u32) = move _5; // scope 0 at $DIR/sroa.rs:+2:8: +2:39 - StorageDead(_5); // scope 0 at $DIR/sroa.rs:+2:38: +2:39 - _3 = &(_4.0: u32); // scope 0 at $DIR/sroa.rs:+2:7: +2:41 - _2 = &raw const (*_3); // scope 0 at $DIR/sroa.rs:+2:7: +2:41 - _1 = f(move _2) -> bb2; // scope 0 at $DIR/sroa.rs:+2:5: +2:42 + _4 = Escaping { a: const 1_u32, b: const 2_u32, c: move _5 }; // scope 0 at $DIR/sroa.rs:+1:8: +1:39 + StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:38: +1:39 + _3 = &(_4.0: u32); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 + _2 = &raw const (*_3); // scope 0 at $DIR/sroa.rs:+1:7: +1:41 + _1 = f(move _2) -> bb2; // scope 0 at $DIR/sroa.rs:+1:5: +1:42 // mir::Constant // + span: $DIR/sroa.rs:78:5: 78:6 // + literal: Const { ty: fn(*const u32) {f}, val: Value() } } bb2: { - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+2:41: +2:42 - StorageDead(_4); // scope 0 at $DIR/sroa.rs:+2:42: +2:43 - StorageDead(_3); // scope 0 at $DIR/sroa.rs:+2:42: +2:43 - StorageDead(_1); // scope 0 at $DIR/sroa.rs:+2:42: +2:43 - _0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +3:2 - return; // scope 0 at $DIR/sroa.rs:+3:2: +3:2 + StorageDead(_2); // scope 0 at $DIR/sroa.rs:+1:41: +1:42 + StorageDead(_4); // scope 0 at $DIR/sroa.rs:+1:42: +1:43 + StorageDead(_3); // scope 0 at $DIR/sroa.rs:+1:42: +1:43 + StorageDead(_1); // scope 0 at $DIR/sroa.rs:+1:42: +1:43 + _0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +2:2 + return; // scope 0 at $DIR/sroa.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff index d4c04d5e6..69631fc02 100644 --- a/tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff @@ -35,28 +35,20 @@ + StorageLive(_9); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 + StorageLive(_10); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 + StorageLive(_11); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 ++ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:45: +1:47 - Deinit(_6); // scope 0 at $DIR/sroa.rs:+1:45: +1:47 + _6 = (); // scope 0 at $DIR/sroa.rs:+1:45: +1:47 StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:60: +1:68 - Deinit(_7); // scope 0 at $DIR/sroa.rs:+1:60: +1:68 - ((_7 as Some).0: isize) = const -4_isize; // scope 0 at $DIR/sroa.rs:+1:60: +1:68 - discriminant(_7) = 1; // scope 0 at $DIR/sroa.rs:+1:60: +1:68 -- Deinit(_5); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -- (_5.0: u8) = const 5_u8; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -- (_5.1: ()) = move _6; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -- (_5.2: &str) = const "a"; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ Deinit(_8); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ Deinit(_9); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ Deinit(_10); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 -+ Deinit(_11); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 + _7 = Option::::Some(const -4_isize); // scope 0 at $DIR/sroa.rs:+1:60: +1:68 +- _5 = Foo { a: const 5_u8, b: move _6, c: const "a", d: move _7 }; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 + _8 = const 5_u8; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 + _9 = move _6; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 + _10 = const "a"; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 // mir::Constant - // + span: $DIR/sroa.rs:57:52: 57:55 + // + span: $DIR/sroa.rs:53:52: 53:55 // + literal: Const { ty: &str, val: Value(Slice(..)) } -- (_5.3: std::option::Option) = move _7; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 + _11 = move _7; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 ++ nop; // scope 0 at $DIR/sroa.rs:+1:30: +1:70 StorageDead(_7); // scope 0 at $DIR/sroa.rs:+1:69: +1:70 StorageDead(_6); // scope 0 at $DIR/sroa.rs:+1:69: +1:70 StorageLive(_1); // scope 0 at $DIR/sroa.rs:+1:15: +1:16 @@ -76,6 +68,7 @@ + StorageDead(_9); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 + StorageDead(_10); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 + StorageDead(_11); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 ++ nop; // scope 0 at $DIR/sroa.rs:+1:70: +1:71 _0 = const (); // scope 0 at $DIR/sroa.rs:+0:15: +6:2 StorageDead(_4); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 diff --git a/tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..f0d62220d --- /dev/null +++ b/tests/mir-opt/sroa.ref_copies.ScalarReplacementOfAggregates.diff @@ -0,0 +1,56 @@ +- // MIR for `ref_copies` before ScalarReplacementOfAggregates ++ // MIR for `ref_copies` after ScalarReplacementOfAggregates + + fn ref_copies(_1: &Foo) -> () { + debug x => _1; // in scope 0 at $DIR/sroa.rs:+0:15: +0:16 + let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:24: +0:24 + let _2: Foo; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _5: u8; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _6: (); // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _7: &str; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ let _8: std::option::Option; // in scope 0 at $DIR/sroa.rs:+1:9: +1:10 + scope 1 { +- debug y => _2; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 ++ debug y => Foo{ .0 => _5, .1 => _6, .2 => _7, .3 => _8, }; // in scope 1 at $DIR/sroa.rs:+1:9: +1:10 + let _3: u8; // in scope 1 at $DIR/sroa.rs:+2:9: +2:10 + scope 2 { + debug t => _3; // in scope 2 at $DIR/sroa.rs:+2:9: +2:10 + let _4: &str; // in scope 2 at $DIR/sroa.rs:+3:9: +3:10 + scope 3 { + debug u => _4; // in scope 3 at $DIR/sroa.rs:+3:9: +3:10 + } + } + } + + bb0: { +- StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 +- _2 = (*_1); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 ++ StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ StorageLive(_7); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ nop; // scope 0 at $DIR/sroa.rs:+1:9: +1:10 ++ _5 = ((*_1).0: u8); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 ++ _6 = ((*_1).1: ()); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 ++ _7 = ((*_1).2: &str); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 ++ _8 = ((*_1).3: std::option::Option); // scope 0 at $DIR/sroa.rs:+1:13: +1:15 ++ nop; // scope 0 at $DIR/sroa.rs:+1:13: +1:15 + StorageLive(_3); // scope 1 at $DIR/sroa.rs:+2:9: +2:10 +- _3 = (_2.0: u8); // scope 1 at $DIR/sroa.rs:+2:13: +2:16 ++ _3 = _5; // scope 1 at $DIR/sroa.rs:+2:13: +2:16 + StorageLive(_4); // scope 2 at $DIR/sroa.rs:+3:9: +3:10 +- _4 = (_2.2: &str); // scope 2 at $DIR/sroa.rs:+3:13: +3:16 ++ _4 = _7; // scope 2 at $DIR/sroa.rs:+3:13: +3:16 + _0 = const (); // scope 0 at $DIR/sroa.rs:+0:24: +4:2 + StorageDead(_4); // scope 2 at $DIR/sroa.rs:+4:1: +4:2 + StorageDead(_3); // scope 1 at $DIR/sroa.rs:+4:1: +4:2 +- StorageDead(_2); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 ++ StorageDead(_5); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 ++ StorageDead(_6); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 ++ StorageDead(_7); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 ++ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+4:1: +4:2 ++ nop; // scope 0 at $DIR/sroa.rs:+4:1: +4:2 + return; // scope 0 at $DIR/sroa.rs:+4:2: +4:2 + } + } + diff --git a/tests/mir-opt/sroa.rs b/tests/mir-opt/sroa.rs index ff8deb40d..fff92cf8d 100644 --- a/tests/mir-opt/sroa.rs +++ b/tests/mir-opt/sroa.rs @@ -12,17 +12,14 @@ impl Drop for Tag { fn drop(&mut self) {} } -// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff pub fn dropping() { S(Tag(0), Tag(1), Tag(2)).1; } -// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff pub fn enums(a: usize) -> usize { if let Some(a) = Some(a) { a } else { 0 } } -// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff pub fn structs(a: f32) -> f32 { struct U { _foo: usize, @@ -32,7 +29,6 @@ pub fn structs(a: f32) -> f32 { U { _foo: 0, a }.a } -// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff pub fn unions(a: f32) -> u32 { union Repr { f: f32, @@ -41,6 +37,7 @@ pub fn unions(a: f32) -> u32 { unsafe { Repr { f: a }.u } } +#[derive(Copy, Clone)] struct Foo { a: u8, b: (), @@ -52,7 +49,6 @@ fn g() -> u32 { 3 } -// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff pub fn flat() { let Foo { a, b, c, d } = Foo { a: 5, b: (), c: "a", d: Some(-4) }; let _ = a; @@ -72,12 +68,37 @@ fn f(a: *const u32) { println!("{}", unsafe { *a.add(2) }); } -// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff +// `f` uses the `&e.a` to access `e.c`. This is UB according to Miri today; however, +// T-opsem has not finalized that decision and as such rustc should not rely on +// it. If SROA were to rely on it, it would be (almost) correct to turn `e` into +// three distinct locals - one for each field - and pass a reference to only one +// of them to `f`. However, this would lead to a miscompilation because `b` and `c` +// might no longer appear right after `a` in memory. pub fn escaping() { - // Verify this struct is not flattened. f(&Escaping { a: 1, b: 2, c: g() }.a); } +fn copies(x: Foo) { + let y = x; + let t = y.a; + let u = y.c; + let z = y; + let a = z.b; +} + +fn ref_copies(x: &Foo) { + let y = *x; + let t = y.a; + let u = y.c; +} + +fn constant() { + const U: (usize, u8) = (5, 9); + let y = U; + let t = y.0; + let u = y.1; +} + fn main() { dropping(); enums(5); @@ -85,4 +106,17 @@ fn main() { unions(5.); flat(); escaping(); + copies(Foo { a: 5, b: (), c: "a", d: Some(-4) }); + ref_copies(&Foo { a: 5, b: (), c: "a", d: Some(-4) }); + constant(); } + +// EMIT_MIR sroa.dropping.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.enums.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.structs.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.flat.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.copies.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.ref_copies.ScalarReplacementOfAggregates.diff +// EMIT_MIR sroa.constant.ScalarReplacementOfAggregates.diff diff --git a/tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff index 69d74c351..2c63d8b26 100644 --- a/tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff @@ -13,21 +13,20 @@ - StorageLive(_2); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 + StorageLive(_4); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 + StorageLive(_5); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 ++ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 StorageLive(_3); // scope 0 at $DIR/sroa.rs:+6:18: +6:19 _3 = _1; // scope 0 at $DIR/sroa.rs:+6:18: +6:19 -- Deinit(_2); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -- (_2.0: usize) = const 0_usize; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -- (_2.1: f32) = move _3; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ Deinit(_4); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 -+ Deinit(_5); // scope 0 at $DIR/sroa.rs:+6:5: +6:21 +- _2 = U { _foo: const 0_usize, a: move _3 }; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 + _4 = const 0_usize; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 + _5 = move _3; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 ++ nop; // scope 0 at $DIR/sroa.rs:+6:5: +6:21 StorageDead(_3); // scope 0 at $DIR/sroa.rs:+6:20: +6:21 - _0 = (_2.1: f32); // scope 0 at $DIR/sroa.rs:+6:5: +6:23 - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+7:1: +7:2 + _0 = _5; // scope 0 at $DIR/sroa.rs:+6:5: +6:23 + StorageDead(_4); // scope 0 at $DIR/sroa.rs:+7:1: +7:2 + StorageDead(_5); // scope 0 at $DIR/sroa.rs:+7:1: +7:2 ++ nop; // scope 0 at $DIR/sroa.rs:+7:1: +7:2 return; // scope 0 at $DIR/sroa.rs:+7:2: +7:2 } } diff --git a/tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff index 03ca976df..adfb01385 100644 --- a/tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff @@ -13,8 +13,7 @@ StorageLive(_2); // scope 1 at $DIR/sroa.rs:+5:14: +5:27 StorageLive(_3); // scope 1 at $DIR/sroa.rs:+5:24: +5:25 _3 = _1; // scope 1 at $DIR/sroa.rs:+5:24: +5:25 - Deinit(_2); // scope 1 at $DIR/sroa.rs:+5:14: +5:27 - (_2.0: f32) = move _3; // scope 1 at $DIR/sroa.rs:+5:14: +5:27 + _2 = Repr { f: move _3 }; // scope 1 at $DIR/sroa.rs:+5:14: +5:27 StorageDead(_3); // scope 1 at $DIR/sroa.rs:+5:26: +5:27 _0 = (_2.1: u32); // scope 1 at $DIR/sroa.rs:+5:14: +5:29 StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 diff --git a/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir b/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir index b254bfeb7..b9cc10575 100644 --- a/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir +++ b/tests/mir-opt/try_identity_e2e.new.PreCodegen.after.mir @@ -5,11 +5,11 @@ fn new(_1: Result) -> Result { let mut _0: std::result::Result; // return place in scope 0 at $DIR/try_identity_e2e.rs:+0:34: +0:46 let mut _2: std::ops::ControlFlow; // in scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 let mut _3: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:22 - let mut _4: T; // in scope 0 at $DIR/try_identity_e2e.rs:+4:48: +4:49 - let mut _5: E; // in scope 0 at $DIR/try_identity_e2e.rs:+5:46: +5:47 + let _4: T; // in scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 + let _5: E; // in scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 let mut _6: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+8:13: +8:37 let _7: T; // in scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 - let mut _8: E; // in scope 0 at $DIR/try_identity_e2e.rs:+9:49: +9:50 + let _8: E; // in scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 scope 1 { debug v => _4; // in scope 1 at $DIR/try_identity_e2e.rs:+4:20: +4:21 } @@ -26,45 +26,40 @@ fn new(_1: Result) -> Result { bb0: { StorageLive(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 _3 = discriminant(_1); // scope 0 at $DIR/try_identity_e2e.rs:+3:19: +3:20 - switchInt(move _3) -> [0: bb2, 1: bb1, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:20 + switchInt(move _3) -> [0: bb2, 1: bb1, otherwise: bb5]; // scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:20 } bb1: { _5 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 - Deinit(_2); // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - ((_2 as Break).0: E) = move _5; // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - discriminant(_2) = 1; // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - _6 = discriminant(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - switchInt(move _6) -> [0: bb5, 1: bb3, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 + _2 = ControlFlow::::Break(move _5); // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 + goto -> bb3; // scope 0 at $DIR/try_identity_e2e.rs:+5:47: +5:48 } bb2: { _4 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 - Deinit(_2); // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - ((_2 as Continue).0: T) = move _4; // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - discriminant(_2) = 0; // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - _6 = discriminant(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - switchInt(move _6) -> [0: bb5, 1: bb3, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 + _2 = ControlFlow::::Continue(move _4); // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 + goto -> bb3; // scope 0 at $DIR/try_identity_e2e.rs:+4:49: +4:50 } bb3: { + _6 = discriminant(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 + switchInt(move _6) -> [0: bb6, 1: bb4, otherwise: bb5]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 + } + + bb4: { _8 = move ((_2 as Break).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 - Deinit(_0); // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51 - ((_0 as Err).0: E) = move _8; // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51 - discriminant(_0) = 1; // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51 + _0 = Result::::Err(move _8); // scope 4 at $DIR/try_identity_e2e.rs:+9:45: +9:51 StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 return; // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 } - bb4: { + bb5: { unreachable; // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 } - bb5: { + bb6: { _7 = move ((_2 as Continue).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 - Deinit(_0); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6 - ((_0 as Ok).0: T) = move _7; // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6 - discriminant(_0) = 0; // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6 + _0 = Result::::Ok(move _7); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +11:6 StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 return; // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 } diff --git a/tests/mir-opt/try_identity_e2e.old.PreCodegen.after.mir b/tests/mir-opt/try_identity_e2e.old.PreCodegen.after.mir index cdbc0681c..d88ae5ac9 100644 --- a/tests/mir-opt/try_identity_e2e.old.PreCodegen.after.mir +++ b/tests/mir-opt/try_identity_e2e.old.PreCodegen.after.mir @@ -5,7 +5,7 @@ fn old(_1: Result) -> Result { let mut _0: std::result::Result; // return place in scope 0 at $DIR/try_identity_e2e.rs:+0:34: +0:46 let mut _2: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:18 let _3: T; // in scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17 - let mut _4: E; // in scope 0 at $DIR/try_identity_e2e.rs:+4:34: +4:35 + let _4: E; // in scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18 scope 1 { debug v => _3; // in scope 1 at $DIR/try_identity_e2e.rs:+3:16: +3:17 } @@ -20,9 +20,7 @@ fn old(_1: Result) -> Result { bb1: { _4 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18 - Deinit(_0); // scope 2 at $DIR/try_identity_e2e.rs:+4:30: +4:36 - ((_0 as Err).0: E) = move _4; // scope 2 at $DIR/try_identity_e2e.rs:+4:30: +4:36 - discriminant(_0) = 1; // scope 2 at $DIR/try_identity_e2e.rs:+4:30: +4:36 + _0 = Result::::Err(move _4); // scope 2 at $DIR/try_identity_e2e.rs:+4:30: +4:36 return; // scope 0 at $DIR/try_identity_e2e.rs:+7:1: +7:2 } @@ -32,9 +30,7 @@ fn old(_1: Result) -> Result { bb3: { _3 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17 - Deinit(_0); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +6:6 - ((_0 as Ok).0: T) = move _3; // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +6:6 - discriminant(_0) = 0; // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +6:6 + _0 = Result::::Ok(move _3); // scope 0 at $DIR/try_identity_e2e.rs:+1:5: +6:6 return; // scope 0 at $DIR/try_identity_e2e.rs:+7:1: +7:2 } } diff --git a/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir index 39ec05277..03f37b14b 100644 --- a/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir +++ b/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir @@ -15,8 +15,7 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +5:6 StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 - Deinit(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 - discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 + _2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 _3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 switchInt(move _3) -> [2: bb1, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19 } @@ -33,8 +32,7 @@ fn main() -> () { StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:+5:6: +5:7 StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +10:6 StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - Deinit(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 + _7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 _8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 switchInt(move _8) -> [4: bb5, 5: bb3, otherwise: bb4]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19 } diff --git a/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff index 598413a1d..671e11622 100644 --- a/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff @@ -16,8 +16,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +5:6 StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 - Deinit(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 - discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 + _2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 _3 = discriminant(_2); // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:11: +1:19 - switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb1, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19 + switchInt(move _3) -> [2: bb1, otherwise: bb2]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+1:5: +1:19 @@ -62,8 +61,7 @@ StorageDead(_1); // scope 0 at $DIR/uninhabited_enum_branching.rs:+5:6: +5:7 StorageLive(_6); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +10:6 StorageLive(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - Deinit(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 - discriminant(_7) = 0; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 + _7 = Test2::D; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 _8 = discriminant(_7); // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:11: +7:19 switchInt(move _8) -> [4: bb8, 5: bb6, otherwise: bb7]; // scope 0 at $DIR/uninhabited_enum_branching.rs:+7:5: +7:19 } diff --git a/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir index c8cd6f6c1..eb2a76ed1 100644 --- a/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir +++ b/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir @@ -22,11 +22,8 @@ fn main() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:9: +1:13 StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 - Deinit(_2); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 - discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 - Deinit(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 - (_1.0: u32) = const 51_u32; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 - (_1.1: Test1) = move _2; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 + _2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 + _1 = Plop { xx: const 51_u32, test1: move _2 }; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 StorageDead(_2); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:47: +1:48 StorageLive(_3); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +8:6 StorageLive(_4); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22 diff --git a/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff index 2aee6d268..4e797774d 100644 --- a/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff @@ -23,11 +23,8 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:9: +1:13 StorageLive(_2); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 - Deinit(_2); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 - discriminant(_2) = 2; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 - Deinit(_1); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 - (_1.0: u32) = const 51_u32; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 - (_1.1: Test1) = move _2; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 + _2 = Test1::C; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:38: +1:46 + _1 = Plop { xx: const 51_u32, test1: move _2 }; // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:16: +1:48 StorageDead(_2); // scope 0 at $DIR/uninhabited_enum_branching2.rs:+1:47: +1:48 StorageLive(_3); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:5: +8:6 StorageLive(_4); // scope 1 at $DIR/uninhabited_enum_branching2.rs:+3:11: +3:22 diff --git a/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir b/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir index ee0296763..8b271135c 100644 --- a/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir +++ b/tests/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir @@ -4,9 +4,7 @@ fn Test::X(_1: usize) -> Test { let mut _0: Test; // return place in scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 bb0: { - Deinit(_0); // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 - ((_0 as X).0: usize) = move _1; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 - discriminant(_0) = 0; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 + _0 = Test::X(move _1); // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 return; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 } } diff --git a/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff b/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff index bb1de59d4..a4f2d8c84 100644 --- a/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff +++ b/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff @@ -16,8 +16,7 @@ StorageLive(_1); // scope 0 at $DIR/while_let_loops.rs:+1:9: +1:15 _1 = const 0_i32; // scope 0 at $DIR/while_let_loops.rs:+1:18: +1:19 StorageLive(_2); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 - Deinit(_2); // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 - discriminant(_2) = 0; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 + _2 = Option::::None; // scope 2 at $DIR/while_let_loops.rs:+2:28: +2:32 - _3 = discriminant(_2); // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 - switchInt(move _3) -> [1: bb1, otherwise: bb3]; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 + _3 = const 0_isize; // scope 2 at $DIR/while_let_loops.rs:+2:15: +2:25 diff --git a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir index b95d91b13..318119bd4 100644 --- a/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir +++ b/tests/mir-opt/while_storage.while_loop.PreCodegen.after.mir @@ -4,9 +4,7 @@ fn while_loop(_1: bool) -> () { debug c => _1; // in scope 0 at $DIR/while_storage.rs:+0:15: +0:16 let mut _0: (); // return place in scope 0 at $DIR/while_storage.rs:+0:24: +0:24 let mut _2: bool; // in scope 0 at $DIR/while_storage.rs:+1:11: +1:22 - let mut _3: bool; // in scope 0 at $DIR/while_storage.rs:+1:20: +1:21 - let mut _4: bool; // in scope 0 at $DIR/while_storage.rs:+2:12: +2:23 - let mut _5: bool; // in scope 0 at $DIR/while_storage.rs:+2:21: +2:22 + let mut _3: bool; // in scope 0 at $DIR/while_storage.rs:+2:12: +2:23 bb0: { goto -> bb1; // scope 0 at $DIR/while_storage.rs:+1:5: +5:6 @@ -14,41 +12,35 @@ fn while_loop(_1: bool) -> () { bb1: { StorageLive(_2); // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 - StorageLive(_3); // scope 0 at $DIR/while_storage.rs:+1:20: +1:21 - _3 = _1; // scope 0 at $DIR/while_storage.rs:+1:20: +1:21 - _2 = get_bool(move _3) -> bb2; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 + _2 = get_bool(_1) -> bb2; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 // mir::Constant // + span: $DIR/while_storage.rs:10:11: 10:19 // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value() } } bb2: { - StorageDead(_3); // scope 0 at $DIR/while_storage.rs:+1:21: +1:22 switchInt(move _2) -> [0: bb7, otherwise: bb3]; // scope 0 at $DIR/while_storage.rs:+1:11: +1:22 } bb3: { - StorageLive(_4); // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 - StorageLive(_5); // scope 0 at $DIR/while_storage.rs:+2:21: +2:22 - _5 = _1; // scope 0 at $DIR/while_storage.rs:+2:21: +2:22 - _4 = get_bool(move _5) -> bb4; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + StorageLive(_3); // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + _3 = get_bool(_1) -> bb4; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 // mir::Constant // + span: $DIR/while_storage.rs:11:12: 11:20 // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value() } } bb4: { - StorageDead(_5); // scope 0 at $DIR/while_storage.rs:+2:22: +2:23 - switchInt(move _4) -> [0: bb6, otherwise: bb5]; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 + switchInt(move _3) -> [0: bb6, otherwise: bb5]; // scope 0 at $DIR/while_storage.rs:+2:12: +2:23 } bb5: { - StorageDead(_4); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 + StorageDead(_3); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 goto -> bb7; // scope 0 at no-location } bb6: { - StorageDead(_4); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 + StorageDead(_3); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 StorageDead(_2); // scope 0 at $DIR/while_storage.rs:+5:5: +5:6 goto -> bb1; // scope 0 at $DIR/while_storage.rs:+1:5: +5:6 } -- cgit v1.2.3