From 4e8199b572f2035b7749cba276ece3a26630d23e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:21 +0200 Subject: Adding upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- src/test/mir-opt/address-of.rs | 47 -- ...dress_of_reborrow.SimplifyCfg-initial.after.mir | 542 ++++++++++----------- ...f.borrow_and_cast.SimplifyCfg-initial.after.mir | 68 +-- src/test/mir-opt/address_of.rs | 47 ++ src/test/mir-opt/array-index-is-temporary.rs | 17 - ...rary.main.SimplifyCfg-elaborate-drops.after.mir | 82 ++-- src/test/mir-opt/array_index_is_temporary.rs | 17 + .../arbitrary_let.arbitrary_let.built.after.mir | 22 + src/test/mir-opt/building/custom/arbitrary_let.rs | 28 ++ .../building/custom/consts.consts.built.after.mir | 22 + src/test/mir-opt/building/custom/consts.rs | 36 ++ .../building/custom/consts.statics.built.after.mir | 27 + .../custom/references.immut_ref.built.after.mir | 14 + .../custom/references.mut_ref.built.after.mir | 14 + src/test/mir-opt/building/custom/references.rs | 43 ++ src/test/mir-opt/building/custom/simple_assign.rs | 37 ++ .../custom/simple_assign.simple.built.after.mir | 18 + .../simple_assign.simple_ref.built.after.mir | 10 + .../mir-opt/building/enum_cast.bar.built.after.mir | 23 + .../mir-opt/building/enum_cast.boo.built.after.mir | 23 + .../building/enum_cast.droppy.built.after.mir | 72 +++ .../mir-opt/building/enum_cast.foo.built.after.mir | 17 + src/test/mir-opt/building/enum_cast.rs | 50 ++ .../building/issue_101867.main.built.after.mir | 75 +++ src/test/mir-opt/building/issue_101867.rs | 7 + .../building/issue_49232.main.built.after.mir | 82 ++++ src/test/mir-opt/building/issue_49232.rs | 15 + ...h_false_edges.full_tested_match.built.after.mir | 112 +++++ ..._false_edges.full_tested_match2.built.after.mir | 112 +++++ .../match_false_edges.main.built.after.mir | 174 +++++++ src/test/mir-opt/building/match_false_edges.rs | 39 ++ .../receiver_ptr_mutability.main.built.after.mir | 96 ++++ .../mir-opt/building/receiver_ptr_mutability.rs | 20 + .../simple_match.match_bool.built.after.mir | 29 ++ src/test/mir-opt/building/simple_match.rs | 12 + ...torage_live_dead_in_statics.XXX.built.after.mir | 203 ++++++++ .../building/storage_live_dead_in_statics.rs | 33 ++ ...y_move_out.move_out_by_subslice.built.after.mir | 111 +++++ ...rray_move_out.move_out_from_end.built.after.mir | 111 +++++ .../mir-opt/building/uniform_array_move_out.rs | 18 + src/test/mir-opt/const-promotion-extern-static.rs | 18 - .../const_debuginfo.main.ConstDebugInfo.diff | 40 +- ...omoted[0].SimplifyCfg-elaborate-drops.after.mir | 20 +- ...t_promotion_extern_static.BAR.PromoteTemps.diff | 60 +-- ...nst_promotion_extern_static.BOP.built.after.mir | 17 + ...const_promotion_extern_static.BOP.mir_map.0.mir | 17 - ...omoted[0].SimplifyCfg-elaborate-drops.after.mir | 20 +- ...t_promotion_extern_static.FOO.PromoteTemps.diff | 60 +-- src/test/mir-opt/const_promotion_extern_static.rs | 18 + .../const_prop/aggregate.main.PreCodegen.after.mir | 28 ++ src/test/mir-opt/const_prop/aggregate.rs | 1 + .../const_prop/control-flow-simplification.rs | 21 - ...ontrol_flow_simplification.hello.ConstProp.diff | 18 +- ...flow_simplification.hello.PreCodegen.before.mir | 4 +- .../const_prop/control_flow_simplification.rs | 21 + src/test/mir-opt/const_prop/issue-66971.rs | 18 - src/test/mir-opt/const_prop/issue-67019.rs | 13 - .../const_prop/issue_66971.main.ConstProp.diff | 38 +- src/test/mir-opt/const_prop/issue_66971.rs | 18 + .../const_prop/issue_67019.main.ConstProp.diff | 40 +- src/test/mir-opt/const_prop/issue_67019.rs | 13 + ...able_variable_unprop_assign.main.ConstProp.diff | 23 +- ...timizes_into_variable.main.ConstProp.32bit.diff | 17 +- ...timizes_into_variable.main.ConstProp.64bit.diff | 17 +- ...s_into_variable.main.PreCodegen.after.32bit.mir | 27 + ...s_into_variable.main.PreCodegen.after.64bit.mir | 27 + ...e.main.ScalarReplacementOfAggregates.32bit.diff | 72 +++ ...e.main.ScalarReplacementOfAggregates.64bit.diff | 72 +++ .../mir-opt/const_prop/optimizes_into_variable.rs | 2 + .../coverage_graphviz.bar.InstrumentCoverage.0.dot | 2 +- ...coverage_graphviz.main.InstrumentCoverage.0.dot | 8 +- .../cast.main.DataflowConstProp.diff | 37 ++ src/test/mir-opt/dataflow-const-prop/cast.rs | 7 + .../checked.main.DataflowConstProp.diff | 80 +++ src/test/mir-opt/dataflow-const-prop/checked.rs | 13 + .../enum.main.DataflowConstProp.diff | 61 +++ src/test/mir-opt/dataflow-const-prop/enum.rs | 13 + .../if.main.DataflowConstProp.diff | 112 +++++ src/test/mir-opt/dataflow-const-prop/if.rs | 11 + .../inherit_overflow.main.DataflowConstProp.diff | 45 ++ .../dataflow-const-prop/inherit_overflow.rs | 8 + .../issue_81605.f.DataflowConstProp.diff | 35 ++ .../mir-opt/dataflow-const-prop/issue_81605.rs | 10 + .../ref_without_sb.main.DataflowConstProp.diff | 55 +++ .../mir-opt/dataflow-const-prop/ref_without_sb.rs | 17 + .../repr_transparent.main.DataflowConstProp.diff | 44 ++ .../dataflow-const-prop/repr_transparent.rs | 12 + .../self_assign.main.DataflowConstProp.diff | 46 ++ .../mir-opt/dataflow-const-prop/self_assign.rs | 12 + .../self_assign_add.main.DataflowConstProp.diff | 23 + .../mir-opt/dataflow-const-prop/self_assign_add.rs | 8 + .../sibling_ptr.main.DataflowConstProp.diff | 56 +++ .../mir-opt/dataflow-const-prop/sibling_ptr.rs | 11 + .../struct.main.DataflowConstProp.diff | 52 ++ src/test/mir-opt/dataflow-const-prop/struct.rs | 11 + .../terminator.main.DataflowConstProp.diff | 40 ++ src/test/mir-opt/dataflow-const-prop/terminator.rs | 10 + .../tuple.main.DataflowConstProp.diff | 75 +++ src/test/mir-opt/dataflow-const-prop/tuple.rs | 9 + .../cycle.cycle.DeadStoreElimination.diff | 69 +-- .../deref-patterns/string.foo.PreCodegen.after.mir | 74 +++ src/test/mir-opt/deref-patterns/string.rs | 12 + .../branch.foo.DestinationPropagation.diff | 75 +++ .../branch.main.DestinationPropagation.diff | 65 --- src/test/mir-opt/dest-prop/branch.rs | 12 +- ...agation_arg.arg_src.DestinationPropagation.diff | 4 +- ...propagation_arg.bar.DestinationPropagation.diff | 18 +- ...propagation_arg.baz.DestinationPropagation.diff | 20 +- ...propagation_arg.foo.DestinationPropagation.diff | 14 +- src/test/mir-opt/dest-prop/copy_propagation_arg.rs | 5 +- .../cycle.main.DestinationPropagation.diff | 68 ++- src/test/mir-opt/dest-prop/cycle.rs | 2 +- ...stores_79191.f.DestinationPropagation.after.mir | 34 ++ src/test/mir-opt/dest-prop/dead_stores_79191.rs | 17 + ...tores_better.f.DestinationPropagation.after.mir | 34 ++ src/test/mir-opt/dest-prop/dead_stores_better.rs | 21 + .../simple.nrvo.DestinationPropagation.diff | 12 +- src/test/mir-opt/dest-prop/simple.rs | 2 +- .../union.main.DestinationPropagation.diff | 11 +- src/test/mir-opt/enum_cast.bar.mir_map.0.mir | 17 - src/test/mir-opt/enum_cast.boo.mir_map.0.mir | 17 - src/test/mir-opt/enum_cast.droppy.mir_map.0.mir | 66 --- src/test/mir-opt/enum_cast.foo.mir_map.0.mir | 17 - src/test/mir-opt/enum_cast.rs | 50 -- src/test/mir-opt/exponential-or.rs | 11 - ...al_or.match_tuple.SimplifyCfg-initial.after.mir | 88 ++-- src/test/mir-opt/exponential_or.rs | 11 + src/test/mir-opt/fn-ptr-shim.rs | 15 - src/test/mir-opt/fn_ptr_shim.rs | 15 + src/test/mir-opt/generator-drop-cleanup.rs | 14 - src/test/mir-opt/generator-storage-dead-unwind.rs | 29 -- src/test/mir-opt/generator-tiny.rs | 26 - ...p_cleanup.main-{closure#0}.generator_drop.0.mir | 58 +-- src/test/mir-opt/generator_drop_cleanup.rs | 14 + ...wind.main-{closure#0}.StateTransform.before.mir | 122 ++--- src/test/mir-opt/generator_storage_dead_unwind.rs | 29 ++ ...or_tiny.main-{closure#0}.generator_resume.0.mir | 84 ++-- src/test/mir-opt/generator_tiny.rs | 26 + src/test/mir-opt/graphviz.main.built.after.dot | 7 + src/test/mir-opt/graphviz.main.mir_map.0.dot | 7 - src/test/mir-opt/graphviz.rs | 2 +- src/test/mir-opt/if-condition-int.rs | 65 --- ...t.dont_opt_bool.SimplifyComparisonIntegral.diff | 24 +- ...dont_opt_floats.SimplifyComparisonIntegral.diff | 32 +- ...move_comparison.SimplifyComparisonIntegral.diff | 76 +-- ...on_int.opt_char.SimplifyComparisonIntegral.diff | 42 +- ...tion_int.opt_i8.SimplifyComparisonIntegral.diff | 42 +- ...pt_multiple_ifs.SimplifyComparisonIntegral.diff | 76 +-- ...nt.opt_negative.SimplifyComparisonIntegral.diff | 42 +- ...ion_int.opt_u32.SimplifyComparisonIntegral.diff | 42 +- src/test/mir-opt/if_condition_int.rs | 65 +++ src/test/mir-opt/inline/asm-unwind.rs | 22 - .../mir-opt/inline/asm_unwind.main.Inline.diff | 34 +- src/test/mir-opt/inline/asm_unwind.rs | 22 + .../mir-opt/inline/caller-with-trivial-bound.rs | 26 - .../caller_with_trivial_bound.foo.Inline.diff | 22 +- .../mir-opt/inline/caller_with_trivial_bound.rs | 26 + src/test/mir-opt/inline/cycle.g.Inline.diff | 23 +- src/test/mir-opt/inline/cycle.main.Inline.diff | 40 +- src/test/mir-opt/inline/dyn-trait.rs | 35 -- .../mir-opt/inline/dyn_trait.get_query.Inline.diff | 66 ++- .../mir-opt/inline/dyn_trait.mk_cycle.Inline.diff | 18 +- src/test/mir-opt/inline/dyn_trait.rs | 35 ++ .../inline/dyn_trait.try_execute_query.Inline.diff | 38 +- .../inline/exponential_runtime.main.Inline.diff | 50 ++ src/test/mir-opt/inline/exponential_runtime.rs | 87 ++++ src/test/mir-opt/inline/inline-any-operand.rs | 18 - src/test/mir-opt/inline/inline-async.rs | 18 - .../mir-opt/inline/inline-closure-borrows-arg.rs | 17 - src/test/mir-opt/inline/inline-closure-captures.rs | 13 - src/test/mir-opt/inline/inline-closure.rs | 13 - src/test/mir-opt/inline/inline-compatibility.rs | 55 --- src/test/mir-opt/inline/inline-cycle-generic.rs | 40 -- src/test/mir-opt/inline/inline-cycle.rs | 60 --- src/test/mir-opt/inline/inline-diverging.rs | 40 -- src/test/mir-opt/inline/inline-generator.rs | 16 - src/test/mir-opt/inline/inline-instruction-set.rs | 54 -- src/test/mir-opt/inline/inline-into-box-place.rs | 9 - src/test/mir-opt/inline/inline-options.rs | 19 - src/test/mir-opt/inline/inline-retag.rs | 18 - src/test/mir-opt/inline/inline-shims.rs | 13 - src/test/mir-opt/inline/inline-specialization.rs | 15 - src/test/mir-opt/inline/inline-trait-method.rs | 22 - src/test/mir-opt/inline/inline-trait-method_2.rs | 27 - .../inline/inline_any_operand.bar.Inline.after.mir | 56 +-- src/test/mir-opt/inline/inline_any_operand.rs | 18 + src/test/mir-opt/inline/inline_async.rs | 18 + .../inline/inline_closure.foo.Inline.after.mir | 78 +-- src/test/mir-opt/inline/inline_closure.rs | 13 + ...inline_closure_borrows_arg.foo.Inline.after.mir | 84 ++-- .../mir-opt/inline/inline_closure_borrows_arg.rs | 17 + .../inline_closure_captures.foo.Inline.after.mir | 110 ++--- src/test/mir-opt/inline/inline_closure_captures.rs | 13 + ...e_compatibility.inlined_no_sanitize.Inline.diff | 18 +- ...ompatibility.inlined_target_feature.Inline.diff | 18 +- ...ompatibility.not_inlined_c_variadic.Inline.diff | 18 +- ...mpatibility.not_inlined_no_sanitize.Inline.diff | 16 +- ...tibility.not_inlined_target_feature.Inline.diff | 16 +- src/test/mir-opt/inline/inline_compatibility.rs | 55 +++ .../mir-opt/inline/inline_cycle.one.Inline.diff | 29 +- src/test/mir-opt/inline/inline_cycle.rs | 60 +++ .../mir-opt/inline/inline_cycle.two.Inline.diff | 67 +-- .../inline/inline_cycle_generic.main.Inline.diff | 31 +- src/test/mir-opt/inline/inline_cycle_generic.rs | 40 ++ .../mir-opt/inline/inline_diverging.f.Inline.diff | 18 +- .../mir-opt/inline/inline_diverging.g.Inline.diff | 46 +- .../mir-opt/inline/inline_diverging.h.Inline.diff | 102 ++-- src/test/mir-opt/inline/inline_diverging.rs | 40 ++ .../inline/inline_generator.main.Inline.diff | 152 +++--- src/test/mir-opt/inline/inline_generator.rs | 16 + .../inline_instruction_set.default.Inline.diff | 54 +- src/test/mir-opt/inline/inline_instruction_set.rs | 61 +++ .../inline/inline_instruction_set.t32.Inline.diff | 56 ++- .../inline/inline_into_box_place.main.Inline.diff | 68 +-- src/test/mir-opt/inline/inline_into_box_place.rs | 9 + .../inline/inline_options.main.Inline.after.mir | 54 +- src/test/mir-opt/inline/inline_options.rs | 19 + .../inline/inline_retag.bar.Inline.after.mir | 108 ++-- src/test/mir-opt/inline/inline_retag.rs | 18 + .../mir-opt/inline/inline_shims.clone.Inline.diff | 20 +- .../mir-opt/inline/inline_shims.drop.Inline.diff | 48 +- src/test/mir-opt/inline/inline_shims.rs | 13 + .../inline/inline_specialization.main.Inline.diff | 22 +- src/test/mir-opt/inline/inline_specialization.rs | 15 + src/test/mir-opt/inline/inline_trait_method.rs | 22 + .../inline_trait_method.test.Inline.after.mir | 18 +- src/test/mir-opt/inline/inline_trait_method_2.rs | 27 + .../inline_trait_method_2.test2.Inline.after.mir | 34 +- .../inline/issue-58867-inline-as-ref-as-mut.rs | 27 - .../inline/issue-76997-inline-scopes-parenting.rs | 7 - src/test/mir-opt/inline/issue-78442.rs | 20 - ...e_58867_inline_as_ref_as_mut.a.Inline.after.mir | 32 +- ...e_58867_inline_as_ref_as_mut.b.Inline.after.mir | 32 +- ...e_58867_inline_as_ref_as_mut.c.Inline.after.mir | 24 +- ...e_58867_inline_as_ref_as_mut.d.Inline.after.mir | 24 +- .../inline/issue_58867_inline_as_ref_as_mut.rs | 27 + ...7_inline_scopes_parenting.main.Inline.after.mir | 60 +-- .../inline/issue_76997_inline_scopes_parenting.rs | 7 + .../mir-opt/inline/issue_78442.bar.Inline.diff | 72 +-- .../mir-opt/inline/issue_78442.bar.RevealAll.diff | 56 +-- src/test/mir-opt/inline/issue_78442.rs | 20 + src/test/mir-opt/inline/polymorphic-recursion.rs | 25 - src/test/mir-opt/inline/polymorphic_recursion.rs | 25 + src/test/mir-opt/issue-101867.rs | 7 - src/test/mir-opt/issue-101973.rs | 20 - src/test/mir-opt/issue-38669.rs | 12 - src/test/mir-opt/issue-41110.rs | 30 -- src/test/mir-opt/issue-41697.rs | 40 -- src/test/mir-opt/issue-41888.rs | 24 - src/test/mir-opt/issue-49232.rs | 15 - src/test/mir-opt/issue-62289.rs | 14 - src/test/mir-opt/issue-72181-1.rs | 21 - src/test/mir-opt/issue-72181.rs | 28 -- src/test/mir-opt/issue-73223.rs | 12 - src/test/mir-opt/issue-78192.rs | 11 - src/test/mir-opt/issue-91633.rs | 31 -- src/test/mir-opt/issue-99325.rs | 12 - src/test/mir-opt/issue_101867.main.mir_map.0.mir | 75 --- src/test/mir-opt/issue_101973.inner.ConstProp.diff | 129 +++-- src/test/mir-opt/issue_101973.rs | 20 + .../issue_38669.main.SimplifyCfg-initial.after.mir | 56 +-- src/test/mir-opt/issue_38669.rs | 12 + .../issue_41110.main.ElaborateDrops.after.mir | 66 +-- src/test/mir-opt/issue_41110.rs | 30 ++ .../issue_41110.test.ElaborateDrops.after.mir | 92 ++-- src/test/mir-opt/issue_41697.rs | 40 ++ ...onstant#0}.SimplifyCfg-promote-consts.after.mir | 18 +- .../issue_41888.main.ElaborateDrops.after.mir | 146 +++--- src/test/mir-opt/issue_41888.rs | 24 + src/test/mir-opt/issue_49232.main.mir_map.0.mir | 82 ---- src/test/mir-opt/issue_62289.rs | 14 + .../issue_62289.test.ElaborateDrops.before.mir | 120 ++--- src/test/mir-opt/issue_72181.bar.built.after.mir | 17 + src/test/mir-opt/issue_72181.bar.mir_map.0.mir | 17 - src/test/mir-opt/issue_72181.foo.built.after.mir | 27 + src/test/mir-opt/issue_72181.foo.mir_map.0.mir | 27 - src/test/mir-opt/issue_72181.main.built.after.mir | 62 +++ src/test/mir-opt/issue_72181.main.mir_map.0.mir | 62 --- src/test/mir-opt/issue_72181.rs | 28 ++ src/test/mir-opt/issue_72181_1.f.built.after.mir | 29 ++ src/test/mir-opt/issue_72181_1.f.mir_map.0.mir | 29 -- .../mir-opt/issue_72181_1.main.built.after.mir | 57 +++ src/test/mir-opt/issue_72181_1.main.mir_map.0.mir | 57 --- src/test/mir-opt/issue_72181_1.rs | 21 + .../issue_73223.main.SimplifyArmIdentity.diff | 99 ++-- src/test/mir-opt/issue_73223.rs | 12 + src/test/mir-opt/issue_78192.f.InstCombine.diff | 36 +- src/test/mir-opt/issue_78192.rs | 11 + src/test/mir-opt/issue_91633.bar.built.after.mir | 39 ++ src/test/mir-opt/issue_91633.bar.mir_map.0.mir | 39 -- src/test/mir-opt/issue_91633.foo.built.after.mir | 57 +++ src/test/mir-opt/issue_91633.foo.mir_map.0.mir | 57 --- src/test/mir-opt/issue_91633.fun.built.after.mir | 35 ++ src/test/mir-opt/issue_91633.fun.mir_map.0.mir | 35 -- src/test/mir-opt/issue_91633.hey.built.after.mir | 35 ++ src/test/mir-opt/issue_91633.hey.mir_map.0.mir | 35 -- src/test/mir-opt/issue_91633.rs | 31 ++ src/test/mir-opt/issue_99325.main.built.after.mir | 295 +++++++++++ src/test/mir-opt/issue_99325.main.mir_map.0.mir | 295 ----------- src/test/mir-opt/issue_99325.rs | 12 + src/test/mir-opt/issues/issue-59352.rs | 19 - src/test/mir-opt/issues/issue-75439.rs | 18 - .../issue_59352.num_to_digit.PreCodegen.after.mir | 93 ++-- src/test/mir-opt/issues/issue_59352.rs | 19 + .../issue_75439.foo.MatchBranchSimplification.diff | 82 ++-- src/test/mir-opt/issues/issue_75439.rs | 18 + ..._array_len_e2e.array_bound.PreCodegen.after.mir | 16 +- ...ay_len_e2e.array_bound_mut.PreCodegen.after.mir | 36 +- ...lower_intrinsics_e2e.f_u64.PreCodegen.after.mir | 7 +- ...ower_intrinsics_e2e.f_unit.PreCodegen.after.mir | 5 +- src/test/mir-opt/match-arm-scopes.rs | 35 -- ...lifyCfg-initial.after-ElaborateDrops.after.diff | 290 +++++------ src/test/mir-opt/match_arm_scopes.rs | 35 ++ ..._edges.full_tested_match.PromoteTemps.after.mir | 113 ----- ...dges.full_tested_match2.PromoteTemps.before.mir | 108 ---- .../match_false_edges.main.PromoteTemps.before.mir | 153 ------ src/test/mir-opt/match_false_edges.rs | 39 -- src/test/mir-opt/nll/named-lifetimes-basic.rs | 15 - src/test/mir-opt/nll/named_lifetimes_basic.rs | 15 + .../nll/named_lifetimes_basic.use_x.nll.0.mir | 30 +- src/test/mir-opt/nll/region-subtyping-basic.rs | 25 - .../region_subtyping_basic.main.nll.0.32bit.mir | 110 ++--- .../region_subtyping_basic.main.nll.0.64bit.mir | 110 ++--- src/test/mir-opt/nll/region_subtyping_basic.rs | 25 + src/test/mir-opt/no-drop-for-inactive-variant.rs | 16 - src/test/mir-opt/no-spurious-drop-after-call.rs | 10 - src/test/mir-opt/no_drop_for_inactive_variant.rs | 16 + ...nt.unwrap.SimplifyCfg-elaborate-drops.after.mir | 38 +- ..._drop_after_call.main.ElaborateDrops.before.mir | 48 +- src/test/mir-opt/no_spurious_drop_after_call.rs | 10 + src/test/mir-opt/nrvo-simple.rs | 12 - .../nrvo_simple.nrvo.RenameReturnPlace.diff | 58 +-- src/test/mir-opt/nrvo_simple.rs | 12 + src/test/mir-opt/packed-struct-drop-aligned.rs | 17 - ...gned.main.SimplifyCfg-elaborate-drops.after.mir | 78 +-- src/test/mir-opt/packed_struct_drop_aligned.rs | 17 + src/test/mir-opt/receiver-ptr-mutability.rs | 20 - .../receiver_ptr_mutability.main.mir_map.0.mir | 96 ---- src/test/mir-opt/remove-never-const.rs | 21 - ...ove_never_const.no_codegen.PreCodegen.after.mir | 4 +- src/test/mir-opt/remove_never_const.rs | 21 + .../remove_zsts.get_union.PreCodegen.after.mir | 10 + .../mir-opt/remove_zsts.get_union.RemoveZsts.diff | 19 + src/test/mir-opt/remove_zsts.rs | 14 + ...ont_touch_unions.get_union.RemoveZsts.after.mir | 15 - src/test/mir-opt/remove_zsts_dont_touch_unions.rs | 19 - ...ray_casts.SimplifyCfg-elaborate-drops.after.mir | 10 - ...p_in_place.Test.SimplifyCfg-make_shim.after.mir | 1 - ...losure#0}.SimplifyCfg-elaborate-drops.after.mir | 1 - ...etag.main.SimplifyCfg-elaborate-drops.after.mir | 11 - ...pl#0}-foo.SimplifyCfg-elaborate-drops.after.mir | 2 - .../rustc.try_identity.DestinationPropagation.diff | 72 --- ..._const_switch.identity.SeparateConstSwitch.diff | 35 +- src/test/mir-opt/simple-match.rs | 12 - .../mir-opt/simple_match.match_bool.mir_map.0.mir | 29 -- src/test/mir-opt/simplify-arm-identity.rs | 26 - src/test/mir-opt/simplify-arm.rs | 50 -- src/test/mir-opt/simplify-locals-fixedpoint.rs | 15 - .../simplify-locals-removes-unused-consts.rs | 18 - ...ify-locals-removes-unused-discriminant-reads.rs | 14 - src/test/mir-opt/simplify-locals.rs | 81 --- src/test/mir-opt/simplify_arm.rs | 50 ++ src/test/mir-opt/simplify_arm_identity.rs | 26 + .../mir-opt/simplify_locals.c.SimplifyLocals.diff | 40 +- .../mir-opt/simplify_locals.d1.SimplifyLocals.diff | 16 +- .../mir-opt/simplify_locals.d2.SimplifyLocals.diff | 40 +- ...simplify_locals.expose_addr.SimplifyLocals.diff | 24 +- .../mir-opt/simplify_locals.r.SimplifyLocals.diff | 32 +- src/test/mir-opt/simplify_locals.rs | 81 +++ .../mir-opt/simplify_locals.t1.SimplifyLocals.diff | 22 +- .../mir-opt/simplify_locals.t2.SimplifyLocals.diff | 22 +- .../mir-opt/simplify_locals.t3.SimplifyLocals.diff | 30 +- .../mir-opt/simplify_locals.t4.SimplifyLocals.diff | 22 +- ...plify_locals_fixedpoint.foo.SimplifyLocals.diff | 78 +-- src/test/mir-opt/simplify_locals_fixedpoint.rs | 15 + ..._removes_unused_consts.main.SimplifyLocals.diff | 176 +++---- .../simplify_locals_removes_unused_consts.rs | 18 + ...used_discriminant_reads.map.SimplifyLocals.diff | 58 +-- ...ify_locals_removes_unused_discriminant_reads.rs | 14 + ...fy_try.try_identity.DestinationPropagation.diff | 106 ---- ...plify_try.try_identity.SimplifyArmIdentity.diff | 85 ---- ...y_try.try_identity.SimplifyBranchSame.after.mir | 83 ---- ...plify_try.try_identity.SimplifyLocals.after.mir | 58 --- src/test/mir-opt/slice-drop-shim.rs | 7 - src/test/mir-opt/slice_drop_shim.rs | 7 + src/test/mir-opt/spanview-block.rs | 5 - src/test/mir-opt/spanview-statement.rs | 5 - src/test/mir-opt/spanview-terminator.rs | 5 - .../mir-opt/spanview_block.main.built.after.html | 66 +++ .../mir-opt/spanview_block.main.mir_map.0.html | 66 --- src/test/mir-opt/spanview_block.rs | 5 + .../spanview_statement.main.built.after.html | 66 +++ .../mir-opt/spanview_statement.main.mir_map.0.html | 66 --- src/test/mir-opt/spanview_statement.rs | 5 + .../spanview_terminator.main.built.after.html | 65 +++ .../spanview_terminator.main.mir_map.0.html | 65 --- src/test/mir-opt/spanview_terminator.rs | 5 + ...roa.dropping.ScalarReplacementOfAggregates.diff | 50 ++ .../sroa.enums.ScalarReplacementOfAggregates.diff | 45 ++ ...roa.escaping.ScalarReplacementOfAggregates.diff | 47 ++ .../sroa.flat.ScalarReplacementOfAggregates.diff | 87 ++++ src/test/mir-opt/sroa.rs | 88 ++++ ...sroa.structs.ScalarReplacementOfAggregates.diff | 34 ++ .../sroa.unions.ScalarReplacementOfAggregates.diff | 24 + .../storage_live_dead_in_statics.XXX.mir_map.0.mir | 203 -------- src/test/mir-opt/storage_live_dead_in_statics.rs | 33 -- src/test/mir-opt/tls-access.rs | 14 - .../mir-opt/tls_access.main.PreCodegen.after.mir | 34 +- src/test/mir-opt/tls_access.rs | 14 + .../try_identity_e2e.new.PreCodegen.after.mir | 89 ++-- .../try_identity_e2e.old.PreCodegen.after.mir | 35 +- ...ray_move_out.move_out_by_subslice.mir_map.0.mir | 111 ----- ..._array_move_out.move_out_from_end.mir_map.0.mir | 111 ----- src/test/mir-opt/uniform_array_move_out.rs | 18 - src/test/mir-opt/uninhabited-enum.rs | 19 - ...ted_enum.process_never.SimplifyLocals.after.mir | 10 +- ...ited_enum.process_void.SimplifyLocals.after.mir | 14 +- src/test/mir-opt/uninhabited_enum.rs | 19 + src/test/mir-opt/unusual-item-types.rs | 29 -- ...ual_item_types.E-V-{constant#0}.built.after.mir | 10 + ...usual_item_types.E-V-{constant#0}.mir_map.0.mir | 10 - ...em_types.Test-X-{constructor#0}.built.after.mir | 12 + ...item_types.Test-X-{constructor#0}.mir_map.0.mir | 12 - src/test/mir-opt/unusual_item_types.rs | 29 ++ ...es.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir | 10 + ...ypes.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.mir | 10 - src/test/mir-opt/while-storage.rs | 19 - src/test/mir-opt/while_storage.rs | 19 + .../while_storage.while_loop.PreCodegen.after.mir | 54 +- 429 files changed, 9509 insertions(+), 7751 deletions(-) delete mode 100644 src/test/mir-opt/address-of.rs create mode 100644 src/test/mir-opt/address_of.rs delete mode 100644 src/test/mir-opt/array-index-is-temporary.rs create mode 100644 src/test/mir-opt/array_index_is_temporary.rs create mode 100644 src/test/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir create mode 100644 src/test/mir-opt/building/custom/arbitrary_let.rs create mode 100644 src/test/mir-opt/building/custom/consts.consts.built.after.mir create mode 100644 src/test/mir-opt/building/custom/consts.rs create mode 100644 src/test/mir-opt/building/custom/consts.statics.built.after.mir create mode 100644 src/test/mir-opt/building/custom/references.immut_ref.built.after.mir create mode 100644 src/test/mir-opt/building/custom/references.mut_ref.built.after.mir create mode 100644 src/test/mir-opt/building/custom/references.rs create mode 100644 src/test/mir-opt/building/custom/simple_assign.rs create mode 100644 src/test/mir-opt/building/custom/simple_assign.simple.built.after.mir create mode 100644 src/test/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir create mode 100644 src/test/mir-opt/building/enum_cast.bar.built.after.mir create mode 100644 src/test/mir-opt/building/enum_cast.boo.built.after.mir create mode 100644 src/test/mir-opt/building/enum_cast.droppy.built.after.mir create mode 100644 src/test/mir-opt/building/enum_cast.foo.built.after.mir create mode 100644 src/test/mir-opt/building/enum_cast.rs create mode 100644 src/test/mir-opt/building/issue_101867.main.built.after.mir create mode 100644 src/test/mir-opt/building/issue_101867.rs create mode 100644 src/test/mir-opt/building/issue_49232.main.built.after.mir create mode 100644 src/test/mir-opt/building/issue_49232.rs create mode 100644 src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir create mode 100644 src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir create mode 100644 src/test/mir-opt/building/match_false_edges.main.built.after.mir create mode 100644 src/test/mir-opt/building/match_false_edges.rs create mode 100644 src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir create mode 100644 src/test/mir-opt/building/receiver_ptr_mutability.rs create mode 100644 src/test/mir-opt/building/simple_match.match_bool.built.after.mir create mode 100644 src/test/mir-opt/building/simple_match.rs create mode 100644 src/test/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir create mode 100644 src/test/mir-opt/building/storage_live_dead_in_statics.rs create mode 100644 src/test/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir create mode 100644 src/test/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir create mode 100644 src/test/mir-opt/building/uniform_array_move_out.rs delete mode 100644 src/test/mir-opt/const-promotion-extern-static.rs create mode 100644 src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir delete mode 100644 src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir create mode 100644 src/test/mir-opt/const_promotion_extern_static.rs create mode 100644 src/test/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir delete mode 100644 src/test/mir-opt/const_prop/control-flow-simplification.rs create mode 100644 src/test/mir-opt/const_prop/control_flow_simplification.rs delete mode 100644 src/test/mir-opt/const_prop/issue-66971.rs delete mode 100644 src/test/mir-opt/const_prop/issue-67019.rs create mode 100644 src/test/mir-opt/const_prop/issue_66971.rs create mode 100644 src/test/mir-opt/const_prop/issue_67019.rs create mode 100644 src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir create mode 100644 src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir create mode 100644 src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff create mode 100644 src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/cast.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/checked.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/enum.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/if.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/inherit_overflow.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/issue_81605.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/repr_transparent.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/self_assign.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/self_assign_add.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/sibling_ptr.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/struct.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/terminator.rs create mode 100644 src/test/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff create mode 100644 src/test/mir-opt/dataflow-const-prop/tuple.rs create mode 100644 src/test/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir create mode 100644 src/test/mir-opt/deref-patterns/string.rs create mode 100644 src/test/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff delete mode 100644 src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff create mode 100644 src/test/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir create mode 100644 src/test/mir-opt/dest-prop/dead_stores_79191.rs create mode 100644 src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir create mode 100644 src/test/mir-opt/dest-prop/dead_stores_better.rs delete mode 100644 src/test/mir-opt/enum_cast.bar.mir_map.0.mir delete mode 100644 src/test/mir-opt/enum_cast.boo.mir_map.0.mir delete mode 100644 src/test/mir-opt/enum_cast.droppy.mir_map.0.mir delete mode 100644 src/test/mir-opt/enum_cast.foo.mir_map.0.mir delete mode 100644 src/test/mir-opt/enum_cast.rs delete mode 100644 src/test/mir-opt/exponential-or.rs create mode 100644 src/test/mir-opt/exponential_or.rs delete mode 100644 src/test/mir-opt/fn-ptr-shim.rs create mode 100644 src/test/mir-opt/fn_ptr_shim.rs delete mode 100644 src/test/mir-opt/generator-drop-cleanup.rs delete mode 100644 src/test/mir-opt/generator-storage-dead-unwind.rs delete mode 100644 src/test/mir-opt/generator-tiny.rs create mode 100644 src/test/mir-opt/generator_drop_cleanup.rs create mode 100644 src/test/mir-opt/generator_storage_dead_unwind.rs create mode 100644 src/test/mir-opt/generator_tiny.rs create mode 100644 src/test/mir-opt/graphviz.main.built.after.dot delete mode 100644 src/test/mir-opt/graphviz.main.mir_map.0.dot delete mode 100644 src/test/mir-opt/if-condition-int.rs create mode 100644 src/test/mir-opt/if_condition_int.rs delete mode 100644 src/test/mir-opt/inline/asm-unwind.rs create mode 100644 src/test/mir-opt/inline/asm_unwind.rs delete mode 100644 src/test/mir-opt/inline/caller-with-trivial-bound.rs create mode 100644 src/test/mir-opt/inline/caller_with_trivial_bound.rs delete mode 100644 src/test/mir-opt/inline/dyn-trait.rs create mode 100644 src/test/mir-opt/inline/dyn_trait.rs create mode 100644 src/test/mir-opt/inline/exponential_runtime.main.Inline.diff create mode 100644 src/test/mir-opt/inline/exponential_runtime.rs delete mode 100644 src/test/mir-opt/inline/inline-any-operand.rs delete mode 100644 src/test/mir-opt/inline/inline-async.rs delete mode 100644 src/test/mir-opt/inline/inline-closure-borrows-arg.rs delete mode 100644 src/test/mir-opt/inline/inline-closure-captures.rs delete mode 100644 src/test/mir-opt/inline/inline-closure.rs delete mode 100644 src/test/mir-opt/inline/inline-compatibility.rs delete mode 100644 src/test/mir-opt/inline/inline-cycle-generic.rs delete mode 100644 src/test/mir-opt/inline/inline-cycle.rs delete mode 100644 src/test/mir-opt/inline/inline-diverging.rs delete mode 100644 src/test/mir-opt/inline/inline-generator.rs delete mode 100644 src/test/mir-opt/inline/inline-instruction-set.rs delete mode 100644 src/test/mir-opt/inline/inline-into-box-place.rs delete mode 100644 src/test/mir-opt/inline/inline-options.rs delete mode 100644 src/test/mir-opt/inline/inline-retag.rs delete mode 100644 src/test/mir-opt/inline/inline-shims.rs delete mode 100644 src/test/mir-opt/inline/inline-specialization.rs delete mode 100644 src/test/mir-opt/inline/inline-trait-method.rs delete mode 100644 src/test/mir-opt/inline/inline-trait-method_2.rs create mode 100644 src/test/mir-opt/inline/inline_any_operand.rs create mode 100644 src/test/mir-opt/inline/inline_async.rs create mode 100644 src/test/mir-opt/inline/inline_closure.rs create mode 100644 src/test/mir-opt/inline/inline_closure_borrows_arg.rs create mode 100644 src/test/mir-opt/inline/inline_closure_captures.rs create mode 100644 src/test/mir-opt/inline/inline_compatibility.rs create mode 100644 src/test/mir-opt/inline/inline_cycle.rs create mode 100644 src/test/mir-opt/inline/inline_cycle_generic.rs create mode 100644 src/test/mir-opt/inline/inline_diverging.rs create mode 100644 src/test/mir-opt/inline/inline_generator.rs create mode 100644 src/test/mir-opt/inline/inline_instruction_set.rs create mode 100644 src/test/mir-opt/inline/inline_into_box_place.rs create mode 100644 src/test/mir-opt/inline/inline_options.rs create mode 100644 src/test/mir-opt/inline/inline_retag.rs create mode 100644 src/test/mir-opt/inline/inline_shims.rs create mode 100644 src/test/mir-opt/inline/inline_specialization.rs create mode 100644 src/test/mir-opt/inline/inline_trait_method.rs create mode 100644 src/test/mir-opt/inline/inline_trait_method_2.rs delete mode 100644 src/test/mir-opt/inline/issue-58867-inline-as-ref-as-mut.rs delete mode 100644 src/test/mir-opt/inline/issue-76997-inline-scopes-parenting.rs delete mode 100644 src/test/mir-opt/inline/issue-78442.rs create mode 100644 src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs create mode 100644 src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.rs create mode 100644 src/test/mir-opt/inline/issue_78442.rs delete mode 100644 src/test/mir-opt/inline/polymorphic-recursion.rs create mode 100644 src/test/mir-opt/inline/polymorphic_recursion.rs delete mode 100644 src/test/mir-opt/issue-101867.rs delete mode 100644 src/test/mir-opt/issue-101973.rs delete mode 100644 src/test/mir-opt/issue-38669.rs delete mode 100644 src/test/mir-opt/issue-41110.rs delete mode 100644 src/test/mir-opt/issue-41697.rs delete mode 100644 src/test/mir-opt/issue-41888.rs delete mode 100644 src/test/mir-opt/issue-49232.rs delete mode 100644 src/test/mir-opt/issue-62289.rs delete mode 100644 src/test/mir-opt/issue-72181-1.rs delete mode 100644 src/test/mir-opt/issue-72181.rs delete mode 100644 src/test/mir-opt/issue-73223.rs delete mode 100644 src/test/mir-opt/issue-78192.rs delete mode 100644 src/test/mir-opt/issue-91633.rs delete mode 100644 src/test/mir-opt/issue-99325.rs delete mode 100644 src/test/mir-opt/issue_101867.main.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_101973.rs create mode 100644 src/test/mir-opt/issue_38669.rs create mode 100644 src/test/mir-opt/issue_41110.rs create mode 100644 src/test/mir-opt/issue_41697.rs create mode 100644 src/test/mir-opt/issue_41888.rs delete mode 100644 src/test/mir-opt/issue_49232.main.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_62289.rs create mode 100644 src/test/mir-opt/issue_72181.bar.built.after.mir delete mode 100644 src/test/mir-opt/issue_72181.bar.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_72181.foo.built.after.mir delete mode 100644 src/test/mir-opt/issue_72181.foo.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_72181.main.built.after.mir delete mode 100644 src/test/mir-opt/issue_72181.main.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_72181.rs create mode 100644 src/test/mir-opt/issue_72181_1.f.built.after.mir delete mode 100644 src/test/mir-opt/issue_72181_1.f.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_72181_1.main.built.after.mir delete mode 100644 src/test/mir-opt/issue_72181_1.main.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_72181_1.rs create mode 100644 src/test/mir-opt/issue_73223.rs create mode 100644 src/test/mir-opt/issue_78192.rs create mode 100644 src/test/mir-opt/issue_91633.bar.built.after.mir delete mode 100644 src/test/mir-opt/issue_91633.bar.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_91633.foo.built.after.mir delete mode 100644 src/test/mir-opt/issue_91633.foo.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_91633.fun.built.after.mir delete mode 100644 src/test/mir-opt/issue_91633.fun.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_91633.hey.built.after.mir delete mode 100644 src/test/mir-opt/issue_91633.hey.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_91633.rs create mode 100644 src/test/mir-opt/issue_99325.main.built.after.mir delete mode 100644 src/test/mir-opt/issue_99325.main.mir_map.0.mir create mode 100644 src/test/mir-opt/issue_99325.rs delete mode 100644 src/test/mir-opt/issues/issue-59352.rs delete mode 100644 src/test/mir-opt/issues/issue-75439.rs create mode 100644 src/test/mir-opt/issues/issue_59352.rs create mode 100644 src/test/mir-opt/issues/issue_75439.rs delete mode 100644 src/test/mir-opt/match-arm-scopes.rs create mode 100644 src/test/mir-opt/match_arm_scopes.rs delete mode 100644 src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir delete mode 100644 src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir delete mode 100644 src/test/mir-opt/match_false_edges.main.PromoteTemps.before.mir delete mode 100644 src/test/mir-opt/match_false_edges.rs delete mode 100644 src/test/mir-opt/nll/named-lifetimes-basic.rs create mode 100644 src/test/mir-opt/nll/named_lifetimes_basic.rs delete mode 100644 src/test/mir-opt/nll/region-subtyping-basic.rs create mode 100644 src/test/mir-opt/nll/region_subtyping_basic.rs delete mode 100644 src/test/mir-opt/no-drop-for-inactive-variant.rs delete mode 100644 src/test/mir-opt/no-spurious-drop-after-call.rs create mode 100644 src/test/mir-opt/no_drop_for_inactive_variant.rs create mode 100644 src/test/mir-opt/no_spurious_drop_after_call.rs delete mode 100644 src/test/mir-opt/nrvo-simple.rs create mode 100644 src/test/mir-opt/nrvo_simple.rs delete mode 100644 src/test/mir-opt/packed-struct-drop-aligned.rs create mode 100644 src/test/mir-opt/packed_struct_drop_aligned.rs delete mode 100644 src/test/mir-opt/receiver-ptr-mutability.rs delete mode 100644 src/test/mir-opt/receiver_ptr_mutability.main.mir_map.0.mir delete mode 100644 src/test/mir-opt/remove-never-const.rs create mode 100644 src/test/mir-opt/remove_never_const.rs create mode 100644 src/test/mir-opt/remove_zsts.get_union.PreCodegen.after.mir create mode 100644 src/test/mir-opt/remove_zsts.get_union.RemoveZsts.diff create mode 100644 src/test/mir-opt/remove_zsts.rs delete mode 100644 src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir delete mode 100644 src/test/mir-opt/remove_zsts_dont_touch_unions.rs delete mode 100644 src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff delete mode 100644 src/test/mir-opt/simple-match.rs delete mode 100644 src/test/mir-opt/simple_match.match_bool.mir_map.0.mir delete mode 100644 src/test/mir-opt/simplify-arm-identity.rs delete mode 100644 src/test/mir-opt/simplify-arm.rs delete mode 100644 src/test/mir-opt/simplify-locals-fixedpoint.rs delete mode 100644 src/test/mir-opt/simplify-locals-removes-unused-consts.rs delete mode 100644 src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs delete mode 100644 src/test/mir-opt/simplify-locals.rs create mode 100644 src/test/mir-opt/simplify_arm.rs create mode 100644 src/test/mir-opt/simplify_arm_identity.rs create mode 100644 src/test/mir-opt/simplify_locals.rs create mode 100644 src/test/mir-opt/simplify_locals_fixedpoint.rs create mode 100644 src/test/mir-opt/simplify_locals_removes_unused_consts.rs create mode 100644 src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs delete mode 100644 src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff delete mode 100644 src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff delete mode 100644 src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir delete mode 100644 src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir delete mode 100644 src/test/mir-opt/slice-drop-shim.rs create mode 100644 src/test/mir-opt/slice_drop_shim.rs delete mode 100644 src/test/mir-opt/spanview-block.rs delete mode 100644 src/test/mir-opt/spanview-statement.rs delete mode 100644 src/test/mir-opt/spanview-terminator.rs create mode 100644 src/test/mir-opt/spanview_block.main.built.after.html delete mode 100644 src/test/mir-opt/spanview_block.main.mir_map.0.html create mode 100644 src/test/mir-opt/spanview_block.rs create mode 100644 src/test/mir-opt/spanview_statement.main.built.after.html delete mode 100644 src/test/mir-opt/spanview_statement.main.mir_map.0.html create mode 100644 src/test/mir-opt/spanview_statement.rs create mode 100644 src/test/mir-opt/spanview_terminator.main.built.after.html delete mode 100644 src/test/mir-opt/spanview_terminator.main.mir_map.0.html create mode 100644 src/test/mir-opt/spanview_terminator.rs create mode 100644 src/test/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff create mode 100644 src/test/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff create mode 100644 src/test/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff create mode 100644 src/test/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff create mode 100644 src/test/mir-opt/sroa.rs create mode 100644 src/test/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff create mode 100644 src/test/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff delete mode 100644 src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir delete mode 100644 src/test/mir-opt/storage_live_dead_in_statics.rs delete mode 100644 src/test/mir-opt/tls-access.rs create mode 100644 src/test/mir-opt/tls_access.rs delete mode 100644 src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir delete mode 100644 src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir delete mode 100644 src/test/mir-opt/uniform_array_move_out.rs delete mode 100644 src/test/mir-opt/uninhabited-enum.rs create mode 100644 src/test/mir-opt/uninhabited_enum.rs delete mode 100644 src/test/mir-opt/unusual-item-types.rs create mode 100644 src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir delete mode 100644 src/test/mir-opt/unusual_item_types.E-V-{constant#0}.mir_map.0.mir create mode 100644 src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir delete mode 100644 src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.mir_map.0.mir create mode 100644 src/test/mir-opt/unusual_item_types.rs create mode 100644 src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir delete mode 100644 src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.mir delete mode 100644 src/test/mir-opt/while-storage.rs create mode 100644 src/test/mir-opt/while_storage.rs (limited to 'src/test/mir-opt') diff --git a/src/test/mir-opt/address-of.rs b/src/test/mir-opt/address-of.rs deleted file mode 100644 index c4bea5613..000000000 --- a/src/test/mir-opt/address-of.rs +++ /dev/null @@ -1,47 +0,0 @@ -// EMIT_MIR address_of.address_of_reborrow.SimplifyCfg-initial.after.mir - -fn address_of_reborrow() { - let y = &[0; 10]; - let mut z = &mut [0; 10]; - - y as *const _; - y as *const [i32; 10]; - y as *const dyn Send; - y as *const [i32]; - y as *const i32; // This is a cast, not a coercion - - let p: *const _ = y; - let p: *const [i32; 10] = y; - let p: *const dyn Send = y; - let p: *const [i32] = y; - - z as *const _; - z as *const [i32; 10]; - z as *const dyn Send; - z as *const [i32]; - - let p: *const _ = z; - let p: *const [i32; 10] = z; - let p: *const dyn Send = z; - let p: *const [i32] = z; - - z as *mut _; - z as *mut [i32; 10]; - z as *mut dyn Send; - z as *mut [i32]; - - let p: *mut _ = z; - let p: *mut [i32; 10] = z; - let p: *mut dyn Send = z; - let p: *mut [i32] = z; -} - -// The normal borrows here should be preserved -// EMIT_MIR address_of.borrow_and_cast.SimplifyCfg-initial.after.mir -fn borrow_and_cast(mut x: i32) { - let p = &x as *const i32; - let q = &mut x as *const i32; - let r = &mut x as *mut i32; -} - -fn main() {} diff --git a/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir index d41a66871..5f8b2f931 100644 --- a/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir @@ -1,115 +1,115 @@ // MIR for `address_of_reborrow` after SimplifyCfg-initial | User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:7:5: 7:18, inferred_ty: *const [i32; 10] -| 1: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:9:5: 9:25, inferred_ty: *const dyn std::marker::Send -| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] -| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] -| 4: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] -| 5: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] -| 6: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send -| 7: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send -| 8: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:16:12: 16:24, inferred_ty: *const [i32] -| 9: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:16:12: 16:24, inferred_ty: *const [i32] -| 10: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:18:5: 18:18, inferred_ty: *const [i32; 10] -| 11: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:20:5: 20:25, inferred_ty: *const dyn std::marker::Send -| 12: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] -| 13: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address-of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] -| 14: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] -| 15: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address-of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] -| 16: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send -| 17: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address-of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send -| 18: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:26:12: 26:24, inferred_ty: *const [i32] -| 19: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address-of.rs:26:12: 26:24, inferred_ty: *const [i32] -| 20: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address-of.rs:28:5: 28:16, inferred_ty: *mut [i32; 10] -| 21: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address-of.rs:30:5: 30:23, inferred_ty: *mut dyn std::marker::Send -| 22: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address-of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] -| 23: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address-of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] -| 24: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address-of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] -| 25: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address-of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] -| 26: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address-of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send -| 27: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address-of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send -| 28: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address-of.rs:36:12: 36:22, inferred_ty: *mut [i32] -| 29: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address-of.rs:36:12: 36:22, inferred_ty: *mut [i32] +| 0: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:7:5: 7:18, inferred_ty: *const [i32; 10] +| 1: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:9:5: 9:25, inferred_ty: *const dyn std::marker::Send +| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] +| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:13:12: 13:20, inferred_ty: *const [i32; 10] +| 4: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] +| 5: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:14:12: 14:28, inferred_ty: *const [i32; 10] +| 6: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send +| 7: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:15:12: 15:27, inferred_ty: *const dyn std::marker::Send +| 8: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] +| 9: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:16:12: 16:24, inferred_ty: *const [i32] +| 10: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:18:5: 18:18, inferred_ty: *const [i32; 10] +| 11: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:20:5: 20:25, inferred_ty: *const dyn std::marker::Send +| 12: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] +| 13: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) }, span: $DIR/address_of.rs:23:12: 23:20, inferred_ty: *const [i32; 10] +| 14: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] +| 15: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) }, span: $DIR/address_of.rs:24:12: 24:28, inferred_ty: *const [i32; 10] +| 16: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send +| 17: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) }, span: $DIR/address_of.rs:25:12: 25:27, inferred_ty: *const dyn std::marker::Send +| 18: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] +| 19: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) }, span: $DIR/address_of.rs:26:12: 26:24, inferred_ty: *const [i32] +| 20: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:28:5: 28:16, inferred_ty: *mut [i32; 10] +| 21: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:30:5: 30:23, inferred_ty: *mut dyn std::marker::Send +| 22: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] +| 23: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) }, span: $DIR/address_of.rs:33:12: 33:18, inferred_ty: *mut [i32; 10] +| 24: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] +| 25: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) }, span: $DIR/address_of.rs:34:12: 34:26, inferred_ty: *mut [i32; 10] +| 26: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send +| 27: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) }, span: $DIR/address_of.rs:35:12: 35:25, inferred_ty: *mut dyn std::marker::Send +| 28: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] +| 29: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) }, span: $DIR/address_of.rs:36:12: 36:22, inferred_ty: *mut [i32] | fn address_of_reborrow() -> () { - let mut _0: (); // return place in scope 0 at $DIR/address-of.rs:+0:26: +0:26 - let _1: &[i32; 10]; // in scope 0 at $DIR/address-of.rs:+1:9: +1:10 - let _2: [i32; 10]; // in scope 0 at $DIR/address-of.rs:+1:14: +1:21 - let mut _4: [i32; 10]; // in scope 0 at $DIR/address-of.rs:+2:22: +2:29 - let _5: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+4:5: +4:18 - let mut _6: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+4:5: +4:18 - let _7: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+5:5: +5:26 - let _8: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+6:5: +6:25 - let mut _9: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+6:5: +6:25 - let mut _10: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+6:5: +6:6 - let _11: *const [i32]; // in scope 0 at $DIR/address-of.rs:+7:5: +7:22 - let mut _12: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+7:5: +7:6 - let _13: *const i32; // in scope 0 at $DIR/address-of.rs:+8:5: +8:20 - let mut _14: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+8:5: +8:6 - let mut _18: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+12:30: +12:31 - let mut _20: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+13:27: +13:28 - let _21: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+15:5: +15:18 - let mut _22: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+15:5: +15:18 - let _23: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+16:5: +16:26 - let _24: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+17:5: +17:25 - let mut _25: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+17:5: +17:25 - let mut _26: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+17:5: +17:6 - let _27: *const [i32]; // in scope 0 at $DIR/address-of.rs:+18:5: +18:22 - let mut _28: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+18:5: +18:6 - let mut _32: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+22:30: +22:31 - let mut _34: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:+23:27: +23:28 - let _35: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:+25:5: +25:16 - let mut _36: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:+25:5: +25:16 - let _37: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:+26:5: +26:24 - let _38: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+27:5: +27:23 - let mut _39: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:+27:5: +27:23 - let mut _40: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:+27:5: +27:6 - let _41: *mut [i32]; // in scope 0 at $DIR/address-of.rs:+28:5: +28:20 - let mut _42: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:+28:5: +28:6 - let mut _46: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:+32:28: +32:29 - let mut _48: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:+33:25: +33:26 + let mut _0: (); // return place in scope 0 at $DIR/address_of.rs:+0:26: +0:26 + let _1: &[i32; 10]; // in scope 0 at $DIR/address_of.rs:+1:9: +1:10 + let _2: [i32; 10]; // in scope 0 at $DIR/address_of.rs:+1:14: +1:21 + let mut _4: [i32; 10]; // in scope 0 at $DIR/address_of.rs:+2:22: +2:29 + let _5: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+4:5: +4:18 + let mut _6: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+4:5: +4:18 + let _7: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+5:5: +5:26 + let _8: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+6:5: +6:25 + let mut _9: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+6:5: +6:25 + let mut _10: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+6:5: +6:6 + let _11: *const [i32]; // in scope 0 at $DIR/address_of.rs:+7:5: +7:22 + let mut _12: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+7:5: +7:6 + let _13: *const i32; // in scope 0 at $DIR/address_of.rs:+8:5: +8:20 + let mut _14: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+8:5: +8:6 + let mut _18: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+12:30: +12:31 + let mut _20: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+13:27: +13:28 + let _21: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+15:5: +15:18 + let mut _22: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+15:5: +15:18 + let _23: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+16:5: +16:26 + let _24: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+17:5: +17:25 + let mut _25: *const dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+17:5: +17:25 + let mut _26: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+17:5: +17:6 + let _27: *const [i32]; // in scope 0 at $DIR/address_of.rs:+18:5: +18:22 + let mut _28: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+18:5: +18:6 + let mut _32: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+22:30: +22:31 + let mut _34: *const [i32; 10]; // in scope 0 at $DIR/address_of.rs:+23:27: +23:28 + let _35: *mut [i32; 10]; // in scope 0 at $DIR/address_of.rs:+25:5: +25:16 + let mut _36: *mut [i32; 10]; // in scope 0 at $DIR/address_of.rs:+25:5: +25:16 + let _37: *mut [i32; 10]; // in scope 0 at $DIR/address_of.rs:+26:5: +26:24 + let _38: *mut dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+27:5: +27:23 + let mut _39: *mut dyn std::marker::Send; // in scope 0 at $DIR/address_of.rs:+27:5: +27:23 + let mut _40: *mut [i32; 10]; // in scope 0 at $DIR/address_of.rs:+27:5: +27:6 + let _41: *mut [i32]; // in scope 0 at $DIR/address_of.rs:+28:5: +28:20 + let mut _42: *mut [i32; 10]; // in scope 0 at $DIR/address_of.rs:+28:5: +28:6 + let mut _46: *mut [i32; 10]; // in scope 0 at $DIR/address_of.rs:+32:28: +32:29 + let mut _48: *mut [i32; 10]; // in scope 0 at $DIR/address_of.rs:+33:25: +33:26 scope 1 { - debug y => _1; // in scope 1 at $DIR/address-of.rs:+1:9: +1:10 - let mut _3: &mut [i32; 10]; // in scope 1 at $DIR/address-of.rs:+2:9: +2:14 + debug y => _1; // in scope 1 at $DIR/address_of.rs:+1:9: +1:10 + let mut _3: &mut [i32; 10]; // in scope 1 at $DIR/address_of.rs:+2:9: +2:14 scope 2 { - debug z => _3; // in scope 2 at $DIR/address-of.rs:+2:9: +2:14 - let _15: *const [i32; 10] as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 2 at $DIR/address-of.rs:+10:9: +10:10 + debug z => _3; // in scope 2 at $DIR/address_of.rs:+2:9: +2:14 + let _15: *const [i32; 10] as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 2 at $DIR/address_of.rs:+10:9: +10:10 scope 3 { - debug p => _15; // in scope 3 at $DIR/address-of.rs:+10:9: +10:10 - let _16: *const [i32; 10] as UserTypeProjection { base: UserType(4), projs: [] }; // in scope 3 at $DIR/address-of.rs:+11:9: +11:10 + debug p => _15; // in scope 3 at $DIR/address_of.rs:+10:9: +10:10 + let _16: *const [i32; 10] as UserTypeProjection { base: UserType(4), projs: [] }; // in scope 3 at $DIR/address_of.rs:+11:9: +11:10 scope 4 { - debug p => _16; // in scope 4 at $DIR/address-of.rs:+11:9: +11:10 - let _17: *const dyn std::marker::Send as UserTypeProjection { base: UserType(6), projs: [] }; // in scope 4 at $DIR/address-of.rs:+12:9: +12:10 + debug p => _16; // in scope 4 at $DIR/address_of.rs:+11:9: +11:10 + let _17: *const dyn std::marker::Send as UserTypeProjection { base: UserType(6), projs: [] }; // in scope 4 at $DIR/address_of.rs:+12:9: +12:10 scope 5 { - debug p => _17; // in scope 5 at $DIR/address-of.rs:+12:9: +12:10 - let _19: *const [i32] as UserTypeProjection { base: UserType(8), projs: [] }; // in scope 5 at $DIR/address-of.rs:+13:9: +13:10 + debug p => _17; // in scope 5 at $DIR/address_of.rs:+12:9: +12:10 + let _19: *const [i32] as UserTypeProjection { base: UserType(8), projs: [] }; // in scope 5 at $DIR/address_of.rs:+13:9: +13:10 scope 6 { - debug p => _19; // in scope 6 at $DIR/address-of.rs:+13:9: +13:10 - let _29: *const [i32; 10] as UserTypeProjection { base: UserType(12), projs: [] }; // in scope 6 at $DIR/address-of.rs:+20:9: +20:10 + debug p => _19; // in scope 6 at $DIR/address_of.rs:+13:9: +13:10 + let _29: *const [i32; 10] as UserTypeProjection { base: UserType(12), projs: [] }; // in scope 6 at $DIR/address_of.rs:+20:9: +20:10 scope 7 { - debug p => _29; // in scope 7 at $DIR/address-of.rs:+20:9: +20:10 - let _30: *const [i32; 10] as UserTypeProjection { base: UserType(14), projs: [] }; // in scope 7 at $DIR/address-of.rs:+21:9: +21:10 + debug p => _29; // in scope 7 at $DIR/address_of.rs:+20:9: +20:10 + let _30: *const [i32; 10] as UserTypeProjection { base: UserType(14), projs: [] }; // in scope 7 at $DIR/address_of.rs:+21:9: +21:10 scope 8 { - debug p => _30; // in scope 8 at $DIR/address-of.rs:+21:9: +21:10 - let _31: *const dyn std::marker::Send as UserTypeProjection { base: UserType(16), projs: [] }; // in scope 8 at $DIR/address-of.rs:+22:9: +22:10 + debug p => _30; // in scope 8 at $DIR/address_of.rs:+21:9: +21:10 + let _31: *const dyn std::marker::Send as UserTypeProjection { base: UserType(16), projs: [] }; // in scope 8 at $DIR/address_of.rs:+22:9: +22:10 scope 9 { - debug p => _31; // in scope 9 at $DIR/address-of.rs:+22:9: +22:10 - let _33: *const [i32] as UserTypeProjection { base: UserType(18), projs: [] }; // in scope 9 at $DIR/address-of.rs:+23:9: +23:10 + debug p => _31; // in scope 9 at $DIR/address_of.rs:+22:9: +22:10 + let _33: *const [i32] as UserTypeProjection { base: UserType(18), projs: [] }; // in scope 9 at $DIR/address_of.rs:+23:9: +23:10 scope 10 { - debug p => _33; // in scope 10 at $DIR/address-of.rs:+23:9: +23:10 - let _43: *mut [i32; 10] as UserTypeProjection { base: UserType(22), projs: [] }; // in scope 10 at $DIR/address-of.rs:+30:9: +30:10 + debug p => _33; // in scope 10 at $DIR/address_of.rs:+23:9: +23:10 + let _43: *mut [i32; 10] as UserTypeProjection { base: UserType(22), projs: [] }; // in scope 10 at $DIR/address_of.rs:+30:9: +30:10 scope 11 { - debug p => _43; // in scope 11 at $DIR/address-of.rs:+30:9: +30:10 - let _44: *mut [i32; 10] as UserTypeProjection { base: UserType(24), projs: [] }; // in scope 11 at $DIR/address-of.rs:+31:9: +31:10 + debug p => _43; // in scope 11 at $DIR/address_of.rs:+30:9: +30:10 + let _44: *mut [i32; 10] as UserTypeProjection { base: UserType(24), projs: [] }; // in scope 11 at $DIR/address_of.rs:+31:9: +31:10 scope 12 { - debug p => _44; // in scope 12 at $DIR/address-of.rs:+31:9: +31:10 - let _45: *mut dyn std::marker::Send as UserTypeProjection { base: UserType(26), projs: [] }; // in scope 12 at $DIR/address-of.rs:+32:9: +32:10 + debug p => _44; // in scope 12 at $DIR/address_of.rs:+31:9: +31:10 + let _45: *mut dyn std::marker::Send as UserTypeProjection { base: UserType(26), projs: [] }; // in scope 12 at $DIR/address_of.rs:+32:9: +32:10 scope 13 { - debug p => _45; // in scope 13 at $DIR/address-of.rs:+32:9: +32:10 - let _47: *mut [i32] as UserTypeProjection { base: UserType(28), projs: [] }; // in scope 13 at $DIR/address-of.rs:+33:9: +33:10 + debug p => _45; // in scope 13 at $DIR/address_of.rs:+32:9: +32:10 + let _47: *mut [i32] as UserTypeProjection { base: UserType(28), projs: [] }; // in scope 13 at $DIR/address_of.rs:+33:9: +33:10 scope 14 { - debug p => _47; // in scope 14 at $DIR/address-of.rs:+33:9: +33:10 + debug p => _47; // in scope 14 at $DIR/address_of.rs:+33:9: +33:10 } } } @@ -126,183 +126,183 @@ fn address_of_reborrow() -> () { } bb0: { - StorageLive(_1); // scope 0 at $DIR/address-of.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/address-of.rs:+1:14: +1:21 - _2 = [const 0_i32; 10]; // scope 0 at $DIR/address-of.rs:+1:14: +1:21 - _1 = &_2; // scope 0 at $DIR/address-of.rs:+1:13: +1:21 - FakeRead(ForLet(None), _1); // scope 0 at $DIR/address-of.rs:+1:9: +1:10 - StorageLive(_3); // scope 1 at $DIR/address-of.rs:+2:9: +2:14 - StorageLive(_4); // scope 1 at $DIR/address-of.rs:+2:22: +2:29 - _4 = [const 0_i32; 10]; // scope 1 at $DIR/address-of.rs:+2:22: +2:29 - _3 = &mut _4; // scope 1 at $DIR/address-of.rs:+2:17: +2:29 - FakeRead(ForLet(None), _3); // scope 1 at $DIR/address-of.rs:+2:9: +2:14 - StorageLive(_5); // scope 2 at $DIR/address-of.rs:+4:5: +4:18 - StorageLive(_6); // scope 2 at $DIR/address-of.rs:+4:5: +4:18 - _6 = &raw const (*_1); // scope 2 at $DIR/address-of.rs:+4:5: +4:6 - AscribeUserType(_6, o, UserTypeProjection { base: UserType(0), projs: [] }); // scope 2 at $DIR/address-of.rs:+4:5: +4:18 - _5 = _6; // scope 2 at $DIR/address-of.rs:+4:5: +4:18 - StorageDead(_6); // scope 2 at $DIR/address-of.rs:+4:18: +4:19 - StorageDead(_5); // scope 2 at $DIR/address-of.rs:+4:18: +4:19 - StorageLive(_7); // scope 2 at $DIR/address-of.rs:+5:5: +5:26 - _7 = &raw const (*_1); // scope 2 at $DIR/address-of.rs:+5:5: +5:6 - StorageDead(_7); // scope 2 at $DIR/address-of.rs:+5:26: +5:27 - StorageLive(_8); // scope 2 at $DIR/address-of.rs:+6:5: +6:25 - StorageLive(_9); // scope 2 at $DIR/address-of.rs:+6:5: +6:25 - StorageLive(_10); // scope 2 at $DIR/address-of.rs:+6:5: +6:6 - _10 = &raw const (*_1); // scope 2 at $DIR/address-of.rs:+6:5: +6:6 - _9 = move _10 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 2 at $DIR/address-of.rs:+6:5: +6:6 - StorageDead(_10); // scope 2 at $DIR/address-of.rs:+6:5: +6:6 - AscribeUserType(_9, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 2 at $DIR/address-of.rs:+6:5: +6:25 - _8 = _9; // scope 2 at $DIR/address-of.rs:+6:5: +6:25 - StorageDead(_9); // scope 2 at $DIR/address-of.rs:+6:25: +6:26 - StorageDead(_8); // scope 2 at $DIR/address-of.rs:+6:25: +6:26 - StorageLive(_11); // scope 2 at $DIR/address-of.rs:+7:5: +7:22 - StorageLive(_12); // scope 2 at $DIR/address-of.rs:+7:5: +7:6 - _12 = &raw const (*_1); // scope 2 at $DIR/address-of.rs:+7:5: +7:6 - _11 = move _12 as *const [i32] (Pointer(Unsize)); // scope 2 at $DIR/address-of.rs:+7:5: +7:6 - StorageDead(_12); // scope 2 at $DIR/address-of.rs:+7:5: +7:6 - StorageDead(_11); // scope 2 at $DIR/address-of.rs:+7:22: +7:23 - StorageLive(_13); // scope 2 at $DIR/address-of.rs:+8:5: +8:20 - StorageLive(_14); // scope 2 at $DIR/address-of.rs:+8:5: +8:6 - _14 = &raw const (*_1); // scope 2 at $DIR/address-of.rs:+8:5: +8:6 - _13 = move _14 as *const i32 (Pointer(ArrayToPointer)); // scope 2 at $DIR/address-of.rs:+8:5: +8:20 - StorageDead(_14); // scope 2 at $DIR/address-of.rs:+8:19: +8:20 - StorageDead(_13); // scope 2 at $DIR/address-of.rs:+8:20: +8:21 - StorageLive(_15); // scope 2 at $DIR/address-of.rs:+10:9: +10:10 - _15 = &raw const (*_1); // scope 2 at $DIR/address-of.rs:+10:23: +10:24 - FakeRead(ForLet(None), _15); // scope 2 at $DIR/address-of.rs:+10:9: +10:10 - AscribeUserType(_15, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 2 at $DIR/address-of.rs:+10:12: +10:20 - StorageLive(_16); // scope 3 at $DIR/address-of.rs:+11:9: +11:10 - _16 = &raw const (*_1); // scope 3 at $DIR/address-of.rs:+11:31: +11:32 - FakeRead(ForLet(None), _16); // scope 3 at $DIR/address-of.rs:+11:9: +11:10 - AscribeUserType(_16, o, UserTypeProjection { base: UserType(5), projs: [] }); // scope 3 at $DIR/address-of.rs:+11:12: +11:28 - StorageLive(_17); // scope 4 at $DIR/address-of.rs:+12:9: +12:10 - StorageLive(_18); // scope 4 at $DIR/address-of.rs:+12:30: +12:31 - _18 = &raw const (*_1); // scope 4 at $DIR/address-of.rs:+12:30: +12:31 - _17 = move _18 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 4 at $DIR/address-of.rs:+12:30: +12:31 - StorageDead(_18); // scope 4 at $DIR/address-of.rs:+12:30: +12:31 - FakeRead(ForLet(None), _17); // scope 4 at $DIR/address-of.rs:+12:9: +12:10 - AscribeUserType(_17, o, UserTypeProjection { base: UserType(7), projs: [] }); // scope 4 at $DIR/address-of.rs:+12:12: +12:27 - StorageLive(_19); // scope 5 at $DIR/address-of.rs:+13:9: +13:10 - StorageLive(_20); // scope 5 at $DIR/address-of.rs:+13:27: +13:28 - _20 = &raw const (*_1); // scope 5 at $DIR/address-of.rs:+13:27: +13:28 - _19 = move _20 as *const [i32] (Pointer(Unsize)); // scope 5 at $DIR/address-of.rs:+13:27: +13:28 - StorageDead(_20); // scope 5 at $DIR/address-of.rs:+13:27: +13:28 - FakeRead(ForLet(None), _19); // scope 5 at $DIR/address-of.rs:+13:9: +13:10 - AscribeUserType(_19, o, UserTypeProjection { base: UserType(9), projs: [] }); // scope 5 at $DIR/address-of.rs:+13:12: +13:24 - StorageLive(_21); // scope 6 at $DIR/address-of.rs:+15:5: +15:18 - StorageLive(_22); // scope 6 at $DIR/address-of.rs:+15:5: +15:18 - _22 = &raw const (*_3); // scope 6 at $DIR/address-of.rs:+15:5: +15:6 - AscribeUserType(_22, o, UserTypeProjection { base: UserType(10), projs: [] }); // scope 6 at $DIR/address-of.rs:+15:5: +15:18 - _21 = _22; // scope 6 at $DIR/address-of.rs:+15:5: +15:18 - StorageDead(_22); // scope 6 at $DIR/address-of.rs:+15:18: +15:19 - StorageDead(_21); // scope 6 at $DIR/address-of.rs:+15:18: +15:19 - StorageLive(_23); // scope 6 at $DIR/address-of.rs:+16:5: +16:26 - _23 = &raw const (*_3); // scope 6 at $DIR/address-of.rs:+16:5: +16:6 - StorageDead(_23); // scope 6 at $DIR/address-of.rs:+16:26: +16:27 - StorageLive(_24); // scope 6 at $DIR/address-of.rs:+17:5: +17:25 - StorageLive(_25); // scope 6 at $DIR/address-of.rs:+17:5: +17:25 - StorageLive(_26); // scope 6 at $DIR/address-of.rs:+17:5: +17:6 - _26 = &raw const (*_3); // scope 6 at $DIR/address-of.rs:+17:5: +17:6 - _25 = move _26 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 6 at $DIR/address-of.rs:+17:5: +17:6 - StorageDead(_26); // scope 6 at $DIR/address-of.rs:+17:5: +17:6 - AscribeUserType(_25, o, UserTypeProjection { base: UserType(11), projs: [] }); // scope 6 at $DIR/address-of.rs:+17:5: +17:25 - _24 = _25; // scope 6 at $DIR/address-of.rs:+17:5: +17:25 - StorageDead(_25); // scope 6 at $DIR/address-of.rs:+17:25: +17:26 - StorageDead(_24); // scope 6 at $DIR/address-of.rs:+17:25: +17:26 - StorageLive(_27); // scope 6 at $DIR/address-of.rs:+18:5: +18:22 - StorageLive(_28); // scope 6 at $DIR/address-of.rs:+18:5: +18:6 - _28 = &raw const (*_3); // scope 6 at $DIR/address-of.rs:+18:5: +18:6 - _27 = move _28 as *const [i32] (Pointer(Unsize)); // scope 6 at $DIR/address-of.rs:+18:5: +18:6 - StorageDead(_28); // scope 6 at $DIR/address-of.rs:+18:5: +18:6 - StorageDead(_27); // scope 6 at $DIR/address-of.rs:+18:22: +18:23 - StorageLive(_29); // scope 6 at $DIR/address-of.rs:+20:9: +20:10 - _29 = &raw const (*_3); // scope 6 at $DIR/address-of.rs:+20:23: +20:24 - FakeRead(ForLet(None), _29); // scope 6 at $DIR/address-of.rs:+20:9: +20:10 - AscribeUserType(_29, o, UserTypeProjection { base: UserType(13), projs: [] }); // scope 6 at $DIR/address-of.rs:+20:12: +20:20 - StorageLive(_30); // scope 7 at $DIR/address-of.rs:+21:9: +21:10 - _30 = &raw const (*_3); // scope 7 at $DIR/address-of.rs:+21:31: +21:32 - FakeRead(ForLet(None), _30); // scope 7 at $DIR/address-of.rs:+21:9: +21:10 - AscribeUserType(_30, o, UserTypeProjection { base: UserType(15), projs: [] }); // scope 7 at $DIR/address-of.rs:+21:12: +21:28 - StorageLive(_31); // scope 8 at $DIR/address-of.rs:+22:9: +22:10 - StorageLive(_32); // scope 8 at $DIR/address-of.rs:+22:30: +22:31 - _32 = &raw const (*_3); // scope 8 at $DIR/address-of.rs:+22:30: +22:31 - _31 = move _32 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 8 at $DIR/address-of.rs:+22:30: +22:31 - StorageDead(_32); // scope 8 at $DIR/address-of.rs:+22:30: +22:31 - FakeRead(ForLet(None), _31); // scope 8 at $DIR/address-of.rs:+22:9: +22:10 - AscribeUserType(_31, o, UserTypeProjection { base: UserType(17), projs: [] }); // scope 8 at $DIR/address-of.rs:+22:12: +22:27 - StorageLive(_33); // scope 9 at $DIR/address-of.rs:+23:9: +23:10 - StorageLive(_34); // scope 9 at $DIR/address-of.rs:+23:27: +23:28 - _34 = &raw const (*_3); // scope 9 at $DIR/address-of.rs:+23:27: +23:28 - _33 = move _34 as *const [i32] (Pointer(Unsize)); // scope 9 at $DIR/address-of.rs:+23:27: +23:28 - StorageDead(_34); // scope 9 at $DIR/address-of.rs:+23:27: +23:28 - FakeRead(ForLet(None), _33); // scope 9 at $DIR/address-of.rs:+23:9: +23:10 - AscribeUserType(_33, o, UserTypeProjection { base: UserType(19), projs: [] }); // scope 9 at $DIR/address-of.rs:+23:12: +23:24 - StorageLive(_35); // scope 10 at $DIR/address-of.rs:+25:5: +25:16 - StorageLive(_36); // scope 10 at $DIR/address-of.rs:+25:5: +25:16 - _36 = &raw mut (*_3); // scope 10 at $DIR/address-of.rs:+25:5: +25:6 - AscribeUserType(_36, o, UserTypeProjection { base: UserType(20), projs: [] }); // scope 10 at $DIR/address-of.rs:+25:5: +25:16 - _35 = _36; // scope 10 at $DIR/address-of.rs:+25:5: +25:16 - StorageDead(_36); // scope 10 at $DIR/address-of.rs:+25:16: +25:17 - StorageDead(_35); // scope 10 at $DIR/address-of.rs:+25:16: +25:17 - StorageLive(_37); // scope 10 at $DIR/address-of.rs:+26:5: +26:24 - _37 = &raw mut (*_3); // scope 10 at $DIR/address-of.rs:+26:5: +26:6 - StorageDead(_37); // scope 10 at $DIR/address-of.rs:+26:24: +26:25 - StorageLive(_38); // scope 10 at $DIR/address-of.rs:+27:5: +27:23 - StorageLive(_39); // scope 10 at $DIR/address-of.rs:+27:5: +27:23 - StorageLive(_40); // scope 10 at $DIR/address-of.rs:+27:5: +27:6 - _40 = &raw mut (*_3); // scope 10 at $DIR/address-of.rs:+27:5: +27:6 - _39 = move _40 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 10 at $DIR/address-of.rs:+27:5: +27:6 - StorageDead(_40); // scope 10 at $DIR/address-of.rs:+27:5: +27:6 - AscribeUserType(_39, o, UserTypeProjection { base: UserType(21), projs: [] }); // scope 10 at $DIR/address-of.rs:+27:5: +27:23 - _38 = _39; // scope 10 at $DIR/address-of.rs:+27:5: +27:23 - StorageDead(_39); // scope 10 at $DIR/address-of.rs:+27:23: +27:24 - StorageDead(_38); // scope 10 at $DIR/address-of.rs:+27:23: +27:24 - StorageLive(_41); // scope 10 at $DIR/address-of.rs:+28:5: +28:20 - StorageLive(_42); // scope 10 at $DIR/address-of.rs:+28:5: +28:6 - _42 = &raw mut (*_3); // scope 10 at $DIR/address-of.rs:+28:5: +28:6 - _41 = move _42 as *mut [i32] (Pointer(Unsize)); // scope 10 at $DIR/address-of.rs:+28:5: +28:6 - StorageDead(_42); // scope 10 at $DIR/address-of.rs:+28:5: +28:6 - StorageDead(_41); // scope 10 at $DIR/address-of.rs:+28:20: +28:21 - StorageLive(_43); // scope 10 at $DIR/address-of.rs:+30:9: +30:10 - _43 = &raw mut (*_3); // scope 10 at $DIR/address-of.rs:+30:21: +30:22 - FakeRead(ForLet(None), _43); // scope 10 at $DIR/address-of.rs:+30:9: +30:10 - AscribeUserType(_43, o, UserTypeProjection { base: UserType(23), projs: [] }); // scope 10 at $DIR/address-of.rs:+30:12: +30:18 - StorageLive(_44); // scope 11 at $DIR/address-of.rs:+31:9: +31:10 - _44 = &raw mut (*_3); // scope 11 at $DIR/address-of.rs:+31:29: +31:30 - FakeRead(ForLet(None), _44); // scope 11 at $DIR/address-of.rs:+31:9: +31:10 - AscribeUserType(_44, o, UserTypeProjection { base: UserType(25), projs: [] }); // scope 11 at $DIR/address-of.rs:+31:12: +31:26 - StorageLive(_45); // scope 12 at $DIR/address-of.rs:+32:9: +32:10 - StorageLive(_46); // scope 12 at $DIR/address-of.rs:+32:28: +32:29 - _46 = &raw mut (*_3); // scope 12 at $DIR/address-of.rs:+32:28: +32:29 - _45 = move _46 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 12 at $DIR/address-of.rs:+32:28: +32:29 - StorageDead(_46); // scope 12 at $DIR/address-of.rs:+32:28: +32:29 - FakeRead(ForLet(None), _45); // scope 12 at $DIR/address-of.rs:+32:9: +32:10 - AscribeUserType(_45, o, UserTypeProjection { base: UserType(27), projs: [] }); // scope 12 at $DIR/address-of.rs:+32:12: +32:25 - StorageLive(_47); // scope 13 at $DIR/address-of.rs:+33:9: +33:10 - StorageLive(_48); // scope 13 at $DIR/address-of.rs:+33:25: +33:26 - _48 = &raw mut (*_3); // scope 13 at $DIR/address-of.rs:+33:25: +33:26 - _47 = move _48 as *mut [i32] (Pointer(Unsize)); // scope 13 at $DIR/address-of.rs:+33:25: +33:26 - StorageDead(_48); // scope 13 at $DIR/address-of.rs:+33:25: +33:26 - FakeRead(ForLet(None), _47); // scope 13 at $DIR/address-of.rs:+33:9: +33:10 - AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // scope 13 at $DIR/address-of.rs:+33:12: +33:22 - _0 = const (); // scope 0 at $DIR/address-of.rs:+0:26: +34:2 - StorageDead(_47); // scope 13 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_45); // scope 12 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_44); // scope 11 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_43); // scope 10 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_33); // scope 9 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_31); // scope 8 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_30); // scope 7 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_29); // scope 6 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_19); // scope 5 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_17); // scope 4 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_16); // scope 3 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_15); // scope 2 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_4); // scope 1 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_3); // scope 1 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_2); // scope 0 at $DIR/address-of.rs:+34:1: +34:2 - StorageDead(_1); // scope 0 at $DIR/address-of.rs:+34:1: +34:2 - return; // scope 0 at $DIR/address-of.rs:+34:2: +34:2 + StorageLive(_1); // scope 0 at $DIR/address_of.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/address_of.rs:+1:14: +1:21 + _2 = [const 0_i32; 10]; // scope 0 at $DIR/address_of.rs:+1:14: +1:21 + _1 = &_2; // scope 0 at $DIR/address_of.rs:+1:13: +1:21 + FakeRead(ForLet(None), _1); // scope 0 at $DIR/address_of.rs:+1:9: +1:10 + StorageLive(_3); // scope 1 at $DIR/address_of.rs:+2:9: +2:14 + StorageLive(_4); // scope 1 at $DIR/address_of.rs:+2:22: +2:29 + _4 = [const 0_i32; 10]; // scope 1 at $DIR/address_of.rs:+2:22: +2:29 + _3 = &mut _4; // scope 1 at $DIR/address_of.rs:+2:17: +2:29 + FakeRead(ForLet(None), _3); // scope 1 at $DIR/address_of.rs:+2:9: +2:14 + StorageLive(_5); // scope 2 at $DIR/address_of.rs:+4:5: +4:18 + StorageLive(_6); // scope 2 at $DIR/address_of.rs:+4:5: +4:18 + _6 = &raw const (*_1); // scope 2 at $DIR/address_of.rs:+4:5: +4:6 + AscribeUserType(_6, o, UserTypeProjection { base: UserType(0), projs: [] }); // scope 2 at $DIR/address_of.rs:+4:5: +4:18 + _5 = _6; // scope 2 at $DIR/address_of.rs:+4:5: +4:18 + StorageDead(_6); // scope 2 at $DIR/address_of.rs:+4:18: +4:19 + StorageDead(_5); // scope 2 at $DIR/address_of.rs:+4:18: +4:19 + StorageLive(_7); // scope 2 at $DIR/address_of.rs:+5:5: +5:26 + _7 = &raw const (*_1); // scope 2 at $DIR/address_of.rs:+5:5: +5:6 + StorageDead(_7); // scope 2 at $DIR/address_of.rs:+5:26: +5:27 + StorageLive(_8); // scope 2 at $DIR/address_of.rs:+6:5: +6:25 + StorageLive(_9); // scope 2 at $DIR/address_of.rs:+6:5: +6:25 + StorageLive(_10); // scope 2 at $DIR/address_of.rs:+6:5: +6:6 + _10 = &raw const (*_1); // scope 2 at $DIR/address_of.rs:+6:5: +6:6 + _9 = move _10 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 2 at $DIR/address_of.rs:+6:5: +6:6 + StorageDead(_10); // scope 2 at $DIR/address_of.rs:+6:5: +6:6 + AscribeUserType(_9, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 2 at $DIR/address_of.rs:+6:5: +6:25 + _8 = _9; // scope 2 at $DIR/address_of.rs:+6:5: +6:25 + StorageDead(_9); // scope 2 at $DIR/address_of.rs:+6:25: +6:26 + StorageDead(_8); // scope 2 at $DIR/address_of.rs:+6:25: +6:26 + StorageLive(_11); // scope 2 at $DIR/address_of.rs:+7:5: +7:22 + StorageLive(_12); // scope 2 at $DIR/address_of.rs:+7:5: +7:6 + _12 = &raw const (*_1); // scope 2 at $DIR/address_of.rs:+7:5: +7:6 + _11 = move _12 as *const [i32] (Pointer(Unsize)); // scope 2 at $DIR/address_of.rs:+7:5: +7:6 + StorageDead(_12); // scope 2 at $DIR/address_of.rs:+7:5: +7:6 + StorageDead(_11); // scope 2 at $DIR/address_of.rs:+7:22: +7:23 + StorageLive(_13); // scope 2 at $DIR/address_of.rs:+8:5: +8:20 + StorageLive(_14); // scope 2 at $DIR/address_of.rs:+8:5: +8:6 + _14 = &raw const (*_1); // scope 2 at $DIR/address_of.rs:+8:5: +8:6 + _13 = move _14 as *const i32 (Pointer(ArrayToPointer)); // scope 2 at $DIR/address_of.rs:+8:5: +8:20 + StorageDead(_14); // scope 2 at $DIR/address_of.rs:+8:19: +8:20 + StorageDead(_13); // scope 2 at $DIR/address_of.rs:+8:20: +8:21 + StorageLive(_15); // scope 2 at $DIR/address_of.rs:+10:9: +10:10 + _15 = &raw const (*_1); // scope 2 at $DIR/address_of.rs:+10:23: +10:24 + FakeRead(ForLet(None), _15); // scope 2 at $DIR/address_of.rs:+10:9: +10:10 + AscribeUserType(_15, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 2 at $DIR/address_of.rs:+10:12: +10:20 + StorageLive(_16); // scope 3 at $DIR/address_of.rs:+11:9: +11:10 + _16 = &raw const (*_1); // scope 3 at $DIR/address_of.rs:+11:31: +11:32 + FakeRead(ForLet(None), _16); // scope 3 at $DIR/address_of.rs:+11:9: +11:10 + AscribeUserType(_16, o, UserTypeProjection { base: UserType(5), projs: [] }); // scope 3 at $DIR/address_of.rs:+11:12: +11:28 + StorageLive(_17); // scope 4 at $DIR/address_of.rs:+12:9: +12:10 + StorageLive(_18); // scope 4 at $DIR/address_of.rs:+12:30: +12:31 + _18 = &raw const (*_1); // scope 4 at $DIR/address_of.rs:+12:30: +12:31 + _17 = move _18 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 4 at $DIR/address_of.rs:+12:30: +12:31 + StorageDead(_18); // scope 4 at $DIR/address_of.rs:+12:30: +12:31 + FakeRead(ForLet(None), _17); // scope 4 at $DIR/address_of.rs:+12:9: +12:10 + AscribeUserType(_17, o, UserTypeProjection { base: UserType(7), projs: [] }); // scope 4 at $DIR/address_of.rs:+12:12: +12:27 + StorageLive(_19); // scope 5 at $DIR/address_of.rs:+13:9: +13:10 + StorageLive(_20); // scope 5 at $DIR/address_of.rs:+13:27: +13:28 + _20 = &raw const (*_1); // scope 5 at $DIR/address_of.rs:+13:27: +13:28 + _19 = move _20 as *const [i32] (Pointer(Unsize)); // scope 5 at $DIR/address_of.rs:+13:27: +13:28 + StorageDead(_20); // scope 5 at $DIR/address_of.rs:+13:27: +13:28 + FakeRead(ForLet(None), _19); // scope 5 at $DIR/address_of.rs:+13:9: +13:10 + AscribeUserType(_19, o, UserTypeProjection { base: UserType(9), projs: [] }); // scope 5 at $DIR/address_of.rs:+13:12: +13:24 + StorageLive(_21); // scope 6 at $DIR/address_of.rs:+15:5: +15:18 + StorageLive(_22); // scope 6 at $DIR/address_of.rs:+15:5: +15:18 + _22 = &raw const (*_3); // scope 6 at $DIR/address_of.rs:+15:5: +15:6 + AscribeUserType(_22, o, UserTypeProjection { base: UserType(10), projs: [] }); // scope 6 at $DIR/address_of.rs:+15:5: +15:18 + _21 = _22; // scope 6 at $DIR/address_of.rs:+15:5: +15:18 + StorageDead(_22); // scope 6 at $DIR/address_of.rs:+15:18: +15:19 + StorageDead(_21); // scope 6 at $DIR/address_of.rs:+15:18: +15:19 + StorageLive(_23); // scope 6 at $DIR/address_of.rs:+16:5: +16:26 + _23 = &raw const (*_3); // scope 6 at $DIR/address_of.rs:+16:5: +16:6 + StorageDead(_23); // scope 6 at $DIR/address_of.rs:+16:26: +16:27 + StorageLive(_24); // scope 6 at $DIR/address_of.rs:+17:5: +17:25 + StorageLive(_25); // scope 6 at $DIR/address_of.rs:+17:5: +17:25 + StorageLive(_26); // scope 6 at $DIR/address_of.rs:+17:5: +17:6 + _26 = &raw const (*_3); // scope 6 at $DIR/address_of.rs:+17:5: +17:6 + _25 = move _26 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 6 at $DIR/address_of.rs:+17:5: +17:6 + StorageDead(_26); // scope 6 at $DIR/address_of.rs:+17:5: +17:6 + AscribeUserType(_25, o, UserTypeProjection { base: UserType(11), projs: [] }); // scope 6 at $DIR/address_of.rs:+17:5: +17:25 + _24 = _25; // scope 6 at $DIR/address_of.rs:+17:5: +17:25 + StorageDead(_25); // scope 6 at $DIR/address_of.rs:+17:25: +17:26 + StorageDead(_24); // scope 6 at $DIR/address_of.rs:+17:25: +17:26 + StorageLive(_27); // scope 6 at $DIR/address_of.rs:+18:5: +18:22 + StorageLive(_28); // scope 6 at $DIR/address_of.rs:+18:5: +18:6 + _28 = &raw const (*_3); // scope 6 at $DIR/address_of.rs:+18:5: +18:6 + _27 = move _28 as *const [i32] (Pointer(Unsize)); // scope 6 at $DIR/address_of.rs:+18:5: +18:6 + StorageDead(_28); // scope 6 at $DIR/address_of.rs:+18:5: +18:6 + StorageDead(_27); // scope 6 at $DIR/address_of.rs:+18:22: +18:23 + StorageLive(_29); // scope 6 at $DIR/address_of.rs:+20:9: +20:10 + _29 = &raw const (*_3); // scope 6 at $DIR/address_of.rs:+20:23: +20:24 + FakeRead(ForLet(None), _29); // scope 6 at $DIR/address_of.rs:+20:9: +20:10 + AscribeUserType(_29, o, UserTypeProjection { base: UserType(13), projs: [] }); // scope 6 at $DIR/address_of.rs:+20:12: +20:20 + StorageLive(_30); // scope 7 at $DIR/address_of.rs:+21:9: +21:10 + _30 = &raw const (*_3); // scope 7 at $DIR/address_of.rs:+21:31: +21:32 + FakeRead(ForLet(None), _30); // scope 7 at $DIR/address_of.rs:+21:9: +21:10 + AscribeUserType(_30, o, UserTypeProjection { base: UserType(15), projs: [] }); // scope 7 at $DIR/address_of.rs:+21:12: +21:28 + StorageLive(_31); // scope 8 at $DIR/address_of.rs:+22:9: +22:10 + StorageLive(_32); // scope 8 at $DIR/address_of.rs:+22:30: +22:31 + _32 = &raw const (*_3); // scope 8 at $DIR/address_of.rs:+22:30: +22:31 + _31 = move _32 as *const dyn std::marker::Send (Pointer(Unsize)); // scope 8 at $DIR/address_of.rs:+22:30: +22:31 + StorageDead(_32); // scope 8 at $DIR/address_of.rs:+22:30: +22:31 + FakeRead(ForLet(None), _31); // scope 8 at $DIR/address_of.rs:+22:9: +22:10 + AscribeUserType(_31, o, UserTypeProjection { base: UserType(17), projs: [] }); // scope 8 at $DIR/address_of.rs:+22:12: +22:27 + StorageLive(_33); // scope 9 at $DIR/address_of.rs:+23:9: +23:10 + StorageLive(_34); // scope 9 at $DIR/address_of.rs:+23:27: +23:28 + _34 = &raw const (*_3); // scope 9 at $DIR/address_of.rs:+23:27: +23:28 + _33 = move _34 as *const [i32] (Pointer(Unsize)); // scope 9 at $DIR/address_of.rs:+23:27: +23:28 + StorageDead(_34); // scope 9 at $DIR/address_of.rs:+23:27: +23:28 + FakeRead(ForLet(None), _33); // scope 9 at $DIR/address_of.rs:+23:9: +23:10 + AscribeUserType(_33, o, UserTypeProjection { base: UserType(19), projs: [] }); // scope 9 at $DIR/address_of.rs:+23:12: +23:24 + StorageLive(_35); // scope 10 at $DIR/address_of.rs:+25:5: +25:16 + StorageLive(_36); // scope 10 at $DIR/address_of.rs:+25:5: +25:16 + _36 = &raw mut (*_3); // scope 10 at $DIR/address_of.rs:+25:5: +25:6 + AscribeUserType(_36, o, UserTypeProjection { base: UserType(20), projs: [] }); // scope 10 at $DIR/address_of.rs:+25:5: +25:16 + _35 = _36; // scope 10 at $DIR/address_of.rs:+25:5: +25:16 + StorageDead(_36); // scope 10 at $DIR/address_of.rs:+25:16: +25:17 + StorageDead(_35); // scope 10 at $DIR/address_of.rs:+25:16: +25:17 + StorageLive(_37); // scope 10 at $DIR/address_of.rs:+26:5: +26:24 + _37 = &raw mut (*_3); // scope 10 at $DIR/address_of.rs:+26:5: +26:6 + StorageDead(_37); // scope 10 at $DIR/address_of.rs:+26:24: +26:25 + StorageLive(_38); // scope 10 at $DIR/address_of.rs:+27:5: +27:23 + StorageLive(_39); // scope 10 at $DIR/address_of.rs:+27:5: +27:23 + StorageLive(_40); // scope 10 at $DIR/address_of.rs:+27:5: +27:6 + _40 = &raw mut (*_3); // scope 10 at $DIR/address_of.rs:+27:5: +27:6 + _39 = move _40 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 10 at $DIR/address_of.rs:+27:5: +27:6 + StorageDead(_40); // scope 10 at $DIR/address_of.rs:+27:5: +27:6 + AscribeUserType(_39, o, UserTypeProjection { base: UserType(21), projs: [] }); // scope 10 at $DIR/address_of.rs:+27:5: +27:23 + _38 = _39; // scope 10 at $DIR/address_of.rs:+27:5: +27:23 + StorageDead(_39); // scope 10 at $DIR/address_of.rs:+27:23: +27:24 + StorageDead(_38); // scope 10 at $DIR/address_of.rs:+27:23: +27:24 + StorageLive(_41); // scope 10 at $DIR/address_of.rs:+28:5: +28:20 + StorageLive(_42); // scope 10 at $DIR/address_of.rs:+28:5: +28:6 + _42 = &raw mut (*_3); // scope 10 at $DIR/address_of.rs:+28:5: +28:6 + _41 = move _42 as *mut [i32] (Pointer(Unsize)); // scope 10 at $DIR/address_of.rs:+28:5: +28:6 + StorageDead(_42); // scope 10 at $DIR/address_of.rs:+28:5: +28:6 + StorageDead(_41); // scope 10 at $DIR/address_of.rs:+28:20: +28:21 + StorageLive(_43); // scope 10 at $DIR/address_of.rs:+30:9: +30:10 + _43 = &raw mut (*_3); // scope 10 at $DIR/address_of.rs:+30:21: +30:22 + FakeRead(ForLet(None), _43); // scope 10 at $DIR/address_of.rs:+30:9: +30:10 + AscribeUserType(_43, o, UserTypeProjection { base: UserType(23), projs: [] }); // scope 10 at $DIR/address_of.rs:+30:12: +30:18 + StorageLive(_44); // scope 11 at $DIR/address_of.rs:+31:9: +31:10 + _44 = &raw mut (*_3); // scope 11 at $DIR/address_of.rs:+31:29: +31:30 + FakeRead(ForLet(None), _44); // scope 11 at $DIR/address_of.rs:+31:9: +31:10 + AscribeUserType(_44, o, UserTypeProjection { base: UserType(25), projs: [] }); // scope 11 at $DIR/address_of.rs:+31:12: +31:26 + StorageLive(_45); // scope 12 at $DIR/address_of.rs:+32:9: +32:10 + StorageLive(_46); // scope 12 at $DIR/address_of.rs:+32:28: +32:29 + _46 = &raw mut (*_3); // scope 12 at $DIR/address_of.rs:+32:28: +32:29 + _45 = move _46 as *mut dyn std::marker::Send (Pointer(Unsize)); // scope 12 at $DIR/address_of.rs:+32:28: +32:29 + StorageDead(_46); // scope 12 at $DIR/address_of.rs:+32:28: +32:29 + FakeRead(ForLet(None), _45); // scope 12 at $DIR/address_of.rs:+32:9: +32:10 + AscribeUserType(_45, o, UserTypeProjection { base: UserType(27), projs: [] }); // scope 12 at $DIR/address_of.rs:+32:12: +32:25 + StorageLive(_47); // scope 13 at $DIR/address_of.rs:+33:9: +33:10 + StorageLive(_48); // scope 13 at $DIR/address_of.rs:+33:25: +33:26 + _48 = &raw mut (*_3); // scope 13 at $DIR/address_of.rs:+33:25: +33:26 + _47 = move _48 as *mut [i32] (Pointer(Unsize)); // scope 13 at $DIR/address_of.rs:+33:25: +33:26 + StorageDead(_48); // scope 13 at $DIR/address_of.rs:+33:25: +33:26 + FakeRead(ForLet(None), _47); // scope 13 at $DIR/address_of.rs:+33:9: +33:10 + AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // scope 13 at $DIR/address_of.rs:+33:12: +33:22 + _0 = const (); // scope 0 at $DIR/address_of.rs:+0:26: +34:2 + StorageDead(_47); // scope 13 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_45); // scope 12 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_44); // scope 11 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_43); // scope 10 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_33); // scope 9 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_31); // scope 8 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_30); // scope 7 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_29); // scope 6 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_19); // scope 5 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_17); // scope 4 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_16); // scope 3 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_15); // scope 2 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_4); // scope 1 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_3); // scope 1 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_2); // scope 0 at $DIR/address_of.rs:+34:1: +34:2 + StorageDead(_1); // scope 0 at $DIR/address_of.rs:+34:1: +34:2 + return; // scope 0 at $DIR/address_of.rs:+34:2: +34:2 } } diff --git a/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir index 060077b8a..4c67376b5 100644 --- a/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir @@ -1,47 +1,47 @@ // MIR for `borrow_and_cast` after SimplifyCfg-initial fn borrow_and_cast(_1: i32) -> () { - debug x => _1; // in scope 0 at $DIR/address-of.rs:+0:20: +0:25 - let mut _0: (); // return place in scope 0 at $DIR/address-of.rs:+0:32: +0:32 - let _2: *const i32; // in scope 0 at $DIR/address-of.rs:+1:9: +1:10 - let _3: &i32; // in scope 0 at $DIR/address-of.rs:+1:13: +1:15 - let _5: &mut i32; // in scope 0 at $DIR/address-of.rs:+2:13: +2:19 - let mut _7: &mut i32; // in scope 0 at $DIR/address-of.rs:+3:13: +3:19 + debug x => _1; // in scope 0 at $DIR/address_of.rs:+0:20: +0:25 + let mut _0: (); // return place in scope 0 at $DIR/address_of.rs:+0:32: +0:32 + let _2: *const i32; // in scope 0 at $DIR/address_of.rs:+1:9: +1:10 + let _3: &i32; // in scope 0 at $DIR/address_of.rs:+1:13: +1:15 + let _5: &mut i32; // in scope 0 at $DIR/address_of.rs:+2:13: +2:19 + let mut _7: &mut i32; // in scope 0 at $DIR/address_of.rs:+3:13: +3:19 scope 1 { - debug p => _2; // in scope 1 at $DIR/address-of.rs:+1:9: +1:10 - let _4: *const i32; // in scope 1 at $DIR/address-of.rs:+2:9: +2:10 + debug p => _2; // in scope 1 at $DIR/address_of.rs:+1:9: +1:10 + let _4: *const i32; // in scope 1 at $DIR/address_of.rs:+2:9: +2:10 scope 2 { - debug q => _4; // in scope 2 at $DIR/address-of.rs:+2:9: +2:10 - let _6: *mut i32; // in scope 2 at $DIR/address-of.rs:+3:9: +3:10 + debug q => _4; // in scope 2 at $DIR/address_of.rs:+2:9: +2:10 + let _6: *mut i32; // in scope 2 at $DIR/address_of.rs:+3:9: +3:10 scope 3 { - debug r => _6; // in scope 3 at $DIR/address-of.rs:+3:9: +3:10 + debug r => _6; // in scope 3 at $DIR/address_of.rs:+3:9: +3:10 } } } bb0: { - StorageLive(_2); // scope 0 at $DIR/address-of.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/address-of.rs:+1:13: +1:15 - _3 = &_1; // scope 0 at $DIR/address-of.rs:+1:13: +1:15 - _2 = &raw const (*_3); // scope 0 at $DIR/address-of.rs:+1:13: +1:15 - FakeRead(ForLet(None), _2); // scope 0 at $DIR/address-of.rs:+1:9: +1:10 - StorageDead(_3); // scope 0 at $DIR/address-of.rs:+1:29: +1:30 - StorageLive(_4); // scope 1 at $DIR/address-of.rs:+2:9: +2:10 - StorageLive(_5); // scope 1 at $DIR/address-of.rs:+2:13: +2:19 - _5 = &mut _1; // scope 1 at $DIR/address-of.rs:+2:13: +2:19 - _4 = &raw const (*_5); // scope 1 at $DIR/address-of.rs:+2:13: +2:19 - FakeRead(ForLet(None), _4); // scope 1 at $DIR/address-of.rs:+2:9: +2:10 - StorageDead(_5); // scope 1 at $DIR/address-of.rs:+2:33: +2:34 - StorageLive(_6); // scope 2 at $DIR/address-of.rs:+3:9: +3:10 - StorageLive(_7); // scope 2 at $DIR/address-of.rs:+3:13: +3:19 - _7 = &mut _1; // scope 2 at $DIR/address-of.rs:+3:13: +3:19 - _6 = &raw mut (*_7); // scope 2 at $DIR/address-of.rs:+3:13: +3:19 - FakeRead(ForLet(None), _6); // scope 2 at $DIR/address-of.rs:+3:9: +3:10 - StorageDead(_7); // scope 2 at $DIR/address-of.rs:+3:31: +3:32 - _0 = const (); // scope 0 at $DIR/address-of.rs:+0:32: +4:2 - StorageDead(_6); // scope 2 at $DIR/address-of.rs:+4:1: +4:2 - StorageDead(_4); // scope 1 at $DIR/address-of.rs:+4:1: +4:2 - StorageDead(_2); // scope 0 at $DIR/address-of.rs:+4:1: +4:2 - return; // scope 0 at $DIR/address-of.rs:+4:2: +4:2 + StorageLive(_2); // scope 0 at $DIR/address_of.rs:+1:9: +1:10 + StorageLive(_3); // scope 0 at $DIR/address_of.rs:+1:13: +1:15 + _3 = &_1; // scope 0 at $DIR/address_of.rs:+1:13: +1:15 + _2 = &raw const (*_3); // scope 0 at $DIR/address_of.rs:+1:13: +1:15 + FakeRead(ForLet(None), _2); // scope 0 at $DIR/address_of.rs:+1:9: +1:10 + StorageDead(_3); // scope 0 at $DIR/address_of.rs:+1:29: +1:30 + StorageLive(_4); // scope 1 at $DIR/address_of.rs:+2:9: +2:10 + StorageLive(_5); // scope 1 at $DIR/address_of.rs:+2:13: +2:19 + _5 = &mut _1; // scope 1 at $DIR/address_of.rs:+2:13: +2:19 + _4 = &raw const (*_5); // scope 1 at $DIR/address_of.rs:+2:13: +2:19 + FakeRead(ForLet(None), _4); // scope 1 at $DIR/address_of.rs:+2:9: +2:10 + StorageDead(_5); // scope 1 at $DIR/address_of.rs:+2:33: +2:34 + StorageLive(_6); // scope 2 at $DIR/address_of.rs:+3:9: +3:10 + StorageLive(_7); // scope 2 at $DIR/address_of.rs:+3:13: +3:19 + _7 = &mut _1; // scope 2 at $DIR/address_of.rs:+3:13: +3:19 + _6 = &raw mut (*_7); // scope 2 at $DIR/address_of.rs:+3:13: +3:19 + FakeRead(ForLet(None), _6); // scope 2 at $DIR/address_of.rs:+3:9: +3:10 + StorageDead(_7); // scope 2 at $DIR/address_of.rs:+3:31: +3:32 + _0 = const (); // scope 0 at $DIR/address_of.rs:+0:32: +4:2 + StorageDead(_6); // scope 2 at $DIR/address_of.rs:+4:1: +4:2 + StorageDead(_4); // scope 1 at $DIR/address_of.rs:+4:1: +4:2 + StorageDead(_2); // scope 0 at $DIR/address_of.rs:+4:1: +4:2 + return; // scope 0 at $DIR/address_of.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/address_of.rs b/src/test/mir-opt/address_of.rs new file mode 100644 index 000000000..c4bea5613 --- /dev/null +++ b/src/test/mir-opt/address_of.rs @@ -0,0 +1,47 @@ +// EMIT_MIR address_of.address_of_reborrow.SimplifyCfg-initial.after.mir + +fn address_of_reborrow() { + let y = &[0; 10]; + let mut z = &mut [0; 10]; + + y as *const _; + y as *const [i32; 10]; + y as *const dyn Send; + y as *const [i32]; + y as *const i32; // This is a cast, not a coercion + + let p: *const _ = y; + let p: *const [i32; 10] = y; + let p: *const dyn Send = y; + let p: *const [i32] = y; + + z as *const _; + z as *const [i32; 10]; + z as *const dyn Send; + z as *const [i32]; + + let p: *const _ = z; + let p: *const [i32; 10] = z; + let p: *const dyn Send = z; + let p: *const [i32] = z; + + z as *mut _; + z as *mut [i32; 10]; + z as *mut dyn Send; + z as *mut [i32]; + + let p: *mut _ = z; + let p: *mut [i32; 10] = z; + let p: *mut dyn Send = z; + let p: *mut [i32] = z; +} + +// The normal borrows here should be preserved +// EMIT_MIR address_of.borrow_and_cast.SimplifyCfg-initial.after.mir +fn borrow_and_cast(mut x: i32) { + let p = &x as *const i32; + let q = &mut x as *const i32; + let r = &mut x as *mut i32; +} + +fn main() {} diff --git a/src/test/mir-opt/array-index-is-temporary.rs b/src/test/mir-opt/array-index-is-temporary.rs deleted file mode 100644 index e7bde81d4..000000000 --- a/src/test/mir-opt/array-index-is-temporary.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Retagging (from Stacked Borrows) relies on the array index being a fresh -// temporary, so that side-effects cannot change it. -// Test that this is indeed the case. - -unsafe fn foo(z: *mut usize) -> u32 { - *z = 2; - 99 -} - - -// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir -fn main() { - let mut x = [42, 43, 44]; - let mut y = 1; - let z: *mut usize = &mut y; - x[y] = unsafe { foo(z) }; -} diff --git a/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir index 27f883ed3..af5178d40 100644 --- a/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir @@ -1,22 +1,22 @@ // MIR for `main` after SimplifyCfg-elaborate-drops fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/array-index-is-temporary.rs:+0:11: +0:11 - let mut _1: [u32; 3]; // in scope 0 at $DIR/array-index-is-temporary.rs:+1:9: +1:14 - let mut _4: &mut usize; // in scope 0 at $DIR/array-index-is-temporary.rs:+3:25: +3:31 - let mut _5: u32; // in scope 0 at $DIR/array-index-is-temporary.rs:+4:12: +4:29 - let mut _6: *mut usize; // in scope 0 at $DIR/array-index-is-temporary.rs:+4:25: +4:26 - let _7: usize; // in scope 0 at $DIR/array-index-is-temporary.rs:+4:7: +4:8 - let mut _8: usize; // in scope 0 at $DIR/array-index-is-temporary.rs:+4:5: +4:9 - let mut _9: bool; // in scope 0 at $DIR/array-index-is-temporary.rs:+4:5: +4:9 + let mut _0: (); // return place in scope 0 at $DIR/array_index_is_temporary.rs:+0:11: +0:11 + let mut _1: [u32; 3]; // in scope 0 at $DIR/array_index_is_temporary.rs:+1:9: +1:14 + let mut _4: &mut usize; // in scope 0 at $DIR/array_index_is_temporary.rs:+3:25: +3:31 + let mut _5: u32; // in scope 0 at $DIR/array_index_is_temporary.rs:+4:12: +4:29 + let mut _6: *mut usize; // in scope 0 at $DIR/array_index_is_temporary.rs:+4:25: +4:26 + let _7: usize; // in scope 0 at $DIR/array_index_is_temporary.rs:+4:7: +4:8 + let mut _8: usize; // in scope 0 at $DIR/array_index_is_temporary.rs:+4:5: +4:9 + let mut _9: bool; // in scope 0 at $DIR/array_index_is_temporary.rs:+4:5: +4:9 scope 1 { - debug x => _1; // in scope 1 at $DIR/array-index-is-temporary.rs:+1:9: +1:14 - let mut _2: usize; // in scope 1 at $DIR/array-index-is-temporary.rs:+2:9: +2:14 + debug x => _1; // in scope 1 at $DIR/array_index_is_temporary.rs:+1:9: +1:14 + let mut _2: usize; // in scope 1 at $DIR/array_index_is_temporary.rs:+2:9: +2:14 scope 2 { - debug y => _2; // in scope 2 at $DIR/array-index-is-temporary.rs:+2:9: +2:14 - let _3: *mut usize; // in scope 2 at $DIR/array-index-is-temporary.rs:+3:9: +3:10 + debug y => _2; // in scope 2 at $DIR/array_index_is_temporary.rs:+2:9: +2:14 + let _3: *mut usize; // in scope 2 at $DIR/array_index_is_temporary.rs:+3:9: +3:10 scope 3 { - debug z => _3; // in scope 3 at $DIR/array-index-is-temporary.rs:+3:9: +3:10 + debug z => _3; // in scope 3 at $DIR/array_index_is_temporary.rs:+3:9: +3:10 scope 4 { } } @@ -24,41 +24,41 @@ fn main() -> () { } bb0: { - StorageLive(_1); // scope 0 at $DIR/array-index-is-temporary.rs:+1:9: +1:14 - _1 = [const 42_u32, const 43_u32, const 44_u32]; // scope 0 at $DIR/array-index-is-temporary.rs:+1:17: +1:29 - StorageLive(_2); // scope 1 at $DIR/array-index-is-temporary.rs:+2:9: +2:14 - _2 = const 1_usize; // scope 1 at $DIR/array-index-is-temporary.rs:+2:17: +2:18 - StorageLive(_3); // scope 2 at $DIR/array-index-is-temporary.rs:+3:9: +3:10 - StorageLive(_4); // scope 2 at $DIR/array-index-is-temporary.rs:+3:25: +3:31 - _4 = &mut _2; // scope 2 at $DIR/array-index-is-temporary.rs:+3:25: +3:31 - _3 = &raw mut (*_4); // scope 2 at $DIR/array-index-is-temporary.rs:+3:25: +3:31 - StorageDead(_4); // scope 2 at $DIR/array-index-is-temporary.rs:+3:31: +3:32 - StorageLive(_5); // scope 3 at $DIR/array-index-is-temporary.rs:+4:12: +4:29 - StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:+4:25: +4:26 - _6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:+4:25: +4:26 - _5 = foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:+4:21: +4:27 + StorageLive(_1); // scope 0 at $DIR/array_index_is_temporary.rs:+1:9: +1:14 + _1 = [const 42_u32, const 43_u32, const 44_u32]; // scope 0 at $DIR/array_index_is_temporary.rs:+1:17: +1:29 + StorageLive(_2); // scope 1 at $DIR/array_index_is_temporary.rs:+2:9: +2:14 + _2 = const 1_usize; // scope 1 at $DIR/array_index_is_temporary.rs:+2:17: +2:18 + StorageLive(_3); // scope 2 at $DIR/array_index_is_temporary.rs:+3:9: +3:10 + StorageLive(_4); // scope 2 at $DIR/array_index_is_temporary.rs:+3:25: +3:31 + _4 = &mut _2; // scope 2 at $DIR/array_index_is_temporary.rs:+3:25: +3:31 + _3 = &raw mut (*_4); // scope 2 at $DIR/array_index_is_temporary.rs:+3:25: +3:31 + StorageDead(_4); // scope 2 at $DIR/array_index_is_temporary.rs:+3:31: +3:32 + StorageLive(_5); // scope 3 at $DIR/array_index_is_temporary.rs:+4:12: +4:29 + StorageLive(_6); // scope 4 at $DIR/array_index_is_temporary.rs:+4:25: +4:26 + _6 = _3; // scope 4 at $DIR/array_index_is_temporary.rs:+4:25: +4:26 + _5 = foo(move _6) -> bb1; // scope 4 at $DIR/array_index_is_temporary.rs:+4:21: +4:27 // mir::Constant - // + span: $DIR/array-index-is-temporary.rs:16:21: 16:24 + // + span: $DIR/array_index_is_temporary.rs:16:21: 16:24 // + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value() } } bb1: { - StorageDead(_6); // scope 4 at $DIR/array-index-is-temporary.rs:+4:26: +4:27 - StorageLive(_7); // scope 3 at $DIR/array-index-is-temporary.rs:+4:7: +4:8 - _7 = _2; // scope 3 at $DIR/array-index-is-temporary.rs:+4:7: +4:8 - _8 = Len(_1); // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:9 - _9 = Lt(_7, _8); // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:9 - assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:9 + StorageDead(_6); // scope 4 at $DIR/array_index_is_temporary.rs:+4:26: +4:27 + StorageLive(_7); // scope 3 at $DIR/array_index_is_temporary.rs:+4:7: +4:8 + _7 = _2; // scope 3 at $DIR/array_index_is_temporary.rs:+4:7: +4:8 + _8 = Len(_1); // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:9 + _9 = Lt(_7, _8); // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:9 + assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2; // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:9 } bb2: { - _1[_7] = move _5; // scope 3 at $DIR/array-index-is-temporary.rs:+4:5: +4:29 - StorageDead(_5); // scope 3 at $DIR/array-index-is-temporary.rs:+4:28: +4:29 - StorageDead(_7); // scope 3 at $DIR/array-index-is-temporary.rs:+4:29: +4:30 - _0 = const (); // scope 0 at $DIR/array-index-is-temporary.rs:+0:11: +5:2 - StorageDead(_3); // scope 2 at $DIR/array-index-is-temporary.rs:+5:1: +5:2 - StorageDead(_2); // scope 1 at $DIR/array-index-is-temporary.rs:+5:1: +5:2 - StorageDead(_1); // scope 0 at $DIR/array-index-is-temporary.rs:+5:1: +5:2 - return; // scope 0 at $DIR/array-index-is-temporary.rs:+5:2: +5:2 + _1[_7] = move _5; // scope 3 at $DIR/array_index_is_temporary.rs:+4:5: +4:29 + StorageDead(_5); // scope 3 at $DIR/array_index_is_temporary.rs:+4:28: +4:29 + StorageDead(_7); // scope 3 at $DIR/array_index_is_temporary.rs:+4:29: +4:30 + _0 = const (); // scope 0 at $DIR/array_index_is_temporary.rs:+0:11: +5:2 + StorageDead(_3); // scope 2 at $DIR/array_index_is_temporary.rs:+5:1: +5:2 + StorageDead(_2); // scope 1 at $DIR/array_index_is_temporary.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/array_index_is_temporary.rs:+5:1: +5:2 + return; // scope 0 at $DIR/array_index_is_temporary.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/array_index_is_temporary.rs b/src/test/mir-opt/array_index_is_temporary.rs new file mode 100644 index 000000000..e7bde81d4 --- /dev/null +++ b/src/test/mir-opt/array_index_is_temporary.rs @@ -0,0 +1,17 @@ +// Retagging (from Stacked Borrows) relies on the array index being a fresh +// temporary, so that side-effects cannot change it. +// Test that this is indeed the case. + +unsafe fn foo(z: *mut usize) -> u32 { + *z = 2; + 99 +} + + +// EMIT_MIR array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir +fn main() { + let mut x = [42, 43, 44]; + let mut y = 1; + let z: *mut usize = &mut y; + x[y] = unsafe { foo(z) }; +} diff --git a/src/test/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir b/src/test/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir new file mode 100644 index 000000000..20dd251e7 --- /dev/null +++ b/src/test/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir @@ -0,0 +1,22 @@ +// MIR for `arbitrary_let` after built + +fn arbitrary_let(_1: i32) -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/arbitrary_let.rs:+0:29: +0:32 + let mut _2: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: i32; // 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 + goto -> bb2; // scope 0 at $DIR/arbitrary_let.rs:+4:13: +4:25 + } + + bb1: { + _0 = _3; // scope 0 at $DIR/arbitrary_let.rs:+7:13: +7:20 + return; // scope 0 at $DIR/arbitrary_let.rs:+8:13: +8:21 + } + + bb2: { + _3 = _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + goto -> bb1; // scope 0 at $DIR/arbitrary_let.rs:+12:13: +12:24 + } +} diff --git a/src/test/mir-opt/building/custom/arbitrary_let.rs b/src/test/mir-opt/building/custom/arbitrary_let.rs new file mode 100644 index 000000000..776df3151 --- /dev/null +++ b/src/test/mir-opt/building/custom/arbitrary_let.rs @@ -0,0 +1,28 @@ +#![feature(custom_mir, core_intrinsics)] + +extern crate core; +use core::intrinsics::mir::*; +use core::ptr::{addr_of, addr_of_mut}; + +// EMIT_MIR arbitrary_let.arbitrary_let.built.after.mir +#[custom_mir(dialect = "built")] +fn arbitrary_let(x: i32) -> i32 { + mir!( + { + let y = x; + Goto(second) + } + third = { + RET = z; + Return() + } + second = { + let z = y; + Goto(third) + } + ) +} + +fn main() { + assert_eq!(arbitrary_let(5), 5); +} diff --git a/src/test/mir-opt/building/custom/consts.consts.built.after.mir b/src/test/mir-opt/building/custom/consts.consts.built.after.mir new file mode 100644 index 000000000..ba753cfc2 --- /dev/null +++ b/src/test/mir-opt/building/custom/consts.consts.built.after.mir @@ -0,0 +1,22 @@ +// MIR for `consts` after built + +fn consts() -> () { + let mut _0: (); // return place in scope 0 at $DIR/consts.rs:+0:27: +0:27 + let mut _1: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: i8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _4: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _5: fn() {consts::<10>}; // 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 = const _; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _3 = const C; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _4 = const _; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + _5 = consts::<10>; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + // mir::Constant + // + span: $DIR/consts.rs:16:18: 16:30 + // + literal: Const { ty: fn() {consts::<10>}, val: Value() } + return; // scope 0 at $DIR/consts.rs:+7:9: +7:17 + } +} diff --git a/src/test/mir-opt/building/custom/consts.rs b/src/test/mir-opt/building/custom/consts.rs new file mode 100644 index 000000000..ff4fe1a93 --- /dev/null +++ b/src/test/mir-opt/building/custom/consts.rs @@ -0,0 +1,36 @@ +#![feature(custom_mir, core_intrinsics, inline_const)] + +extern crate core; +use core::intrinsics::mir::*; + +const D: i32 = 5; + +// EMIT_MIR consts.consts.built.after.mir +#[custom_mir(dialect = "built")] +fn consts() { + mir!({ + let _a = 5_u8; + let _b = const { 5_i8 }; + let _c = C; + let _d = D; + let _e = consts::<10>; + Return() + }) +} + +static S: i32 = 5; +static mut T: i32 = 10; +// EMIT_MIR consts.statics.built.after.mir +#[custom_mir(dialect = "built")] +fn statics() { + mir!({ + let _a: &i32 = Static(S); + let _b: *mut i32 = StaticMut(T); + Return() + }) +} + +fn main() { + consts::<5>(); + statics(); +} diff --git a/src/test/mir-opt/building/custom/consts.statics.built.after.mir b/src/test/mir-opt/building/custom/consts.statics.built.after.mir new file mode 100644 index 000000000..ee768e263 --- /dev/null +++ b/src/test/mir-opt/building/custom/consts.statics.built.after.mir @@ -0,0 +1,27 @@ +// MIR for `statics` after built + +fn statics() -> () { + let mut _0: (); // return place in scope 0 at $DIR/consts.rs:+0:14: +0:14 + let mut _1: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _2: *mut i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _1 = const {alloc1: &i32}; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + // mir::Constant + // + span: $DIR/consts.rs:27:31: 27:32 + // + literal: Const { ty: &i32, val: Value(Scalar(alloc1)) } + _2 = const {alloc2: *mut i32}; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + // mir::Constant + // + span: $DIR/consts.rs:28:38: 28:39 + // + literal: Const { ty: *mut i32, val: Value(Scalar(alloc2)) } + return; // scope 0 at $DIR/consts.rs:+4:9: +4:17 + } +} + +alloc2 (static: T, size: 4, align: 4) { + 0a 00 00 00 │ .... +} + +alloc1 (static: S, size: 4, align: 4) { + 05 00 00 00 │ .... +} diff --git a/src/test/mir-opt/building/custom/references.immut_ref.built.after.mir b/src/test/mir-opt/building/custom/references.immut_ref.built.after.mir new file mode 100644 index 000000000..4d38d45c0 --- /dev/null +++ b/src/test/mir-opt/building/custom/references.immut_ref.built.after.mir @@ -0,0 +1,14 @@ +// MIR for `immut_ref` after built + +fn immut_ref(_1: &i32) -> &i32 { + let mut _0: &i32; // return place in scope 0 at $DIR/references.rs:+0:30: +0:34 + let mut _2: *const i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _2 = &raw const (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:29 + Retag([raw] _2); // scope 0 at $DIR/references.rs:+6:13: +6:24 + _0 = &(*_2); // scope 0 at $DIR/references.rs:+7:13: +7:23 + Retag(_0); // scope 0 at $DIR/references.rs:+8:13: +8:23 + return; // scope 0 at $DIR/references.rs:+9:13: +9:21 + } +} diff --git a/src/test/mir-opt/building/custom/references.mut_ref.built.after.mir b/src/test/mir-opt/building/custom/references.mut_ref.built.after.mir new file mode 100644 index 000000000..01bc8a9cd --- /dev/null +++ b/src/test/mir-opt/building/custom/references.mut_ref.built.after.mir @@ -0,0 +1,14 @@ +// MIR for `mut_ref` after built + +fn mut_ref(_1: &mut i32) -> &mut i32 { + let mut _0: &mut i32; // return place in scope 0 at $DIR/references.rs:+0:32: +0:40 + let mut _2: *mut i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _2 = &raw mut (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:33 + Retag([raw] _2); // scope 0 at $DIR/references.rs:+6:13: +6:24 + _0 = &mut (*_2); // scope 0 at $DIR/references.rs:+7:13: +7:26 + Retag(_0); // scope 0 at $DIR/references.rs:+8:13: +8:23 + return; // scope 0 at $DIR/references.rs:+9:13: +9:21 + } +} diff --git a/src/test/mir-opt/building/custom/references.rs b/src/test/mir-opt/building/custom/references.rs new file mode 100644 index 000000000..dee85722e --- /dev/null +++ b/src/test/mir-opt/building/custom/references.rs @@ -0,0 +1,43 @@ +#![feature(custom_mir, core_intrinsics)] + +extern crate core; +use core::intrinsics::mir::*; +use core::ptr::{addr_of, addr_of_mut}; + +// EMIT_MIR references.mut_ref.built.after.mir +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn mut_ref(x: &mut i32) -> &mut i32 { + mir!( + let t: *mut i32; + + { + t = addr_of_mut!(*x); + RetagRaw(t); + RET = &mut *t; + Retag(RET); + Return() + } + ) +} + +// EMIT_MIR references.immut_ref.built.after.mir +#[custom_mir(dialect = "runtime", phase = "optimized")] +pub fn immut_ref(x: &i32) -> &i32 { + mir!( + let t: *const i32; + + { + t = addr_of!(*x); + RetagRaw(t); + RET = & *t; + Retag(RET); + Return() + } + ) +} + +fn main() { + let mut x = 5; + assert_eq!(*mut_ref(&mut x), 5); + assert_eq!(*immut_ref(&x), 5); +} diff --git a/src/test/mir-opt/building/custom/simple_assign.rs b/src/test/mir-opt/building/custom/simple_assign.rs new file mode 100644 index 000000000..ec6dbe1d0 --- /dev/null +++ b/src/test/mir-opt/building/custom/simple_assign.rs @@ -0,0 +1,37 @@ +#![feature(custom_mir, core_intrinsics)] + +extern crate core; +use core::intrinsics::mir::*; + +// EMIT_MIR simple_assign.simple.built.after.mir +#[custom_mir(dialect = "built")] +pub fn simple(x: i32) -> i32 { + mir!( + let temp1: i32; + let temp2: _; + + { + temp1 = x; + Goto(exit) + } + + exit = { + temp2 = Move(temp1); + RET = temp2; + Return() + } + ) +} + +// EMIT_MIR simple_assign.simple_ref.built.after.mir +#[custom_mir(dialect = "built")] +pub fn simple_ref(x: &mut i32) -> &mut i32 { + mir!({ + RET = Move(x); + Return() + }) +} + +fn main() { + assert_eq!(5, simple(5)); +} diff --git a/src/test/mir-opt/building/custom/simple_assign.simple.built.after.mir b/src/test/mir-opt/building/custom/simple_assign.simple.built.after.mir new file mode 100644 index 000000000..d7560fde6 --- /dev/null +++ b/src/test/mir-opt/building/custom/simple_assign.simple.built.after.mir @@ -0,0 +1,18 @@ +// MIR for `simple` after built + +fn simple(_1: i32) -> i32 { + let mut _0: i32; // return place in scope 0 at $DIR/simple_assign.rs:+0:26: +0:29 + let mut _2: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL + + bb0: { + _2 = _1; // scope 0 at $DIR/simple_assign.rs:+6:13: +6:22 + goto -> bb1; // scope 0 at $DIR/simple_assign.rs:+7:13: +7:23 + } + + bb1: { + _3 = move _2; // scope 0 at $DIR/simple_assign.rs:+11:13: +11:32 + _0 = _3; // scope 0 at $DIR/simple_assign.rs:+12:13: +12:24 + return; // scope 0 at $DIR/simple_assign.rs:+13:13: +13:21 + } +} diff --git a/src/test/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir b/src/test/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir new file mode 100644 index 000000000..2b0e8f104 --- /dev/null +++ b/src/test/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `simple_ref` after built + +fn simple_ref(_1: &mut i32) -> &mut i32 { + let mut _0: &mut i32; // return place in scope 0 at $DIR/simple_assign.rs:+0:35: +0:43 + + bb0: { + _0 = move _1; // scope 0 at $DIR/simple_assign.rs:+2:9: +2:22 + return; // scope 0 at $DIR/simple_assign.rs:+3:9: +3:17 + } +} diff --git a/src/test/mir-opt/building/enum_cast.bar.built.after.mir b/src/test/mir-opt/building/enum_cast.bar.built.after.mir new file mode 100644 index 000000000..0746e0b49 --- /dev/null +++ b/src/test/mir-opt/building/enum_cast.bar.built.after.mir @@ -0,0 +1,23 @@ +// MIR for `bar` after built + +fn bar(_1: Bar) -> usize { + debug bar => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 + let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 + let _2: Bar; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + let mut _4: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _4 = Ge(const 1_isize, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + assume(_4); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _5 = Le(const 0_isize, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + assume(_5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 + return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 + } +} diff --git a/src/test/mir-opt/building/enum_cast.boo.built.after.mir b/src/test/mir-opt/building/enum_cast.boo.built.after.mir new file mode 100644 index 000000000..699c876b0 --- /dev/null +++ b/src/test/mir-opt/building/enum_cast.boo.built.after.mir @@ -0,0 +1,23 @@ +// MIR for `boo` after built + +fn boo(_1: Boo) -> usize { + debug boo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 + let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 + let _2: Boo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + let mut _3: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + let mut _4: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _4 = Ge(const 1_u8, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + assume(_4); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _5 = Le(const 0_u8, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + assume(_5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 + return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 + } +} diff --git a/src/test/mir-opt/building/enum_cast.droppy.built.after.mir b/src/test/mir-opt/building/enum_cast.droppy.built.after.mir new file mode 100644 index 000000000..5231c2eab --- /dev/null +++ b/src/test/mir-opt/building/enum_cast.droppy.built.after.mir @@ -0,0 +1,72 @@ +// MIR for `droppy` after built + +fn droppy() -> () { + let mut _0: (); // return place in scope 0 at $DIR/enum_cast.rs:+0:13: +0:13 + let _1: (); // in scope 0 at $DIR/enum_cast.rs:+1:5: +6:6 + let _2: Droppy; // in scope 0 at $DIR/enum_cast.rs:+2:13: +2:14 + let _4: Droppy; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18 + let mut _5: isize; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18 + let mut _6: bool; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:27 + let mut _7: bool; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:27 + let _8: Droppy; // in scope 0 at $DIR/enum_cast.rs:+7:9: +7:10 + scope 1 { + debug x => _2; // in scope 1 at $DIR/enum_cast.rs:+2:13: +2:14 + scope 2 { + debug y => _3; // in scope 2 at $DIR/enum_cast.rs:+5:13: +5:14 + } + scope 3 { + let _3: usize; // in scope 3 at $DIR/enum_cast.rs:+5:13: +5:14 + } + } + scope 4 { + debug z => _8; // in scope 4 at $DIR/enum_cast.rs:+7:9: +7:10 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/enum_cast.rs:+1:5: +6:6 + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+2:13: +2:14 + _2 = Droppy::C; // scope 0 at $DIR/enum_cast.rs:+2:17: +2:26 + FakeRead(ForLet(None), _2); // scope 0 at $DIR/enum_cast.rs:+2:13: +2:14 + StorageLive(_3); // scope 3 at $DIR/enum_cast.rs:+5:13: +5:14 + StorageLive(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18 + _4 = move _2; // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18 + _5 = discriminant(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + _6 = Ge(const 2_isize, _5); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + assume(_6); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + _7 = Le(const 0_isize, _5); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + assume(_7); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + _3 = move _5 as usize (IntToInt); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 + drop(_4) -> [return: bb1, unwind: bb4]; // scope 3 at $DIR/enum_cast.rs:+5:26: +5:27 + } + + bb1: { + StorageDead(_4); // scope 3 at $DIR/enum_cast.rs:+5:26: +5:27 + FakeRead(ForLet(None), _3); // scope 3 at $DIR/enum_cast.rs:+5:13: +5:14 + _1 = const (); // scope 0 at $DIR/enum_cast.rs:+1:5: +6:6 + StorageDead(_3); // scope 1 at $DIR/enum_cast.rs:+6:5: +6:6 + drop(_2) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 + } + + bb2: { + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 + StorageDead(_1); // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 + StorageLive(_8); // scope 0 at $DIR/enum_cast.rs:+7:9: +7:10 + _8 = Droppy::B; // scope 0 at $DIR/enum_cast.rs:+7:13: +7:22 + FakeRead(ForLet(None), _8); // scope 0 at $DIR/enum_cast.rs:+7:9: +7:10 + _0 = const (); // scope 0 at $DIR/enum_cast.rs:+0:13: +8:2 + drop(_8) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/enum_cast.rs:+8:1: +8:2 + } + + bb3: { + StorageDead(_8); // scope 0 at $DIR/enum_cast.rs:+8:1: +8:2 + return; // scope 0 at $DIR/enum_cast.rs:+8:2: +8:2 + } + + bb4 (cleanup): { + drop(_2) -> bb5; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 + } + + bb5 (cleanup): { + resume; // scope 0 at $DIR/enum_cast.rs:+0:1: +8:2 + } +} diff --git a/src/test/mir-opt/building/enum_cast.foo.built.after.mir b/src/test/mir-opt/building/enum_cast.foo.built.after.mir new file mode 100644 index 000000000..17e0abf2e --- /dev/null +++ b/src/test/mir-opt/building/enum_cast.foo.built.after.mir @@ -0,0 +1,17 @@ +// MIR for `foo` after built + +fn foo(_1: Foo) -> usize { + debug foo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 + let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 + let _2: Foo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 + _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 + StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 + return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 + } +} diff --git a/src/test/mir-opt/building/enum_cast.rs b/src/test/mir-opt/building/enum_cast.rs new file mode 100644 index 000000000..98fd5acfb --- /dev/null +++ b/src/test/mir-opt/building/enum_cast.rs @@ -0,0 +1,50 @@ +// EMIT_MIR enum_cast.foo.built.after.mir +// EMIT_MIR enum_cast.bar.built.after.mir +// EMIT_MIR enum_cast.boo.built.after.mir + +enum Foo { + A +} + +enum Bar { + A, B +} + +#[repr(u8)] +enum Boo { + A, B +} + +fn foo(foo: Foo) -> usize { + foo as usize +} + +fn bar(bar: Bar) -> usize { + bar as usize +} + +fn boo(boo: Boo) -> usize { + boo as usize +} + +// EMIT_MIR enum_cast.droppy.built.after.mir +enum Droppy { + A, B, C +} + +impl Drop for Droppy { + fn drop(&mut self) {} +} + +fn droppy() { + { + let x = Droppy::C; + // remove this entire test once `cenum_impl_drop_cast` becomes a hard error + #[allow(cenum_impl_drop_cast)] + let y = x as usize; + } + let z = Droppy::B; +} + +fn main() { +} diff --git a/src/test/mir-opt/building/issue_101867.main.built.after.mir b/src/test/mir-opt/building/issue_101867.main.built.after.mir new file mode 100644 index 000000000..0ebd840cf --- /dev/null +++ b/src/test/mir-opt/building/issue_101867.main.built.after.mir @@ -0,0 +1,75 @@ +// MIR for `main` after built + +| User Type Annotations +| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option +| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_101867.rs:+0:11: +0:11 + let _1: std::option::Option as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue_101867.rs:+1:9: +1:10 + let mut _2: !; // in scope 0 at $DIR/issue_101867.rs:+2:26: +4:6 + let _3: (); // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL + let mut _4: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL + let mut _6: isize; // in scope 0 at $DIR/issue_101867.rs:+2:9: +2:16 + scope 1 { + debug x => _1; // in scope 1 at $DIR/issue_101867.rs:+1:9: +1:10 + let _5: u8; // in scope 1 at $DIR/issue_101867.rs:+2:14: +2:15 + scope 2 { + debug y => _5; // in scope 2 at $DIR/issue_101867.rs:+2:14: +2:15 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue_101867.rs:+1:9: +1:10 + _1 = Option::::Some(const 1_u8); // scope 0 at $DIR/issue_101867.rs:+1:25: +1:32 + FakeRead(ForLet(None), _1); // scope 0 at $DIR/issue_101867.rs:+1:9: +1:10 + AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue_101867.rs:+1:12: +1:22 + StorageLive(_5); // scope 1 at $DIR/issue_101867.rs:+2:14: +2:15 + FakeRead(ForMatchedPlace(None), _1); // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20 + _6 = discriminant(_1); // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20 + switchInt(move _6) -> [1_isize: bb4, otherwise: bb3]; // scope 1 at $DIR/issue_101867.rs:+2:9: +2:16 + } + + bb1: { + StorageLive(_3); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + StorageLive(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + _4 = begin_panic::<&str>(const "explicit panic") -> bb7; // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/std/src/panic.rs:LL:COL + // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value() } + // mir::Constant + // + span: $SRC_DIR/std/src/panic.rs:LL:COL + // + literal: Const { ty: &str, val: Value(Slice(..)) } + } + + bb2: { + StorageDead(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + StorageDead(_3); // scope 1 at $DIR/issue_101867.rs:+3:16: +3:17 + unreachable; // scope 1 at $DIR/issue_101867.rs:+2:26: +4:6 + } + + bb3: { + goto -> bb6; // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20 + } + + bb4: { + falseEdge -> [real: bb5, imaginary: bb3]; // scope 1 at $DIR/issue_101867.rs:+2:9: +2:16 + } + + bb5: { + _5 = ((_1 as Some).0: u8); // scope 1 at $DIR/issue_101867.rs:+2:14: +2:15 + _0 = const (); // scope 0 at $DIR/issue_101867.rs:+0:11: +5:2 + StorageDead(_5); // scope 1 at $DIR/issue_101867.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/issue_101867.rs:+5:1: +5:2 + return; // scope 0 at $DIR/issue_101867.rs:+5:2: +5:2 + } + + bb6: { + StorageDead(_5); // scope 1 at $DIR/issue_101867.rs:+5:1: +5:2 + goto -> bb1; // scope 0 at $DIR/issue_101867.rs:+0:11: +5:2 + } + + bb7 (cleanup): { + resume; // scope 0 at $DIR/issue_101867.rs:+0:1: +5:2 + } +} diff --git a/src/test/mir-opt/building/issue_101867.rs b/src/test/mir-opt/building/issue_101867.rs new file mode 100644 index 000000000..a32d8cb37 --- /dev/null +++ b/src/test/mir-opt/building/issue_101867.rs @@ -0,0 +1,7 @@ +// EMIT_MIR issue_101867.main.built.after.mir +fn main() { + let x: Option = Some(1); + let Some(y) = x else { + panic!(); + }; +} diff --git a/src/test/mir-opt/building/issue_49232.main.built.after.mir b/src/test/mir-opt/building/issue_49232.main.built.after.mir new file mode 100644 index 000000000..9182bcaa2 --- /dev/null +++ b/src/test/mir-opt/building/issue_49232.main.built.after.mir @@ -0,0 +1,82 @@ +// MIR for `main` after built + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_49232.rs:+0:11: +0:11 + let mut _1: (); // in scope 0 at $DIR/issue_49232.rs:+0:1: +10:2 + let _2: i32; // in scope 0 at $DIR/issue_49232.rs:+2:13: +2:19 + let mut _3: bool; // in scope 0 at $DIR/issue_49232.rs:+3:19: +3:23 + let mut _4: !; // in scope 0 at $DIR/issue_49232.rs:+5:25: +5:30 + let _5: (); // in scope 0 at $DIR/issue_49232.rs:+8:9: +8:22 + let mut _6: &i32; // in scope 0 at $DIR/issue_49232.rs:+8:14: +8:21 + scope 1 { + debug beacon => _2; // in scope 1 at $DIR/issue_49232.rs:+2:13: +2:19 + } + + bb0: { + goto -> bb1; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6 + } + + bb1: { + falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6 + } + + bb2: { + StorageLive(_2); // scope 0 at $DIR/issue_49232.rs:+2:13: +2:19 + StorageLive(_3); // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23 + _3 = const true; // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23 + FakeRead(ForMatchedPlace(None), _3); // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23 + switchInt(_3) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/issue_49232.rs:+3:13: +3:23 + } + + bb3: { + falseEdge -> [real: bb5, imaginary: bb4]; // scope 0 at $DIR/issue_49232.rs:+4:17: +4:22 + } + + bb4: { + _0 = const (); // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30 + goto -> bb10; // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30 + } + + bb5: { + _2 = const 4_i32; // scope 0 at $DIR/issue_49232.rs:+4:26: +4:27 + goto -> bb8; // scope 0 at $DIR/issue_49232.rs:+4:26: +4:27 + } + + bb6: { + unreachable; // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30 + } + + bb7: { + goto -> bb8; // scope 0 at $DIR/issue_49232.rs:+6:13: +6:14 + } + + bb8: { + FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue_49232.rs:+2:13: +2:19 + StorageDead(_3); // scope 0 at $DIR/issue_49232.rs:+7:10: +7:11 + StorageLive(_5); // scope 1 at $DIR/issue_49232.rs:+8:9: +8:22 + StorageLive(_6); // scope 1 at $DIR/issue_49232.rs:+8:14: +8:21 + _6 = &_2; // scope 1 at $DIR/issue_49232.rs:+8:14: +8:21 + _5 = std::mem::drop::<&i32>(move _6) -> [return: bb9, unwind: bb11]; // scope 1 at $DIR/issue_49232.rs:+8:9: +8:22 + // mir::Constant + // + span: $DIR/issue_49232.rs:13:9: 13:13 + // + literal: Const { ty: fn(&i32) {std::mem::drop::<&i32>}, val: Value() } + } + + bb9: { + StorageDead(_6); // scope 1 at $DIR/issue_49232.rs:+8:21: +8:22 + StorageDead(_5); // scope 1 at $DIR/issue_49232.rs:+8:22: +8:23 + _1 = const (); // scope 0 at $DIR/issue_49232.rs:+1:10: +9:6 + StorageDead(_2); // scope 0 at $DIR/issue_49232.rs:+9:5: +9:6 + goto -> bb1; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6 + } + + bb10: { + StorageDead(_3); // scope 0 at $DIR/issue_49232.rs:+7:10: +7:11 + StorageDead(_2); // scope 0 at $DIR/issue_49232.rs:+9:5: +9:6 + return; // scope 0 at $DIR/issue_49232.rs:+10:2: +10:2 + } + + bb11 (cleanup): { + resume; // scope 0 at $DIR/issue_49232.rs:+0:1: +10:2 + } +} diff --git a/src/test/mir-opt/building/issue_49232.rs b/src/test/mir-opt/building/issue_49232.rs new file mode 100644 index 000000000..7e9f0de81 --- /dev/null +++ b/src/test/mir-opt/building/issue_49232.rs @@ -0,0 +1,15 @@ +// We must mark a variable whose initialization fails due to an +// abort statement as StorageDead. + +// EMIT_MIR issue_49232.main.built.after.mir +fn main() { + loop { + let beacon = { + match true { + false => 4, + true => break, + } + }; + drop(&beacon); + } +} diff --git a/src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir b/src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir new file mode 100644 index 000000000..9a190c3d6 --- /dev/null +++ b/src/test/mir-opt/building/match_false_edges.full_tested_match.built.after.mir @@ -0,0 +1,112 @@ +// MIR for `full_tested_match` after built + +fn full_tested_match() -> () { + let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:28: +0:28 + let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 + let mut _2: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 + let mut _4: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36 + let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 + let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:24: +3:25 + scope 1 { + } + scope 2 { + debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 + debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 + } + scope 3 { + debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:+3:14: +3:15 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 + StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + _2 = Option::::Some(const 42_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + switchInt(move _3) -> [0_isize: bb1, 1_isize: bb2, otherwise: bb4]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:27 + } + + bb1: { + _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23 + } + + bb2: { + falseEdge -> [real: bb5, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 + } + + bb3: { + falseEdge -> [real: bb10, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16 + } + + bb4: { + unreachable; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + } + + bb5: { + StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + _6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + _7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + // mir::Constant + // + span: $DIR/match_false_edges.rs:14:20: 14:25 + // + literal: Const { ty: fn() -> bool {guard}, val: Value() } + } + + bb6: { + switchInt(move _7) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb7: { + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + _5 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + StorageLive(_8); // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 + _8 = _5; // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 + _1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:+2:31: +2:37 + StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37 + StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + } + + bb8: { + goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb9: { + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + goto -> bb3; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb10: { + StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 + _9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 + StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25 + _10 = _9; // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25 + _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+3:20: +3:26 + StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+3:25: +3:26 + StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26 + } + + bb11: { + StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 + StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 + _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2 + return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2 + } + + bb12 (cleanup): { + resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2 + } +} diff --git a/src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir b/src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir new file mode 100644 index 000000000..1c9953e7e --- /dev/null +++ b/src/test/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir @@ -0,0 +1,112 @@ +// MIR for `full_tested_match2` after built + +fn full_tested_match2() -> () { + let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:29: +0:29 + let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 + let mut _2: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 + let mut _4: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36 + let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:24: +4:25 + scope 1 { + } + scope 2 { + debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 + debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 + } + scope 3 { + debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:+4:14: +4:15 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 + StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + _2 = Option::::Some(const 42_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + switchInt(move _3) -> [0_isize: bb1, 1_isize: bb2, otherwise: bb4]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:27 + } + + bb1: { + falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13 + } + + bb2: { + falseEdge -> [real: bb5, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 + } + + bb3: { + StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + _9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+4:24: +4:25 + _10 = _9; // scope 3 at $DIR/match_false_edges.rs:+4:24: +4:25 + _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+4:20: +4:26 + StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+4:25: +4:26 + StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26 + } + + bb4: { + unreachable; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + } + + bb5: { + StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + _6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 + StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + _7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + // mir::Constant + // + span: $DIR/match_false_edges.rs:25:20: 25:25 + // + literal: Const { ty: fn() -> bool {guard}, val: Value() } + } + + bb6: { + switchInt(move _7) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb7: { + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + _5 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 + StorageLive(_8); // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 + _8 = _5; // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 + _1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:+2:31: +2:37 + StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37 + StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + } + + bb8: { + goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb9: { + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 + falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 + } + + bb10: { + _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23 + goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23 + } + + bb11: { + StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 + StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 + _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2 + return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2 + } + + bb12 (cleanup): { + resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2 + } +} diff --git a/src/test/mir-opt/building/match_false_edges.main.built.after.mir b/src/test/mir-opt/building/match_false_edges.main.built.after.mir new file mode 100644 index 000000000..08c67d39d --- /dev/null +++ b/src/test/mir-opt/building/match_false_edges.main.built.after.mir @@ -0,0 +1,174 @@ +// MIR for `main` after built + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:11: +0:11 + let mut _1: i32; // in scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6 + let mut _2: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16 + let mut _4: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17 + let mut _5: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + let _6: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 + let _7: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 + let mut _8: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + let _9: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 + let _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + let _11: &i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + let mut _12: bool; // in scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + let mut _13: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 + let _14: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 + scope 1 { + } + scope 2 { + debug _w => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:16 + debug _w => _7; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:16 + } + scope 3 { + debug _x => _9; // in scope 3 at $DIR/match_false_edges.rs:+3:9: +3:11 + } + scope 4 { + debug y => _10; // in scope 4 at $DIR/match_false_edges.rs:+4:14: +4:15 + debug y => _11; // in scope 4 at $DIR/match_false_edges.rs:+4:14: +4:15 + } + scope 5 { + debug _z => _14; // in scope 5 at $DIR/match_false_edges.rs:+5:9: +5:11 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6 + StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + _2 = Option::::Some(const 1_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + _4 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 + } + + bb1: { + falseEdge -> [real: bb13, imaginary: bb6]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 + } + + bb2: { + falseEdge -> [real: bb8, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17 + } + + bb3: { + goto -> bb1; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 + } + + bb4: { + _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + switchInt(move _3) -> [1_isize: bb6, otherwise: bb5]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 + } + + bb5: { + StorageLive(_14); // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 + _14 = _2; // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 + _1 = const 4_i32; // scope 5 at $DIR/match_false_edges.rs:+5:15: +5:16 + StorageDead(_14); // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16 + } + + bb6: { + falseEdge -> [real: bb14, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16 + } + + bb7: { + goto -> bb5; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 + } + + bb8: { + StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 + _7 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 + _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + StorageLive(_8); // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + _8 = guard() -> [return: bb9, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + // mir::Constant + // + span: $DIR/match_false_edges.rs:34:21: 34:26 + // + literal: Const { ty: fn() -> bool {guard}, val: Value() } + } + + bb9: { + switchInt(move _8) -> [false: bb11, otherwise: bb10]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + } + + bb10: { + StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 + FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 + FakeRead(ForGuardBinding, _7); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 + StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 + _6 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 + _1 = const 1_i32; // scope 2 at $DIR/match_false_edges.rs:+2:32: +2:33 + StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 + } + + bb11: { + goto -> bb12; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + } + + bb12: { + StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 + StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 + falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 + } + + bb13: { + StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 + _9 = _2; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 + _1 = const 2_i32; // scope 3 at $DIR/match_false_edges.rs:+3:15: +3:16 + StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16 + } + + bb14: { + StorageLive(_11); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + _11 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 + StorageLive(_12); // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + StorageLive(_13); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 + _13 = (*_11); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 + _12 = guard2(move _13) -> [return: bb15, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + // mir::Constant + // + span: $DIR/match_false_edges.rs:36:20: 36:26 + // + literal: Const { ty: fn(i32) -> bool {guard2}, val: Value() } + } + + bb15: { + switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + } + + bb16: { + StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 + StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 + FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 + FakeRead(ForGuardBinding, _11); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 + StorageLive(_10); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + _10 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 + _1 = const 3_i32; // scope 4 at $DIR/match_false_edges.rs:+4:33: +4:34 + StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 + StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 + goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 + } + + bb17: { + goto -> bb18; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + } + + bb18: { + StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 + StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 + StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 + falseEdge -> [real: bb7, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 + } + + bb19: { + StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 + StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 + _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2 + return; // scope 0 at $DIR/match_false_edges.rs:+7:2: +7:2 + } + + bb20 (cleanup): { + resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +7:2 + } +} diff --git a/src/test/mir-opt/building/match_false_edges.rs b/src/test/mir-opt/building/match_false_edges.rs new file mode 100644 index 000000000..ddfcc1493 --- /dev/null +++ b/src/test/mir-opt/building/match_false_edges.rs @@ -0,0 +1,39 @@ +fn guard() -> bool { + false +} + +fn guard2(_: i32) -> bool { + true +} + +// no_mangle to make sure this gets instantiated even in an executable. +#[no_mangle] +// EMIT_MIR match_false_edges.full_tested_match.built.after.mir +pub fn full_tested_match() { + let _ = match Some(42) { + Some(x) if guard() => (1, x), + Some(y) => (2, y), + None => (3, 3), + }; +} + +// no_mangle to make sure this gets instantiated even in an executable. +#[no_mangle] +// EMIT_MIR match_false_edges.full_tested_match2.built.after.mir +pub fn full_tested_match2() { + let _ = match Some(42) { + Some(x) if guard() => (1, x), + None => (3, 3), + Some(y) => (2, y), + }; +} + +// EMIT_MIR match_false_edges.main.built.after.mir +fn main() { + let _ = match Some(1) { + Some(_w) if guard() => 1, + _x => 2, + Some(y) if guard2(y) => 3, + _z => 4, + }; +} diff --git a/src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir b/src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir new file mode 100644 index 000000000..41eb00363 --- /dev/null +++ b/src/test/mir-opt/building/receiver_ptr_mutability.main.built.after.mir @@ -0,0 +1,96 @@ +// MIR for `main` after built + +| User Type Annotations +| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test +| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test +| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test +| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/receiver_ptr_mutability.rs:+0:11: +0:11 + let _1: *mut Test as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12 + let _2: (); // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12 + let mut _3: *const Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12 + let mut _4: *mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8 + let _6: &&&&*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41 + let _7: &&&*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41 + let _8: &&*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41 + let _9: &*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41 + let _10: (); // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + let mut _11: *const Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + let mut _12: *mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + scope 1 { + debug ptr => _1; // in scope 1 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12 + let _5: &&&&*mut Test as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16 + scope 2 { + debug ptr_ref => _5; // in scope 2 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12 + _1 = null_mut::() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:26: +1:46 + // mir::Constant + // + span: $DIR/receiver_ptr_mutability.rs:14:26: 14:44 + // + literal: Const { ty: fn() -> *mut Test {null_mut::}, val: Value() } + } + + bb1: { + FakeRead(ForLet(None), _1); // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12 + AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:14: +1:23 + StorageLive(_2); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12 + StorageLive(_3); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12 + StorageLive(_4); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8 + _4 = _1; // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8 + _3 = move _4 as *const Test (Pointer(MutToConstPointer)); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12 + StorageDead(_4); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:7: +2:8 + _2 = Test::x(move _3) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12 + // mir::Constant + // + span: $DIR/receiver_ptr_mutability.rs:15:9: 15:10 + // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value() } + } + + bb2: { + StorageDead(_3); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:11: +2:12 + StorageDead(_2); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:12: +2:13 + StorageLive(_5); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16 + StorageLive(_6); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41 + StorageLive(_7); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41 + StorageLive(_8); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41 + StorageLive(_9); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41 + _9 = &_1; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41 + _8 = &_9; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41 + _7 = &_8; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41 + _6 = &_7; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41 + _5 = &(*_6); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41 + FakeRead(ForLet(None), _5); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16 + AscribeUserType(_5, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:18: +5:31 + StorageDead(_6); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:41: +5:42 + StorageLive(_10); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + StorageLive(_11); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + StorageLive(_12); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + _12 = (*(*(*(*_5)))); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + _11 = move _12 as *const Test (Pointer(MutToConstPointer)); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + StorageDead(_12); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:11: +6:12 + _10 = Test::x(move _11) -> [return: bb3, unwind: bb4]; // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16 + // mir::Constant + // + span: $DIR/receiver_ptr_mutability.rs:19:13: 19:14 + // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value() } + } + + bb3: { + StorageDead(_11); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:15: +6:16 + StorageDead(_10); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:16: +6:17 + _0 = const (); // scope 0 at $DIR/receiver_ptr_mutability.rs:+0:11: +7:2 + StorageDead(_9); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2 + StorageDead(_8); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2 + StorageDead(_7); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2 + StorageDead(_5); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2 + StorageDead(_1); // scope 0 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2 + return; // scope 0 at $DIR/receiver_ptr_mutability.rs:+7:2: +7:2 + } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/receiver_ptr_mutability.rs:+0:1: +7:2 + } +} diff --git a/src/test/mir-opt/building/receiver_ptr_mutability.rs b/src/test/mir-opt/building/receiver_ptr_mutability.rs new file mode 100644 index 000000000..668530968 --- /dev/null +++ b/src/test/mir-opt/building/receiver_ptr_mutability.rs @@ -0,0 +1,20 @@ +// EMIT_MIR receiver_ptr_mutability.main.built.after.mir + +#![feature(arbitrary_self_types)] + +struct Test {} + +impl Test { + fn x(self: *const Self) { + println!("x called"); + } +} + +fn main() { + let ptr: *mut Test = std::ptr::null_mut(); + ptr.x(); + + // Test autoderefs + let ptr_ref: &&&&*mut Test = &&&&ptr; + ptr_ref.x(); +} diff --git a/src/test/mir-opt/building/simple_match.match_bool.built.after.mir b/src/test/mir-opt/building/simple_match.match_bool.built.after.mir new file mode 100644 index 000000000..a4516026c --- /dev/null +++ b/src/test/mir-opt/building/simple_match.match_bool.built.after.mir @@ -0,0 +1,29 @@ +// MIR for `match_bool` after built + +fn match_bool(_1: bool) -> usize { + debug x => _1; // in scope 0 at $DIR/simple_match.rs:+0:15: +0:16 + let mut _0: usize; // return place in scope 0 at $DIR/simple_match.rs:+0:27: +0:32 + + bb0: { + FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/simple_match.rs:+1:11: +1:12 + switchInt(_1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/simple_match.rs:+1:5: +1:12 + } + + bb1: { + falseEdge -> [real: bb3, imaginary: bb2]; // scope 0 at $DIR/simple_match.rs:+2:9: +2:13 + } + + bb2: { + _0 = const 20_usize; // scope 0 at $DIR/simple_match.rs:+3:14: +3:16 + goto -> bb4; // scope 0 at $DIR/simple_match.rs:+3:14: +3:16 + } + + bb3: { + _0 = const 10_usize; // scope 0 at $DIR/simple_match.rs:+2:17: +2:19 + goto -> bb4; // scope 0 at $DIR/simple_match.rs:+2:17: +2:19 + } + + bb4: { + return; // scope 0 at $DIR/simple_match.rs:+5:2: +5:2 + } +} diff --git a/src/test/mir-opt/building/simple_match.rs b/src/test/mir-opt/building/simple_match.rs new file mode 100644 index 000000000..0ef97dde6 --- /dev/null +++ b/src/test/mir-opt/building/simple_match.rs @@ -0,0 +1,12 @@ +// Test that we don't generate unnecessarily large MIR for very simple matches + + +// EMIT_MIR simple_match.match_bool.built.after.mir +fn match_bool(x: bool) -> usize { + match x { + true => 10, + _ => 20, + } +} + +fn main() {} diff --git a/src/test/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir b/src/test/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir new file mode 100644 index 000000000..1d3f77e07 --- /dev/null +++ b/src/test/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir @@ -0,0 +1,203 @@ +// MIR for `XXX` after built + +static XXX: &Foo = { + let mut _0: &Foo; // return place in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:13: +0:25 + let _1: &Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 + let _2: Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2 + let mut _3: &[(u32, u32)]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + let mut _4: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + let _5: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + let _6: [(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6 + let mut _7: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15 + let mut _8: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23 + let mut _9: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31 + let mut _10: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15 + let mut _11: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23 + let mut _12: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31 + let mut _13: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15 + let mut _14: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23 + let mut _15: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31 + let mut _16: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15 + let mut _17: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23 + let mut _18: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31 + let mut _19: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15 + let mut _20: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23 + let mut _21: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31 + let mut _22: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15 + let mut _23: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23 + let mut _24: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31 + let mut _25: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15 + let mut _26: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23 + let mut _27: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31 + let mut _28: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15 + let mut _29: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23 + let mut _30: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31 + let mut _31: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15 + let mut _32: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23 + let mut _33: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31 + let mut _34: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15 + let mut _35: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23 + let mut _36: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31 + let mut _37: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15 + let mut _38: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23 + let mut _39: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31 + let mut _40: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15 + let mut _41: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23 + let mut _42: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31 + let mut _43: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15 + let mut _44: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23 + let mut _45: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31 + let mut _46: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15 + let mut _47: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23 + let mut _48: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 + StorageLive(_2); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2 + StorageLive(_3); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + StorageLive(_4); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + StorageLive(_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + StorageLive(_6); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6 + StorageLive(_7); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15 + _7 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15 + StorageLive(_8); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23 + _8 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23 + StorageLive(_9); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31 + _9 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31 + StorageLive(_10); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15 + _10 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15 + StorageLive(_11); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23 + _11 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23 + StorageLive(_12); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31 + _12 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31 + StorageLive(_13); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15 + _13 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15 + StorageLive(_14); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23 + _14 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23 + StorageLive(_15); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31 + _15 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31 + StorageLive(_16); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15 + _16 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15 + StorageLive(_17); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23 + _17 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23 + StorageLive(_18); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31 + _18 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31 + StorageLive(_19); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15 + _19 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15 + StorageLive(_20); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23 + _20 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23 + StorageLive(_21); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31 + _21 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31 + StorageLive(_22); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15 + _22 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15 + StorageLive(_23); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23 + _23 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23 + StorageLive(_24); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31 + _24 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31 + StorageLive(_25); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15 + _25 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15 + StorageLive(_26); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23 + _26 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23 + StorageLive(_27); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31 + _27 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31 + StorageLive(_28); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15 + _28 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15 + StorageLive(_29); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23 + _29 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23 + StorageLive(_30); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31 + _30 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31 + StorageLive(_31); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15 + _31 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15 + StorageLive(_32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23 + _32 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23 + StorageLive(_33); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31 + _33 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31 + StorageLive(_34); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15 + _34 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15 + StorageLive(_35); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23 + _35 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23 + StorageLive(_36); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31 + _36 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31 + StorageLive(_37); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15 + _37 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15 + StorageLive(_38); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23 + _38 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23 + StorageLive(_39); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31 + _39 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31 + StorageLive(_40); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15 + _40 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15 + StorageLive(_41); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23 + _41 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23 + StorageLive(_42); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31 + _42 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31 + StorageLive(_43); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15 + _43 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15 + StorageLive(_44); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23 + _44 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23 + StorageLive(_45); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31 + _45 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31 + StorageLive(_46); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15 + _46 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15 + StorageLive(_47); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23 + _47 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23 + StorageLive(_48); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31 + _48 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31 + _6 = [move _7, move _8, move _9, move _10, move _11, move _12, move _13, move _14, move _15, move _16, move _17, move _18, move _19, move _20, move _21, move _22, move _23, move _24, move _25, move _26, move _27, move _28, move _29, move _30, move _31, move _32, move _33, move _34, move _35, move _36, move _37, move _38, move _39, move _40, move _41, move _42, move _43, move _44, move _45, move _46, move _47, move _48]; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6 + StorageDead(_48); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_47); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_46); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_45); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_44); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_43); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_42); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_41); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_40); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_39); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_38); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_37); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_36); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_35); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_34); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_33); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_31); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_30); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_29); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_28); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_27); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_26); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_25); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_24); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_23); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_22); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_21); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_20); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_19); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_18); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_17); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_16); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_15); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_14); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_13); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_12); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_11); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_10); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_9); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_8); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + StorageDead(_7); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + _5 = &_6; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + _4 = &(*_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + _3 = move _4 as &[(u32, u32)] (Pointer(Unsize)); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 + StorageDead(_4); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 + _2 = Foo { tup: const "hi", data: move _3 }; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2 + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:6:10: 6:14 + // + literal: Const { ty: &str, val: Value(Slice(..)) } + StorageDead(_3); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 + _1 = &_2; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 + _0 = &(*_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 + StorageDead(_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 + StorageDead(_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 + return; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:1: +18:3 + } +} diff --git a/src/test/mir-opt/building/storage_live_dead_in_statics.rs b/src/test/mir-opt/building/storage_live_dead_in_statics.rs new file mode 100644 index 000000000..79f709148 --- /dev/null +++ b/src/test/mir-opt/building/storage_live_dead_in_statics.rs @@ -0,0 +1,33 @@ +// Check that when we compile the static `XXX` into MIR, we do not +// generate `StorageStart` or `StorageEnd` statements. + +// EMIT_MIR storage_live_dead_in_statics.XXX.built.after.mir +static XXX: &'static Foo = &Foo { + tup: "hi", + data: &[ + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + (0, 1), (0, 2), (0, 3), + ] +}; + +#[derive(Debug)] +struct Foo { + tup: &'static str, + data: &'static [(u32, u32)] +} + +fn main() { + println!("{:?}", XXX); +} diff --git a/src/test/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/src/test/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir new file mode 100644 index 000000000..234cd0839 --- /dev/null +++ b/src/test/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir @@ -0,0 +1,111 @@ +// MIR for `move_out_by_subslice` after built + +fn move_out_by_subslice() -> () { + let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +0:27 + let _1: [std::boxed::Box; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + let mut _2: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _6: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _7: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _11: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + scope 1 { + debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + let _12: [std::boxed::Box; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 + scope 4 { + debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 + } + } + scope 2 { + } + scope 3 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:11:14: 11:19 + // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } + } + + bb1: { + StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + } + + bb2: { + StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:11:21: 11:26 + // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } + } + + bb3: { + StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + } + + bb4: { + StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27 + drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb5: { + StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb6: { + StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 + _12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 + _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +3:2 + drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + } + + bb7: { + StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + } + + bb8: { + StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2 + } + + bb9 (cleanup): { + drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + } + + bb10 (cleanup): { + drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb11 (cleanup): { + drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb12 (cleanup): { + resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2 + } +} diff --git a/src/test/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/src/test/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir new file mode 100644 index 000000000..24a189498 --- /dev/null +++ b/src/test/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir @@ -0,0 +1,111 @@ +// MIR for `move_out_from_end` after built + +fn move_out_from_end() -> () { + let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +0:24 + let _1: [std::boxed::Box; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + let mut _2: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _6: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + let mut _7: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + let mut _11: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + scope 1 { + debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + let _12: std::boxed::Box; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 + scope 4 { + debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 + } + } + scope 2 { + } + scope 3 { + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:5:14: 5:19 + // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } + } + + bb1: { + StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 + drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + } + + bb2: { + StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 + StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:5:21: 5:26 + // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } + } + + bb3: { + StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 + drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + } + + bb4: { + StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 + _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27 + drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb5: { + StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb6: { + StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 + StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 + _12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 + _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +3:2 + drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + } + + bb7: { + StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + } + + bb8: { + StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2 + } + + bb9 (cleanup): { + drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 + } + + bb10 (cleanup): { + drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb11 (cleanup): { + drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 + } + + bb12 (cleanup): { + resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2 + } +} diff --git a/src/test/mir-opt/building/uniform_array_move_out.rs b/src/test/mir-opt/building/uniform_array_move_out.rs new file mode 100644 index 000000000..e925036ec --- /dev/null +++ b/src/test/mir-opt/building/uniform_array_move_out.rs @@ -0,0 +1,18 @@ +#![feature(box_syntax)] + +// EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir +fn move_out_from_end() { + let a = [box 1, box 2]; + let [.., _y] = a; +} + +// EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir +fn move_out_by_subslice() { + let a = [box 1, box 2]; + let [_y @ ..] = a; +} + +fn main() { + move_out_by_subslice(); + move_out_from_end(); +} diff --git a/src/test/mir-opt/const-promotion-extern-static.rs b/src/test/mir-opt/const-promotion-extern-static.rs deleted file mode 100644 index a0d4e9b2c..000000000 --- a/src/test/mir-opt/const-promotion-extern-static.rs +++ /dev/null @@ -1,18 +0,0 @@ -// ignore-endian-big -extern "C" { - static X: i32; -} -static Y: i32 = 42; - -// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff -// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir -static mut BAR: *const &i32 = [&Y].as_ptr(); - -// EMIT_MIR const_promotion_extern_static.FOO.PromoteTemps.diff -// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir -static mut FOO: *const &i32 = [unsafe { &X }].as_ptr(); - -// EMIT_MIR const_promotion_extern_static.BOP.mir_map.0.mir -static BOP: &i32 = &13; - -fn main() {} diff --git a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff index a092f3752..e959e1b2f 100644 --- a/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff +++ b/src/test/mir-opt/const_debuginfo.main.ConstDebugInfo.diff @@ -30,14 +30,19 @@ - debug s => _9; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10 + debug s => const "hello, world!"; // in scope 5 at $DIR/const_debuginfo.rs:+6:9: +6:10 let _10: (bool, bool, u32); // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + let _16: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + let _17: bool; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + let _18: u32; // in scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 scope 6 { - debug f => _10; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10 + debug f => (bool, bool, u32){ .0 => _16, .1 => _17, .2 => _18, }; // in scope 6 at $DIR/const_debuginfo.rs:+8:9: +8:10 let _11: std::option::Option; // in scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10 scope 7 { debug o => _11; // in scope 7 at $DIR/const_debuginfo.rs:+10:9: +10:10 let _12: Point; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + let _19: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + let _20: u32; // in scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 scope 8 { - debug p => _12; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10 + debug p => Point{ .0 => _19, .1 => _20, }; // in scope 8 at $DIR/const_debuginfo.rs:+12:9: +12:10 let _13: u32; // in scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10 scope 9 { - debug a => _13; // in scope 9 at $DIR/const_debuginfo.rs:+13:9: +13:10 @@ -78,19 +83,25 @@ // mir::Constant // + span: $DIR/const_debuginfo.rs:14:13: 14:28 // + literal: Const { ty: &str, val: Value(Slice(..)) } - StorageLive(_10); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 - Deinit(_10); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - (_10.0: bool) = const true; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - (_10.1: bool) = const false; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 - (_10.2: u32) = const 123_u32; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + StorageLive(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + StorageLive(_17); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + StorageLive(_18); // scope 5 at $DIR/const_debuginfo.rs:+8:9: +8:10 + Deinit(_16); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + Deinit(_17); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + Deinit(_18); // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + _16 = const true; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + _17 = const false; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 + _18 = const 123_u32; // scope 5 at $DIR/const_debuginfo.rs:+8:13: +8:34 StorageLive(_11); // scope 6 at $DIR/const_debuginfo.rs:+10:9: +10:10 Deinit(_11); // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 ((_11 as Some).0: u16) = const 99_u16; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 discriminant(_11) = 1; // scope 6 at $DIR/const_debuginfo.rs:+10:13: +10:24 - StorageLive(_12); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 - Deinit(_12); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 - (_12.0: u32) = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 - (_12.1: u32) = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + StorageLive(_19); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + StorageLive(_20); // scope 7 at $DIR/const_debuginfo.rs:+12:9: +12:10 + Deinit(_19); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + Deinit(_20); // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + _19 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 + _20 = const 32_u32; // scope 7 at $DIR/const_debuginfo.rs:+12:13: +12:35 StorageLive(_13); // scope 8 at $DIR/const_debuginfo.rs:+13:9: +13:10 StorageLive(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 _14 = const 32_u32; // scope 8 at $DIR/const_debuginfo.rs:+13:13: +13:16 @@ -101,9 +112,12 @@ StorageDead(_14); // scope 8 at $DIR/const_debuginfo.rs:+13:21: +13:22 nop; // scope 0 at $DIR/const_debuginfo.rs:+0:11: +14:2 StorageDead(_13); // scope 8 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_12); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_19); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_20); // scope 7 at $DIR/const_debuginfo.rs:+14:1: +14:2 StorageDead(_11); // scope 6 at $DIR/const_debuginfo.rs:+14:1: +14:2 - StorageDead(_10); // 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(_17); // scope 5 at $DIR/const_debuginfo.rs:+14:1: +14:2 + StorageDead(_18); // 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 diff --git a/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir index 7650769de..028480bdc 100644 --- a/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir @@ -1,20 +1,20 @@ // MIR for `BAR::promoted[0]` after SimplifyCfg-elaborate-drops promoted[0] in BAR: &[&i32; 1] = { - let mut _0: &[&i32; 1]; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 - let mut _1: [&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35 - let mut _2: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34 - let mut _3: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34 + let mut _0: &[&i32; 1]; // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 + let mut _1: [&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35 + let mut _2: &i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34 + let mut _3: &i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34 bb0: { - _3 = const {alloc1: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34 + _3 = const {alloc1: &i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34 // mir::Constant - // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34 + // + span: $DIR/const_promotion_extern_static.rs:9:33: 9:34 // + literal: Const { ty: &i32, val: Value(Scalar(alloc1)) } - _2 = &(*_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34 - _1 = [move _2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35 - _0 = &_1; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 + _2 = &(*_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34 + _1 = [move _2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35 + _0 = &_1; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 + return; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 } } diff --git a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff index f8a7c687e..2ef437811 100644 --- a/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff +++ b/src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff @@ -2,49 +2,49 @@ + // MIR for `BAR` after PromoteTemps static mut BAR: *const &i32 = { - let mut _0: *const &i32; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:17: +0:28 - let mut _1: &[&i32]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 - let mut _2: &[&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 - let _3: [&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35 - let mut _4: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34 - let _5: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34 -+ let mut _6: &[&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 + let mut _0: *const &i32; // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:17: +0:28 + let mut _1: &[&i32]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 + let mut _2: &[&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 + let _3: [&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35 + let mut _4: &i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34 + let _5: &i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34 ++ let mut _6: &[&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 bb0: { - StorageLive(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 - StorageLive(_2); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 -- StorageLive(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35 -- StorageLive(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34 -- StorageLive(_5); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34 -- _5 = const {alloc1: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:33: +0:34 -+ _6 = const _; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 + StorageLive(_1); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 + StorageLive(_2); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 +- StorageLive(_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35 +- StorageLive(_4); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34 +- StorageLive(_5); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34 +- _5 = const {alloc1: &i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:33: +0:34 ++ _6 = const _; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 // mir::Constant -- // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34 +- // + span: $DIR/const_promotion_extern_static.rs:9:33: 9:34 - // + literal: Const { ty: &i32, val: Value(Scalar(alloc1)) } -- _4 = &(*_5); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:34 -- _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:35 -- _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 -+ // + span: $DIR/const-promotion-extern-static.rs:9:31: 9:44 +- _4 = &(*_5); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:34 +- _3 = [move _4]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:35 +- _2 = &_3; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 ++ // + span: $DIR/const_promotion_extern_static.rs:9:31: 9:44 + // + literal: Const { ty: &[&i32; 1], val: Unevaluated(BAR, [], Some(promoted[0])) } -+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 - _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 -- StorageDead(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:34: +0:35 - StorageDead(_2); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:34: +0:35 - _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:44 ++ _2 = &(*_6); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 + _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 +- StorageDead(_4); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:34: +0:35 + StorageDead(_2); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:34: +0:35 + _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:44 // mir::Constant - // + span: $DIR/const-promotion-extern-static.rs:9:36: 9:42 + // + span: $DIR/const_promotion_extern_static.rs:9:36: 9:42 // + literal: Const { ty: for<'a> fn(&'a [&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() } } bb1: { -- StorageDead(_5); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44 -- StorageDead(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44 - StorageDead(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:43: +0:44 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:45 +- StorageDead(_5); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:43: +0:44 +- StorageDead(_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:43: +0:44 + StorageDead(_1); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:43: +0:44 + return; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:45 } bb2 (cleanup): { - resume; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:45 + resume; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:45 } - } - diff --git a/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir b/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir new file mode 100644 index 000000000..476fc49a1 --- /dev/null +++ b/src/test/mir-opt/const_promotion_extern_static.BOP.built.after.mir @@ -0,0 +1,17 @@ +// MIR for `BOP` after built + +static BOP: &i32 = { + let mut _0: &i32; // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:13: +0:17 + let _1: &i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23 + let _2: i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:21: +0:23 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23 + StorageLive(_2); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:21: +0:23 + _2 = const 13_i32; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:21: +0:23 + _1 = &_2; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23 + _0 = &(*_1); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:20: +0:23 + StorageDead(_1); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:22: +0:23 + return; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:24 + } +} diff --git a/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir b/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir deleted file mode 100644 index 90920fbe7..000000000 --- a/src/test/mir-opt/const_promotion_extern_static.BOP.mir_map.0.mir +++ /dev/null @@ -1,17 +0,0 @@ -// MIR for `BOP` 0 mir_map - -static BOP: &i32 = { - let mut _0: &i32; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:13: +0:17 - let _1: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23 - let _2: i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:21: +0:23 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23 - StorageLive(_2); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:21: +0:23 - _2 = const 13_i32; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:21: +0:23 - _1 = &_2; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23 - _0 = &(*_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:20: +0:23 - StorageDead(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:22: +0:23 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:24 - } -} diff --git a/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir index 71827eab1..41657b53f 100644 --- a/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir @@ -1,20 +1,20 @@ // MIR for `FOO::promoted[0]` after SimplifyCfg-elaborate-drops promoted[0] in FOO: &[&i32; 1] = { - let mut _0: &[&i32; 1]; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 - let mut _1: [&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46 - let mut _2: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:45 - let mut _3: *const i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43 + let mut _0: &[&i32; 1]; // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 + let mut _1: [&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 + let mut _2: &i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45 + let mut _3: *const i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 bb0: { - _3 = const {alloc3: *const i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43 + _3 = const {alloc3: *const i32}; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 // mir::Constant - // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43 + // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43 // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) } - _2 = &(*_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:41: +0:43 - _1 = [move _2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46 - _0 = &_1; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 + _2 = &(*_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43 + _1 = [move _2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 + _0 = &_1; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 + return; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 } } diff --git a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff index e938ca28a..25ba0face 100644 --- a/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff +++ b/src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff @@ -2,51 +2,51 @@ + // MIR for `FOO` after PromoteTemps static mut FOO: *const &i32 = { - let mut _0: *const &i32; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:+0:17: +0:28 - let mut _1: &[&i32]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 - let mut _2: &[&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 - let _3: [&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46 - let mut _4: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:45 - let _5: *const i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43 -+ let mut _6: &[&i32; 1]; // in scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 + let mut _0: *const &i32; // return place in scope 0 at $DIR/const_promotion_extern_static.rs:+0:17: +0:28 + let mut _1: &[&i32]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 + let mut _2: &[&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 + let _3: [&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 + let mut _4: &i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45 + let _5: *const i32; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 ++ let mut _6: &[&i32; 1]; // in scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 scope 1 { } bb0: { - StorageLive(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 - StorageLive(_2); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 -- StorageLive(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46 -- StorageLive(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:32: +0:45 -- StorageLive(_5); // scope 1 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43 -- _5 = const {alloc3: *const i32}; // scope 1 at $DIR/const-promotion-extern-static.rs:+0:42: +0:43 -+ _6 = const _; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 + StorageLive(_1); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 + StorageLive(_2); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 +- StorageLive(_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 +- StorageLive(_4); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:32: +0:45 +- StorageLive(_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 +- _5 = const {alloc3: *const i32}; // scope 1 at $DIR/const_promotion_extern_static.rs:+0:42: +0:43 ++ _6 = const _; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 // mir::Constant -- // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43 +- // + span: $DIR/const_promotion_extern_static.rs:13:42: 13:43 - // + literal: Const { ty: *const i32, val: Value(Scalar(alloc3)) } -- _4 = &(*_5); // scope 1 at $DIR/const-promotion-extern-static.rs:+0:41: +0:43 -- _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:46 -- _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 -+ // + span: $DIR/const-promotion-extern-static.rs:13:31: 13:55 +- _4 = &(*_5); // scope 1 at $DIR/const_promotion_extern_static.rs:+0:41: +0:43 +- _3 = [move _4]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:46 +- _2 = &_3; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 ++ // + span: $DIR/const_promotion_extern_static.rs:13:31: 13:55 + // + literal: Const { ty: &[&i32; 1], val: Unevaluated(FOO, [], Some(promoted[0])) } -+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 - _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 -- StorageDead(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:45: +0:46 - StorageDead(_2); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:45: +0:46 - _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:31: +0:55 ++ _2 = &(*_6); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 + _1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 +- StorageDead(_4); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:45: +0:46 + StorageDead(_2); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:45: +0:46 + _0 = core::slice::::as_ptr(move _1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:31: +0:55 // mir::Constant - // + span: $DIR/const-promotion-extern-static.rs:13:47: 13:53 + // + span: $DIR/const_promotion_extern_static.rs:13:47: 13:53 // + literal: Const { ty: for<'a> fn(&'a [&i32]) -> *const &i32 {core::slice::::as_ptr}, val: Value() } } bb1: { -- StorageDead(_5); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55 -- StorageDead(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55 - StorageDead(_1); // scope 0 at $DIR/const-promotion-extern-static.rs:+0:54: +0:55 - return; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:56 +- StorageDead(_5); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:54: +0:55 +- StorageDead(_3); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:54: +0:55 + StorageDead(_1); // scope 0 at $DIR/const_promotion_extern_static.rs:+0:54: +0:55 + return; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:56 } bb2 (cleanup): { - resume; // scope 0 at $DIR/const-promotion-extern-static.rs:+0:1: +0:56 + resume; // scope 0 at $DIR/const_promotion_extern_static.rs:+0:1: +0:56 } } - diff --git a/src/test/mir-opt/const_promotion_extern_static.rs b/src/test/mir-opt/const_promotion_extern_static.rs new file mode 100644 index 000000000..e4261cfe5 --- /dev/null +++ b/src/test/mir-opt/const_promotion_extern_static.rs @@ -0,0 +1,18 @@ +// ignore-endian-big +extern "C" { + static X: i32; +} +static Y: i32 = 42; + +// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff +// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir +static mut BAR: *const &i32 = [&Y].as_ptr(); + +// EMIT_MIR const_promotion_extern_static.FOO.PromoteTemps.diff +// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir +static mut FOO: *const &i32 = [unsafe { &X }].as_ptr(); + +// EMIT_MIR const_promotion_extern_static.BOP.built.after.mir +static BOP: &i32 = &13; + +fn main() {} diff --git a/src/test/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir b/src/test/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir new file mode 100644 index 000000000..cfc9a72e3 --- /dev/null +++ b/src/test/mir-opt/const_prop/aggregate.main.PreCodegen.after.mir @@ -0,0 +1,28 @@ +// MIR for `main` after PreCodegen + +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 + scope 1 { + debug x => _1; // in scope 1 at $DIR/aggregate.rs:+1:9: +1:10 + } + + bb0: { + 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 + 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 + } +} diff --git a/src/test/mir-opt/const_prop/aggregate.rs b/src/test/mir-opt/const_prop/aggregate.rs index 493d0508a..6a3080384 100644 --- a/src/test/mir-opt/const_prop/aggregate.rs +++ b/src/test/mir-opt/const_prop/aggregate.rs @@ -2,6 +2,7 @@ // compile-flags: -O // EMIT_MIR aggregate.main.ConstProp.diff +// EMIT_MIR aggregate.main.PreCodegen.after.mir fn main() { let x = (0, 1, 2).1 + 0; } diff --git a/src/test/mir-opt/const_prop/control-flow-simplification.rs b/src/test/mir-opt/const_prop/control-flow-simplification.rs deleted file mode 100644 index 7dbe8e734..000000000 --- a/src/test/mir-opt/const_prop/control-flow-simplification.rs +++ /dev/null @@ -1,21 +0,0 @@ -// unit-test: ConstProp -// compile-flags: -Zmir-opt-level=1 - -trait NeedsDrop: Sized { - const NEEDS: bool = std::mem::needs_drop::(); -} - -impl NeedsDrop for This {} - -// EMIT_MIR control_flow_simplification.hello.ConstProp.diff -// EMIT_MIR control_flow_simplification.hello.PreCodegen.before.mir -fn hello(){ - if ::NEEDS { - panic!() - } -} - -pub fn main() { - hello::<()>(); - hello::>(); -} diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff index a07bdd998..8b3b9d0a4 100644 --- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -2,15 +2,15 @@ + // MIR for `hello` after ConstProp fn hello() -> () { - let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:+0:14: +0:14 - let mut _1: bool; // in scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21 + let mut _0: (); // return place in scope 0 at $DIR/control_flow_simplification.rs:+0:14: +0:14 + let mut _1: bool; // in scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 let mut _2: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL bb0: { - StorageLive(_1); // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21 - _1 = const _; // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21 -- switchInt(move _1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21 -+ switchInt(const false) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control-flow-simplification.rs:+1:8: +1:21 + StorageLive(_1); // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 + _1 = const _; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 +- switchInt(move _1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 ++ switchInt(const false) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/control_flow_simplification.rs:+1:8: +1:21 } bb1: { @@ -25,9 +25,9 @@ } bb2: { - nop; // scope 0 at $DIR/control-flow-simplification.rs:+3:6: +3:6 - StorageDead(_1); // scope 0 at $DIR/control-flow-simplification.rs:+3:5: +3:6 - return; // scope 0 at $DIR/control-flow-simplification.rs:+4:2: +4:2 + nop; // scope 0 at $DIR/control_flow_simplification.rs:+3:6: +3:6 + StorageDead(_1); // scope 0 at $DIR/control_flow_simplification.rs:+3:5: +3:6 + return; // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir b/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir index 70f979775..9f7528f0c 100644 --- a/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir +++ b/src/test/mir-opt/const_prop/control_flow_simplification.hello.PreCodegen.before.mir @@ -1,9 +1,9 @@ // MIR for `hello` before PreCodegen fn hello() -> () { - let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:+0:14: +0:14 + let mut _0: (); // return place in scope 0 at $DIR/control_flow_simplification.rs:+0:14: +0:14 bb0: { - return; // scope 0 at $DIR/control-flow-simplification.rs:+4:2: +4:2 + return; // scope 0 at $DIR/control_flow_simplification.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/const_prop/control_flow_simplification.rs b/src/test/mir-opt/const_prop/control_flow_simplification.rs new file mode 100644 index 000000000..7dbe8e734 --- /dev/null +++ b/src/test/mir-opt/const_prop/control_flow_simplification.rs @@ -0,0 +1,21 @@ +// unit-test: ConstProp +// compile-flags: -Zmir-opt-level=1 + +trait NeedsDrop: Sized { + const NEEDS: bool = std::mem::needs_drop::(); +} + +impl NeedsDrop for This {} + +// EMIT_MIR control_flow_simplification.hello.ConstProp.diff +// EMIT_MIR control_flow_simplification.hello.PreCodegen.before.mir +fn hello(){ + if ::NEEDS { + panic!() + } +} + +pub fn main() { + hello::<()>(); + hello::>(); +} diff --git a/src/test/mir-opt/const_prop/issue-66971.rs b/src/test/mir-opt/const_prop/issue-66971.rs deleted file mode 100644 index 6ca03438e..000000000 --- a/src/test/mir-opt/const_prop/issue-66971.rs +++ /dev/null @@ -1,18 +0,0 @@ -// unit-test: ConstProp -// compile-flags: -Z mir-opt-level=3 - -// Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected -// outputs below, after ConstProp this is how _2 would look like with the bug: -// -// _2 = (const Scalar(0x00) : (), const 0u8); -// -// Which has the wrong type. - -fn encode(this: ((), u8, u8)) { - assert!(this.2 == 0); -} - -// EMIT_MIR issue_66971.main.ConstProp.diff -fn main() { - encode(((), 0, 0)); -} diff --git a/src/test/mir-opt/const_prop/issue-67019.rs b/src/test/mir-opt/const_prop/issue-67019.rs deleted file mode 100644 index ffc6fa1f2..000000000 --- a/src/test/mir-opt/const_prop/issue-67019.rs +++ /dev/null @@ -1,13 +0,0 @@ -// unit-test: ConstProp -// compile-flags: -Z mir-opt-level=3 - -// This used to ICE in const-prop - -fn test(this: ((u8, u8),)) { - assert!((this.0).0 == 1); -} - -// EMIT_MIR issue_67019.main.ConstProp.diff -fn main() { - test(((1, 2),)); -} diff --git a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff index 9d541dcab..7d8e647cb 100644 --- a/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue_66971.main.ConstProp.diff @@ -2,32 +2,32 @@ + // MIR for `main` after ConstProp fn main() -> () { - 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 + 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 - StorageLive(_3); // scope 0 at $DIR/issue-66971.rs:+1:13: +1:15 - nop; // scope 0 at $DIR/issue-66971.rs:+1:13: +1:15 - Deinit(_2); // scope 0 at $DIR/issue-66971.rs:+1:12: +1:22 - nop; // 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 - 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 + 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 + StorageLive(_3); // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 + nop; // scope 0 at $DIR/issue_66971.rs:+1:13: +1:15 + Deinit(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 + nop; // 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 + 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 + // + span: $DIR/issue_66971.rs:17:5: 17:11 // + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value() } } bb1: { - StorageDead(_2); // scope 0 at $DIR/issue-66971.rs:+1:22: +1:23 - StorageDead(_1); // scope 0 at $DIR/issue-66971.rs:+1:23: +1:24 - nop; // scope 0 at $DIR/issue-66971.rs:+0:11: +2:2 - return; // scope 0 at $DIR/issue-66971.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/issue_66971.rs:+1:22: +1:23 + StorageDead(_1); // scope 0 at $DIR/issue_66971.rs:+1:23: +1:24 + nop; // scope 0 at $DIR/issue_66971.rs:+0:11: +2:2 + return; // scope 0 at $DIR/issue_66971.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_prop/issue_66971.rs b/src/test/mir-opt/const_prop/issue_66971.rs new file mode 100644 index 000000000..6ca03438e --- /dev/null +++ b/src/test/mir-opt/const_prop/issue_66971.rs @@ -0,0 +1,18 @@ +// unit-test: ConstProp +// compile-flags: -Z mir-opt-level=3 + +// Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected +// outputs below, after ConstProp this is how _2 would look like with the bug: +// +// _2 = (const Scalar(0x00) : (), const 0u8); +// +// Which has the wrong type. + +fn encode(this: ((), u8, u8)) { + assert!(this.2 == 0); +} + +// EMIT_MIR issue_66971.main.ConstProp.diff +fn main() { + encode(((), 0, 0)); +} diff --git a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff index b79d81476..79cd8bf48 100644 --- a/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -2,33 +2,33 @@ + // MIR for `main` after ConstProp fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-67019.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/issue-67019.rs:+1:5: +1:20 - let mut _2: ((u8, u8),); // in scope 0 at $DIR/issue-67019.rs:+1:10: +1:19 - let mut _3: (u8, u8); // in scope 0 at $DIR/issue-67019.rs:+1:11: +1:17 + let mut _0: (); // return place in scope 0 at $DIR/issue_67019.rs:+0:11: +0:11 + let _1: (); // in scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 + let mut _2: ((u8, u8),); // in scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 + let mut _3: (u8, u8); // in scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 bb0: { - 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 - 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 + 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 + 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 - // + span: $DIR/issue-67019.rs:12:5: 12:9 + // + span: $DIR/issue_67019.rs:12:5: 12:9 // + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value() } } bb1: { - StorageDead(_2); // scope 0 at $DIR/issue-67019.rs:+1:19: +1:20 - StorageDead(_1); // scope 0 at $DIR/issue-67019.rs:+1:20: +1:21 - nop; // scope 0 at $DIR/issue-67019.rs:+0:11: +2:2 - return; // scope 0 at $DIR/issue-67019.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/issue_67019.rs:+1:19: +1:20 + StorageDead(_1); // scope 0 at $DIR/issue_67019.rs:+1:20: +1:21 + nop; // scope 0 at $DIR/issue_67019.rs:+0:11: +2:2 + return; // scope 0 at $DIR/issue_67019.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/const_prop/issue_67019.rs b/src/test/mir-opt/const_prop/issue_67019.rs new file mode 100644 index 000000000..ffc6fa1f2 --- /dev/null +++ b/src/test/mir-opt/const_prop/issue_67019.rs @@ -0,0 +1,13 @@ +// unit-test: ConstProp +// compile-flags: -Z mir-opt-level=3 + +// This used to ICE in const-prop + +fn test(this: ((u8, u8),)) { + assert!((this.0).0 == 1); +} + +// EMIT_MIR issue_67019.main.ConstProp.diff +fn main() { + test(((1, 2),)); +} diff --git a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff index 186a95373..2e4b0e79e 100644 --- a/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff +++ b/src/test/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.diff @@ -8,8 +8,10 @@ scope 1 { debug a => _1; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+1:9: +1:10 let mut _2: (i32, i32); // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let mut _6: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + let mut _7: i32; // in scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 scope 2 { - debug x => _2; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + debug x => (i32, i32){ .0 => _6, .1 => _7, }; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 let _4: i32; // in scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 scope 3 { debug y => _4; // in scope 3 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 @@ -30,23 +32,26 @@ } bb1: { - StorageLive(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 - Deinit(_2); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - (_2.0: i32) = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 - (_2.1: i32) = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + StorageLive(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + StorageLive(_7); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:9: +2:14 + Deinit(_6); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + Deinit(_7); // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + _6 = const 1_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 + _7 = const 2_i32; // scope 1 at $DIR/mutable_variable_unprop_assign.rs:+2:29: +2:35 StorageLive(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 _3 = _1; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 - (_2.1: i32) = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 + _7 = move _3; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:5: +3:12 StorageDead(_3); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+3:11: +3:12 StorageLive(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:9: +4:10 - _4 = (_2.1: i32); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 + _4 = _7; // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+4:13: +4:16 StorageLive(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:9: +5:10 -- _5 = (_2.0: i32); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 +- _5 = _6; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 + _5 = const 1_i32; // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+5:13: +5:16 nop; // scope 0 at $DIR/mutable_variable_unprop_assign.rs:+0:11: +6:2 StorageDead(_5); // scope 3 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 StorageDead(_4); // scope 2 at $DIR/mutable_variable_unprop_assign.rs:+6:1: +6:2 - StorageDead(_2); // 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(_7); // 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/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff index 94aadfaf8..7e8ebd31a 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.32bit.diff @@ -10,6 +10,8 @@ let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + let mut _11: 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 _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 @@ -51,13 +53,16 @@ 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.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 -- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + 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 + _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 +- _8 = _11; // 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(_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 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/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff index 94aadfaf8..7e8ebd31a 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ConstProp.64bit.diff @@ -10,6 +10,8 @@ let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 + let mut _11: 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 _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 @@ -51,13 +53,16 @@ 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.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 -- _8 = (_9.1: u32); // scope 2 at $DIR/optimizes_into_variable.rs:+3:13: +3:38 + 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 + _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 +- _8 = _11; // 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(_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 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/src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir b/src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir new file mode 100644 index 000000000..9db87cfc8 --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.32bit.mir @@ -0,0 +1,27 @@ +// MIR for `main` after PreCodegen + +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 + 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 + } + } + } + + 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/src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir b/src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir new file mode 100644 index 000000000..9db87cfc8 --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.PreCodegen.after.64bit.mir @@ -0,0 +1,27 @@ +// MIR for `main` after PreCodegen + +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 + 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 + } + } + } + + 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/src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff new file mode 100644 index 000000000..3f9f3b2ea --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.32bit.diff @@ -0,0 +1,72 @@ +- // MIR for `main` before ScalarReplacementOfAggregates ++ // MIR for `main` after ScalarReplacementOfAggregates + + 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 _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:31 + let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 + let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ let mut _11: 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 _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + scope 2 { + 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 + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + } + + bb1: { + _1 = move (_2.0: i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + StorageLive(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + StorageLive(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31 + _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31 + StorageLive(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 + _5 = const 3_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 + _6 = Len(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + _7 = Lt(_5, _6); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + } + + bb2: { + _3 = _4[_5]; // 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.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 +- _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 ++ _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 ++ _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 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 + 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/src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff new file mode 100644 index 000000000..3f9f3b2ea --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.main.ScalarReplacementOfAggregates.64bit.diff @@ -0,0 +1,72 @@ +- // MIR for `main` before ScalarReplacementOfAggregates ++ // MIR for `main` after ScalarReplacementOfAggregates + + 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 _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:31 + let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 + let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ let mut _10: u32; // in scope 0 at $DIR/optimizes_into_variable.rs:+3:13: +3:36 ++ let mut _11: 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 _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + scope 2 { + 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 + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/optimizes_into_variable.rs:+1:9: +1:10 + _2 = CheckedAdd(const 2_i32, const 2_i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> bb1; // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + } + + bb1: { + _1 = move (_2.0: i32); // scope 0 at $DIR/optimizes_into_variable.rs:+1:13: +1:18 + StorageLive(_3); // scope 1 at $DIR/optimizes_into_variable.rs:+2:9: +2:10 + StorageLive(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31 + _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:31 + StorageLive(_5); // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 + _5 = const 3_usize; // scope 1 at $DIR/optimizes_into_variable.rs:+2:32: +2:33 + _6 = Len(_4); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + _7 = Lt(_5, _6); // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> bb2; // scope 1 at $DIR/optimizes_into_variable.rs:+2:13: +2:34 + } + + bb2: { + _3 = _4[_5]; // 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.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 +- _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 ++ _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 ++ _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 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 + 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/src/test/mir-opt/const_prop/optimizes_into_variable.rs b/src/test/mir-opt/const_prop/optimizes_into_variable.rs index c0fbd2558..025666548 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.rs +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.rs @@ -7,8 +7,10 @@ struct Point { } // EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR optimizes_into_variable.main.ScalarReplacementOfAggregates.diff // EMIT_MIR optimizes_into_variable.main.ConstProp.diff // EMIT_MIR optimizes_into_variable.main.SimplifyLocals.after.mir +// EMIT_MIR optimizes_into_variable.main.PreCodegen.after.mir fn main() { let x = 2 + 2; let y = [0, 1, 2, 3, 4, 5][3]; diff --git a/src/test/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot b/src/test/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot index c00eae96e..03df5c950 100644 --- a/src/test/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot +++ b/src/test/mir-opt/coverage_graphviz.bar.InstrumentCoverage.0.dot @@ -2,5 +2,5 @@ digraph Cov_0_4 { graph [fontname="Courier, monospace"]; node [fontname="Courier, monospace"]; edge [fontname="Courier, monospace"]; - bcb0__Cov_0_4 [shape="none", label=<
bcb0
Counter(bcb0) at 18:1-20:2
19:5-19:9: @0[0]: Coverage::Counter(1) for $DIR/coverage_graphviz.rs:18:1 - 20:2
20:2-20:2: @0.Return: return
bb0: Return
>]; + bcb0__Cov_0_4 [shape="none", label=<
bcb0
Counter(bcb0) at 18:1-20:2
19:5-19:9: @0[0]: Coverage::Counter(1) for $DIR/coverage_graphviz.rs:18:1 - 20:2
20:2-20:2: @0.Return: return
bb0: Return
>]; } diff --git a/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot b/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot index ca0eb7e84..fd21b14af 100644 --- a/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot +++ b/src/test/mir-opt/coverage_graphviz.main.InstrumentCoverage.0.dot @@ -2,10 +2,10 @@ digraph Cov_0_3 { graph [fontname="Courier, monospace"]; node [fontname="Courier, monospace"]; edge [fontname="Courier, monospace"]; - bcb3__Cov_0_3 [shape="none", label=<
bcb3
Counter(bcb3) at 13:10-13:10
13:10-13:10: @5[0]: Coverage::Counter(2) for $DIR/coverage_graphviz.rs:13:10 - 13:11
bb5: Goto
>]; - bcb2__Cov_0_3 [shape="none", label=<
bcb2
Expression(bcb1:(bcb0 + bcb3) - bcb3) at 12:13-12:18
12:13-12:18: @4[0]: Coverage::Expression(4294967293) = 4294967294 + 0 for $DIR/coverage_graphviz.rs:15:1 - 15:2
Expression(bcb2:(bcb1:(bcb0 + bcb3) - bcb3) + 0) at 15:2-15:2
15:2-15:2: @4.Return: return
bb4: Return
>]; - bcb1__Cov_0_3 [shape="none", label=<
bcb1
Expression(bcb0 + bcb3) at 10:5-11:17
11:12-11:17: @2.Call: _2 = bar() -> [return: bb3, unwind: bb6]
bb1: FalseUnwind
bb2: Call
bb3: SwitchInt
>]; - bcb0__Cov_0_3 [shape="none", label=<
bcb0
Counter(bcb0) at 9:1-9:11
bb0: Goto
>]; + bcb3__Cov_0_3 [shape="none", label=<
bcb3
Counter(bcb3) at 13:10-13:10
13:10-13:10: @5[0]: Coverage::Counter(2) for $DIR/coverage_graphviz.rs:13:10 - 13:11
bb5: Goto
>]; + bcb2__Cov_0_3 [shape="none", label=<
bcb2
Expression(bcb1:(bcb0 + bcb3) - bcb3) at 12:13-12:18
12:13-12:18: @4[0]: Coverage::Expression(4294967293) = 4294967294 + 0 for $DIR/coverage_graphviz.rs:15:1 - 15:2
Expression(bcb2:(bcb1:(bcb0 + bcb3) - bcb3) + 0) at 15:2-15:2
15:2-15:2: @4.Return: return
bb4: Return
>]; + bcb1__Cov_0_3 [shape="none", label=<
bcb1
Expression(bcb0 + bcb3) at 10:5-11:17
11:12-11:17: @2.Call: _2 = bar() -> [return: bb3, unwind: bb6]
bb1: FalseUnwind
bb2: Call
bb3: SwitchInt
>]; + bcb0__Cov_0_3 [shape="none", label=<
bcb0
Counter(bcb0) at 9:1-9:11
bb0: Goto
>]; bcb3__Cov_0_3 -> bcb1__Cov_0_3 [label=<>]; bcb1__Cov_0_3 -> bcb3__Cov_0_3 [label=]; bcb1__Cov_0_3 -> bcb2__Cov_0_3 [label=]; diff --git a/src/test/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff new file mode 100644 index 000000000..bf9ab8669 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/cast.main.DataflowConstProp.diff @@ -0,0 +1,37 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/cast.rs:+0:11: +0:11 + let _1: i32; // in scope 0 at $DIR/cast.rs:+1:9: +1:10 + let mut _3: u8; // in scope 0 at $DIR/cast.rs:+2:13: +2:20 + let mut _4: i32; // in scope 0 at $DIR/cast.rs:+2:13: +2:14 + scope 1 { + debug a => _1; // in scope 1 at $DIR/cast.rs:+1:9: +1:10 + let _2: u8; // in scope 1 at $DIR/cast.rs:+2:9: +2:10 + scope 2 { + debug b => _2; // in scope 2 at $DIR/cast.rs:+2:9: +2:10 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/cast.rs:+1:9: +1:10 + _1 = const 257_i32; // scope 0 at $DIR/cast.rs:+1:13: +1:16 + StorageLive(_2); // scope 1 at $DIR/cast.rs:+2:9: +2:10 + StorageLive(_3); // scope 1 at $DIR/cast.rs:+2:13: +2:20 + StorageLive(_4); // scope 1 at $DIR/cast.rs:+2:13: +2:14 +- _4 = _1; // scope 1 at $DIR/cast.rs:+2:13: +2:14 +- _3 = move _4 as u8 (IntToInt); // scope 1 at $DIR/cast.rs:+2:13: +2:20 ++ _4 = const 257_i32; // scope 1 at $DIR/cast.rs:+2:13: +2:14 ++ _3 = const 1_u8; // scope 1 at $DIR/cast.rs:+2:13: +2:20 + StorageDead(_4); // scope 1 at $DIR/cast.rs:+2:19: +2:20 +- _2 = Add(move _3, const 1_u8); // scope 1 at $DIR/cast.rs:+2:13: +2:24 ++ _2 = const 2_u8; // scope 1 at $DIR/cast.rs:+2:13: +2:24 + StorageDead(_3); // scope 1 at $DIR/cast.rs:+2:23: +2:24 + _0 = const (); // scope 0 at $DIR/cast.rs:+0:11: +3:2 + StorageDead(_2); // scope 1 at $DIR/cast.rs:+3:1: +3:2 + StorageDead(_1); // scope 0 at $DIR/cast.rs:+3:1: +3:2 + return; // scope 0 at $DIR/cast.rs:+3:2: +3:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/cast.rs b/src/test/mir-opt/dataflow-const-prop/cast.rs new file mode 100644 index 000000000..484403f7f --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/cast.rs @@ -0,0 +1,7 @@ +// unit-test: DataflowConstProp + +// EMIT_MIR cast.main.DataflowConstProp.diff +fn main() { + let a = 257; + let b = a as u8 + 1; +} diff --git a/src/test/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff new file mode 100644 index 000000000..a4ebd0c8c --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/checked.main.DataflowConstProp.diff @@ -0,0 +1,80 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/checked.rs:+0:11: +0:11 + let _1: i32; // in scope 0 at $DIR/checked.rs:+1:9: +1:10 + let mut _4: i32; // in scope 0 at $DIR/checked.rs:+3:13: +3:14 + let mut _5: i32; // in scope 0 at $DIR/checked.rs:+3:17: +3:18 + let mut _6: (i32, bool); // in scope 0 at $DIR/checked.rs:+3:13: +3:18 + let mut _9: i32; // in scope 0 at $DIR/checked.rs:+6:13: +6:14 + let mut _10: (i32, bool); // in scope 0 at $DIR/checked.rs:+6:13: +6:18 + scope 1 { + debug a => _1; // in scope 1 at $DIR/checked.rs:+1:9: +1:10 + let _2: i32; // in scope 1 at $DIR/checked.rs:+2:9: +2:10 + scope 2 { + debug b => _2; // in scope 2 at $DIR/checked.rs:+2:9: +2:10 + let _3: i32; // in scope 2 at $DIR/checked.rs:+3:9: +3:10 + scope 3 { + debug c => _3; // in scope 3 at $DIR/checked.rs:+3:9: +3:10 + let _7: i32; // in scope 3 at $DIR/checked.rs:+5:9: +5:10 + scope 4 { + debug d => _7; // in scope 4 at $DIR/checked.rs:+5:9: +5:10 + let _8: i32; // in scope 4 at $DIR/checked.rs:+6:9: +6:10 + scope 5 { + debug e => _8; // in scope 5 at $DIR/checked.rs:+6:9: +6:10 + } + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/checked.rs:+1:9: +1:10 + _1 = const 1_i32; // scope 0 at $DIR/checked.rs:+1:13: +1:14 + StorageLive(_2); // scope 1 at $DIR/checked.rs:+2:9: +2:10 + _2 = const 2_i32; // scope 1 at $DIR/checked.rs:+2:13: +2:14 + StorageLive(_3); // scope 2 at $DIR/checked.rs:+3:9: +3:10 + StorageLive(_4); // scope 2 at $DIR/checked.rs:+3:13: +3:14 +- _4 = _1; // scope 2 at $DIR/checked.rs:+3:13: +3:14 ++ _4 = const 1_i32; // scope 2 at $DIR/checked.rs:+3:13: +3:14 + StorageLive(_5); // scope 2 at $DIR/checked.rs:+3:17: +3:18 +- _5 = _2; // scope 2 at $DIR/checked.rs:+3:17: +3:18 +- _6 = CheckedAdd(_4, _5); // scope 2 at $DIR/checked.rs:+3:13: +3:18 +- assert(!move (_6.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, move _5) -> bb1; // scope 2 at $DIR/checked.rs:+3:13: +3:18 ++ _5 = const 2_i32; // scope 2 at $DIR/checked.rs:+3:17: +3:18 ++ _6 = CheckedAdd(const 1_i32, const 2_i32); // scope 2 at $DIR/checked.rs:+3:13: +3:18 ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_i32, const 2_i32) -> bb1; // scope 2 at $DIR/checked.rs:+3:13: +3:18 + } + + bb1: { +- _3 = move (_6.0: i32); // scope 2 at $DIR/checked.rs:+3:13: +3:18 ++ _3 = const 3_i32; // scope 2 at $DIR/checked.rs:+3:13: +3:18 + StorageDead(_5); // scope 2 at $DIR/checked.rs:+3:17: +3:18 + StorageDead(_4); // scope 2 at $DIR/checked.rs:+3:17: +3:18 + StorageLive(_7); // scope 3 at $DIR/checked.rs:+5:9: +5:10 + _7 = const _; // scope 3 at $DIR/checked.rs:+5:13: +5:21 + StorageLive(_8); // scope 4 at $DIR/checked.rs:+6:9: +6:10 + StorageLive(_9); // scope 4 at $DIR/checked.rs:+6:13: +6:14 +- _9 = _7; // scope 4 at $DIR/checked.rs:+6:13: +6:14 +- _10 = CheckedAdd(_9, const 1_i32); // scope 4 at $DIR/checked.rs:+6:13: +6:18 +- 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 + } + + bb2: { +- _8 = move (_10.0: i32); // scope 4 at $DIR/checked.rs:+6:13: +6:18 ++ _8 = const i32::MIN; // scope 4 at $DIR/checked.rs:+6:13: +6:18 + StorageDead(_9); // scope 4 at $DIR/checked.rs:+6:17: +6:18 + _0 = const (); // scope 0 at $DIR/checked.rs:+0:11: +7:2 + StorageDead(_8); // scope 4 at $DIR/checked.rs:+7:1: +7:2 + StorageDead(_7); // scope 3 at $DIR/checked.rs:+7:1: +7:2 + StorageDead(_3); // scope 2 at $DIR/checked.rs:+7:1: +7:2 + StorageDead(_2); // scope 1 at $DIR/checked.rs:+7:1: +7:2 + StorageDead(_1); // scope 0 at $DIR/checked.rs:+7:1: +7:2 + return; // scope 0 at $DIR/checked.rs:+7:2: +7:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/checked.rs b/src/test/mir-opt/dataflow-const-prop/checked.rs new file mode 100644 index 000000000..0738a4ee5 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/checked.rs @@ -0,0 +1,13 @@ +// unit-test: DataflowConstProp +// compile-flags: -Coverflow-checks=on + +// EMIT_MIR checked.main.DataflowConstProp.diff +#[allow(arithmetic_overflow)] +fn main() { + let a = 1; + let b = 2; + let c = a + b; + + let d = i32::MAX; + let e = d + 1; +} diff --git a/src/test/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff new file mode 100644 index 000000000..2ced794e6 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/enum.main.DataflowConstProp.diff @@ -0,0 +1,61 @@ +- // 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_isize: bb3, 1_isize: 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/src/test/mir-opt/dataflow-const-prop/enum.rs b/src/test/mir-opt/dataflow-const-prop/enum.rs new file mode 100644 index 000000000..13288577d --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/enum.rs @@ -0,0 +1,13 @@ +// unit-test: DataflowConstProp + +// Not trackable, because variants could be aliased. +enum E { + V1(i32), + V2(i32) +} + +// EMIT_MIR enum.main.DataflowConstProp.diff +fn main() { + let e = E::V1(0); + let x = match e { E::V1(x) => x, E::V2(x) => x }; +} diff --git a/src/test/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff new file mode 100644 index 000000000..26808c70f --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff @@ -0,0 +1,112 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/if.rs:+0:11: +0:11 + let _1: i32; // in scope 0 at $DIR/if.rs:+1:9: +1:10 + let mut _3: bool; // in scope 0 at $DIR/if.rs:+2:16: +2:22 + let mut _4: i32; // in scope 0 at $DIR/if.rs:+2:16: +2:17 + let mut _6: i32; // in scope 0 at $DIR/if.rs:+3:13: +3:14 + let mut _8: bool; // in scope 0 at $DIR/if.rs:+5:16: +5:22 + let mut _9: i32; // in scope 0 at $DIR/if.rs:+5:16: +5:17 + let mut _10: i32; // in scope 0 at $DIR/if.rs:+5:36: +5:37 + let mut _12: i32; // in scope 0 at $DIR/if.rs:+6:13: +6:14 + scope 1 { + debug a => _1; // in scope 1 at $DIR/if.rs:+1:9: +1:10 + let _2: i32; // in scope 1 at $DIR/if.rs:+2:9: +2:10 + scope 2 { + debug b => _2; // in scope 2 at $DIR/if.rs:+2:9: +2:10 + let _5: i32; // in scope 2 at $DIR/if.rs:+3:9: +3:10 + scope 3 { + debug c => _5; // in scope 3 at $DIR/if.rs:+3:9: +3:10 + let _7: i32; // in scope 3 at $DIR/if.rs:+5:9: +5:10 + scope 4 { + debug d => _7; // in scope 4 at $DIR/if.rs:+5:9: +5:10 + let _11: i32; // in scope 4 at $DIR/if.rs:+6:9: +6:10 + scope 5 { + debug e => _11; // in scope 5 at $DIR/if.rs:+6:9: +6:10 + } + } + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/if.rs:+1:9: +1:10 + _1 = const 1_i32; // scope 0 at $DIR/if.rs:+1:13: +1:14 + StorageLive(_2); // scope 1 at $DIR/if.rs:+2:9: +2:10 + StorageLive(_3); // scope 1 at $DIR/if.rs:+2:16: +2:22 + StorageLive(_4); // scope 1 at $DIR/if.rs:+2:16: +2:17 +- _4 = _1; // scope 1 at $DIR/if.rs:+2:16: +2:17 +- _3 = Eq(move _4, const 1_i32); // scope 1 at $DIR/if.rs:+2:16: +2:22 ++ _4 = const 1_i32; // scope 1 at $DIR/if.rs:+2:16: +2:17 ++ _3 = const true; // scope 1 at $DIR/if.rs:+2:16: +2:22 + StorageDead(_4); // scope 1 at $DIR/if.rs:+2:21: +2:22 +- switchInt(move _3) -> [false: bb2, otherwise: bb1]; // scope 1 at $DIR/if.rs:+2:16: +2:22 ++ switchInt(const true) -> [false: bb2, otherwise: bb1]; // scope 1 at $DIR/if.rs:+2:16: +2:22 + } + + bb1: { + _2 = const 2_i32; // scope 1 at $DIR/if.rs:+2:25: +2:26 + goto -> bb3; // scope 1 at $DIR/if.rs:+2:13: +2:39 + } + + bb2: { + _2 = const 3_i32; // scope 1 at $DIR/if.rs:+2:36: +2:37 + goto -> bb3; // scope 1 at $DIR/if.rs:+2:13: +2:39 + } + + bb3: { + StorageDead(_3); // scope 1 at $DIR/if.rs:+2:38: +2:39 + StorageLive(_5); // scope 2 at $DIR/if.rs:+3:9: +3:10 + StorageLive(_6); // scope 2 at $DIR/if.rs:+3:13: +3:14 +- _6 = _2; // scope 2 at $DIR/if.rs:+3:13: +3:14 +- _5 = Add(move _6, const 1_i32); // scope 2 at $DIR/if.rs:+3:13: +3:18 ++ _6 = const 2_i32; // scope 2 at $DIR/if.rs:+3:13: +3:14 ++ _5 = const 3_i32; // scope 2 at $DIR/if.rs:+3:13: +3:18 + StorageDead(_6); // scope 2 at $DIR/if.rs:+3:17: +3:18 + StorageLive(_7); // scope 3 at $DIR/if.rs:+5:9: +5:10 + StorageLive(_8); // scope 3 at $DIR/if.rs:+5:16: +5:22 + StorageLive(_9); // scope 3 at $DIR/if.rs:+5:16: +5:17 +- _9 = _1; // scope 3 at $DIR/if.rs:+5:16: +5:17 +- _8 = Eq(move _9, const 1_i32); // scope 3 at $DIR/if.rs:+5:16: +5:22 ++ _9 = const 1_i32; // scope 3 at $DIR/if.rs:+5:16: +5:17 ++ _8 = const true; // scope 3 at $DIR/if.rs:+5:16: +5:22 + StorageDead(_9); // scope 3 at $DIR/if.rs:+5:21: +5:22 +- switchInt(move _8) -> [false: bb5, otherwise: bb4]; // scope 3 at $DIR/if.rs:+5:16: +5:22 ++ switchInt(const true) -> [false: bb5, otherwise: bb4]; // scope 3 at $DIR/if.rs:+5:16: +5:22 + } + + bb4: { +- _7 = _1; // scope 3 at $DIR/if.rs:+5:25: +5:26 ++ _7 = const 1_i32; // scope 3 at $DIR/if.rs:+5:25: +5:26 + goto -> bb6; // scope 3 at $DIR/if.rs:+5:13: +5:43 + } + + bb5: { + StorageLive(_10); // scope 3 at $DIR/if.rs:+5:36: +5:37 + _10 = _1; // scope 3 at $DIR/if.rs:+5:36: +5:37 + _7 = Add(move _10, const 1_i32); // scope 3 at $DIR/if.rs:+5:36: +5:41 + StorageDead(_10); // scope 3 at $DIR/if.rs:+5:40: +5:41 + goto -> bb6; // scope 3 at $DIR/if.rs:+5:13: +5:43 + } + + bb6: { + StorageDead(_8); // scope 3 at $DIR/if.rs:+5:42: +5:43 + StorageLive(_11); // scope 4 at $DIR/if.rs:+6:9: +6:10 + StorageLive(_12); // scope 4 at $DIR/if.rs:+6:13: +6:14 +- _12 = _7; // scope 4 at $DIR/if.rs:+6:13: +6:14 +- _11 = Add(move _12, const 1_i32); // scope 4 at $DIR/if.rs:+6:13: +6:18 ++ _12 = const 1_i32; // scope 4 at $DIR/if.rs:+6:13: +6:14 ++ _11 = const 2_i32; // scope 4 at $DIR/if.rs:+6:13: +6:18 + StorageDead(_12); // scope 4 at $DIR/if.rs:+6:17: +6:18 + _0 = const (); // scope 0 at $DIR/if.rs:+0:11: +7:2 + StorageDead(_11); // scope 4 at $DIR/if.rs:+7:1: +7:2 + StorageDead(_7); // scope 3 at $DIR/if.rs:+7:1: +7:2 + StorageDead(_5); // scope 2 at $DIR/if.rs:+7:1: +7:2 + StorageDead(_2); // scope 1 at $DIR/if.rs:+7:1: +7:2 + StorageDead(_1); // scope 0 at $DIR/if.rs:+7:1: +7:2 + return; // scope 0 at $DIR/if.rs:+7:2: +7:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/if.rs b/src/test/mir-opt/dataflow-const-prop/if.rs new file mode 100644 index 000000000..34fc35790 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/if.rs @@ -0,0 +1,11 @@ +// unit-test: DataflowConstProp + +// EMIT_MIR if.main.DataflowConstProp.diff +fn main() { + let a = 1; + let b = if a == 1 { 2 } else { 3 }; + let c = b + 1; + + let d = if a == 1 { a } else { a + 1 }; + let e = d + 1; +} diff --git a/src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff new file mode 100644 index 000000000..bf4557ed3 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/inherit_overflow.main.DataflowConstProp.diff @@ -0,0 +1,45 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + 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:7:13: 7: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; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + let mut _5: u8; // in scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + let mut _6: (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 + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + _4 = const u8::MAX; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + _5 = const 1_u8; // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + _6 = CheckedAdd(const u8::MAX, const 1_u8); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + assert(!move (_6.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 + } + + bb1: { +- _1 = move (_6.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(_5); // scope 2 at $SRC_DIR/core/src/ops/arith.rs:LL:COL + StorageDead(_4); // 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 + nop; // 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/src/test/mir-opt/dataflow-const-prop/inherit_overflow.rs b/src/test/mir-opt/dataflow-const-prop/inherit_overflow.rs new file mode 100644 index 000000000..2f2d9d010 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/inherit_overflow.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunsound-mir-opts + +// 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. + let _ = ::add(255, 1); +} diff --git a/src/test/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff new file mode 100644 index 000000000..881d80f7c --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/issue_81605.f.DataflowConstProp.diff @@ -0,0 +1,35 @@ +- // MIR for `f` before DataflowConstProp ++ // MIR for `f` after DataflowConstProp + + fn f() -> usize { + let mut _0: usize; // return place in scope 0 at $DIR/issue_81605.rs:+0:11: +0:16 + let mut _1: usize; // in scope 0 at $DIR/issue_81605.rs:+1:9: +1:33 + let mut _2: bool; // in scope 0 at $DIR/issue_81605.rs:+1:12: +1:16 + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue_81605.rs:+1:9: +1:33 + StorageLive(_2); // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16 + _2 = const true; // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16 ++ switchInt(const true) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/issue_81605.rs:+1:12: +1:16 + } + + bb1: { + _1 = const 1_usize; // scope 0 at $DIR/issue_81605.rs:+1:19: +1:20 + goto -> bb3; // scope 0 at $DIR/issue_81605.rs:+1:9: +1:33 + } + + bb2: { + _1 = const 2_usize; // scope 0 at $DIR/issue_81605.rs:+1:30: +1:31 + goto -> bb3; // scope 0 at $DIR/issue_81605.rs:+1:9: +1:33 + } + + bb3: { + StorageDead(_2); // scope 0 at $DIR/issue_81605.rs:+1:32: +1:33 +- _0 = Add(const 1_usize, move _1); // scope 0 at $DIR/issue_81605.rs:+1:5: +1:33 ++ _0 = const 2_usize; // scope 0 at $DIR/issue_81605.rs:+1:5: +1:33 + StorageDead(_1); // scope 0 at $DIR/issue_81605.rs:+1:32: +1:33 + return; // scope 0 at $DIR/issue_81605.rs:+2:2: +2:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/issue_81605.rs b/src/test/mir-opt/dataflow-const-prop/issue_81605.rs new file mode 100644 index 000000000..d75e2a28b --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/issue_81605.rs @@ -0,0 +1,10 @@ +// unit-test: DataflowConstProp + +// EMIT_MIR issue_81605.f.DataflowConstProp.diff +fn f() -> usize { + 1 + if true { 1 } else { 2 } +} + +fn main() { + f(); +} diff --git a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff new file mode 100644 index 000000000..158f187f1 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff @@ -0,0 +1,55 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_without_sb.rs:+0:11: +0:11 + let mut _1: i32; // in scope 0 at $DIR/ref_without_sb.rs:+1:9: +1:14 + let _2: (); // in scope 0 at $DIR/ref_without_sb.rs:+2:5: +2:15 + let mut _3: &i32; // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14 + let _4: &i32; // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14 + let _5: (); // in scope 0 at $DIR/ref_without_sb.rs:+4:5: +4:20 + scope 1 { + debug a => _1; // in scope 1 at $DIR/ref_without_sb.rs:+1:9: +1:14 + let _6: i32; // in scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10 + scope 2 { + debug b => _6; // in scope 2 at $DIR/ref_without_sb.rs:+6:9: +6:10 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/ref_without_sb.rs:+1:9: +1:14 + _1 = const 0_i32; // scope 0 at $DIR/ref_without_sb.rs:+1:17: +1:18 + StorageLive(_2); // scope 1 at $DIR/ref_without_sb.rs:+2:5: +2:15 + StorageLive(_3); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14 + StorageLive(_4); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14 + _4 = &_1; // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14 + _3 = &(*_4); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14 + _2 = escape::(move _3) -> bb1; // scope 1 at $DIR/ref_without_sb.rs:+2:5: +2:15 + // mir::Constant + // + span: $DIR/ref_without_sb.rs:12:5: 12:11 + // + literal: Const { ty: for<'a> fn(&'a i32) {escape::}, val: Value() } + } + + bb1: { + StorageDead(_3); // scope 1 at $DIR/ref_without_sb.rs:+2:14: +2:15 + StorageDead(_4); // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16 + StorageDead(_2); // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16 + _1 = const 1_i32; // scope 1 at $DIR/ref_without_sb.rs:+3:5: +3:10 + StorageLive(_5); // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20 + _5 = some_function() -> bb2; // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20 + // mir::Constant + // + span: $DIR/ref_without_sb.rs:14:5: 14:18 + // + literal: Const { ty: fn() {some_function}, val: Value() } + } + + bb2: { + StorageDead(_5); // scope 1 at $DIR/ref_without_sb.rs:+4:20: +4:21 + StorageLive(_6); // scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10 + _6 = _1; // scope 1 at $DIR/ref_without_sb.rs:+6:13: +6:14 + _0 = const (); // scope 0 at $DIR/ref_without_sb.rs:+0:11: +7:2 + StorageDead(_6); // scope 1 at $DIR/ref_without_sb.rs:+7:1: +7:2 + StorageDead(_1); // scope 0 at $DIR/ref_without_sb.rs:+7:1: +7:2 + return; // scope 0 at $DIR/ref_without_sb.rs:+7:2: +7:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs new file mode 100644 index 000000000..2fd480b09 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs @@ -0,0 +1,17 @@ +// unit-test: DataflowConstProp + +#[inline(never)] +fn escape(x: &T) {} + +#[inline(never)] +fn some_function() {} + +// EMIT_MIR ref_without_sb.main.DataflowConstProp.diff +fn main() { + let mut a = 0; + escape(&a); + a = 1; + some_function(); + // This should currently not be propagated. + let b = a; +} diff --git a/src/test/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff new file mode 100644 index 000000000..f66b00a9a --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/repr_transparent.main.DataflowConstProp.diff @@ -0,0 +1,44 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/repr_transparent.rs:+0:11: +0:11 + let _1: I32; // in scope 0 at $DIR/repr_transparent.rs:+1:9: +1:10 + let mut _3: i32; // in scope 0 at $DIR/repr_transparent.rs:+2:17: +2:26 + let mut _4: i32; // in scope 0 at $DIR/repr_transparent.rs:+2:17: +2:20 + let mut _5: i32; // in scope 0 at $DIR/repr_transparent.rs:+2:23: +2:26 + scope 1 { + debug x => _1; // in scope 1 at $DIR/repr_transparent.rs:+1:9: +1:10 + let _2: I32; // in scope 1 at $DIR/repr_transparent.rs:+2:9: +2:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/repr_transparent.rs:+2:9: +2:10 + } + } + + 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 + 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 +- _4 = (_1.0: i32); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:20 ++ _4 = const 0_i32; // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:20 + StorageLive(_5); // scope 1 at $DIR/repr_transparent.rs:+2:23: +2:26 +- _5 = (_1.0: i32); // scope 1 at $DIR/repr_transparent.rs:+2:23: +2:26 +- _3 = Add(move _4, move _5); // scope 1 at $DIR/repr_transparent.rs:+2:17: +2:26 ++ _5 = const 0_i32; // scope 1 at $DIR/repr_transparent.rs:+2:23: +2:26 ++ _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 + 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 + StorageDead(_1); // scope 0 at $DIR/repr_transparent.rs:+3:1: +3:2 + return; // scope 0 at $DIR/repr_transparent.rs:+3:2: +3:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/repr_transparent.rs b/src/test/mir-opt/dataflow-const-prop/repr_transparent.rs new file mode 100644 index 000000000..4ce0ca4df --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/repr_transparent.rs @@ -0,0 +1,12 @@ +// unit-test: DataflowConstProp + +// The struct has scalar ABI, but is not a scalar type. +// Make sure that we handle this correctly. +#[repr(transparent)] +struct I32(i32); + +// EMIT_MIR repr_transparent.main.DataflowConstProp.diff +fn main() { + let x = I32(0); + let y = I32(x.0 + x.0); +} diff --git a/src/test/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff new file mode 100644 index 000000000..df08eff94 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/self_assign.main.DataflowConstProp.diff @@ -0,0 +1,46 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/self_assign.rs:+0:11: +0:11 + let mut _1: i32; // in scope 0 at $DIR/self_assign.rs:+1:9: +1:14 + let mut _2: i32; // in scope 0 at $DIR/self_assign.rs:+2:9: +2:10 + let mut _3: i32; // in scope 0 at $DIR/self_assign.rs:+3:9: +3:10 + let mut _5: &i32; // in scope 0 at $DIR/self_assign.rs:+6:9: +6:10 + let mut _6: i32; // in scope 0 at $DIR/self_assign.rs:+7:9: +7:11 + scope 1 { + debug a => _1; // in scope 1 at $DIR/self_assign.rs:+1:9: +1:14 + let mut _4: &i32; // in scope 1 at $DIR/self_assign.rs:+5:9: +5:14 + scope 2 { + debug b => _4; // in scope 2 at $DIR/self_assign.rs:+5:9: +5:14 + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/self_assign.rs:+1:9: +1:14 + _1 = const 0_i32; // scope 0 at $DIR/self_assign.rs:+1:17: +1:18 + StorageLive(_2); // scope 1 at $DIR/self_assign.rs:+2:9: +2:10 + _2 = _1; // scope 1 at $DIR/self_assign.rs:+2:9: +2:10 + _1 = Add(move _2, const 1_i32); // scope 1 at $DIR/self_assign.rs:+2:5: +2:14 + StorageDead(_2); // scope 1 at $DIR/self_assign.rs:+2:13: +2:14 + StorageLive(_3); // scope 1 at $DIR/self_assign.rs:+3:9: +3:10 + _3 = _1; // scope 1 at $DIR/self_assign.rs:+3:9: +3:10 + _1 = move _3; // scope 1 at $DIR/self_assign.rs:+3:5: +3:10 + StorageDead(_3); // scope 1 at $DIR/self_assign.rs:+3:9: +3:10 + StorageLive(_4); // scope 1 at $DIR/self_assign.rs:+5:9: +5:14 + _4 = &_1; // scope 1 at $DIR/self_assign.rs:+5:17: +5:19 + StorageLive(_5); // scope 2 at $DIR/self_assign.rs:+6:9: +6:10 + _5 = _4; // scope 2 at $DIR/self_assign.rs:+6:9: +6:10 + _4 = move _5; // scope 2 at $DIR/self_assign.rs:+6:5: +6:10 + StorageDead(_5); // scope 2 at $DIR/self_assign.rs:+6:9: +6:10 + StorageLive(_6); // scope 2 at $DIR/self_assign.rs:+7:9: +7:11 + _6 = (*_4); // scope 2 at $DIR/self_assign.rs:+7:9: +7:11 + _1 = move _6; // scope 2 at $DIR/self_assign.rs:+7:5: +7:11 + StorageDead(_6); // scope 2 at $DIR/self_assign.rs:+7:10: +7:11 + _0 = const (); // scope 0 at $DIR/self_assign.rs:+0:11: +8:2 + StorageDead(_4); // scope 1 at $DIR/self_assign.rs:+8:1: +8:2 + StorageDead(_1); // scope 0 at $DIR/self_assign.rs:+8:1: +8:2 + return; // scope 0 at $DIR/self_assign.rs:+8:2: +8:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/self_assign.rs b/src/test/mir-opt/dataflow-const-prop/self_assign.rs new file mode 100644 index 000000000..8de2195f9 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/self_assign.rs @@ -0,0 +1,12 @@ +// unit-test: DataflowConstProp + +// EMIT_MIR self_assign.main.DataflowConstProp.diff +fn main() { + let mut a = 0; + a = a + 1; + a = a; + + let mut b = &a; + b = b; + a = *b; +} diff --git a/src/test/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff new file mode 100644 index 000000000..c09e4061e --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/self_assign_add.main.DataflowConstProp.diff @@ -0,0 +1,23 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/self_assign_add.rs:+0:11: +0:11 + let mut _1: i32; // in scope 0 at $DIR/self_assign_add.rs:+1:9: +1:14 + scope 1 { + debug a => _1; // in scope 1 at $DIR/self_assign_add.rs:+1:9: +1:14 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/self_assign_add.rs:+1:9: +1:14 + _1 = const 0_i32; // scope 0 at $DIR/self_assign_add.rs:+1:17: +1:18 +- _1 = Add(_1, const 1_i32); // scope 1 at $DIR/self_assign_add.rs:+2:5: +2:11 +- _1 = Add(_1, const 1_i32); // scope 1 at $DIR/self_assign_add.rs:+3:5: +3:11 ++ _1 = const 1_i32; // scope 1 at $DIR/self_assign_add.rs:+2:5: +2:11 ++ _1 = const 2_i32; // scope 1 at $DIR/self_assign_add.rs:+3:5: +3:11 + _0 = const (); // scope 0 at $DIR/self_assign_add.rs:+0:11: +4:2 + StorageDead(_1); // scope 0 at $DIR/self_assign_add.rs:+4:1: +4:2 + return; // scope 0 at $DIR/self_assign_add.rs:+4:2: +4:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/self_assign_add.rs b/src/test/mir-opt/dataflow-const-prop/self_assign_add.rs new file mode 100644 index 000000000..e32827624 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/self_assign_add.rs @@ -0,0 +1,8 @@ +// unit-test: DataflowConstProp + +// EMIT_MIR self_assign_add.main.DataflowConstProp.diff +fn main() { + let mut a = 0; + a += 1; + a += 1; +} diff --git a/src/test/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff new file mode 100644 index 000000000..8126d4b85 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/sibling_ptr.main.DataflowConstProp.diff @@ -0,0 +1,56 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/sibling_ptr.rs:+0:11: +0:11 + let mut _1: (u8, u8); // in scope 0 at $DIR/sibling_ptr.rs:+1:9: +1:14 + let _2: (); // in scope 0 at $DIR/sibling_ptr.rs:+2:5: +5:6 + let mut _4: *mut u8; // in scope 0 at $DIR/sibling_ptr.rs:+4:10: +4:18 + let mut _5: *mut u8; // in scope 0 at $DIR/sibling_ptr.rs:+4:10: +4:11 + scope 1 { + debug x => _1; // in scope 1 at $DIR/sibling_ptr.rs:+1:9: +1:14 + let _6: u8; // in scope 1 at $DIR/sibling_ptr.rs:+6:9: +6:11 + scope 2 { + let _3: *mut u8; // in scope 2 at $DIR/sibling_ptr.rs:+3:13: +3:14 + scope 3 { + debug p => _3; // in scope 3 at $DIR/sibling_ptr.rs:+3:13: +3:14 + } + } + scope 4 { + debug x1 => _6; // in scope 4 at $DIR/sibling_ptr.rs:+6:9: +6:11 + } + } + + 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 + 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 + StorageLive(_4); // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:18 + StorageLive(_5); // scope 3 at $DIR/sibling_ptr.rs:+4:10: +4:11 + _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 + // + literal: Const { ty: unsafe fn(*mut u8, usize) -> *mut u8 {ptr::mut_ptr::::add}, val: Value() } + } + + bb1: { + StorageDead(_5); // scope 3 at $DIR/sibling_ptr.rs:+4:17: +4:18 + (*_4) = const 1_u8; // scope 3 at $DIR/sibling_ptr.rs:+4:9: +4:22 + StorageDead(_4); // scope 3 at $DIR/sibling_ptr.rs:+4:22: +4:23 + _2 = const (); // scope 2 at $DIR/sibling_ptr.rs:+2:5: +5:6 + StorageDead(_3); // scope 2 at $DIR/sibling_ptr.rs:+5:5: +5:6 + StorageDead(_2); // scope 1 at $DIR/sibling_ptr.rs:+5:5: +5:6 + StorageLive(_6); // scope 1 at $DIR/sibling_ptr.rs:+6:9: +6:11 + _6 = (_1.1: u8); // scope 1 at $DIR/sibling_ptr.rs:+6:14: +6:17 + _0 = const (); // scope 0 at $DIR/sibling_ptr.rs:+0:11: +7:2 + StorageDead(_6); // scope 1 at $DIR/sibling_ptr.rs:+7:1: +7:2 + StorageDead(_1); // scope 0 at $DIR/sibling_ptr.rs:+7:1: +7:2 + return; // scope 0 at $DIR/sibling_ptr.rs:+7:2: +7:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/sibling_ptr.rs b/src/test/mir-opt/dataflow-const-prop/sibling_ptr.rs new file mode 100644 index 000000000..87ef00d18 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/sibling_ptr.rs @@ -0,0 +1,11 @@ +// unit-test: DataflowConstProp + +// EMIT_MIR sibling_ptr.main.DataflowConstProp.diff +fn main() { + let mut x: (u8, u8) = (0, 0); + unsafe { + let p = std::ptr::addr_of_mut!(x.0); + *p.add(1) = 1; + } + let x1 = x.1; // should not be propagated +} diff --git a/src/test/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff new file mode 100644 index 000000000..cfb2706c1 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/struct.main.DataflowConstProp.diff @@ -0,0 +1,52 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/struct.rs:+0:11: +0:11 + let mut _1: S; // in scope 0 at $DIR/struct.rs:+1:9: +1:14 + let mut _3: i32; // in scope 0 at $DIR/struct.rs:+2:13: +2:16 + let mut _5: i32; // in scope 0 at $DIR/struct.rs:+4:13: +4:14 + let mut _6: i32; // in scope 0 at $DIR/struct.rs:+4:17: +4:20 + scope 1 { + debug s => _1; // in scope 1 at $DIR/struct.rs:+1:9: +1:14 + let _2: i32; // in scope 1 at $DIR/struct.rs:+2:9: +2:10 + scope 2 { + debug a => _2; // in scope 2 at $DIR/struct.rs:+2:9: +2:10 + let _4: i32; // in scope 2 at $DIR/struct.rs:+4:9: +4:10 + scope 3 { + debug b => _4; // in scope 3 at $DIR/struct.rs:+4:9: +4:10 + } + } + } + + 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 + 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 +- _2 = Add(move _3, const 2_i32); // scope 1 at $DIR/struct.rs:+2:13: +2:20 ++ _3 = const 1_i32; // scope 1 at $DIR/struct.rs:+2:13: +2:16 ++ _2 = const 3_i32; // scope 1 at $DIR/struct.rs:+2:13: +2:20 + StorageDead(_3); // scope 1 at $DIR/struct.rs:+2:19: +2:20 + (_1.0: i32) = const 3_i32; // scope 2 at $DIR/struct.rs:+3:5: +3:12 + StorageLive(_4); // scope 2 at $DIR/struct.rs:+4:9: +4:10 + StorageLive(_5); // scope 2 at $DIR/struct.rs:+4:13: +4:14 +- _5 = _2; // scope 2 at $DIR/struct.rs:+4:13: +4:14 ++ _5 = const 3_i32; // scope 2 at $DIR/struct.rs:+4:13: +4:14 + StorageLive(_6); // scope 2 at $DIR/struct.rs:+4:17: +4:20 +- _6 = (_1.0: i32); // scope 2 at $DIR/struct.rs:+4:17: +4:20 +- _4 = Add(move _5, move _6); // scope 2 at $DIR/struct.rs:+4:13: +4:20 ++ _6 = const 3_i32; // scope 2 at $DIR/struct.rs:+4:17: +4:20 ++ _4 = const 6_i32; // scope 2 at $DIR/struct.rs:+4:13: +4:20 + StorageDead(_6); // scope 2 at $DIR/struct.rs:+4:19: +4:20 + StorageDead(_5); // scope 2 at $DIR/struct.rs:+4:19: +4:20 + _0 = const (); // scope 0 at $DIR/struct.rs:+0:11: +5:2 + StorageDead(_4); // scope 2 at $DIR/struct.rs:+5:1: +5:2 + StorageDead(_2); // scope 1 at $DIR/struct.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/struct.rs:+5:1: +5:2 + return; // scope 0 at $DIR/struct.rs:+5:2: +5:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/struct.rs b/src/test/mir-opt/dataflow-const-prop/struct.rs new file mode 100644 index 000000000..841b279e0 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/struct.rs @@ -0,0 +1,11 @@ +// unit-test: DataflowConstProp + +struct S(i32); + +// EMIT_MIR struct.main.DataflowConstProp.diff +fn main() { + let mut s = S(1); + let a = s.0 + 2; + s.0 = 3; + let b = a + s.0; +} diff --git a/src/test/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff new file mode 100644 index 000000000..8018400e7 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/terminator.main.DataflowConstProp.diff @@ -0,0 +1,40 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/terminator.rs:+0:11: +0:11 + let _1: i32; // in scope 0 at $DIR/terminator.rs:+1:9: +1:10 + let _2: (); // in scope 0 at $DIR/terminator.rs:+3:5: +3:15 + let mut _3: i32; // in scope 0 at $DIR/terminator.rs:+3:9: +3:14 + let mut _4: i32; // in scope 0 at $DIR/terminator.rs:+3:9: +3:10 + scope 1 { + debug a => _1; // in scope 1 at $DIR/terminator.rs:+1:9: +1:10 + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/terminator.rs:+1:9: +1:10 + _1 = const 1_i32; // scope 0 at $DIR/terminator.rs:+1:13: +1:14 + StorageLive(_2); // scope 1 at $DIR/terminator.rs:+3:5: +3:15 + StorageLive(_3); // scope 1 at $DIR/terminator.rs:+3:9: +3:14 + StorageLive(_4); // scope 1 at $DIR/terminator.rs:+3:9: +3:10 +- _4 = _1; // scope 1 at $DIR/terminator.rs:+3:9: +3:10 +- _3 = Add(move _4, const 1_i32); // scope 1 at $DIR/terminator.rs:+3:9: +3:14 ++ _4 = const 1_i32; // scope 1 at $DIR/terminator.rs:+3:9: +3:10 ++ _3 = const 2_i32; // scope 1 at $DIR/terminator.rs:+3:9: +3:14 + StorageDead(_4); // scope 1 at $DIR/terminator.rs:+3:13: +3:14 +- _2 = foo(move _3) -> bb1; // scope 1 at $DIR/terminator.rs:+3:5: +3:15 ++ _2 = foo(const 2_i32) -> bb1; // scope 1 at $DIR/terminator.rs:+3:5: +3:15 + // mir::Constant + // + span: $DIR/terminator.rs:9:5: 9:8 + // + literal: Const { ty: fn(i32) {foo}, val: Value() } + } + + bb1: { + StorageDead(_3); // scope 1 at $DIR/terminator.rs:+3:14: +3:15 + StorageDead(_2); // scope 1 at $DIR/terminator.rs:+3:15: +3:16 + _0 = const (); // scope 0 at $DIR/terminator.rs:+0:11: +4:2 + StorageDead(_1); // scope 0 at $DIR/terminator.rs:+4:1: +4:2 + return; // scope 0 at $DIR/terminator.rs:+4:2: +4:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/terminator.rs b/src/test/mir-opt/dataflow-const-prop/terminator.rs new file mode 100644 index 000000000..d151f666a --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/terminator.rs @@ -0,0 +1,10 @@ +// unit-test: DataflowConstProp + +fn foo(n: i32) {} + +// EMIT_MIR terminator.main.DataflowConstProp.diff +fn main() { + let a = 1; + // Checks that we propagate into terminators. + foo(a + 1); +} diff --git a/src/test/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff new file mode 100644 index 000000000..e028def00 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/tuple.main.DataflowConstProp.diff @@ -0,0 +1,75 @@ +- // MIR for `main` before DataflowConstProp ++ // MIR for `main` after DataflowConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/tuple.rs:+0:11: +0:11 + let mut _1: (i32, i32); // in scope 0 at $DIR/tuple.rs:+1:9: +1:14 + let mut _3: i32; // in scope 0 at $DIR/tuple.rs:+2:13: +2:22 + let mut _4: i32; // in scope 0 at $DIR/tuple.rs:+2:13: +2:16 + let mut _5: i32; // in scope 0 at $DIR/tuple.rs:+2:19: +2:22 + let mut _7: i32; // in scope 0 at $DIR/tuple.rs:+4:13: +4:22 + let mut _8: i32; // in scope 0 at $DIR/tuple.rs:+4:13: +4:16 + let mut _9: i32; // in scope 0 at $DIR/tuple.rs:+4:19: +4:22 + let mut _10: i32; // in scope 0 at $DIR/tuple.rs:+4:25: +4:26 + scope 1 { + debug a => _1; // in scope 1 at $DIR/tuple.rs:+1:9: +1:14 + let _2: i32; // in scope 1 at $DIR/tuple.rs:+2:9: +2:10 + scope 2 { + debug b => _2; // in scope 2 at $DIR/tuple.rs:+2:9: +2:10 + let _6: i32; // in scope 2 at $DIR/tuple.rs:+4:9: +4:10 + scope 3 { + debug c => _6; // in scope 3 at $DIR/tuple.rs:+4:9: +4:10 + } + } + } + + 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 + 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 +- _4 = (_1.0: i32); // scope 1 at $DIR/tuple.rs:+2:13: +2:16 ++ _4 = const 1_i32; // scope 1 at $DIR/tuple.rs:+2:13: +2:16 + StorageLive(_5); // scope 1 at $DIR/tuple.rs:+2:19: +2:22 +- _5 = (_1.1: i32); // scope 1 at $DIR/tuple.rs:+2:19: +2:22 +- _3 = Add(move _4, move _5); // scope 1 at $DIR/tuple.rs:+2:13: +2:22 ++ _5 = const 2_i32; // scope 1 at $DIR/tuple.rs:+2:19: +2:22 ++ _3 = const 3_i32; // scope 1 at $DIR/tuple.rs:+2:13: +2:22 + StorageDead(_5); // scope 1 at $DIR/tuple.rs:+2:21: +2:22 + StorageDead(_4); // scope 1 at $DIR/tuple.rs:+2:21: +2:22 +- _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 + 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 +- _8 = (_1.0: i32); // scope 2 at $DIR/tuple.rs:+4:13: +4:16 ++ _8 = const 2_i32; // scope 2 at $DIR/tuple.rs:+4:13: +4:16 + StorageLive(_9); // scope 2 at $DIR/tuple.rs:+4:19: +4:22 +- _9 = (_1.1: i32); // scope 2 at $DIR/tuple.rs:+4:19: +4:22 +- _7 = Add(move _8, move _9); // scope 2 at $DIR/tuple.rs:+4:13: +4:22 ++ _9 = const 3_i32; // scope 2 at $DIR/tuple.rs:+4:19: +4:22 ++ _7 = const 5_i32; // scope 2 at $DIR/tuple.rs:+4:13: +4:22 + StorageDead(_9); // scope 2 at $DIR/tuple.rs:+4:21: +4:22 + StorageDead(_8); // scope 2 at $DIR/tuple.rs:+4:21: +4:22 + StorageLive(_10); // scope 2 at $DIR/tuple.rs:+4:25: +4:26 +- _10 = _2; // scope 2 at $DIR/tuple.rs:+4:25: +4:26 +- _6 = Add(move _7, move _10); // scope 2 at $DIR/tuple.rs:+4:13: +4:26 ++ _10 = const 6_i32; // scope 2 at $DIR/tuple.rs:+4:25: +4:26 ++ _6 = const 11_i32; // scope 2 at $DIR/tuple.rs:+4:13: +4:26 + StorageDead(_10); // scope 2 at $DIR/tuple.rs:+4:25: +4:26 + StorageDead(_7); // scope 2 at $DIR/tuple.rs:+4:25: +4:26 + _0 = const (); // scope 0 at $DIR/tuple.rs:+0:11: +5:2 + StorageDead(_6); // scope 2 at $DIR/tuple.rs:+5:1: +5:2 + StorageDead(_2); // scope 1 at $DIR/tuple.rs:+5:1: +5:2 + StorageDead(_1); // scope 0 at $DIR/tuple.rs:+5:1: +5:2 + return; // scope 0 at $DIR/tuple.rs:+5:2: +5:2 + } + } + diff --git a/src/test/mir-opt/dataflow-const-prop/tuple.rs b/src/test/mir-opt/dataflow-const-prop/tuple.rs new file mode 100644 index 000000000..92c70eab0 --- /dev/null +++ b/src/test/mir-opt/dataflow-const-prop/tuple.rs @@ -0,0 +1,9 @@ +// unit-test: DataflowConstProp + +// EMIT_MIR tuple.main.DataflowConstProp.diff +fn main() { + let mut a = (1, 2); + let b = a.0 + a.1 + 3; + a = (2, 3); + let c = a.0 + a.1 + b; +} diff --git a/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff b/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff index 58dd788b6..61d24c3b5 100644 --- a/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff +++ b/src/test/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff @@ -6,17 +6,20 @@ debug y => _2; // in scope 0 at $DIR/cycle.rs:+0:22: +0:27 debug z => _3; // in scope 0 at $DIR/cycle.rs:+0:34: +0:39 let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:46: +0:46 - let mut _4: (); // in scope 0 at $DIR/cycle.rs:+0:1: +9:2 - let mut _5: bool; // in scope 0 at $DIR/cycle.rs:+3:11: +3:17 - let _6: i32; // in scope 0 at $DIR/cycle.rs:+4:13: +4:17 - let mut _7: i32; // in scope 0 at $DIR/cycle.rs:+5:13: +5:14 - let mut _8: i32; // in scope 0 at $DIR/cycle.rs:+6:13: +6:14 - let mut _9: i32; // in scope 0 at $DIR/cycle.rs:+7:13: +7:17 - let mut _10: !; // in scope 0 at $DIR/cycle.rs:+3:5: +8:6 - let _11: (); // in scope 0 at $DIR/cycle.rs:+3:5: +8:6 - let mut _12: !; // in scope 0 at $DIR/cycle.rs:+3:5: +8:6 +- let mut _4: (); // in scope 0 at $DIR/cycle.rs:+0:1: +9:2 +- let mut _5: bool; // in scope 0 at $DIR/cycle.rs:+3:11: +3:17 +- let _6: i32; // in scope 0 at $DIR/cycle.rs:+4:13: +4:17 +- let mut _7: i32; // in scope 0 at $DIR/cycle.rs:+5:13: +5:14 +- let mut _8: i32; // in scope 0 at $DIR/cycle.rs:+6:13: +6:14 +- let mut _9: i32; // in scope 0 at $DIR/cycle.rs:+7:13: +7:17 +- let mut _10: !; // in scope 0 at $DIR/cycle.rs:+3:5: +8:6 +- let _11: (); // in scope 0 at $DIR/cycle.rs:+3:5: +8:6 +- let mut _12: !; // in scope 0 at $DIR/cycle.rs:+3:5: +8:6 ++ let mut _4: bool; // in scope 0 at $DIR/cycle.rs:+3:11: +3:17 ++ let _5: i32; // in scope 0 at $DIR/cycle.rs:+4:13: +4:17 scope 1 { - debug temp => _6; // in scope 1 at $DIR/cycle.rs:+4:13: +4:17 +- debug temp => _6; // in scope 1 at $DIR/cycle.rs:+4:13: +4:17 ++ debug temp => _5; // in scope 1 at $DIR/cycle.rs:+4:13: +4:17 } bb0: { @@ -24,51 +27,57 @@ } bb1: { - StorageLive(_5); // scope 0 at $DIR/cycle.rs:+3:11: +3:17 - _5 = cond() -> bb2; // scope 0 at $DIR/cycle.rs:+3:11: +3:17 +- StorageLive(_5); // scope 0 at $DIR/cycle.rs:+3:11: +3:17 +- _5 = cond() -> bb2; // scope 0 at $DIR/cycle.rs:+3:11: +3:17 ++ StorageLive(_4); // scope 0 at $DIR/cycle.rs:+3:11: +3:17 ++ _4 = cond() -> bb2; // scope 0 at $DIR/cycle.rs:+3:11: +3:17 // mir::Constant // + span: $DIR/cycle.rs:12:11: 12:15 // + literal: Const { ty: fn() -> bool {cond}, val: Value() } } bb2: { - switchInt(move _5) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/cycle.rs:+3:11: +3:17 +- switchInt(move _5) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/cycle.rs:+3:11: +3:17 ++ switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/cycle.rs:+3:11: +3:17 } bb3: { - StorageLive(_6); // scope 0 at $DIR/cycle.rs:+4:13: +4:17 +- StorageLive(_6); // scope 0 at $DIR/cycle.rs:+4:13: +4:17 - _6 = _3; // scope 0 at $DIR/cycle.rs:+4:20: +4:21 -+ nop; // scope 0 at $DIR/cycle.rs:+4:20: +4:21 - StorageLive(_7); // scope 1 at $DIR/cycle.rs:+5:13: +5:14 +- StorageLive(_7); // scope 1 at $DIR/cycle.rs:+5:13: +5:14 - _7 = _2; // scope 1 at $DIR/cycle.rs:+5:13: +5:14 - _3 = move _7; // scope 1 at $DIR/cycle.rs:+5:9: +5:14 -+ nop; // scope 1 at $DIR/cycle.rs:+5:13: +5:14 -+ nop; // scope 1 at $DIR/cycle.rs:+5:9: +5:14 - StorageDead(_7); // scope 1 at $DIR/cycle.rs:+5:13: +5:14 - StorageLive(_8); // scope 1 at $DIR/cycle.rs:+6:13: +6:14 +- StorageDead(_7); // scope 1 at $DIR/cycle.rs:+5:13: +5:14 +- StorageLive(_8); // scope 1 at $DIR/cycle.rs:+6:13: +6:14 - _8 = _1; // scope 1 at $DIR/cycle.rs:+6:13: +6:14 - _2 = move _8; // scope 1 at $DIR/cycle.rs:+6:9: +6:14 -+ nop; // scope 1 at $DIR/cycle.rs:+6:13: +6:14 -+ nop; // scope 1 at $DIR/cycle.rs:+6:9: +6:14 - StorageDead(_8); // scope 1 at $DIR/cycle.rs:+6:13: +6:14 - StorageLive(_9); // scope 1 at $DIR/cycle.rs:+7:13: +7:17 +- StorageDead(_8); // scope 1 at $DIR/cycle.rs:+6:13: +6:14 +- StorageLive(_9); // scope 1 at $DIR/cycle.rs:+7:13: +7:17 - _9 = _6; // scope 1 at $DIR/cycle.rs:+7:13: +7:17 - _1 = move _9; // scope 1 at $DIR/cycle.rs:+7:9: +7:17 +- StorageDead(_9); // scope 1 at $DIR/cycle.rs:+7:16: +7:17 +- _4 = const (); // scope 0 at $DIR/cycle.rs:+3:18: +8:6 +- StorageDead(_6); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 ++ StorageLive(_5); // scope 0 at $DIR/cycle.rs:+4:13: +4:17 ++ nop; // scope 0 at $DIR/cycle.rs:+4:20: +4:21 ++ nop; // scope 1 at $DIR/cycle.rs:+5:13: +5:14 ++ nop; // scope 1 at $DIR/cycle.rs:+5:9: +5:14 ++ nop; // scope 1 at $DIR/cycle.rs:+6:13: +6:14 ++ nop; // scope 1 at $DIR/cycle.rs:+6:9: +6:14 + nop; // scope 1 at $DIR/cycle.rs:+7:13: +7:17 + nop; // scope 1 at $DIR/cycle.rs:+7:9: +7:17 - StorageDead(_9); // scope 1 at $DIR/cycle.rs:+7:16: +7:17 -- _4 = const (); // scope 0 at $DIR/cycle.rs:+3:18: +8:6 + nop; // scope 0 at $DIR/cycle.rs:+3:18: +8:6 - StorageDead(_6); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 StorageDead(_5); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 ++ StorageDead(_4); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 goto -> bb1; // scope 0 at $DIR/cycle.rs:+3:5: +8:6 } bb4: { - StorageLive(_11); // scope 0 at $DIR/cycle.rs:+3:5: +8:6 +- StorageLive(_11); // scope 0 at $DIR/cycle.rs:+3:5: +8:6 _0 = const (); // scope 0 at $DIR/cycle.rs:+3:5: +8:6 - StorageDead(_11); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 - StorageDead(_5); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 +- StorageDead(_11); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 +- StorageDead(_5); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 ++ StorageDead(_4); // scope 0 at $DIR/cycle.rs:+8:5: +8:6 return; // scope 0 at $DIR/cycle.rs:+9:2: +9:2 } } diff --git a/src/test/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir b/src/test/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir new file mode 100644 index 000000000..5b185082d --- /dev/null +++ b/src/test/mir-opt/deref-patterns/string.foo.PreCodegen.after.mir @@ -0,0 +1,74 @@ +// MIR for `foo` after PreCodegen + +fn foo(_1: Option) -> i32 { + debug s => _1; // in scope 0 at $DIR/string.rs:+0:12: +0:13 + let mut _0: i32; // return place in scope 0 at $DIR/string.rs:+0:34: +0:37 + let mut _2: &std::string::String; // in scope 0 at $DIR/string.rs:+2:14: +2:17 + let mut _3: &str; // in scope 0 at $DIR/string.rs:+2:14: +2:17 + let mut _4: bool; // in scope 0 at $DIR/string.rs:+2:14: +2:17 + let mut _5: isize; // in scope 0 at $DIR/string.rs:+2:9: +2:18 + let _6: std::option::Option; // in scope 0 at $DIR/string.rs:+3:9: +3:10 + let mut _7: bool; // in scope 0 at $DIR/string.rs:+5:1: +5:2 + scope 1 { + debug s => _6; // in scope 1 at $DIR/string.rs:+3:9: +3:10 + } + + bb0: { + _7 = const false; // scope 0 at $DIR/string.rs:+1:11: +1:12 + _7 = const true; // scope 0 at $DIR/string.rs:+1:11: +1:12 + _5 = discriminant(_1); // scope 0 at $DIR/string.rs:+1:11: +1:12 + switchInt(move _5) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/string.rs:+1:5: +1:12 + } + + bb1: { + StorageLive(_6); // scope 0 at $DIR/string.rs:+3:9: +3:10 + _7 = const false; // scope 0 at $DIR/string.rs:+3:9: +3:10 + _6 = move _1; // scope 0 at $DIR/string.rs:+3:9: +3:10 + _0 = const 4321_i32; // scope 1 at $DIR/string.rs:+3:14: +3:18 + drop(_6) -> bb6; // scope 0 at $DIR/string.rs:+3:17: +3:18 + } + + bb2: { + _2 = &((_1 as Some).0: std::string::String); // scope 0 at $DIR/string.rs:+2:14: +2:17 + _3 = ::deref(move _2) -> bb3; // scope 0 at $DIR/string.rs:+2:14: +2:17 + // mir::Constant + // + span: $DIR/string.rs:9:14: 9:17 + // + literal: Const { ty: for<'a> fn(&'a String) -> &'a ::Target {::deref}, val: Value() } + } + + bb3: { + _4 = ::eq(_3, const "a") -> bb4; // scope 0 at $DIR/string.rs:+2:14: +2:17 + // mir::Constant + // + span: $DIR/string.rs:9:14: 9:17 + // + literal: Const { ty: for<'a, 'b> fn(&'a str, &'b str) -> bool {::eq}, val: Value() } + // mir::Constant + // + span: $DIR/string.rs:9:14: 9:17 + // + literal: Const { ty: &str, val: Value(Slice(..)) } + } + + bb4: { + switchInt(move _4) -> [false: bb1, otherwise: bb5]; // scope 0 at $DIR/string.rs:+2:14: +2:17 + } + + bb5: { + _0 = const 1234_i32; // scope 0 at $DIR/string.rs:+2:22: +2:26 + goto -> bb9; // scope 0 at $DIR/string.rs:+2:22: +2:26 + } + + bb6: { + StorageDead(_6); // scope 0 at $DIR/string.rs:+3:17: +3:18 + goto -> bb9; // scope 0 at $DIR/string.rs:+3:17: +3:18 + } + + bb7: { + return; // scope 0 at $DIR/string.rs:+5:2: +5:2 + } + + bb8: { + drop(_1) -> bb7; // scope 0 at $DIR/string.rs:+5:1: +5:2 + } + + bb9: { + switchInt(_7) -> [false: bb7, otherwise: bb8]; // scope 0 at $DIR/string.rs:+5:1: +5:2 + } +} diff --git a/src/test/mir-opt/deref-patterns/string.rs b/src/test/mir-opt/deref-patterns/string.rs new file mode 100644 index 000000000..3a99c44aa --- /dev/null +++ b/src/test/mir-opt/deref-patterns/string.rs @@ -0,0 +1,12 @@ +// compile-flags: -Z mir-opt-level=0 -C panic=abort + +#![feature(string_deref_patterns)] +#![crate_type = "lib"] + +// EMIT_MIR string.foo.PreCodegen.after.mir +pub fn foo(s: Option) -> i32 { + match s { + Some("a") => 1234, + s => 4321, + } +} diff --git a/src/test/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff new file mode 100644 index 000000000..5fa7013d5 --- /dev/null +++ b/src/test/mir-opt/dest-prop/branch.foo.DestinationPropagation.diff @@ -0,0 +1,75 @@ +- // MIR for `foo` before DestinationPropagation ++ // MIR for `foo` after DestinationPropagation + + 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 ++ debug x => _0; // 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 ++ debug y => _0; // 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 ++ nop; // scope 0 at $DIR/branch.rs:+1:9: +1:10 ++ _0 = 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 ++ nop; // 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) -> [false: 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 ++ nop; // 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 ++ nop; // 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 ++ nop; // scope 2 at $DIR/branch.rs:+10:5: +10:6 ++ nop; // scope 1 at $DIR/branch.rs:+11:1: +11:2 ++ nop; // scope 0 at $DIR/branch.rs:+11:1: +11:2 + return; // scope 0 at $DIR/branch.rs:+11:2: +11:2 + } + } + diff --git a/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff deleted file mode 100644 index 8929f2cc7..000000000 --- a/src/test/mir-opt/dest-prop/branch.main.DestinationPropagation.diff +++ /dev/null @@ -1,65 +0,0 @@ -- // MIR for `main` before DestinationPropagation -+ // MIR for `main` after DestinationPropagation - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/branch.rs:+0:11: +0:11 - 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) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/branch.rs:+3:16: +3:22 - } - - bb3: { - nop; // 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 - nop; // 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 - nop; // scope 0 at $DIR/branch.rs:+0:11: +9:2 - StorageDead(_2); // scope 1 at $DIR/branch.rs:+9:1: +9:2 - StorageDead(_1); // scope 0 at $DIR/branch.rs:+9:1: +9:2 - return; // scope 0 at $DIR/branch.rs:+9:2: +9:2 - } - } - diff --git a/src/test/mir-opt/dest-prop/branch.rs b/src/test/mir-opt/dest-prop/branch.rs index fffcf82b3..898c908b1 100644 --- a/src/test/mir-opt/dest-prop/branch.rs +++ b/src/test/mir-opt/dest-prop/branch.rs @@ -1,5 +1,5 @@ //! Tests that assignment in both branches of an `if` are eliminated. -// compile-flags: -Zunsound-mir-opts +// unit-test: DestinationPropagation fn val() -> i32 { 1 } @@ -8,8 +8,8 @@ fn cond() -> bool { true } -// EMIT_MIR branch.main.DestinationPropagation.diff -fn main() { +// EMIT_MIR branch.foo.DestinationPropagation.diff +fn foo() -> i32 { let x = val(); let y = if cond() { @@ -18,4 +18,10 @@ fn main() { val(); x }; + + y +} + +fn main() { + foo(); } diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff index f28bc72df..4343a5935 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.arg_src.DestinationPropagation.diff @@ -2,7 +2,7 @@ + // MIR for `arg_src` after DestinationPropagation fn arg_src(_1: i32) -> i32 { - debug x => const 123_i32; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:12: +0:17 + 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 { @@ -15,7 +15,7 @@ - _2 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 + nop; // scope 0 at $DIR/copy_propagation_arg.rs:+1:9: +1:10 + _0 = _1; // scope 0 at $DIR/copy_propagation_arg.rs:+1:13: +1:14 - nop; // scope 1 at $DIR/copy_propagation_arg.rs:+2:5: +2:12 + _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 + nop; // scope 1 at $DIR/copy_propagation_arg.rs:+3:5: +3:6 diff --git a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff index a8a7e9ab6..298991b5a 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.bar.DestinationPropagation.diff @@ -2,26 +2,30 @@ + // MIR for `bar` after DestinationPropagation fn bar(_1: u8) -> () { - debug x => const 5_u8; // in scope 0 at $DIR/copy_propagation_arg.rs:+0:8: +0:13 + 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 +- 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 ++ nop; // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 ++ nop; // scope 0 at $DIR/copy_propagation_arg.rs:+1:11: +1:12 ++ _2 = dummy(move _1) -> 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(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+1:12: +1:13 ++ nop; // 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 - nop; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:10 - nop; // scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +3:2 + _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/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff index ce9be4c27..bc88787e6 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.baz.DestinationPropagation.diff @@ -1,18 +1,22 @@ - // MIR for `baz` before DestinationPropagation + // MIR for `baz` after DestinationPropagation - fn baz(_1: i32) -> () { + fn baz(_1: i32) -> i32 { 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:20: +0:20 + 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 - nop; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 - nop; // 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 - nop; // scope 0 at $DIR/copy_propagation_arg.rs:+0:20: +3:2 - return; // scope 0 at $DIR/copy_propagation_arg.rs:+3:2: +3:2 +- 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 ++ nop; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 ++ nop; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:10 ++ nop; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:10 ++ nop; // 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/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff index d7a0b950f..d37a9f71d 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.foo.DestinationPropagation.diff @@ -8,10 +8,12 @@ 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(_2); // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 ++ nop; // 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 +- _2 = dummy(move _3) -> bb1; // scope 0 at $DIR/copy_propagation_arg.rs:+2:9: +2:17 ++ _1 = 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() } @@ -19,9 +21,11 @@ bb1: { StorageDead(_3); // scope 0 at $DIR/copy_propagation_arg.rs:+2:16: +2:17 - nop; // 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 - nop; // scope 0 at $DIR/copy_propagation_arg.rs:+0:19: +3:2 +- _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 ++ nop; // scope 0 at $DIR/copy_propagation_arg.rs:+2:5: +2:17 ++ nop; // 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/src/test/mir-opt/dest-prop/copy_propagation_arg.rs b/src/test/mir-opt/dest-prop/copy_propagation_arg.rs index a5fb0f640..31be6c931 100644 --- a/src/test/mir-opt/dest-prop/copy_propagation_arg.rs +++ b/src/test/mir-opt/dest-prop/copy_propagation_arg.rs @@ -1,6 +1,6 @@ // Check that DestinationPropagation does not propagate an assignment to a function argument // (doing so can break usages of the original argument value) -// compile-flags: -Zunsound-mir-opts +// unit-test: DestinationPropagation fn dummy(x: u8) -> u8 { x } @@ -18,9 +18,10 @@ fn bar(mut x: u8) { } // EMIT_MIR copy_propagation_arg.baz.DestinationPropagation.diff -fn baz(mut x: i32) { +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.DestinationPropagation.diff diff --git a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff index 8eeb0d354..cfc203c5f 100644 --- a/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/cycle.main.DestinationPropagation.diff @@ -8,45 +8,69 @@ 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 +- debug x => _1; // in scope 1 at $DIR/cycle.rs:+1:9: +1:14 ++ debug x => _6; // 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 +- debug y => _2; // in scope 2 at $DIR/cycle.rs:+2:9: +2:10 ++ debug y => _6; // 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 - scope 4 (inlined std::mem::drop::) { // at $DIR/cycle.rs:14:5: 14:12 - debug _x => _6; // in scope 4 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - } +- debug z => _3; // in scope 3 at $DIR/cycle.rs:+3:9: +3:10 ++ debug z => _6; // 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 +- 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 ++ nop; // scope 0 at $DIR/cycle.rs:+1:9: +1:14 ++ _6 = 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 - nop; // scope 1 at $DIR/cycle.rs:+2:13: +2:14 - StorageLive(_3); // scope 2 at $DIR/cycle.rs:+3:9: +3:10 - nop; // scope 2 at $DIR/cycle.rs:+3:13: +3:14 - StorageLive(_4); // scope 3 at $DIR/cycle.rs:+4:9: +4:10 - nop; // scope 3 at $DIR/cycle.rs:+4:9: +4:10 - nop; // scope 3 at $DIR/cycle.rs:+4:5: +4:10 - StorageDead(_4); // scope 3 at $DIR/cycle.rs:+4:9: +4:10 +- 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 ++ nop; // scope 1 at $DIR/cycle.rs:+2:9: +2:10 ++ nop; // scope 1 at $DIR/cycle.rs:+2:13: +2:14 ++ nop; // scope 2 at $DIR/cycle.rs:+3:9: +3:10 ++ nop; // scope 2 at $DIR/cycle.rs:+3:13: +3:14 ++ nop; // scope 3 at $DIR/cycle.rs:+4:9: +4:10 ++ nop; // scope 3 at $DIR/cycle.rs:+4:9: +4:10 ++ nop; // scope 3 at $DIR/cycle.rs:+4:5: +4:10 ++ nop; // scope 3 at $DIR/cycle.rs:+4:9: +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 - nop; // scope 3 at $DIR/cycle.rs:+6:10: +6:11 - StorageDead(_6); // scope 3 at $DIR/cycle.rs:+6:11: +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 ++ nop; // scope 3 at $DIR/cycle.rs:+6:10: +6:11 ++ nop; // 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 ++ nop; // scope 3 at $DIR/cycle.rs:+6:11: +6:12 StorageDead(_5); // scope 3 at $DIR/cycle.rs:+6:12: +6:13 - 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 + _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 ++ nop; // scope 2 at $DIR/cycle.rs:+7:1: +7:2 ++ nop; // scope 1 at $DIR/cycle.rs:+7:1: +7:2 ++ nop; // scope 0 at $DIR/cycle.rs:+7:1: +7:2 return; // scope 0 at $DIR/cycle.rs:+7:2: +7:2 } } diff --git a/src/test/mir-opt/dest-prop/cycle.rs b/src/test/mir-opt/dest-prop/cycle.rs index c9187d408..6182878f3 100644 --- a/src/test/mir-opt/dest-prop/cycle.rs +++ b/src/test/mir-opt/dest-prop/cycle.rs @@ -1,5 +1,5 @@ //! Tests that cyclic assignments don't hang DestinationPropagation, and result in reasonable code. -// compile-flags: -Zunsound-mir-opts +// unit-test: DestinationPropagation fn val() -> i32 { 1 } diff --git a/src/test/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir b/src/test/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir new file mode 100644 index 000000000..63cac133b --- /dev/null +++ b/src/test/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.mir @@ -0,0 +1,34 @@ +// MIR for `f` after DestinationPropagation + +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 => _3; // in scope 1 at $DIR/dead_stores_79191.rs:+1:9: +1:10 + } + + bb0: { + nop; // scope 0 at $DIR/dead_stores_79191.rs:+1:9: +1:10 + _3 = _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 + nop; // scope 1 at $DIR/dead_stores_79191.rs:+3:9: +3:10 + nop; // scope 1 at $DIR/dead_stores_79191.rs:+3:9: +3:10 + _1 = move _3; // scope 1 at $DIR/dead_stores_79191.rs:+3:5: +3:10 + nop; // scope 1 at $DIR/dead_stores_79191.rs:+3:9: +3:10 + nop; // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 + nop; // scope 1 at $DIR/dead_stores_79191.rs:+4:8: +4:9 + _0 = id::(move _1) -> 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: { + nop; // scope 1 at $DIR/dead_stores_79191.rs:+4:9: +4:10 + nop; // scope 0 at $DIR/dead_stores_79191.rs:+5:1: +5:2 + return; // scope 0 at $DIR/dead_stores_79191.rs:+5:2: +5:2 + } +} diff --git a/src/test/mir-opt/dest-prop/dead_stores_79191.rs b/src/test/mir-opt/dest-prop/dead_stores_79191.rs new file mode 100644 index 000000000..43e0bf664 --- /dev/null +++ b/src/test/mir-opt/dest-prop/dead_stores_79191.rs @@ -0,0 +1,17 @@ +// unit-test: DestinationPropagation + +fn id(x: T) -> T { + x +} + +// EMIT_MIR dead_stores_79191.f.DestinationPropagation.after.mir +fn f(mut a: usize) -> usize { + let b = a; + a = 5; + a = b; + id(a) +} + +fn main() { + f(0); +} diff --git a/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir b/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir new file mode 100644 index 000000000..ba7f76d28 --- /dev/null +++ b/src/test/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.mir @@ -0,0 +1,34 @@ +// MIR for `f` after DestinationPropagation + +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 => _1; // in scope 1 at $DIR/dead_stores_better.rs:+1:9: +1:10 + } + + bb0: { + nop; // scope 0 at $DIR/dead_stores_better.rs:+1:9: +1:10 + nop; // scope 0 at $DIR/dead_stores_better.rs:+1:13: +1:14 + nop; // scope 1 at $DIR/dead_stores_better.rs:+2:5: +2:10 + nop; // scope 1 at $DIR/dead_stores_better.rs:+3:9: +3:10 + nop; // scope 1 at $DIR/dead_stores_better.rs:+3:9: +3:10 + nop; // scope 1 at $DIR/dead_stores_better.rs:+3:5: +3:10 + nop; // scope 1 at $DIR/dead_stores_better.rs:+3:9: +3:10 + nop; // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 + nop; // scope 1 at $DIR/dead_stores_better.rs:+4:8: +4:9 + _0 = id::(move _1) -> 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: { + nop; // scope 1 at $DIR/dead_stores_better.rs:+4:9: +4:10 + nop; // scope 0 at $DIR/dead_stores_better.rs:+5:1: +5:2 + return; // scope 0 at $DIR/dead_stores_better.rs:+5:2: +5:2 + } +} diff --git a/src/test/mir-opt/dest-prop/dead_stores_better.rs b/src/test/mir-opt/dest-prop/dead_stores_better.rs new file mode 100644 index 000000000..003ad57d8 --- /dev/null +++ b/src/test/mir-opt/dest-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: DestinationPropagation +// compile-flags: -Zmir-enable-passes=+DeadStoreElimination + +fn id(x: T) -> T { + x +} + +// EMIT_MIR dead_stores_better.f.DestinationPropagation.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/src/test/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff index 80b09ed5f..c2a3a0025 100644 --- a/src/test/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/simple.nrvo.DestinationPropagation.diff @@ -17,18 +17,22 @@ StorageLive(_2); // scope 0 at $DIR/simple.rs:+1:9: +1:16 _2 = [const 0_u8; 1024]; // scope 0 at $DIR/simple.rs:+1:19: +1:28 StorageLive(_3); // scope 1 at $DIR/simple.rs:+2:5: +2:19 - StorageLive(_4); // scope 1 at $DIR/simple.rs:+2:5: +2:9 - _4 = _1; // scope 1 at $DIR/simple.rs:+2:5: +2:9 +- StorageLive(_4); // scope 1 at $DIR/simple.rs:+2:5: +2:9 +- _4 = _1; // scope 1 at $DIR/simple.rs:+2:5: +2:9 ++ nop; // scope 1 at $DIR/simple.rs:+2:5: +2:9 ++ nop; // scope 1 at $DIR/simple.rs:+2:5: +2:9 StorageLive(_5); // scope 1 at $DIR/simple.rs:+2:10: +2:18 StorageLive(_6); // scope 1 at $DIR/simple.rs:+2:10: +2:18 _6 = &mut _2; // scope 1 at $DIR/simple.rs:+2:10: +2:18 _5 = &mut (*_6); // scope 1 at $DIR/simple.rs:+2:10: +2:18 - _3 = move _4(move _5) -> bb1; // scope 1 at $DIR/simple.rs:+2:5: +2:19 +- _3 = move _4(move _5) -> bb1; // scope 1 at $DIR/simple.rs:+2:5: +2:19 ++ _3 = move _1(move _5) -> bb1; // scope 1 at $DIR/simple.rs:+2:5: +2:19 } bb1: { StorageDead(_5); // scope 1 at $DIR/simple.rs:+2:18: +2:19 - StorageDead(_4); // scope 1 at $DIR/simple.rs:+2:18: +2:19 +- StorageDead(_4); // scope 1 at $DIR/simple.rs:+2:18: +2:19 ++ nop; // scope 1 at $DIR/simple.rs:+2:18: +2:19 StorageDead(_6); // scope 1 at $DIR/simple.rs:+2:19: +2:20 StorageDead(_3); // scope 1 at $DIR/simple.rs:+2:19: +2:20 _0 = _2; // scope 1 at $DIR/simple.rs:+3:5: +3:8 diff --git a/src/test/mir-opt/dest-prop/simple.rs b/src/test/mir-opt/dest-prop/simple.rs index 3627d479a..d4c27228f 100644 --- a/src/test/mir-opt/dest-prop/simple.rs +++ b/src/test/mir-opt/dest-prop/simple.rs @@ -1,5 +1,5 @@ //! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too. -// compile-flags: -Zunsound-mir-opts +// unit-test: DestinationPropagation // EMIT_MIR simple.nrvo.DestinationPropagation.diff fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] { let mut buf = [0; 1024]; diff --git a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff index accdb0085..85d994bc8 100644 --- a/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff +++ b/src/test/mir-opt/dest-prop/union.main.DestinationPropagation.diff @@ -5,14 +5,13 @@ let mut _0: (); // return place in scope 0 at $DIR/union.rs:+0:11: +0:11 let _1: main::Un; // in scope 0 at $DIR/union.rs:+5:9: +5:11 let mut _2: u32; // in scope 0 at $DIR/union.rs:+5:23: +5:28 - let _3: (); // in scope 0 at $DIR/union.rs:+7:5: +7:27 - let mut _4: u32; // in scope 0 at $DIR/union.rs:+7:10: +7:26 + let mut _3: u32; // in scope 0 at $DIR/union.rs:+7:10: +7:26 scope 1 { debug un => _1; // in scope 1 at $DIR/union.rs:+5:9: +5:11 scope 2 { } scope 3 (inlined std::mem::drop::) { // at $DIR/union.rs:15:5: 15:27 - debug _x => _4; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL + debug _x => _3; // in scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL } } @@ -29,11 +28,9 @@ nop; // scope 0 at $DIR/union.rs:+5:14: +5:30 nop; // scope 0 at $DIR/union.rs:+5:14: +5:30 StorageDead(_2); // scope 0 at $DIR/union.rs:+5:29: +5:30 - StorageLive(_3); // scope 1 at $DIR/union.rs:+7:5: +7:27 - StorageLive(_4); // scope 1 at $DIR/union.rs:+7:10: +7:26 + StorageLive(_3); // scope 1 at $DIR/union.rs:+7:10: +7:26 nop; // scope 2 at $DIR/union.rs:+7:19: +7:24 - StorageDead(_4); // scope 1 at $DIR/union.rs:+7:26: +7:27 - StorageDead(_3); // scope 1 at $DIR/union.rs:+7:27: +7:28 + StorageDead(_3); // scope 1 at $DIR/union.rs:+7:26: +7:27 StorageDead(_1); // scope 0 at $DIR/union.rs:+8:1: +8:2 return; // scope 0 at $DIR/union.rs:+8:2: +8:2 } diff --git a/src/test/mir-opt/enum_cast.bar.mir_map.0.mir b/src/test/mir-opt/enum_cast.bar.mir_map.0.mir deleted file mode 100644 index e58085f70..000000000 --- a/src/test/mir-opt/enum_cast.bar.mir_map.0.mir +++ /dev/null @@ -1,17 +0,0 @@ -// MIR for `bar` 0 mir_map - -fn bar(_1: Bar) -> usize { - debug bar => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 - let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 - let _2: Bar; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 - return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 - } -} diff --git a/src/test/mir-opt/enum_cast.boo.mir_map.0.mir b/src/test/mir-opt/enum_cast.boo.mir_map.0.mir deleted file mode 100644 index 525c6234e..000000000 --- a/src/test/mir-opt/enum_cast.boo.mir_map.0.mir +++ /dev/null @@ -1,17 +0,0 @@ -// MIR for `boo` 0 mir_map - -fn boo(_1: Boo) -> usize { - debug boo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 - let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 - let _2: Boo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - let mut _3: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 - return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 - } -} diff --git a/src/test/mir-opt/enum_cast.droppy.mir_map.0.mir b/src/test/mir-opt/enum_cast.droppy.mir_map.0.mir deleted file mode 100644 index bb5faa480..000000000 --- a/src/test/mir-opt/enum_cast.droppy.mir_map.0.mir +++ /dev/null @@ -1,66 +0,0 @@ -// MIR for `droppy` 0 mir_map - -fn droppy() -> () { - let mut _0: (); // return place in scope 0 at $DIR/enum_cast.rs:+0:13: +0:13 - let _1: (); // in scope 0 at $DIR/enum_cast.rs:+1:5: +6:6 - let _2: Droppy; // in scope 0 at $DIR/enum_cast.rs:+2:13: +2:14 - let _4: Droppy; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18 - let mut _5: isize; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18 - let _6: Droppy; // in scope 0 at $DIR/enum_cast.rs:+7:9: +7:10 - scope 1 { - debug x => _2; // in scope 1 at $DIR/enum_cast.rs:+2:13: +2:14 - scope 2 { - debug y => _3; // in scope 2 at $DIR/enum_cast.rs:+5:13: +5:14 - } - scope 3 { - let _3: usize; // in scope 3 at $DIR/enum_cast.rs:+5:13: +5:14 - } - } - scope 4 { - debug z => _6; // in scope 4 at $DIR/enum_cast.rs:+7:9: +7:10 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/enum_cast.rs:+1:5: +6:6 - StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+2:13: +2:14 - _2 = Droppy::C; // scope 0 at $DIR/enum_cast.rs:+2:17: +2:26 - FakeRead(ForLet(None), _2); // scope 0 at $DIR/enum_cast.rs:+2:13: +2:14 - StorageLive(_3); // scope 3 at $DIR/enum_cast.rs:+5:13: +5:14 - StorageLive(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18 - _4 = move _2; // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18 - _5 = discriminant(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 - _3 = move _5 as usize (IntToInt); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27 - drop(_4) -> [return: bb1, unwind: bb4]; // scope 3 at $DIR/enum_cast.rs:+5:26: +5:27 - } - - bb1: { - StorageDead(_4); // scope 3 at $DIR/enum_cast.rs:+5:26: +5:27 - FakeRead(ForLet(None), _3); // scope 3 at $DIR/enum_cast.rs:+5:13: +5:14 - _1 = const (); // scope 0 at $DIR/enum_cast.rs:+1:5: +6:6 - StorageDead(_3); // scope 1 at $DIR/enum_cast.rs:+6:5: +6:6 - drop(_2) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 - } - - bb2: { - StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 - StorageDead(_1); // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 - StorageLive(_6); // scope 0 at $DIR/enum_cast.rs:+7:9: +7:10 - _6 = Droppy::B; // scope 0 at $DIR/enum_cast.rs:+7:13: +7:22 - FakeRead(ForLet(None), _6); // scope 0 at $DIR/enum_cast.rs:+7:9: +7:10 - _0 = const (); // scope 0 at $DIR/enum_cast.rs:+0:13: +8:2 - drop(_6) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/enum_cast.rs:+8:1: +8:2 - } - - bb3: { - StorageDead(_6); // scope 0 at $DIR/enum_cast.rs:+8:1: +8:2 - return; // scope 0 at $DIR/enum_cast.rs:+8:2: +8:2 - } - - bb4 (cleanup): { - drop(_2) -> bb5; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6 - } - - bb5 (cleanup): { - resume; // scope 0 at $DIR/enum_cast.rs:+0:1: +8:2 - } -} diff --git a/src/test/mir-opt/enum_cast.foo.mir_map.0.mir b/src/test/mir-opt/enum_cast.foo.mir_map.0.mir deleted file mode 100644 index a1d29a0b9..000000000 --- a/src/test/mir-opt/enum_cast.foo.mir_map.0.mir +++ /dev/null @@ -1,17 +0,0 @@ -// MIR for `foo` 0 mir_map - -fn foo(_1: Foo) -> usize { - debug foo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11 - let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26 - let _2: Foo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8 - _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17 - StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17 - return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2 - } -} diff --git a/src/test/mir-opt/enum_cast.rs b/src/test/mir-opt/enum_cast.rs deleted file mode 100644 index 090142aaf..000000000 --- a/src/test/mir-opt/enum_cast.rs +++ /dev/null @@ -1,50 +0,0 @@ -// EMIT_MIR enum_cast.foo.mir_map.0.mir -// EMIT_MIR enum_cast.bar.mir_map.0.mir -// EMIT_MIR enum_cast.boo.mir_map.0.mir - -enum Foo { - A -} - -enum Bar { - A, B -} - -#[repr(u8)] -enum Boo { - A, B -} - -fn foo(foo: Foo) -> usize { - foo as usize -} - -fn bar(bar: Bar) -> usize { - bar as usize -} - -fn boo(boo: Boo) -> usize { - boo as usize -} - -// EMIT_MIR enum_cast.droppy.mir_map.0.mir -enum Droppy { - A, B, C -} - -impl Drop for Droppy { - fn drop(&mut self) {} -} - -fn droppy() { - { - let x = Droppy::C; - // remove this entire test once `cenum_impl_drop_cast` becomes a hard error - #[allow(cenum_impl_drop_cast)] - let y = x as usize; - } - let z = Droppy::B; -} - -fn main() { -} diff --git a/src/test/mir-opt/exponential-or.rs b/src/test/mir-opt/exponential-or.rs deleted file mode 100644 index 0b8be8385..000000000 --- a/src/test/mir-opt/exponential-or.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Test that simple or-patterns don't get expanded to exponentially large CFGs - -// EMIT_MIR exponential_or.match_tuple.SimplifyCfg-initial.after.mir -fn match_tuple(x: (u32, bool, Option, u32)) -> u32 { - match x { - (y @ (1 | 4), true | false, Some(1 | 8) | None, z @ (6..=9 | 13..=16)) => y ^ z, - _ => 0, - } -} - -fn main() {} diff --git a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir index 96716a39a..08481777e 100644 --- a/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/exponential_or.match_tuple.SimplifyCfg-initial.after.mir @@ -1,83 +1,83 @@ // MIR for `match_tuple` after SimplifyCfg-initial fn match_tuple(_1: (u32, bool, Option, u32)) -> u32 { - debug x => _1; // in scope 0 at $DIR/exponential-or.rs:+0:16: +0:17 - let mut _0: u32; // return place in scope 0 at $DIR/exponential-or.rs:+0:53: +0:56 - let mut _2: isize; // in scope 0 at $DIR/exponential-or.rs:+2:37: +2:48 - let mut _3: bool; // in scope 0 at $DIR/exponential-or.rs:+2:70: +2:77 - let mut _4: bool; // in scope 0 at $DIR/exponential-or.rs:+2:70: +2:77 - let mut _5: bool; // in scope 0 at $DIR/exponential-or.rs:+2:62: +2:67 - let mut _6: bool; // in scope 0 at $DIR/exponential-or.rs:+2:62: +2:67 - let _7: u32; // in scope 0 at $DIR/exponential-or.rs:+2:10: +2:11 - let _8: u32; // in scope 0 at $DIR/exponential-or.rs:+2:57: +2:58 - let mut _9: u32; // in scope 0 at $DIR/exponential-or.rs:+2:83: +2:84 - let mut _10: u32; // in scope 0 at $DIR/exponential-or.rs:+2:87: +2:88 + debug x => _1; // in scope 0 at $DIR/exponential_or.rs:+0:16: +0:17 + let mut _0: u32; // return place in scope 0 at $DIR/exponential_or.rs:+0:53: +0:56 + let mut _2: isize; // in scope 0 at $DIR/exponential_or.rs:+2:37: +2:48 + let mut _3: bool; // in scope 0 at $DIR/exponential_or.rs:+2:70: +2:77 + let mut _4: bool; // in scope 0 at $DIR/exponential_or.rs:+2:70: +2:77 + let mut _5: bool; // in scope 0 at $DIR/exponential_or.rs:+2:62: +2:67 + let mut _6: bool; // in scope 0 at $DIR/exponential_or.rs:+2:62: +2:67 + let _7: u32; // in scope 0 at $DIR/exponential_or.rs:+2:10: +2:11 + let _8: u32; // in scope 0 at $DIR/exponential_or.rs:+2:57: +2:58 + let mut _9: u32; // in scope 0 at $DIR/exponential_or.rs:+2:83: +2:84 + let mut _10: u32; // in scope 0 at $DIR/exponential_or.rs:+2:87: +2:88 scope 1 { - debug y => _7; // in scope 1 at $DIR/exponential-or.rs:+2:10: +2:11 - debug z => _8; // in scope 1 at $DIR/exponential-or.rs:+2:57: +2:58 + debug y => _7; // in scope 1 at $DIR/exponential_or.rs:+2:10: +2:11 + debug z => _8; // in scope 1 at $DIR/exponential_or.rs:+2:57: +2:58 } bb0: { - FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/exponential-or.rs:+1:11: +1:12 - switchInt((_1.0: u32)) -> [1_u32: bb2, 4_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:15: +2:20 + FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/exponential_or.rs:+1:11: +1:12 + switchInt((_1.0: u32)) -> [1_u32: bb2, 4_u32: bb2, otherwise: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:15: +2:20 } bb1: { - _0 = const 0_u32; // scope 0 at $DIR/exponential-or.rs:+3:14: +3:15 - goto -> bb10; // scope 0 at $DIR/exponential-or.rs:+3:14: +3:15 + _0 = const 0_u32; // scope 0 at $DIR/exponential_or.rs:+3:14: +3:15 + goto -> bb10; // scope 0 at $DIR/exponential_or.rs:+3:14: +3:15 } bb2: { - _2 = discriminant((_1.2: std::option::Option)); // scope 0 at $DIR/exponential-or.rs:+2:37: +2:55 - switchInt(move _2) -> [0_isize: bb4, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:37: +2:55 + _2 = discriminant((_1.2: std::option::Option)); // scope 0 at $DIR/exponential_or.rs:+2:37: +2:55 + switchInt(move _2) -> [0_isize: bb4, 1_isize: bb3, otherwise: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:37: +2:55 } bb3: { - switchInt((((_1.2: std::option::Option) as Some).0: i32)) -> [1_i32: bb4, 8_i32: bb4, otherwise: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:37: +2:55 + switchInt((((_1.2: std::option::Option) as Some).0: i32)) -> [1_i32: bb4, 8_i32: bb4, otherwise: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:37: +2:55 } bb4: { - _5 = Le(const 6_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67 - switchInt(move _5) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67 + _5 = Le(const 6_u32, (_1.3: u32)); // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67 + switchInt(move _5) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67 } bb5: { - _6 = Le((_1.3: u32), const 9_u32); // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67 - switchInt(move _6) -> [false: bb6, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:+2:62: +2:67 + _6 = Le((_1.3: u32), const 9_u32); // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67 + switchInt(move _6) -> [false: bb6, otherwise: bb8]; // scope 0 at $DIR/exponential_or.rs:+2:62: +2:67 } bb6: { - _3 = Le(const 13_u32, (_1.3: u32)); // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77 - switchInt(move _3) -> [false: bb1, otherwise: bb7]; // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77 + _3 = Le(const 13_u32, (_1.3: u32)); // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77 + switchInt(move _3) -> [false: bb1, otherwise: bb7]; // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77 } bb7: { - _4 = Le((_1.3: u32), const 16_u32); // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77 - switchInt(move _4) -> [false: bb1, otherwise: bb8]; // scope 0 at $DIR/exponential-or.rs:+2:70: +2:77 + _4 = Le((_1.3: u32), const 16_u32); // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77 + switchInt(move _4) -> [false: bb1, otherwise: bb8]; // scope 0 at $DIR/exponential_or.rs:+2:70: +2:77 } bb8: { - falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/exponential-or.rs:+2:9: +2:79 + falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/exponential_or.rs:+2:9: +2:79 } bb9: { - StorageLive(_7); // scope 0 at $DIR/exponential-or.rs:+2:10: +2:11 - _7 = (_1.0: u32); // scope 0 at $DIR/exponential-or.rs:+2:10: +2:11 - StorageLive(_8); // scope 0 at $DIR/exponential-or.rs:+2:57: +2:58 - _8 = (_1.3: u32); // scope 0 at $DIR/exponential-or.rs:+2:57: +2:58 - StorageLive(_9); // scope 1 at $DIR/exponential-or.rs:+2:83: +2:84 - _9 = _7; // scope 1 at $DIR/exponential-or.rs:+2:83: +2:84 - StorageLive(_10); // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88 - _10 = _8; // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88 - _0 = BitXor(move _9, move _10); // scope 1 at $DIR/exponential-or.rs:+2:83: +2:88 - StorageDead(_10); // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88 - StorageDead(_9); // scope 1 at $DIR/exponential-or.rs:+2:87: +2:88 - StorageDead(_8); // scope 0 at $DIR/exponential-or.rs:+2:87: +2:88 - StorageDead(_7); // scope 0 at $DIR/exponential-or.rs:+2:87: +2:88 - goto -> bb10; // scope 0 at $DIR/exponential-or.rs:+2:87: +2:88 + StorageLive(_7); // scope 0 at $DIR/exponential_or.rs:+2:10: +2:11 + _7 = (_1.0: u32); // scope 0 at $DIR/exponential_or.rs:+2:10: +2:11 + StorageLive(_8); // scope 0 at $DIR/exponential_or.rs:+2:57: +2:58 + _8 = (_1.3: u32); // scope 0 at $DIR/exponential_or.rs:+2:57: +2:58 + StorageLive(_9); // scope 1 at $DIR/exponential_or.rs:+2:83: +2:84 + _9 = _7; // scope 1 at $DIR/exponential_or.rs:+2:83: +2:84 + StorageLive(_10); // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88 + _10 = _8; // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88 + _0 = BitXor(move _9, move _10); // scope 1 at $DIR/exponential_or.rs:+2:83: +2:88 + StorageDead(_10); // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88 + StorageDead(_9); // scope 1 at $DIR/exponential_or.rs:+2:87: +2:88 + StorageDead(_8); // scope 0 at $DIR/exponential_or.rs:+2:87: +2:88 + StorageDead(_7); // scope 0 at $DIR/exponential_or.rs:+2:87: +2:88 + goto -> bb10; // scope 0 at $DIR/exponential_or.rs:+2:87: +2:88 } bb10: { - return; // scope 0 at $DIR/exponential-or.rs:+5:2: +5:2 + return; // scope 0 at $DIR/exponential_or.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/exponential_or.rs b/src/test/mir-opt/exponential_or.rs new file mode 100644 index 000000000..0b8be8385 --- /dev/null +++ b/src/test/mir-opt/exponential_or.rs @@ -0,0 +1,11 @@ +// Test that simple or-patterns don't get expanded to exponentially large CFGs + +// EMIT_MIR exponential_or.match_tuple.SimplifyCfg-initial.after.mir +fn match_tuple(x: (u32, bool, Option, u32)) -> u32 { + match x { + (y @ (1 | 4), true | false, Some(1 | 8) | None, z @ (6..=9 | 13..=16)) => y ^ z, + _ => 0, + } +} + +fn main() {} diff --git a/src/test/mir-opt/fn-ptr-shim.rs b/src/test/mir-opt/fn-ptr-shim.rs deleted file mode 100644 index 64fbdc9de..000000000 --- a/src/test/mir-opt/fn-ptr-shim.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags: -Zmir-opt-level=0 - -// Tests that the `` shim does not create a `Call` terminator with a `Self` callee -// (as only `FnDef` and `FnPtr` callees are allowed in MIR). - -// EMIT_MIR core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir -fn main() { - call(noop as fn()); -} - -fn noop() {} - -fn call(f: F) { - f(); -} diff --git a/src/test/mir-opt/fn_ptr_shim.rs b/src/test/mir-opt/fn_ptr_shim.rs new file mode 100644 index 000000000..64fbdc9de --- /dev/null +++ b/src/test/mir-opt/fn_ptr_shim.rs @@ -0,0 +1,15 @@ +// compile-flags: -Zmir-opt-level=0 + +// Tests that the `` shim does not create a `Call` terminator with a `Self` callee +// (as only `FnDef` and `FnPtr` callees are allowed in MIR). + +// EMIT_MIR core.ops-function-Fn-call.AddMovesForPackedDrops.before.mir +fn main() { + call(noop as fn()); +} + +fn noop() {} + +fn call(f: F) { + f(); +} diff --git a/src/test/mir-opt/generator-drop-cleanup.rs b/src/test/mir-opt/generator-drop-cleanup.rs deleted file mode 100644 index 82c1292cb..000000000 --- a/src/test/mir-opt/generator-drop-cleanup.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(generators, generator_trait)] - -// ignore-wasm32-bare compiled with panic=abort by default - -// Regression test for #58892, generator drop shims should not have blocks -// spuriously marked as cleanup - -// EMIT_MIR generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir -fn main() { - let gen = || { - let _s = String::new(); - yield; - }; -} diff --git a/src/test/mir-opt/generator-storage-dead-unwind.rs b/src/test/mir-opt/generator-storage-dead-unwind.rs deleted file mode 100644 index b72170ade..000000000 --- a/src/test/mir-opt/generator-storage-dead-unwind.rs +++ /dev/null @@ -1,29 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default - -// Test that we generate StorageDead on unwind paths for generators. -// -// Basic block and local names can safely change, but the StorageDead statements -// should not go away. - -#![feature(generators, generator_trait)] - -struct Foo(i32); - -impl Drop for Foo { - fn drop(&mut self) {} -} - -struct Bar(i32); - -fn take(_x: T) {} - -// EMIT_MIR generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir -fn main() { - let _gen = || { - let a = Foo(5); - let b = Bar(6); - yield; - take(a); - take(b); - }; -} diff --git a/src/test/mir-opt/generator-tiny.rs b/src/test/mir-opt/generator-tiny.rs deleted file mode 100644 index 7dad63a61..000000000 --- a/src/test/mir-opt/generator-tiny.rs +++ /dev/null @@ -1,26 +0,0 @@ -//! Tests that generators that cannot return or unwind don't have unnecessary -//! panic branches. - -// compile-flags: -C panic=abort -// no-prefer-dynamic - -#![feature(generators, generator_trait)] - -struct HasDrop; - -impl Drop for HasDrop { - fn drop(&mut self) {} -} - -fn callee() {} - -// EMIT_MIR generator_tiny.main-{closure#0}.generator_resume.0.mir -fn main() { - let _gen = |_x: u8| { - let _d = HasDrop; - loop { - yield; - callee(); - } - }; -} diff --git a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir index c718138b6..c3b08bf06 100644 --- a/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir +++ b/src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir @@ -14,71 +14,71 @@ }, } */ -fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 10:17]) -> () { - let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 - let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 - let _3: std::string::String; // in scope 0 at $DIR/generator-drop-cleanup.rs:+1:13: +1:15 - let _4: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+2:9: +2:14 - let mut _5: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+2:9: +2:14 - let mut _6: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:18: +0:18 - let mut _7: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 - let mut _8: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 +fn main::{closure#0}(_1: *mut [generator@$DIR/generator_drop_cleanup.rs:10:15: 10:17]) -> () { + let mut _0: (); // return place in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 + let mut _2: (); // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 + let _3: std::string::String; // in scope 0 at $DIR/generator_drop_cleanup.rs:+1:13: +1:15 + let _4: (); // in scope 0 at $DIR/generator_drop_cleanup.rs:+2:9: +2:14 + let mut _5: (); // in scope 0 at $DIR/generator_drop_cleanup.rs:+2:9: +2:14 + let mut _6: (); // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:18: +0:18 + let mut _7: (); // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 + let mut _8: u32; // in scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 scope 1 { - debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:+1:13: +1:15 + debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator_drop_cleanup.rs:+1:13: +1:15 } bb0: { - _8 = discriminant((*_1)); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 - switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + _8 = discriminant((*_1)); // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 + switchInt(move _8) -> [0_u32: bb7, 3_u32: bb10, otherwise: bb11]; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } bb1: { - StorageDead(_5); // scope 1 at $DIR/generator-drop-cleanup.rs:+2:13: +2:14 - StorageDead(_4); // scope 1 at $DIR/generator-drop-cleanup.rs:+2:14: +2:15 - drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 + StorageDead(_5); // scope 1 at $DIR/generator_drop_cleanup.rs:+2:13: +2:14 + StorageDead(_4); // scope 1 at $DIR/generator_drop_cleanup.rs:+2:14: +2:15 + drop((((*_1) as variant#3).0: std::string::String)) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6 } bb2: { - nop; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 - goto -> bb8; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 + nop; // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6 + goto -> bb8; // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6 } bb3: { - return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + return; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } bb4 (cleanup): { - resume; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + resume; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } bb5 (cleanup): { - nop; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 - goto -> bb4; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 + nop; // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6 + goto -> bb4; // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6 } bb6: { - return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + return; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } bb7: { - goto -> bb9; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + goto -> bb9; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } bb8: { - goto -> bb3; // scope 0 at $DIR/generator-drop-cleanup.rs:+3:5: +3:6 + goto -> bb3; // scope 0 at $DIR/generator_drop_cleanup.rs:+3:5: +3:6 } bb9: { - goto -> bb6; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + goto -> bb6; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } bb10: { - StorageLive(_4); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 - StorageLive(_5); // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 - goto -> bb1; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + StorageLive(_4); // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 + StorageLive(_5); // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 + goto -> bb1; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } bb11: { - return; // scope 0 at $DIR/generator-drop-cleanup.rs:+0:15: +3:6 + return; // scope 0 at $DIR/generator_drop_cleanup.rs:+0:15: +3:6 } } diff --git a/src/test/mir-opt/generator_drop_cleanup.rs b/src/test/mir-opt/generator_drop_cleanup.rs new file mode 100644 index 000000000..82c1292cb --- /dev/null +++ b/src/test/mir-opt/generator_drop_cleanup.rs @@ -0,0 +1,14 @@ +#![feature(generators, generator_trait)] + +// ignore-wasm32-bare compiled with panic=abort by default + +// Regression test for #58892, generator drop shims should not have blocks +// spuriously marked as cleanup + +// EMIT_MIR generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir +fn main() { + let gen = || { + let _s = String::new(); + yield; + }; +} diff --git a/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir b/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir index 3184343f2..cfbe0aaf2 100644 --- a/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir +++ b/src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir @@ -1,124 +1,124 @@ // MIR for `main::{closure#0}` before StateTransform -fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 22:18], _2: ()) -> () +fn main::{closure#0}(_1: [generator@$DIR/generator_storage_dead_unwind.rs:22:16: 22:18], _2: ()) -> () yields () { - let mut _0: (); // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:19: +0:19 - let _3: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14 - let _5: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 - let mut _6: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 - let _7: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16 - let mut _8: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15 - let _9: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16 - let mut _10: Bar; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15 + let mut _0: (); // return place in scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:19: +0:19 + let _3: Foo; // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+1:13: +1:14 + let _5: (); // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14 + let mut _6: (); // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14 + let _7: (); // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+4:9: +4:16 + let mut _8: Foo; // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+4:14: +4:15 + let _9: (); // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+5:9: +5:16 + let mut _10: Bar; // in scope 0 at $DIR/generator_storage_dead_unwind.rs:+5:14: +5:15 scope 1 { - debug a => _3; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14 - let _4: Bar; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14 + debug a => _3; // in scope 1 at $DIR/generator_storage_dead_unwind.rs:+1:13: +1:14 + let _4: Bar; // in scope 1 at $DIR/generator_storage_dead_unwind.rs:+2:13: +2:14 scope 2 { - debug b => _4; // in scope 2 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14 + debug b => _4; // in scope 2 at $DIR/generator_storage_dead_unwind.rs:+2:13: +2:14 } } bb0: { - StorageLive(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:13: +1:14 - _3 = Foo(const 5_i32); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+1:17: +1:23 - StorageLive(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:13: +2:14 - _4 = Bar(const 6_i32); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+2:17: +2:23 - StorageLive(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 - StorageLive(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 - _6 = (); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 - _5 = yield(move _6) -> [resume: bb1, drop: bb6]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:9: +3:14 + StorageLive(_3); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+1:13: +1:14 + _3 = Foo(const 5_i32); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+1:17: +1:23 + StorageLive(_4); // scope 1 at $DIR/generator_storage_dead_unwind.rs:+2:13: +2:14 + _4 = Bar(const 6_i32); // scope 1 at $DIR/generator_storage_dead_unwind.rs:+2:17: +2:23 + StorageLive(_5); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14 + StorageLive(_6); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14 + _6 = (); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14 + _5 = yield(move _6) -> [resume: bb1, drop: bb6]; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:9: +3:14 } bb1: { - StorageDead(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:13: +3:14 - StorageDead(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:14: +3:15 - StorageLive(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16 - StorageLive(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15 - _8 = move _3; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:14: +4:15 - _7 = take::(move _8) -> [return: bb2, unwind: bb10]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:9: +4:16 + StorageDead(_6); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:13: +3:14 + StorageDead(_5); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:14: +3:15 + StorageLive(_7); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:9: +4:16 + StorageLive(_8); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:14: +4:15 + _8 = move _3; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:14: +4:15 + _7 = take::(move _8) -> [return: bb2, unwind: bb10]; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:9: +4:16 // mir::Constant - // + span: $DIR/generator-storage-dead-unwind.rs:26:9: 26:13 + // + span: $DIR/generator_storage_dead_unwind.rs:26:9: 26:13 // + literal: Const { ty: fn(Foo) {take::}, val: Value() } } bb2: { - StorageDead(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16 - StorageDead(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:16: +4:17 - StorageLive(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16 - StorageLive(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15 - _10 = move _4; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:14: +5:15 - _9 = take::(move _10) -> [return: bb3, unwind: bb9]; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:9: +5:16 + StorageDead(_8); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:15: +4:16 + StorageDead(_7); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:16: +4:17 + StorageLive(_9); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:9: +5:16 + StorageLive(_10); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:14: +5:15 + _10 = move _4; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:14: +5:15 + _9 = take::(move _10) -> [return: bb3, unwind: bb9]; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:9: +5:16 // mir::Constant - // + span: $DIR/generator-storage-dead-unwind.rs:27:9: 27:13 + // + span: $DIR/generator_storage_dead_unwind.rs:27:9: 27:13 // + literal: Const { ty: fn(Bar) {take::}, val: Value() } } bb3: { - StorageDead(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:15: +5:16 - StorageDead(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:16: +5:17 - _0 = const (); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:19: +6:6 - StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 - goto -> bb4; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + StorageDead(_10); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:15: +5:16 + StorageDead(_9); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:16: +5:17 + _0 = const (); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:19: +6:6 + StorageDead(_4); // scope 1 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + goto -> bb4; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } bb4: { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 - drop(_1) -> [return: bb5, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + StorageDead(_3); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + drop(_1) -> [return: bb5, unwind: bb14]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } bb5: { - return; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:6: +6:6 + return; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:6: +6:6 } bb6: { - StorageDead(_6); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:13: +3:14 - StorageDead(_5); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+3:14: +3:15 - StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 - drop(_3) -> [return: bb7, unwind: bb15]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + StorageDead(_6); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:13: +3:14 + StorageDead(_5); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+3:14: +3:15 + StorageDead(_4); // scope 1 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + drop(_3) -> [return: bb7, unwind: bb15]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } bb7: { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 - drop(_1) -> [return: bb8, unwind: bb14]; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + StorageDead(_3); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + drop(_1) -> [return: bb8, unwind: bb14]; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } bb8: { - generator_drop; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +6:6 + generator_drop; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:16: +6:6 } bb9 (cleanup): { - StorageDead(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:15: +5:16 - StorageDead(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+5:16: +5:17 + StorageDead(_10); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:15: +5:16 + StorageDead(_9); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+5:16: +5:17 goto -> bb12; // scope 2 at no-location } bb10 (cleanup): { - goto -> bb11; // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16 + goto -> bb11; // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:15: +4:16 } bb11 (cleanup): { - StorageDead(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:15: +4:16 - StorageDead(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:+4:16: +4:17 + StorageDead(_8); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:15: +4:16 + StorageDead(_7); // scope 2 at $DIR/generator_storage_dead_unwind.rs:+4:16: +4:17 goto -> bb12; // scope 2 at no-location } bb12 (cleanup): { - StorageDead(_4); // scope 1 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 - goto -> bb13; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + StorageDead(_4); // scope 1 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + goto -> bb13; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } bb13 (cleanup): { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 - drop(_1) -> bb14; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + StorageDead(_3); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + drop(_1) -> bb14; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } bb14 (cleanup): { - resume; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+0:16: +6:6 + resume; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+0:16: +6:6 } bb15 (cleanup): { - StorageDead(_3); // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 - drop(_1) -> bb14; // scope 0 at $DIR/generator-storage-dead-unwind.rs:+6:5: +6:6 + StorageDead(_3); // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 + drop(_1) -> bb14; // scope 0 at $DIR/generator_storage_dead_unwind.rs:+6:5: +6:6 } } diff --git a/src/test/mir-opt/generator_storage_dead_unwind.rs b/src/test/mir-opt/generator_storage_dead_unwind.rs new file mode 100644 index 000000000..b72170ade --- /dev/null +++ b/src/test/mir-opt/generator_storage_dead_unwind.rs @@ -0,0 +1,29 @@ +// ignore-wasm32-bare compiled with panic=abort by default + +// Test that we generate StorageDead on unwind paths for generators. +// +// Basic block and local names can safely change, but the StorageDead statements +// should not go away. + +#![feature(generators, generator_trait)] + +struct Foo(i32); + +impl Drop for Foo { + fn drop(&mut self) {} +} + +struct Bar(i32); + +fn take(_x: T) {} + +// EMIT_MIR generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir +fn main() { + let _gen = || { + let a = Foo(5); + let b = Bar(6); + yield; + take(a); + take(b); + }; +} diff --git a/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir b/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir index 07aeeaae0..fee6da2c6 100644 --- a/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir +++ b/src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir @@ -14,71 +14,71 @@ }, } */ -fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]>, _2: u8) -> GeneratorState<(), ()> { - debug _x => _10; // in scope 0 at $DIR/generator-tiny.rs:+0:17: +0:19 - let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - let _3: HasDrop; // in scope 0 at $DIR/generator-tiny.rs:+1:13: +1:15 - let mut _4: !; // in scope 0 at $DIR/generator-tiny.rs:+2:9: +5:10 - let mut _5: (); // in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - let _6: u8; // in scope 0 at $DIR/generator-tiny.rs:+3:13: +3:18 - let mut _7: (); // in scope 0 at $DIR/generator-tiny.rs:+3:13: +3:18 - let _8: (); // in scope 0 at $DIR/generator-tiny.rs:+4:13: +4:21 - let mut _9: (); // in scope 0 at $DIR/generator-tiny.rs:+0:25: +0:25 - let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:+0:17: +0:19 - let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 +fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator_tiny.rs:19:16: 19:24]>, _2: u8) -> GeneratorState<(), ()> { + debug _x => _10; // in scope 0 at $DIR/generator_tiny.rs:+0:17: +0:19 + let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + let _3: HasDrop; // in scope 0 at $DIR/generator_tiny.rs:+1:13: +1:15 + let mut _4: !; // in scope 0 at $DIR/generator_tiny.rs:+2:9: +5:10 + let mut _5: (); // in scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + let _6: u8; // in scope 0 at $DIR/generator_tiny.rs:+3:13: +3:18 + let mut _7: (); // in scope 0 at $DIR/generator_tiny.rs:+3:13: +3:18 + let _8: (); // in scope 0 at $DIR/generator_tiny.rs:+4:13: +4:21 + let mut _9: (); // in scope 0 at $DIR/generator_tiny.rs:+0:25: +0:25 + let _10: u8; // in scope 0 at $DIR/generator_tiny.rs:+0:17: +0:19 + let mut _11: u32; // in scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 scope 1 { - debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:+1:13: +1:15 + debug _d => (((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator_tiny.rs:+1:13: +1:15 } bb0: { - _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24]))); // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 } bb1: { - _10 = move _2; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - nop; // scope 0 at $DIR/generator-tiny.rs:+1:13: +1:15 - (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator-tiny.rs:+1:18: +1:25 - StorageLive(_4); // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10 - goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10 + _10 = move _2; // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + nop; // scope 0 at $DIR/generator_tiny.rs:+1:13: +1:15 + (((*(_1.0: &mut [generator@$DIR/generator_tiny.rs:19:16: 19:24])) as variant#3).0: HasDrop) = HasDrop; // scope 0 at $DIR/generator_tiny.rs:+1:18: +1:25 + StorageLive(_4); // scope 1 at $DIR/generator_tiny.rs:+2:9: +5:10 + goto -> bb2; // scope 1 at $DIR/generator_tiny.rs:+2:9: +5:10 } bb2: { - 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 - 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 + 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 + 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 } bb3: { - StorageDead(_7); // scope 1 at $DIR/generator-tiny.rs:+3:17: +3:18 - StorageDead(_6); // scope 1 at $DIR/generator-tiny.rs:+3:18: +3:19 - StorageLive(_8); // scope 1 at $DIR/generator-tiny.rs:+4:13: +4:21 - _8 = callee() -> bb4; // scope 1 at $DIR/generator-tiny.rs:+4:13: +4:21 + StorageDead(_7); // scope 1 at $DIR/generator_tiny.rs:+3:17: +3:18 + StorageDead(_6); // scope 1 at $DIR/generator_tiny.rs:+3:18: +3:19 + StorageLive(_8); // scope 1 at $DIR/generator_tiny.rs:+4:13: +4:21 + _8 = callee() -> bb4; // scope 1 at $DIR/generator_tiny.rs:+4:13: +4:21 // mir::Constant - // + span: $DIR/generator-tiny.rs:23:13: 23:19 + // + span: $DIR/generator_tiny.rs:23:13: 23:19 // + literal: Const { ty: fn() {callee}, val: Value() } } bb4: { - StorageDead(_8); // scope 1 at $DIR/generator-tiny.rs:+4:21: +4:22 - _5 = const (); // scope 1 at $DIR/generator-tiny.rs:+2:14: +5:10 - goto -> bb2; // scope 1 at $DIR/generator-tiny.rs:+2:9: +5:10 + StorageDead(_8); // scope 1 at $DIR/generator_tiny.rs:+4:21: +4:22 + _5 = const (); // scope 1 at $DIR/generator_tiny.rs:+2:14: +5:10 + goto -> bb2; // scope 1 at $DIR/generator_tiny.rs:+2:9: +5:10 } bb5: { - StorageLive(_4); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - StorageLive(_6); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - StorageLive(_7); // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - _6 = move _2; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 - goto -> bb3; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + StorageLive(_4); // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + StorageLive(_6); // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + StorageLive(_7); // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + _6 = move _2; // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 + goto -> bb3; // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 } bb6: { - unreachable; // scope 0 at $DIR/generator-tiny.rs:+0:16: +6:6 + unreachable; // scope 0 at $DIR/generator_tiny.rs:+0:16: +6:6 } } diff --git a/src/test/mir-opt/generator_tiny.rs b/src/test/mir-opt/generator_tiny.rs new file mode 100644 index 000000000..7dad63a61 --- /dev/null +++ b/src/test/mir-opt/generator_tiny.rs @@ -0,0 +1,26 @@ +//! Tests that generators that cannot return or unwind don't have unnecessary +//! panic branches. + +// compile-flags: -C panic=abort +// no-prefer-dynamic + +#![feature(generators, generator_trait)] + +struct HasDrop; + +impl Drop for HasDrop { + fn drop(&mut self) {} +} + +fn callee() {} + +// EMIT_MIR generator_tiny.main-{closure#0}.generator_resume.0.mir +fn main() { + let _gen = |_x: u8| { + let _d = HasDrop; + loop { + yield; + callee(); + } + }; +} diff --git a/src/test/mir-opt/graphviz.main.built.after.dot b/src/test/mir-opt/graphviz.main.built.after.dot new file mode 100644 index 000000000..8d1da7f1b --- /dev/null +++ b/src/test/mir-opt/graphviz.main.built.after.dot @@ -0,0 +1,7 @@ +digraph Mir_0_3 { + graph [fontname="Courier, monospace"]; + node [fontname="Courier, monospace"]; + edge [fontname="Courier, monospace"]; + label=>; + bb0__0_3 [shape="none", label=<
0
_0 = const ()
return
>]; +} diff --git a/src/test/mir-opt/graphviz.main.mir_map.0.dot b/src/test/mir-opt/graphviz.main.mir_map.0.dot deleted file mode 100644 index 8d1da7f1b..000000000 --- a/src/test/mir-opt/graphviz.main.mir_map.0.dot +++ /dev/null @@ -1,7 +0,0 @@ -digraph Mir_0_3 { - graph [fontname="Courier, monospace"]; - node [fontname="Courier, monospace"]; - edge [fontname="Courier, monospace"]; - label=>; - bb0__0_3 [shape="none", label=<
0
_0 = const ()
return
>]; -} diff --git a/src/test/mir-opt/graphviz.rs b/src/test/mir-opt/graphviz.rs index 074dba2c3..6906b86c2 100644 --- a/src/test/mir-opt/graphviz.rs +++ b/src/test/mir-opt/graphviz.rs @@ -1,5 +1,5 @@ // Test graphviz output // compile-flags: -Z dump-mir-graphviz -// EMIT_MIR graphviz.main.mir_map.0.dot +// EMIT_MIR graphviz.main.built.after.dot fn main() {} diff --git a/src/test/mir-opt/if-condition-int.rs b/src/test/mir-opt/if-condition-int.rs deleted file mode 100644 index 398311e6b..000000000 --- a/src/test/mir-opt/if-condition-int.rs +++ /dev/null @@ -1,65 +0,0 @@ -// unit-test: SimplifyComparisonIntegral -// EMIT_MIR if_condition_int.opt_u32.SimplifyComparisonIntegral.diff -// EMIT_MIR if_condition_int.opt_negative.SimplifyComparisonIntegral.diff -// EMIT_MIR if_condition_int.opt_char.SimplifyComparisonIntegral.diff -// EMIT_MIR if_condition_int.opt_i8.SimplifyComparisonIntegral.diff -// EMIT_MIR if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff -// EMIT_MIR if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff -// EMIT_MIR if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff -// EMIT_MIR if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff - -fn opt_u32(x: u32) -> u32 { - if x == 42 { 0 } else { 1 } -} - -// don't opt: it is already optimal to switch on the bool -fn dont_opt_bool(x: bool) -> u32 { - if x { 0 } else { 1 } -} - -fn opt_char(x: char) -> u32 { - if x == 'x' { 0 } else { 1 } -} - -fn opt_i8(x: i8) -> u32 { - if x == 42 { 0 } else { 1 } -} - -fn opt_negative(x: i32) -> u32 { - if x == -42 { 0 } else { 1 } -} - -fn opt_multiple_ifs(x: u32) -> u32 { - if x == 42 { - 0 - } else if x != 21 { - 1 - } else { - 2 - } -} - -// test that we optimize, but do not remove the b statement, as that is used later on -fn dont_remove_comparison(a: i8) -> i32 { - let b = a == 17; - match b { - false => 10 + b as i32, - true => 100 + b as i32, - } -} - -// test that we do not optimize on floats -fn dont_opt_floats(a: f32) -> i32 { - if a == -42.0 { 0 } else { 1 } -} - -fn main() { - opt_u32(0); - opt_char('0'); - opt_i8(22); - dont_opt_bool(false); - opt_negative(0); - opt_multiple_ifs(0); - dont_remove_comparison(11); - dont_opt_floats(1.0); -} diff --git a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff index 19b5ab441..94180d203 100644 --- a/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff @@ -2,29 +2,29 @@ + // MIR for `dont_opt_bool` after SimplifyComparisonIntegral fn dont_opt_bool(_1: bool) -> u32 { - debug x => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:18: +0:19 - let mut _0: u32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:30: +0:33 - let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 + debug x => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:18: +0:19 + let mut _0: u32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:30: +0:33 + let mut _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _2 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _2 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 } bb1: { - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:+1:12: +1:13 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:26 + _0 = const 0_u32; // scope 0 at $DIR/if_condition_int.rs:+1:12: +1:13 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:26 } bb2: { - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:+1:23: +1:24 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:26 + _0 = const 1_u32; // scope 0 at $DIR/if_condition_int.rs:+1:23: +1:24 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:26 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+1:25: +1:26 - return; // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+1:25: +1:26 + return; // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff index 256af7b94..b22c7eac6 100644 --- a/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff @@ -2,33 +2,33 @@ + // MIR for `dont_opt_floats` after SimplifyComparisonIntegral fn dont_opt_floats(_1: f32) -> i32 { - debug a => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:20: +0:21 - let mut _0: i32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:31: +0:34 - let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18 - let mut _3: f32; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 + debug a => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:20: +0:21 + let mut _0: i32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:31: +0:34 + let mut _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18 + let mut _3: f32; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18 - StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _2 = Eq(move _3, const -42f32); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18 - StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:17: +1:18 - switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:18 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18 + StorageLive(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _3 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _2 = Eq(move _3, const -42f32); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18 + StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:17: +1:18 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:18 } bb1: { - _0 = const 0_i32; // scope 0 at $DIR/if-condition-int.rs:+1:21: +1:22 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:35 + _0 = const 0_i32; // scope 0 at $DIR/if_condition_int.rs:+1:21: +1:22 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:35 } bb2: { - _0 = const 1_i32; // scope 0 at $DIR/if-condition-int.rs:+1:32: +1:33 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:35 + _0 = const 1_i32; // scope 0 at $DIR/if_condition_int.rs:+1:32: +1:33 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:35 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+1:34: +1:35 - return; // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+1:34: +1:35 + return; // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff index ed53c9a95..cc0995f99 100644 --- a/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff @@ -2,57 +2,57 @@ + // MIR for `dont_remove_comparison` after SimplifyComparisonIntegral fn dont_remove_comparison(_1: i8) -> i32 { - debug a => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:27: +0:28 - let mut _0: i32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:37: +0:40 - let _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:9: +1:10 - let mut _3: i8; // in scope 0 at $DIR/if-condition-int.rs:+1:13: +1:14 - let mut _4: i32; // in scope 0 at $DIR/if-condition-int.rs:+3:23: +3:31 - let mut _5: bool; // in scope 0 at $DIR/if-condition-int.rs:+3:23: +3:24 - let mut _6: i32; // in scope 0 at $DIR/if-condition-int.rs:+4:23: +4:31 - let mut _7: bool; // in scope 0 at $DIR/if-condition-int.rs:+4:23: +4:24 + debug a => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:27: +0:28 + let mut _0: i32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:37: +0:40 + let _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:9: +1:10 + let mut _3: i8; // in scope 0 at $DIR/if_condition_int.rs:+1:13: +1:14 + let mut _4: i32; // in scope 0 at $DIR/if_condition_int.rs:+3:23: +3:31 + let mut _5: bool; // in scope 0 at $DIR/if_condition_int.rs:+3:23: +3:24 + let mut _6: i32; // in scope 0 at $DIR/if_condition_int.rs:+4:23: +4:31 + let mut _7: bool; // in scope 0 at $DIR/if_condition_int.rs:+4:23: +4:24 scope 1 { - debug b => _2; // in scope 1 at $DIR/if-condition-int.rs:+1:9: +1:10 + debug b => _2; // in scope 1 at $DIR/if_condition_int.rs:+1:9: +1:10 } bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:14 - _3 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:14 -- _2 = Eq(move _3, const 17_i8); // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:20 -- StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20 -- switchInt(_2) -> [false: bb2, otherwise: bb1]; // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12 -+ _2 = Eq(_3, const 17_i8); // scope 0 at $DIR/if-condition-int.rs:+1:13: +1:20 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20 -+ switchInt(move _3) -> [17_i8: bb1, otherwise: bb2]; // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:9: +1:10 + StorageLive(_3); // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:14 + _3 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:14 +- _2 = Eq(move _3, const 17_i8); // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:20 +- StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20 +- switchInt(_2) -> [false: bb2, otherwise: bb1]; // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12 ++ _2 = Eq(_3, const 17_i8); // scope 0 at $DIR/if_condition_int.rs:+1:13: +1:20 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20 ++ switchInt(move _3) -> [17_i8: bb1, otherwise: bb2]; // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12 } bb1: { -+ StorageDead(_3); // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12 - StorageLive(_6); // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:31 - StorageLive(_7); // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:24 - _7 = _2; // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:24 - _6 = move _7 as i32 (IntToInt); // scope 1 at $DIR/if-condition-int.rs:+4:23: +4:31 - StorageDead(_7); // scope 1 at $DIR/if-condition-int.rs:+4:30: +4:31 - _0 = Add(const 100_i32, move _6); // scope 1 at $DIR/if-condition-int.rs:+4:17: +4:31 - StorageDead(_6); // scope 1 at $DIR/if-condition-int.rs:+4:30: +4:31 - goto -> bb3; // scope 1 at $DIR/if-condition-int.rs:+4:30: +4:31 ++ StorageDead(_3); // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12 + StorageLive(_6); // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:31 + StorageLive(_7); // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:24 + _7 = _2; // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:24 + _6 = move _7 as i32 (IntToInt); // scope 1 at $DIR/if_condition_int.rs:+4:23: +4:31 + StorageDead(_7); // scope 1 at $DIR/if_condition_int.rs:+4:30: +4:31 + _0 = Add(const 100_i32, move _6); // scope 1 at $DIR/if_condition_int.rs:+4:17: +4:31 + StorageDead(_6); // scope 1 at $DIR/if_condition_int.rs:+4:30: +4:31 + goto -> bb3; // scope 1 at $DIR/if_condition_int.rs:+4:30: +4:31 } bb2: { -+ StorageDead(_3); // scope 1 at $DIR/if-condition-int.rs:+2:5: +2:12 - StorageLive(_4); // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:31 - StorageLive(_5); // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:24 - _5 = _2; // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:24 - _4 = move _5 as i32 (IntToInt); // scope 1 at $DIR/if-condition-int.rs:+3:23: +3:31 - StorageDead(_5); // scope 1 at $DIR/if-condition-int.rs:+3:30: +3:31 - _0 = Add(const 10_i32, move _4); // scope 1 at $DIR/if-condition-int.rs:+3:18: +3:31 - StorageDead(_4); // scope 1 at $DIR/if-condition-int.rs:+3:30: +3:31 - goto -> bb3; // scope 1 at $DIR/if-condition-int.rs:+3:30: +3:31 ++ StorageDead(_3); // scope 1 at $DIR/if_condition_int.rs:+2:5: +2:12 + StorageLive(_4); // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:31 + StorageLive(_5); // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:24 + _5 = _2; // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:24 + _4 = move _5 as i32 (IntToInt); // scope 1 at $DIR/if_condition_int.rs:+3:23: +3:31 + StorageDead(_5); // scope 1 at $DIR/if_condition_int.rs:+3:30: +3:31 + _0 = Add(const 10_i32, move _4); // scope 1 at $DIR/if_condition_int.rs:+3:18: +3:31 + StorageDead(_4); // scope 1 at $DIR/if_condition_int.rs:+3:30: +3:31 + goto -> bb3; // scope 1 at $DIR/if_condition_int.rs:+3:30: +3:31 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+6:1: +6:2 - return; // scope 0 at $DIR/if-condition-int.rs:+6:2: +6:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+6:1: +6:2 + return; // scope 0 at $DIR/if_condition_int.rs:+6:2: +6:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff index 9b64c379f..801ea0402 100644 --- a/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff @@ -2,38 +2,38 @@ + // MIR for `opt_char` after SimplifyComparisonIntegral fn opt_char(_1: char) -> u32 { - debug x => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:13: +0:14 - let mut _0: u32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:25: +0:28 - let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - let mut _3: char; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 + debug x => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:13: +0:14 + let mut _0: u32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:25: +0:28 + let mut _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + let mut _3: char; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 -- _2 = Eq(move _3, const 'x'); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 -- StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16 -- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16 -+ switchInt(move _3) -> ['x': bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + StorageLive(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _3 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 +- _2 = Eq(move _3, const 'x'); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 +- StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16 ++ switchInt(move _3) -> ['x': bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 } bb1: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + _0 = const 0_u32; // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33 } bb2: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:+1:30: +1:31 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + _0 = const 1_u32; // scope 0 at $DIR/if_condition_int.rs:+1:30: +1:31 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+1:32: +1:33 - return; // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+1:32: +1:33 + return; // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff index 8042d63bb..4297f4d64 100644 --- a/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff @@ -2,38 +2,38 @@ + // MIR for `opt_i8` after SimplifyComparisonIntegral fn opt_i8(_1: i8) -> u32 { - debug x => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:11: +0:12 - let mut _0: u32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:21: +0:24 - let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - let mut _3: i8; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 + debug x => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:11: +0:12 + let mut _0: u32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:21: +0:24 + let mut _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + let mut _3: i8; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 -- _2 = Eq(move _3, const 42_i8); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -- StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15 -- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15 -+ switchInt(move _3) -> [42_i8: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + StorageLive(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _3 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 +- _2 = Eq(move _3, const 42_i8); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 +- StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15 ++ switchInt(move _3) -> [42_i8: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 } bb1: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:+1:18: +1:19 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + _0 = const 0_u32; // scope 0 at $DIR/if_condition_int.rs:+1:18: +1:19 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32 } bb2: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:+1:29: +1:30 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + _0 = const 1_u32; // scope 0 at $DIR/if_condition_int.rs:+1:29: +1:30 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+1:31: +1:32 - return; // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+1:31: +1:32 + return; // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff index a408de1ef..8fb794abb 100644 --- a/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff @@ -2,64 +2,64 @@ + // MIR for `opt_multiple_ifs` after SimplifyComparisonIntegral fn opt_multiple_ifs(_1: u32) -> u32 { - debug x => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:21: +0:22 - let mut _0: u32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:32: +0:35 - let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - let mut _3: u32; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - let mut _4: bool; // in scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 - let mut _5: u32; // in scope 0 at $DIR/if-condition-int.rs:+3:15: +3:16 + debug x => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:21: +0:22 + let mut _0: u32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:32: +0:35 + let mut _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + let mut _3: u32; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + let mut _4: bool; // in scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 + let mut _5: u32; // in scope 0 at $DIR/if_condition_int.rs:+3:15: +3:16 bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 -- _2 = Eq(move _3, const 42_u32); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -- StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15 -- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15 -+ switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + StorageLive(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _3 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 +- _2 = Eq(move _3, const 42_u32); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 +- StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15 ++ switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 } bb1: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:+2:9: +2:10 - goto -> bb6; // scope 0 at $DIR/if-condition-int.rs:+1:5: +7:6 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + _0 = const 0_u32; // scope 0 at $DIR/if_condition_int.rs:+2:9: +2:10 + goto -> bb6; // scope 0 at $DIR/if_condition_int.rs:+1:5: +7:6 } bb2: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - StorageLive(_4); // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 - StorageLive(_5); // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:16 - _5 = _1; // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:16 -- _4 = Ne(move _5, const 21_u32); // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 -- StorageDead(_5); // scope 0 at $DIR/if-condition-int.rs:+3:21: +3:22 -- switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+3:21: +3:22 -+ switchInt(move _5) -> [21_u32: bb4, otherwise: bb3]; // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + StorageLive(_4); // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 + StorageLive(_5); // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:16 + _5 = _1; // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:16 +- _4 = Ne(move _5, const 21_u32); // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 +- StorageDead(_5); // scope 0 at $DIR/if_condition_int.rs:+3:21: +3:22 +- switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+3:21: +3:22 ++ switchInt(move _5) -> [21_u32: bb4, otherwise: bb3]; // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 } bb3: { -+ StorageDead(_5); // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:+4:9: +4:10 - goto -> bb5; // scope 0 at $DIR/if-condition-int.rs:+3:12: +7:6 ++ StorageDead(_5); // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 + _0 = const 1_u32; // scope 0 at $DIR/if_condition_int.rs:+4:9: +4:10 + goto -> bb5; // scope 0 at $DIR/if_condition_int.rs:+3:12: +7:6 } bb4: { -+ StorageDead(_5); // scope 0 at $DIR/if-condition-int.rs:+3:15: +3:22 - _0 = const 2_u32; // scope 0 at $DIR/if-condition-int.rs:+6:9: +6:10 - goto -> bb5; // scope 0 at $DIR/if-condition-int.rs:+3:12: +7:6 ++ StorageDead(_5); // scope 0 at $DIR/if_condition_int.rs:+3:15: +3:22 + _0 = const 2_u32; // scope 0 at $DIR/if_condition_int.rs:+6:9: +6:10 + goto -> bb5; // scope 0 at $DIR/if_condition_int.rs:+3:12: +7:6 } bb5: { - StorageDead(_4); // scope 0 at $DIR/if-condition-int.rs:+7:5: +7:6 - goto -> bb6; // scope 0 at $DIR/if-condition-int.rs:+1:5: +7:6 + StorageDead(_4); // scope 0 at $DIR/if_condition_int.rs:+7:5: +7:6 + goto -> bb6; // scope 0 at $DIR/if_condition_int.rs:+1:5: +7:6 } bb6: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+7:5: +7:6 - return; // scope 0 at $DIR/if-condition-int.rs:+8:2: +8:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+7:5: +7:6 + return; // scope 0 at $DIR/if_condition_int.rs:+8:2: +8:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff index 6802f89d9..992253ea7 100644 --- a/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff @@ -2,38 +2,38 @@ + // MIR for `opt_negative` after SimplifyComparisonIntegral fn opt_negative(_1: i32) -> u32 { - debug x => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:17: +0:18 - let mut _0: u32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:28: +0:31 - let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - let mut _3: i32; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 + debug x => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:17: +0:18 + let mut _0: u32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:28: +0:31 + let mut _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + let mut _3: i32; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 -- _2 = Eq(move _3, const -42_i32); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 -- StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16 -- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:15: +1:16 -+ switchInt(move _3) -> [-42_i32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + StorageLive(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _3 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 +- _2 = Eq(move _3, const -42_i32); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 +- StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:15: +1:16 ++ switchInt(move _3) -> [-42_i32: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 } bb1: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:+1:19: +1:20 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + _0 = const 0_u32; // scope 0 at $DIR/if_condition_int.rs:+1:19: +1:20 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33 } bb2: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:16 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:+1:30: +1:31 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:33 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:16 + _0 = const 1_u32; // scope 0 at $DIR/if_condition_int.rs:+1:30: +1:31 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:33 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+1:32: +1:33 - return; // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+1:32: +1:33 + return; // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff index 96387771d..7cea9472d 100644 --- a/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff +++ b/src/test/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff @@ -2,38 +2,38 @@ + // MIR for `opt_u32` after SimplifyComparisonIntegral fn opt_u32(_1: u32) -> u32 { - debug x => _1; // in scope 0 at $DIR/if-condition-int.rs:+0:12: +0:13 - let mut _0: u32; // return place in scope 0 at $DIR/if-condition-int.rs:+0:23: +0:26 - let mut _2: bool; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - let mut _3: u32; // in scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 + debug x => _1; // in scope 0 at $DIR/if_condition_int.rs:+0:12: +0:13 + let mut _0: u32; // return place in scope 0 at $DIR/if_condition_int.rs:+0:23: +0:26 + let mut _2: bool; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + let mut _3: u32; // in scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 bb0: { - StorageLive(_2); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - StorageLive(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:9 -- _2 = Eq(move _3, const 42_u32); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -- StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15 -- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 -+ nop; // scope 0 at $DIR/if-condition-int.rs:+1:14: +1:15 -+ switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 + StorageLive(_2); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + StorageLive(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 + _3 = _1; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:9 +- _2 = Eq(move _3, const 42_u32); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 +- StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15 +- switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 ++ nop; // scope 0 at $DIR/if_condition_int.rs:+1:14: +1:15 ++ switchInt(move _3) -> [42_u32: bb1, otherwise: bb2]; // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 } bb1: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - _0 = const 0_u32; // scope 0 at $DIR/if-condition-int.rs:+1:18: +1:19 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + _0 = const 0_u32; // scope 0 at $DIR/if_condition_int.rs:+1:18: +1:19 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32 } bb2: { -+ StorageDead(_3); // scope 0 at $DIR/if-condition-int.rs:+1:8: +1:15 - _0 = const 1_u32; // scope 0 at $DIR/if-condition-int.rs:+1:29: +1:30 - goto -> bb3; // scope 0 at $DIR/if-condition-int.rs:+1:5: +1:32 ++ StorageDead(_3); // scope 0 at $DIR/if_condition_int.rs:+1:8: +1:15 + _0 = const 1_u32; // scope 0 at $DIR/if_condition_int.rs:+1:29: +1:30 + goto -> bb3; // scope 0 at $DIR/if_condition_int.rs:+1:5: +1:32 } bb3: { - StorageDead(_2); // scope 0 at $DIR/if-condition-int.rs:+1:31: +1:32 - return; // scope 0 at $DIR/if-condition-int.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/if_condition_int.rs:+1:31: +1:32 + return; // scope 0 at $DIR/if_condition_int.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/if_condition_int.rs b/src/test/mir-opt/if_condition_int.rs new file mode 100644 index 000000000..398311e6b --- /dev/null +++ b/src/test/mir-opt/if_condition_int.rs @@ -0,0 +1,65 @@ +// unit-test: SimplifyComparisonIntegral +// EMIT_MIR if_condition_int.opt_u32.SimplifyComparisonIntegral.diff +// EMIT_MIR if_condition_int.opt_negative.SimplifyComparisonIntegral.diff +// EMIT_MIR if_condition_int.opt_char.SimplifyComparisonIntegral.diff +// EMIT_MIR if_condition_int.opt_i8.SimplifyComparisonIntegral.diff +// EMIT_MIR if_condition_int.dont_opt_bool.SimplifyComparisonIntegral.diff +// EMIT_MIR if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff +// EMIT_MIR if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff +// EMIT_MIR if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff + +fn opt_u32(x: u32) -> u32 { + if x == 42 { 0 } else { 1 } +} + +// don't opt: it is already optimal to switch on the bool +fn dont_opt_bool(x: bool) -> u32 { + if x { 0 } else { 1 } +} + +fn opt_char(x: char) -> u32 { + if x == 'x' { 0 } else { 1 } +} + +fn opt_i8(x: i8) -> u32 { + if x == 42 { 0 } else { 1 } +} + +fn opt_negative(x: i32) -> u32 { + if x == -42 { 0 } else { 1 } +} + +fn opt_multiple_ifs(x: u32) -> u32 { + if x == 42 { + 0 + } else if x != 21 { + 1 + } else { + 2 + } +} + +// test that we optimize, but do not remove the b statement, as that is used later on +fn dont_remove_comparison(a: i8) -> i32 { + let b = a == 17; + match b { + false => 10 + b as i32, + true => 100 + b as i32, + } +} + +// test that we do not optimize on floats +fn dont_opt_floats(a: f32) -> i32 { + if a == -42.0 { 0 } else { 1 } +} + +fn main() { + opt_u32(0); + opt_char('0'); + opt_i8(22); + dont_opt_bool(false); + opt_negative(0); + opt_multiple_ifs(0); + dont_remove_comparison(11); + dont_opt_floats(1.0); +} diff --git a/src/test/mir-opt/inline/asm-unwind.rs b/src/test/mir-opt/inline/asm-unwind.rs deleted file mode 100644 index c03feb433..000000000 --- a/src/test/mir-opt/inline/asm-unwind.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Tests inlining of `may_unwind` inline assembly. -// -// ignore-wasm32-bare compiled with panic=abort by default -// needs-asm-support -#![feature(asm_unwind)] - -struct D; - -impl Drop for D { - fn drop(&mut self) {} -} - -#[inline(always)] -fn foo() { - let _d = D; - unsafe { std::arch::asm!("", options(may_unwind)) }; -} - -// EMIT_MIR asm_unwind.main.Inline.diff -pub fn main() { - foo(); -} diff --git a/src/test/mir-opt/inline/asm_unwind.main.Inline.diff b/src/test/mir-opt/inline/asm_unwind.main.Inline.diff index 57072fc0a..f1b62ac38 100644 --- a/src/test/mir-opt/inline/asm_unwind.main.Inline.diff +++ b/src/test/mir-opt/inline/asm_unwind.main.Inline.diff @@ -2,44 +2,44 @@ + // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/asm-unwind.rs:+0:15: +0:15 - let _1: (); // in scope 0 at $DIR/asm-unwind.rs:+1:5: +1:10 -+ scope 1 (inlined foo) { // at $DIR/asm-unwind.rs:21:5: 21:10 -+ let _2: D; // in scope 1 at $DIR/asm-unwind.rs:15:9: 15:11 + let mut _0: (); // return place in scope 0 at $DIR/asm_unwind.rs:+0:15: +0:15 + let _1: (); // in scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 ++ scope 1 (inlined foo) { // at $DIR/asm_unwind.rs:21:5: 21:10 ++ let _2: D; // in scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 + scope 2 { -+ debug _d => _2; // in scope 2 at $DIR/asm-unwind.rs:15:9: 15:11 ++ debug _d => _2; // in scope 2 at $DIR/asm_unwind.rs:15:9: 15:11 + scope 3 { + } + } + } bb0: { - StorageLive(_1); // scope 0 at $DIR/asm-unwind.rs:+1:5: +1:10 -- _1 = foo() -> bb1; // scope 0 at $DIR/asm-unwind.rs:+1:5: +1:10 + StorageLive(_1); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 +- _1 = foo() -> bb1; // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 - // mir::Constant -- // + span: $DIR/asm-unwind.rs:21:5: 21:8 +- // + span: $DIR/asm_unwind.rs:21:5: 21:8 - // + literal: Const { ty: fn() {foo}, val: Value() } -+ StorageLive(_2); // scope 1 at $DIR/asm-unwind.rs:15:9: 15:11 -+ asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb3]; // scope 3 at $DIR/asm-unwind.rs:16:14: 16:54 ++ StorageLive(_2); // scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 ++ asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54 } bb1: { -+ drop(_2) -> bb2; // scope 1 at $DIR/asm-unwind.rs:17:1: 17:2 ++ drop(_2) -> bb2; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 + } + + bb2: { -+ StorageDead(_2); // scope 1 at $DIR/asm-unwind.rs:17:1: 17:2 - StorageDead(_1); // scope 0 at $DIR/asm-unwind.rs:+1:10: +1:11 - _0 = const (); // scope 0 at $DIR/asm-unwind.rs:+0:15: +2:2 - return; // scope 0 at $DIR/asm-unwind.rs:+2:2: +2:2 ++ StorageDead(_2); // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 + StorageDead(_1); // scope 0 at $DIR/asm_unwind.rs:+1:10: +1:11 + _0 = const (); // scope 0 at $DIR/asm_unwind.rs:+0:15: +2:2 + return; // scope 0 at $DIR/asm_unwind.rs:+2:2: +2:2 + } + + bb3 (cleanup): { -+ drop(_2) -> bb4; // scope 1 at $DIR/asm-unwind.rs:17:1: 17:2 ++ drop(_2) -> bb4; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 + } + + bb4 (cleanup): { -+ resume; // scope 1 at $DIR/asm-unwind.rs:14:1: 17:2 ++ resume; // scope 1 at $DIR/asm_unwind.rs:14:1: 17:2 } } diff --git a/src/test/mir-opt/inline/asm_unwind.rs b/src/test/mir-opt/inline/asm_unwind.rs new file mode 100644 index 000000000..c03feb433 --- /dev/null +++ b/src/test/mir-opt/inline/asm_unwind.rs @@ -0,0 +1,22 @@ +// Tests inlining of `may_unwind` inline assembly. +// +// ignore-wasm32-bare compiled with panic=abort by default +// needs-asm-support +#![feature(asm_unwind)] + +struct D; + +impl Drop for D { + fn drop(&mut self) {} +} + +#[inline(always)] +fn foo() { + let _d = D; + unsafe { std::arch::asm!("", options(may_unwind)) }; +} + +// EMIT_MIR asm_unwind.main.Inline.diff +pub fn main() { + foo(); +} diff --git a/src/test/mir-opt/inline/caller-with-trivial-bound.rs b/src/test/mir-opt/inline/caller-with-trivial-bound.rs deleted file mode 100644 index 8545db894..000000000 --- a/src/test/mir-opt/inline/caller-with-trivial-bound.rs +++ /dev/null @@ -1,26 +0,0 @@ -// ignore-wasm32 compiled with panic=abort by default -// needs-unwind - -#![crate_type = "lib"] -pub trait Factory { - type Item; -} - -pub struct IntFactory; - -impl Factory for IntFactory { - type Item = usize; -} - -// EMIT_MIR caller_with_trivial_bound.foo.Inline.diff -pub fn foo() -where - IntFactory: Factory, -{ - let mut x: >::Item = bar::(); -} - -#[inline(always)] -pub fn bar() -> >::Item { - 0usize -} diff --git a/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff b/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff index d7deb9c66..8b0300678 100644 --- a/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff +++ b/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff @@ -2,32 +2,32 @@ + // MIR for `foo` after Inline fn foo() -> () { - let mut _0: (); // return place in scope 0 at $DIR/caller-with-trivial-bound.rs:+1:1: +1:1 - let mut _1: >::Item; // in scope 0 at $DIR/caller-with-trivial-bound.rs:+4:9: +4:14 + let mut _0: (); // return place in scope 0 at $DIR/caller_with_trivial_bound.rs:+1:1: +1:1 + let mut _1: >::Item; // in scope 0 at $DIR/caller_with_trivial_bound.rs:+4:9: +4:14 scope 1 { - debug x => _1; // in scope 1 at $DIR/caller-with-trivial-bound.rs:+4:9: +4:14 + debug x => _1; // in scope 1 at $DIR/caller_with_trivial_bound.rs:+4:9: +4:14 } bb0: { - StorageLive(_1); // scope 0 at $DIR/caller-with-trivial-bound.rs:+4:9: +4:14 - _1 = bar::() -> bb1; // scope 0 at $DIR/caller-with-trivial-bound.rs:+4:51: +4:61 + StorageLive(_1); // scope 0 at $DIR/caller_with_trivial_bound.rs:+4:9: +4:14 + _1 = bar::() -> bb1; // scope 0 at $DIR/caller_with_trivial_bound.rs:+4:51: +4:61 // mir::Constant - // + span: $DIR/caller-with-trivial-bound.rs:20:51: 20:59 + // + span: $DIR/caller_with_trivial_bound.rs:20:51: 20:59 // + literal: Const { ty: fn() -> >::Item {bar::}, val: Value() } } bb1: { - _0 = const (); // scope 0 at $DIR/caller-with-trivial-bound.rs:+3:1: +5:2 - drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/caller-with-trivial-bound.rs:+5:1: +5:2 + _0 = const (); // scope 0 at $DIR/caller_with_trivial_bound.rs:+3:1: +5:2 + drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/caller_with_trivial_bound.rs:+5:1: +5:2 } bb2: { - StorageDead(_1); // scope 0 at $DIR/caller-with-trivial-bound.rs:+5:1: +5:2 - return; // scope 0 at $DIR/caller-with-trivial-bound.rs:+5:2: +5:2 + StorageDead(_1); // scope 0 at $DIR/caller_with_trivial_bound.rs:+5:1: +5:2 + return; // scope 0 at $DIR/caller_with_trivial_bound.rs:+5:2: +5:2 } bb3 (cleanup): { - resume; // scope 0 at $DIR/caller-with-trivial-bound.rs:+0:1: +5:2 + resume; // scope 0 at $DIR/caller_with_trivial_bound.rs:+0:1: +5:2 } } diff --git a/src/test/mir-opt/inline/caller_with_trivial_bound.rs b/src/test/mir-opt/inline/caller_with_trivial_bound.rs new file mode 100644 index 000000000..8545db894 --- /dev/null +++ b/src/test/mir-opt/inline/caller_with_trivial_bound.rs @@ -0,0 +1,26 @@ +// ignore-wasm32 compiled with panic=abort by default +// needs-unwind + +#![crate_type = "lib"] +pub trait Factory { + type Item; +} + +pub struct IntFactory; + +impl Factory for IntFactory { + type Item = usize; +} + +// EMIT_MIR caller_with_trivial_bound.foo.Inline.diff +pub fn foo() +where + IntFactory: Factory, +{ + let mut x: >::Item = bar::(); +} + +#[inline(always)] +pub fn bar() -> >::Item { + 0usize +} diff --git a/src/test/mir-opt/inline/cycle.g.Inline.diff b/src/test/mir-opt/inline/cycle.g.Inline.diff index 5f3ee467c..afe157ccd 100644 --- a/src/test/mir-opt/inline/cycle.g.Inline.diff +++ b/src/test/mir-opt/inline/cycle.g.Inline.diff @@ -10,8 +10,6 @@ + let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + let mut _4: &fn() {main}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6 + let mut _5: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ scope 2 (inlined >::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8 -+ } + } bb0: { @@ -29,7 +27,10 @@ + StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 + _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 + StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ _3 = >::call(move _4, move _5) -> [return: bb2, unwind: bb3]; // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ // mir::Constant ++ // + span: $DIR/cycle.rs:6:5: 6:6 ++ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {main}, ()) -> >::Output {>::call}, val: Value() } } bb1: { @@ -39,19 +40,19 @@ return; // scope 0 at $DIR/cycle.rs:+2:2: +2:2 + } + -+ bb2 (cleanup): { -+ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ bb2: { ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 ++ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + + bb3 (cleanup): { -+ resume; // scope 1 at $DIR/cycle.rs:5:1: 7:2 ++ drop(_2) -> bb4; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + -+ bb4: { -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 -+ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ bb4 (cleanup): { ++ resume; // scope 1 at $DIR/cycle.rs:5:1: 7:2 } } diff --git a/src/test/mir-opt/inline/cycle.main.Inline.diff b/src/test/mir-opt/inline/cycle.main.Inline.diff index 8b4099b9d..bd89e09ec 100644 --- a/src/test/mir-opt/inline/cycle.main.Inline.diff +++ b/src/test/mir-opt/inline/cycle.main.Inline.diff @@ -10,18 +10,6 @@ + let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + let mut _4: &fn() {g}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6 + let mut _5: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ scope 2 (inlined >::call - shim(fn() {g})) { // at $DIR/cycle.rs:6:5: 6:8 -+ scope 3 (inlined g) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL -+ let mut _6: fn() {main}; // in scope 3 at $DIR/cycle.rs:12:5: 12:12 -+ scope 4 (inlined f::) { // at $DIR/cycle.rs:12:5: 12:12 -+ debug g => _6; // in scope 4 at $DIR/cycle.rs:5:6: 5:7 -+ let _7: (); // in scope 4 at $DIR/cycle.rs:6:5: 6:8 -+ let mut _8: &fn() {main}; // in scope 4 at $DIR/cycle.rs:6:5: 6:6 -+ scope 5 (inlined >::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8 -+ } -+ } -+ } -+ } + } bb0: { @@ -39,11 +27,10 @@ + StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 + _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 + StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ StorageLive(_6); // scope 3 at $DIR/cycle.rs:12:5: 12:12 -+ StorageLive(_7); // scope 4 at $DIR/cycle.rs:6:5: 6:8 -+ StorageLive(_8); // scope 4 at $DIR/cycle.rs:6:5: 6:6 -+ _8 = &_6; // scope 4 at $DIR/cycle.rs:6:5: 6:6 -+ _7 = move (*_8)() -> [return: bb4, unwind: bb2]; // scope 5 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ _3 = >::call(move _4, move _5) -> [return: bb2, unwind: bb3]; // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ // mir::Constant ++ // + span: $DIR/cycle.rs:6:5: 6:6 ++ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {g}, ()) -> >::Output {>::call}, val: Value() } } bb1: { @@ -53,22 +40,19 @@ return; // scope 0 at $DIR/cycle.rs:+2:2: +2:2 + } + -+ bb2 (cleanup): { -+ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ bb2: { ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 ++ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + + bb3 (cleanup): { -+ resume; // scope 1 at $DIR/cycle.rs:5:1: 7:2 ++ drop(_2) -> bb4; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + -+ bb4: { -+ StorageDead(_8); // scope 4 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_7); // scope 4 at $DIR/cycle.rs:6:8: 6:9 -+ StorageDead(_6); // scope 3 at $DIR/cycle.rs:12:5: 12:12 -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 -+ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ bb4 (cleanup): { ++ resume; // scope 1 at $DIR/cycle.rs:5:1: 7:2 } } diff --git a/src/test/mir-opt/inline/dyn-trait.rs b/src/test/mir-opt/inline/dyn-trait.rs deleted file mode 100644 index 6a46e1e07..000000000 --- a/src/test/mir-opt/inline/dyn-trait.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![crate_type = "lib"] - -use std::fmt::Debug; - -pub trait Cache { - type V: Debug; - - fn store_nocache(&self); -} - -pub trait Query { - type V; - type C: Cache; - - fn cache(s: &T) -> &Self::C; -} - -// EMIT_MIR dyn_trait.mk_cycle.Inline.diff -#[inline(always)] -pub fn mk_cycle(c: &dyn Cache) { - c.store_nocache() -} - -// EMIT_MIR dyn_trait.try_execute_query.Inline.diff -#[inline(always)] -pub fn try_execute_query(c: &C) { - mk_cycle(c) -} - -// EMIT_MIR dyn_trait.get_query.Inline.diff -#[inline(always)] -pub fn get_query(t: &T) { - let c = Q::cache(t); - try_execute_query(c) -} diff --git a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff index 1e95b5b29..8ea1a0757 100644 --- a/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -2,61 +2,53 @@ + // MIR for `get_query` after Inline fn get_query(_1: &T) -> () { - debug t => _1; // in scope 0 at $DIR/dyn-trait.rs:+0:31: +0:32 - let mut _0: (); // return place in scope 0 at $DIR/dyn-trait.rs:+0:38: +0:38 - let _2: &::C; // in scope 0 at $DIR/dyn-trait.rs:+1:9: +1:10 - let mut _3: &T; // in scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23 - let mut _4: &::C; // in scope 0 at $DIR/dyn-trait.rs:+2:23: +2:24 + debug t => _1; // in scope 0 at $DIR/dyn_trait.rs:+0:31: +0:32 + let mut _0: (); // return place in scope 0 at $DIR/dyn_trait.rs:+0:38: +0:38 + let _2: &::C; // in scope 0 at $DIR/dyn_trait.rs:+1:9: +1:10 + let mut _3: &T; // in scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23 + let mut _4: &::C; // in scope 0 at $DIR/dyn_trait.rs:+2:23: +2:24 scope 1 { - debug c => _2; // in scope 1 at $DIR/dyn-trait.rs:+1:9: +1:10 -+ scope 2 (inlined try_execute_query::<::C>) { // at $DIR/dyn-trait.rs:34:5: 34:25 -+ debug c => _4; // in scope 2 at $DIR/dyn-trait.rs:26:36: 26:37 -+ let mut _5: &dyn Cache::V>; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 -+ let mut _6: &::C; // in scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 -+ scope 3 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16 -+ debug c => _5; // in scope 3 at $DIR/dyn-trait.rs:20:27: 20:28 -+ let mut _7: &dyn Cache::V>; // in scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 + debug c => _2; // in scope 1 at $DIR/dyn_trait.rs:+1:9: +1:10 ++ scope 2 (inlined try_execute_query::<::C>) { // at $DIR/dyn_trait.rs:34:5: 34:25 ++ debug c => _4; // in scope 2 at $DIR/dyn_trait.rs:26:36: 26:37 ++ let mut _5: &dyn Cache::V>; // in scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 ++ scope 3 (inlined mk_cycle::<::V>) { // at $DIR/dyn_trait.rs:27:5: 27:16 ++ debug c => _5; // in scope 3 at $DIR/dyn_trait.rs:20:27: 20:28 + } + } } bb0: { - StorageLive(_2); // scope 0 at $DIR/dyn-trait.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23 - _3 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:+1:22: +1:23 - _2 = ::cache::(move _3) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:13: +1:24 + StorageLive(_2); // scope 0 at $DIR/dyn_trait.rs:+1:9: +1:10 + StorageLive(_3); // scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23 + _3 = &(*_1); // scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23 + _2 = ::cache::(move _3) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:13: +1:24 // mir::Constant - // + span: $DIR/dyn-trait.rs:33:13: 33:21 + // + span: $DIR/dyn_trait.rs:33:13: 33:21 // + user_ty: UserType(0) // + literal: Const { ty: for<'a> fn(&'a T) -> &'a ::C {::cache::}, val: Value() } } bb1: { - StorageDead(_3); // scope 0 at $DIR/dyn-trait.rs:+1:23: +1:24 - StorageLive(_4); // scope 1 at $DIR/dyn-trait.rs:+2:23: +2:24 - _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 -+ StorageLive(_6); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 -+ _6 = _4; // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 -+ _5 = move _6 as &dyn Cache::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 -+ StorageDead(_6); // scope 2 at $DIR/dyn-trait.rs:27:14: 27:15 -+ StorageLive(_7); // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 -+ _7 = _5; // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 -+ _0 = ::V> as Cache>::store_nocache(move _7) -> bb2; // scope 3 at $DIR/dyn-trait.rs:21:5: 21:22 + StorageDead(_3); // scope 0 at $DIR/dyn_trait.rs:+1:23: +1:24 + StorageLive(_4); // scope 1 at $DIR/dyn_trait.rs:+2:23: +2:24 + _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 // mir::Constant -- // + span: $DIR/dyn-trait.rs:34:5: 34:22 +- // + span: $DIR/dyn_trait.rs:34:5: 34:22 - // + literal: Const { ty: for<'a> fn(&'a ::C) {try_execute_query::<::C>}, val: Value() } -+ // + span: $DIR/dyn-trait.rs:21:7: 21:20 ++ // + span: $DIR/dyn_trait.rs:21:7: 21:20 + // + literal: Const { ty: for<'a> fn(&'a dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } } bb2: { -+ StorageDead(_7); // scope 3 at $DIR/dyn-trait.rs:21:21: 21:22 -+ StorageDead(_5); // scope 2 at $DIR/dyn-trait.rs:27:15: 27:16 - StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:+2:24: +2:25 - StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:+3:1: +3:2 - return; // scope 0 at $DIR/dyn-trait.rs:+3:2: +3:2 ++ StorageDead(_5); // scope 2 at $DIR/dyn_trait.rs:27:15: 27:16 + StorageDead(_4); // scope 1 at $DIR/dyn_trait.rs:+2:24: +2:25 + StorageDead(_2); // scope 0 at $DIR/dyn_trait.rs:+3:1: +3:2 + return; // scope 0 at $DIR/dyn_trait.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff index 7421db4d0..7653a5ded 100644 --- a/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff @@ -2,22 +2,22 @@ + // MIR for `mk_cycle` after Inline fn mk_cycle(_1: &dyn Cache) -> () { - debug c => _1; // in scope 0 at $DIR/dyn-trait.rs:+0:27: +0:28 - let mut _0: (); // return place in scope 0 at $DIR/dyn-trait.rs:+0:49: +0:49 - let mut _2: &dyn Cache; // in scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22 + debug c => _1; // in scope 0 at $DIR/dyn_trait.rs:+0:27: +0:28 + let mut _0: (); // return place in scope 0 at $DIR/dyn_trait.rs:+0:49: +0:49 + let mut _2: &dyn Cache; // in scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22 bb0: { - StorageLive(_2); // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22 - _2 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22 - _0 = as Cache>::store_nocache(move _2) -> bb1; // scope 0 at $DIR/dyn-trait.rs:+1:5: +1:22 + StorageLive(_2); // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22 + _2 = &(*_1); // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22 + _0 = as Cache>::store_nocache(move _2) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:22 // mir::Constant - // + span: $DIR/dyn-trait.rs:21:7: 21:20 + // + span: $DIR/dyn_trait.rs:21:7: 21:20 // + literal: Const { ty: for<'a> fn(&'a dyn Cache) { as Cache>::store_nocache}, val: Value() } } bb1: { - StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:+1:21: +1:22 - return; // scope 0 at $DIR/dyn-trait.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/dyn_trait.rs:+1:21: +1:22 + return; // scope 0 at $DIR/dyn_trait.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/dyn_trait.rs b/src/test/mir-opt/inline/dyn_trait.rs new file mode 100644 index 000000000..6a46e1e07 --- /dev/null +++ b/src/test/mir-opt/inline/dyn_trait.rs @@ -0,0 +1,35 @@ +#![crate_type = "lib"] + +use std::fmt::Debug; + +pub trait Cache { + type V: Debug; + + fn store_nocache(&self); +} + +pub trait Query { + type V; + type C: Cache; + + fn cache(s: &T) -> &Self::C; +} + +// EMIT_MIR dyn_trait.mk_cycle.Inline.diff +#[inline(always)] +pub fn mk_cycle(c: &dyn Cache) { + c.store_nocache() +} + +// EMIT_MIR dyn_trait.try_execute_query.Inline.diff +#[inline(always)] +pub fn try_execute_query(c: &C) { + mk_cycle(c) +} + +// EMIT_MIR dyn_trait.get_query.Inline.diff +#[inline(always)] +pub fn get_query(t: &T) { + let c = Q::cache(t); + try_execute_query(c) +} diff --git a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff index e6e783744..a71d73b74 100644 --- a/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff +++ b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -2,36 +2,32 @@ + // MIR for `try_execute_query` after Inline fn try_execute_query(_1: &C) -> () { - debug c => _1; // in scope 0 at $DIR/dyn-trait.rs:+0:36: +0:37 - let mut _0: (); // return place in scope 0 at $DIR/dyn-trait.rs:+0:43: +0:43 - let mut _2: &dyn Cache::V>; // in scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 - let mut _3: &C; // in scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 -+ scope 1 (inlined mk_cycle::<::V>) { // at $DIR/dyn-trait.rs:27:5: 27:16 -+ debug c => _2; // in scope 1 at $DIR/dyn-trait.rs:20:27: 20:28 -+ let mut _4: &dyn Cache::V>; // in scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 + debug c => _1; // in scope 0 at $DIR/dyn_trait.rs:+0:36: +0:37 + let mut _0: (); // return place in scope 0 at $DIR/dyn_trait.rs:+0:43: +0:43 + let mut _2: &dyn Cache::V>; // in scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 + let mut _3: &C; // in scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 ++ scope 1 (inlined mk_cycle::<::V>) { // at $DIR/dyn_trait.rs:27:5: 27:16 ++ debug c => _2; // in scope 1 at $DIR/dyn_trait.rs:20:27: 20:28 + } bb0: { - StorageLive(_2); // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 - StorageLive(_3); // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 - _3 = &(*_1); // scope 0 at $DIR/dyn-trait.rs:+1:14: +1:15 - _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 -+ StorageLive(_4); // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 -+ _4 = _2; // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 -+ _0 = ::V> as Cache>::store_nocache(move _4) -> bb1; // scope 1 at $DIR/dyn-trait.rs:21:5: 21:22 + StorageLive(_2); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 + StorageLive(_3); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 + _3 = &(*_1); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 + _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 // mir::Constant -- // + span: $DIR/dyn-trait.rs:27:5: 27:13 +- // + 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() } -+ // + span: $DIR/dyn-trait.rs:21:7: 21:20 ++ // + span: $DIR/dyn_trait.rs:21:7: 21:20 + // + literal: Const { ty: for<'a> fn(&'a dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } } bb1: { -+ StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:21:21: 21:22 - StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:+1:15: +1:16 - return; // scope 0 at $DIR/dyn-trait.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/dyn_trait.rs:+1:15: +1:16 + return; // scope 0 at $DIR/dyn_trait.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/exponential_runtime.main.Inline.diff b/src/test/mir-opt/inline/exponential_runtime.main.Inline.diff new file mode 100644 index 000000000..d9fd7b324 --- /dev/null +++ b/src/test/mir-opt/inline/exponential_runtime.main.Inline.diff @@ -0,0 +1,50 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/exponential_runtime.rs:+0:11: +0:11 + let _1: (); // in scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ scope 1 (inlined <() as G>::call) { // at $DIR/exponential_runtime.rs:86:5: 86:22 ++ let _2: (); // in scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ let _3: (); // in scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ let _4: (); // in scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 ++ } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 +- _1 = <() as G>::call() -> bb1; // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageLive(_2); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ _2 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 + // mir::Constant +- // + span: $DIR/exponential_runtime.rs:86:5: 86:20 +- // + literal: Const { ty: fn() {<() as G>::call}, val: Value() } ++ // + span: $DIR/exponential_runtime.rs:73:9: 73:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value() } + } + + bb1: { ++ StorageDead(_2); // scope 1 at $DIR/exponential_runtime.rs:73:25: 73:26 ++ StorageLive(_3); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ _3 = <() as F>::call() -> bb2; // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:74:9: 74:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value() } ++ } ++ ++ bb2: { ++ StorageDead(_3); // scope 1 at $DIR/exponential_runtime.rs:74:25: 74:26 ++ StorageLive(_4); // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 ++ _4 = <() as F>::call() -> bb3; // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:75:9: 75:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value() } ++ } ++ ++ bb3: { ++ StorageDead(_4); // scope 1 at $DIR/exponential_runtime.rs:75:25: 75:26 + StorageDead(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:22: +1:23 + _0 = const (); // scope 0 at $DIR/exponential_runtime.rs:+0:11: +2:2 + return; // scope 0 at $DIR/exponential_runtime.rs:+2:2: +2:2 + } + } + diff --git a/src/test/mir-opt/inline/exponential_runtime.rs b/src/test/mir-opt/inline/exponential_runtime.rs new file mode 100644 index 000000000..d9219d76a --- /dev/null +++ b/src/test/mir-opt/inline/exponential_runtime.rs @@ -0,0 +1,87 @@ +// Checks that code with exponential runtime does not have exponential behavior in inlining. + +trait A { + fn call(); +} + +trait B { + fn call(); +} +impl B for T { + #[inline] + fn call() { + ::call(); + ::call(); + ::call(); + } +} + +trait C { + fn call(); +} +impl C for T { + #[inline] + fn call() { + ::call(); + ::call(); + ::call(); + } +} + +trait D { + fn call(); +} +impl D for T { + #[inline] + fn call() { + ::call(); + ::call(); + ::call(); + } +} + +trait E { + fn call(); +} +impl E for T { + #[inline] + fn call() { + ::call(); + ::call(); + ::call(); + } +} + +trait F { + fn call(); +} +impl F for T { + #[inline] + fn call() { + ::call(); + ::call(); + ::call(); + } +} + +trait G { + fn call(); +} +impl G for T { + #[inline] + fn call() { + ::call(); + ::call(); + ::call(); + } +} + +impl A for () { + #[inline(never)] + fn call() {} +} + +// EMIT_MIR exponential_runtime.main.Inline.diff +fn main() { + <() as G>::call(); +} diff --git a/src/test/mir-opt/inline/inline-any-operand.rs b/src/test/mir-opt/inline/inline-any-operand.rs deleted file mode 100644 index fb0de020f..000000000 --- a/src/test/mir-opt/inline/inline-any-operand.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags: -Z span_free_formats - -// Tests that MIR inliner works for any operand - -fn main() { - println!("{}", bar()); -} - -// EMIT_MIR inline_any_operand.bar.Inline.after.mir -fn bar() -> bool { - let f = foo; - f(1, -1) -} - -#[inline(always)] -fn foo(x: i32, y: i32) -> bool { - x == y -} diff --git a/src/test/mir-opt/inline/inline-async.rs b/src/test/mir-opt/inline/inline-async.rs deleted file mode 100644 index 5c838159b..000000000 --- a/src/test/mir-opt/inline/inline-async.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Checks that inliner doesn't introduce cycles when optimizing generators. -// The outcome of optimization is not verfied, just the absence of the cycle. -// Regression test for #76181. -// -// edition:2018 - -#![crate_type = "lib"] - -pub struct S; - -impl S { - pub async fn g(&mut self) { - self.h(); - } - pub fn h(&mut self) { - let _ = self.g(); - } -} diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs b/src/test/mir-opt/inline/inline-closure-borrows-arg.rs deleted file mode 100644 index d76bc33f5..000000000 --- a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-flags: -Z span_free_formats -Zunsound-mir-opts - -// Tests that MIR inliner can handle closure arguments, -// even when (#45894) - -fn main() { - println!("{}", foo(0, &14)); -} - -// EMIT_MIR inline_closure_borrows_arg.foo.Inline.after.mir -fn foo(_t: T, q: &i32) -> i32 { - let x = |r: &i32, _s: &i32| { - let variable = &*r; - *variable - }; - x(q, q) -} diff --git a/src/test/mir-opt/inline/inline-closure-captures.rs b/src/test/mir-opt/inline/inline-closure-captures.rs deleted file mode 100644 index 52b6817e4..000000000 --- a/src/test/mir-opt/inline/inline-closure-captures.rs +++ /dev/null @@ -1,13 +0,0 @@ -// compile-flags: -Z span_free_formats - -// Tests that MIR inliner can handle closure captures. - -fn main() { - println!("{:?}", foo(0, 14)); -} - -// EMIT_MIR inline_closure_captures.foo.Inline.after.mir -fn foo(t: T, q: i32) -> (i32, T) { - let x = |_q| (q, t); - x(q) -} diff --git a/src/test/mir-opt/inline/inline-closure.rs b/src/test/mir-opt/inline/inline-closure.rs deleted file mode 100644 index 715fd0138..000000000 --- a/src/test/mir-opt/inline/inline-closure.rs +++ /dev/null @@ -1,13 +0,0 @@ -// compile-flags: -Z span_free_formats - -// Tests that MIR inliner can handle closure arguments. (#45894) - -fn main() { - println!("{}", foo(0, 14)); -} - -// EMIT_MIR inline_closure.foo.Inline.after.mir -fn foo(_t: T, q: i32) -> i32 { - let x = |_t, _q| _t; - x(q, q) -} diff --git a/src/test/mir-opt/inline/inline-compatibility.rs b/src/test/mir-opt/inline/inline-compatibility.rs deleted file mode 100644 index 30aff0a64..000000000 --- a/src/test/mir-opt/inline/inline-compatibility.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Checks that only functions with compatible attributes are inlined. -// -// only-x86_64 - -#![crate_type = "lib"] -#![feature(no_sanitize)] -#![feature(target_feature_11)] -#![feature(c_variadic)] - -// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff -#[target_feature(enable = "sse2")] -pub unsafe fn inlined_target_feature() { - target_feature(); -} - -// EMIT_MIR inline_compatibility.not_inlined_target_feature.Inline.diff -pub unsafe fn not_inlined_target_feature() { - target_feature(); -} - -// EMIT_MIR inline_compatibility.inlined_no_sanitize.Inline.diff -#[no_sanitize(address)] -pub unsafe fn inlined_no_sanitize() { - no_sanitize(); -} - -// EMIT_MIR inline_compatibility.not_inlined_no_sanitize.Inline.diff -pub unsafe fn not_inlined_no_sanitize() { - no_sanitize(); -} - -#[inline] -#[target_feature(enable = "sse2")] -pub unsafe fn target_feature() {} - -#[inline] -#[no_sanitize(address)] -pub unsafe fn no_sanitize() {} - -// EMIT_MIR inline_compatibility.not_inlined_c_variadic.Inline.diff -pub unsafe fn not_inlined_c_variadic() { - let s = sum(4u32, 4u32, 30u32, 200u32, 1000u32); -} - -#[no_mangle] -#[inline(always)] -unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 { - let mut s = 0; - let mut i = 0; - while i != n { - s += vs.arg::(); - i += 1; - } - s -} diff --git a/src/test/mir-opt/inline/inline-cycle-generic.rs b/src/test/mir-opt/inline/inline-cycle-generic.rs deleted file mode 100644 index 24b4f3793..000000000 --- a/src/test/mir-opt/inline/inline-cycle-generic.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Check that inliner handles various forms of recursion and doesn't fall into -// an infinite inlining cycle. The particular outcome of inlining is not -// crucial otherwise. -// -// Regression test for issue #78573. - -// EMIT_MIR inline_cycle_generic.main.Inline.diff -fn main() { - ::call(); -} - -pub trait Call { - fn call(); -} - -pub struct A; -pub struct B(T); -pub struct C; - -impl Call for A { - #[inline] - fn call() { - as Call>::call() - } -} - - -impl Call for B { - #[inline] - fn call() { - ::call() - } -} - -impl Call for C { - #[inline] - fn call() { - as Call>::call() - } -} diff --git a/src/test/mir-opt/inline/inline-cycle.rs b/src/test/mir-opt/inline/inline-cycle.rs deleted file mode 100644 index 63ad57de1..000000000 --- a/src/test/mir-opt/inline/inline-cycle.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Check that inliner handles various forms of recursion and doesn't fall into -// an infinite inlining cycle. The particular outcome of inlining is not -// crucial otherwise. -// -// Regression test for issue #78573. - -fn main() { - one(); - two(); -} - -// EMIT_MIR inline_cycle.one.Inline.diff -fn one() { - ::call(); -} - -pub trait Call { - fn call(); -} - -pub struct A(T); -pub struct B(T); -pub struct C; - -impl Call for A { - #[inline] - fn call() { - as Call>::call() - } -} - - -impl Call for B { - #[inline] - fn call() { - ::call() - } -} - -impl Call for C { - #[inline] - fn call() { - A::::call() - } -} - -// EMIT_MIR inline_cycle.two.Inline.diff -fn two() { - call(f); -} - -#[inline] -fn call(f: F) { - f(); -} - -#[inline] -fn f() { - call(f); -} diff --git a/src/test/mir-opt/inline/inline-diverging.rs b/src/test/mir-opt/inline/inline-diverging.rs deleted file mode 100644 index ae6f814c2..000000000 --- a/src/test/mir-opt/inline/inline-diverging.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Tests inlining of diverging calls. -// -// ignore-wasm32-bare compiled with panic=abort by default -#![crate_type = "lib"] - -// EMIT_MIR inline_diverging.f.Inline.diff -pub fn f() { - sleep(); -} - -// EMIT_MIR inline_diverging.g.Inline.diff -pub fn g(i: i32) -> u32 { - if i > 0 { - i as u32 - } else { - panic(); - } -} - -// EMIT_MIR inline_diverging.h.Inline.diff -pub fn h() { - call_twice(sleep); -} - -#[inline(always)] -pub fn call_twice R>(f: F) -> (R, R) { - let a = f(); - let b = f(); - (a, b) -} - -#[inline(always)] -fn panic() -> ! { - panic!(); -} - -#[inline(always)] -fn sleep() -> ! { - loop {} -} diff --git a/src/test/mir-opt/inline/inline-generator.rs b/src/test/mir-opt/inline/inline-generator.rs deleted file mode 100644 index d11b3e548..000000000 --- a/src/test/mir-opt/inline/inline-generator.rs +++ /dev/null @@ -1,16 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default -#![feature(generators, generator_trait)] - -use std::ops::Generator; -use std::pin::Pin; - -// EMIT_MIR inline_generator.main.Inline.diff -fn main() { - let _r = Pin::new(&mut g()).resume(false); -} - -#[inline(always)] -pub fn g() -> impl Generator { - #[inline(always)] - |a| { yield if a { 7 } else { 13 } } -} diff --git a/src/test/mir-opt/inline/inline-instruction-set.rs b/src/test/mir-opt/inline/inline-instruction-set.rs deleted file mode 100644 index be36ff50c..000000000 --- a/src/test/mir-opt/inline/inline-instruction-set.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Checks that only functions with the compatible instruction_set attributes are inlined. -// -// compile-flags: --target thumbv4t-none-eabi -// needs-llvm-components: arm - -#![crate_type = "lib"] -#![feature(rustc_attrs)] -#![feature(no_core, lang_items)] -#![feature(isa_attribute)] -#![no_core] - -#[rustc_builtin_macro] -#[macro_export] -macro_rules! asm { - ("assembly template", - $(operands,)* - $(options($(option),*))? - ) => { - /* compiler built-in */ - }; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -#[instruction_set(arm::a32)] -#[inline] -fn instruction_set_a32() {} - -#[instruction_set(arm::t32)] -#[inline] -fn instruction_set_t32() {} - -#[inline] -fn instruction_set_default() {} - -// EMIT_MIR inline_instruction_set.t32.Inline.diff -#[instruction_set(arm::t32)] -pub fn t32() { - instruction_set_a32(); - instruction_set_t32(); - // The default instruction set is currently - // conservatively assumed to be incompatible. - instruction_set_default(); -} - -// EMIT_MIR inline_instruction_set.default.Inline.diff -pub fn default() { - instruction_set_a32(); - instruction_set_t32(); - instruction_set_default(); -} diff --git a/src/test/mir-opt/inline/inline-into-box-place.rs b/src/test/mir-opt/inline/inline-into-box-place.rs deleted file mode 100644 index 232bcc7b2..000000000 --- a/src/test/mir-opt/inline/inline-into-box-place.rs +++ /dev/null @@ -1,9 +0,0 @@ -// ignore-endian-big -// ignore-wasm32-bare compiled with panic=abort by default -// compile-flags: -Z mir-opt-level=4 - -#![feature(box_syntax)] -// EMIT_MIR inline_into_box_place.main.Inline.diff -fn main() { - let _x: Box> = box Vec::new(); -} diff --git a/src/test/mir-opt/inline/inline-options.rs b/src/test/mir-opt/inline/inline-options.rs deleted file mode 100644 index 477f050b6..000000000 --- a/src/test/mir-opt/inline/inline-options.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Checks that inlining threshold can be controlled with -// inline-mir-threshold and inline-hint-threshold options. -// -// compile-flags: -Zinline-mir-threshold=90 -// compile-flags: -Zinline-mir-hint-threshold=50 - -// EMIT_MIR inline_options.main.Inline.after.mir -fn main() { - not_inlined(); - inlined::(); -} - -// Cost is approximately 3 * 25 + 5 = 80. -#[inline] -pub fn not_inlined() { g(); g(); g(); } -pub fn inlined() { g(); g(); g(); } - -#[inline(never)] -fn g() {} diff --git a/src/test/mir-opt/inline/inline-retag.rs b/src/test/mir-opt/inline/inline-retag.rs deleted file mode 100644 index c6950f269..000000000 --- a/src/test/mir-opt/inline/inline-retag.rs +++ /dev/null @@ -1,18 +0,0 @@ -// compile-flags: -Z span_free_formats -Z mir-emit-retag - -// Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag - -fn main() { - println!("{}", bar()); -} - -// EMIT_MIR inline_retag.bar.Inline.after.mir -fn bar() -> bool { - let f = foo; - f(&1, &-1) -} - -#[inline(always)] -fn foo(x: &i32, y: &i32) -> bool { - *x == *y -} diff --git a/src/test/mir-opt/inline/inline-shims.rs b/src/test/mir-opt/inline/inline-shims.rs deleted file mode 100644 index 7c8618f71..000000000 --- a/src/test/mir-opt/inline/inline-shims.rs +++ /dev/null @@ -1,13 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default -#![crate_type = "lib"] - -// EMIT_MIR inline_shims.clone.Inline.diff -pub fn clone(f: fn(A, B)) -> fn(A, B) { - f.clone() -} - -// EMIT_MIR inline_shims.drop.Inline.diff -pub fn drop(a: *mut Vec, b: *mut Option) { - unsafe { std::ptr::drop_in_place(a) } - unsafe { std::ptr::drop_in_place(b) } -} diff --git a/src/test/mir-opt/inline/inline-specialization.rs b/src/test/mir-opt/inline/inline-specialization.rs deleted file mode 100644 index 87275b4e5..000000000 --- a/src/test/mir-opt/inline/inline-specialization.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(specialization)] - -// EMIT_MIR inline_specialization.main.Inline.diff -fn main() { - let x = as Foo>::bar(); -} - -trait Foo { - fn bar() -> u32; -} - -impl Foo for Vec { - #[inline(always)] - default fn bar() -> u32 { 123 } -} diff --git a/src/test/mir-opt/inline/inline-trait-method.rs b/src/test/mir-opt/inline/inline-trait-method.rs deleted file mode 100644 index 74be53f55..000000000 --- a/src/test/mir-opt/inline/inline-trait-method.rs +++ /dev/null @@ -1,22 +0,0 @@ -// compile-flags: -Z span_free_formats - -fn main() { - println!("{}", test(&())); -} - -// EMIT_MIR inline_trait_method.test.Inline.after.mir -fn test(x: &dyn X) -> u32 { - x.y() -} - -trait X { - fn y(&self) -> u32 { - 1 - } -} - -impl X for () { - fn y(&self) -> u32 { - 2 - } -} diff --git a/src/test/mir-opt/inline/inline-trait-method_2.rs b/src/test/mir-opt/inline/inline-trait-method_2.rs deleted file mode 100644 index 378e71a25..000000000 --- a/src/test/mir-opt/inline/inline-trait-method_2.rs +++ /dev/null @@ -1,27 +0,0 @@ -// compile-flags: -Z span_free_formats -Z mir-opt-level=4 - -// EMIT_MIR inline_trait_method_2.test2.Inline.after.mir -fn test2(x: &dyn X) -> bool { - test(x) -} - -#[inline] -fn test(x: &dyn X) -> bool { - x.y() -} - -trait X { - fn y(&self) -> bool { - false - } -} - -impl X for () { - fn y(&self) -> bool { - true - } -} - -fn main() { - println!("Should be true: {}", test2(&())); -} diff --git a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir index b27425fb1..3502c2586 100644 --- a/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir @@ -1,44 +1,36 @@ // MIR for `bar` after Inline fn bar() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/inline-any-operand.rs:+0:13: +0:17 - let _1: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:+1:9: +1:10 - let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:+2:5: +2:6 - let mut _3: i32; // in scope 0 at $DIR/inline-any-operand.rs:+2:5: +2:13 - let mut _4: i32; // in scope 0 at $DIR/inline-any-operand.rs:+2:5: +2:13 + let mut _0: bool; // return place in scope 0 at $DIR/inline_any_operand.rs:+0:13: +0:17 + let _1: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline_any_operand.rs:+1:9: +1:10 + let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:6 + let mut _3: i32; // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:13 + let mut _4: i32; // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:13 scope 1 { - debug f => _1; // in scope 1 at $DIR/inline-any-operand.rs:+1:9: +1:10 - scope 2 (inlined foo) { // at $DIR/inline-any-operand.rs:12:5: 12:13 - debug x => _3; // in scope 2 at $DIR/inline-any-operand.rs:16:8: 16:9 - debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:16:16: 16:17 - let mut _5: i32; // in scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6 - let mut _6: i32; // in scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 + debug f => _1; // in scope 1 at $DIR/inline_any_operand.rs:+1:9: +1:10 + scope 2 (inlined foo) { // at $DIR/inline_any_operand.rs:12:5: 12:13 + debug x => _3; // in scope 2 at $DIR/inline_any_operand.rs:16:8: 16:9 + debug y => _4; // in scope 2 at $DIR/inline_any_operand.rs:16:16: 16:17 } } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-any-operand.rs:+1:9: +1:10 - _1 = foo; // scope 0 at $DIR/inline-any-operand.rs:+1:13: +1:16 + StorageLive(_1); // scope 0 at $DIR/inline_any_operand.rs:+1:9: +1:10 + _1 = foo; // scope 0 at $DIR/inline_any_operand.rs:+1:13: +1:16 // mir::Constant - // + span: $DIR/inline-any-operand.rs:11:13: 11:16 + // + span: $DIR/inline_any_operand.rs:11:13: 11:16 // + literal: Const { ty: fn(i32, i32) -> bool {foo}, val: Value() } - StorageLive(_2); // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:6 - _2 = _1; // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:6 - StorageLive(_3); // scope 1 at $DIR/inline-any-operand.rs:+2:5: +2:13 - _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 - StorageLive(_5); // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6 - _5 = _3; // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:6 - StorageLive(_6); // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 - _6 = _4; // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 - _0 = Eq(move _5, move _6); // scope 2 at $DIR/inline-any-operand.rs:17:5: 17:11 - StorageDead(_6); // scope 2 at $DIR/inline-any-operand.rs:17:10: 17:11 - StorageDead(_5); // scope 2 at $DIR/inline-any-operand.rs:17:10: 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 - StorageDead(_1); // scope 0 at $DIR/inline-any-operand.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline-any-operand.rs:+3:2: +3:2 + StorageLive(_2); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:6 + _2 = _1; // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:6 + StorageLive(_3); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 + _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 + 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 + StorageDead(_1); // scope 0 at $DIR/inline_any_operand.rs:+3:1: +3:2 + return; // scope 0 at $DIR/inline_any_operand.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/inline/inline_any_operand.rs b/src/test/mir-opt/inline/inline_any_operand.rs new file mode 100644 index 000000000..fb0de020f --- /dev/null +++ b/src/test/mir-opt/inline/inline_any_operand.rs @@ -0,0 +1,18 @@ +// compile-flags: -Z span_free_formats + +// Tests that MIR inliner works for any operand + +fn main() { + println!("{}", bar()); +} + +// EMIT_MIR inline_any_operand.bar.Inline.after.mir +fn bar() -> bool { + let f = foo; + f(1, -1) +} + +#[inline(always)] +fn foo(x: i32, y: i32) -> bool { + x == y +} diff --git a/src/test/mir-opt/inline/inline_async.rs b/src/test/mir-opt/inline/inline_async.rs new file mode 100644 index 000000000..5c838159b --- /dev/null +++ b/src/test/mir-opt/inline/inline_async.rs @@ -0,0 +1,18 @@ +// Checks that inliner doesn't introduce cycles when optimizing generators. +// The outcome of optimization is not verfied, just the absence of the cycle. +// Regression test for #76181. +// +// edition:2018 + +#![crate_type = "lib"] + +pub struct S; + +impl S { + pub async fn g(&mut self) { + self.h(); + } + pub fn h(&mut self) { + let _ = self.g(); + } +} diff --git a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir index 1fadd2464..9eb3a01ee 100644 --- a/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -1,49 +1,49 @@ // MIR for `foo` after Inline fn foo(_1: T, _2: i32) -> i32 { - debug _t => _1; // in scope 0 at $DIR/inline-closure.rs:+0:17: +0:19 - debug q => _2; // in scope 0 at $DIR/inline-closure.rs:+0:24: +0:25 - let mut _0: i32; // return place in scope 0 at $DIR/inline-closure.rs:+0:35: +0:38 - let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure.rs:+1:9: +1:10 - let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:6 - let mut _5: (i32, i32); // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:12 - let mut _6: i32; // in scope 0 at $DIR/inline-closure.rs:+2:7: +2:8 - let mut _7: i32; // in scope 0 at $DIR/inline-closure.rs:+2:10: +2:11 - let mut _8: i32; // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:12 - let mut _9: i32; // in scope 0 at $DIR/inline-closure.rs:+2:5: +2:12 + debug _t => _1; // in scope 0 at $DIR/inline_closure.rs:+0:17: +0:19 + debug q => _2; // in scope 0 at $DIR/inline_closure.rs:+0:24: +0:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline_closure.rs:+0:35: +0:38 + let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure.rs:+1:9: +1:10 + let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:6 + let mut _5: (i32, i32); // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12 + let mut _6: i32; // in scope 0 at $DIR/inline_closure.rs:+2:7: +2:8 + let mut _7: i32; // in scope 0 at $DIR/inline_closure.rs:+2:10: +2:11 + let mut _8: i32; // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12 + let mut _9: i32; // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12 scope 1 { - debug x => _3; // in scope 1 at $DIR/inline-closure.rs:+1:9: +1:10 - scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure.rs:12:5: 12:12 - debug _t => _8; // in scope 2 at $DIR/inline-closure.rs:+1:14: +1:16 - debug _q => _9; // in scope 2 at $DIR/inline-closure.rs:+1:18: +1:20 + debug x => _3; // in scope 1 at $DIR/inline_closure.rs:+1:9: +1:10 + scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline_closure.rs:12:5: 12:12 + debug _t => _8; // in scope 2 at $DIR/inline_closure.rs:+1:14: +1:16 + debug _q => _9; // in scope 2 at $DIR/inline_closure.rs:+1:18: +1:20 } } 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 - 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 - StorageLive(_6); // scope 1 at $DIR/inline-closure.rs:+2:7: +2:8 - _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 - 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 - _9 = move (_5.1: i32); // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12 - _0 = _8; // scope 2 at $DIR/inline-closure.rs:+1:22: +1:24 - StorageDead(_9); // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12 - StorageDead(_8); // scope 1 at $DIR/inline-closure.rs:+2:5: +2:12 - StorageDead(_7); // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12 - StorageDead(_6); // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12 - StorageDead(_5); // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12 - StorageDead(_4); // scope 1 at $DIR/inline-closure.rs:+2:11: +2:12 - StorageDead(_3); // scope 0 at $DIR/inline-closure.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline-closure.rs:+3:2: +3:2 + 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 + 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 + StorageLive(_6); // scope 1 at $DIR/inline_closure.rs:+2:7: +2:8 + _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 + 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 + _9 = move (_5.1: i32); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 + _0 = _8; // scope 2 at $DIR/inline_closure.rs:+1:22: +1:24 + StorageDead(_9); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 + StorageDead(_8); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 + StorageDead(_7); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 + StorageDead(_6); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 + StorageDead(_5); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 + StorageDead(_4); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 + StorageDead(_3); // scope 0 at $DIR/inline_closure.rs:+3:1: +3:2 + return; // scope 0 at $DIR/inline_closure.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/inline/inline_closure.rs b/src/test/mir-opt/inline/inline_closure.rs new file mode 100644 index 000000000..715fd0138 --- /dev/null +++ b/src/test/mir-opt/inline/inline_closure.rs @@ -0,0 +1,13 @@ +// compile-flags: -Z span_free_formats + +// Tests that MIR inliner can handle closure arguments. (#45894) + +fn main() { + println!("{}", foo(0, 14)); +} + +// EMIT_MIR inline_closure.foo.Inline.after.mir +fn foo(_t: T, q: i32) -> i32 { + let x = |_t, _q| _t; + x(q, q) +} diff --git a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index 4069e9f89..dd32eb2d8 100644 --- a/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -1,56 +1,52 @@ // MIR for `foo` after Inline fn foo(_1: T, _2: &i32) -> i32 { - debug _t => _1; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:17: +0:19 - debug q => _2; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:24: +0:25 - let mut _0: i32; // return place in scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:36: +0:39 - let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10 - let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:6 - let mut _5: (&i32, &i32); // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 - let mut _6: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:7: +5:8 - let mut _7: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:10: +5:11 - let mut _8: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 - let mut _9: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 + debug _t => _1; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+0:17: +0:19 + debug q => _2; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+0:24: +0:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline_closure_borrows_arg.rs:+0:36: +0:39 + let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10 + let mut _4: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6 + let mut _5: (&i32, &i32); // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 + let mut _6: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:7: +5:8 + let mut _7: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:10: +5:11 + let mut _8: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 + let mut _9: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 scope 1 { - debug x => _3; // in scope 1 at $DIR/inline-closure-borrows-arg.rs:+1:9: +1:10 - scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 - debug r => _8; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+1:14: +1:15 - debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+1:23: +1:25 - let _10: &i32; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:+2:13: +2:21 + debug x => _3; // in scope 1 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10 + scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline_closure_borrows_arg.rs:16:5: 16:12 + debug r => _8; // in scope 2 at $DIR/inline_closure_borrows_arg.rs:+1:14: +1:15 + debug _s => _9; // in scope 2 at $DIR/inline_closure_borrows_arg.rs:+1:23: +1:25 scope 3 { - debug variable => _10; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:+2:13: +2:21 + debug variable => _8; // in scope 3 at $DIR/inline_closure_borrows_arg.rs:+2:13: +2:21 } } } 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 - 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 - StorageLive(_6); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:7: +5:8 - _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 - 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 - _9 = move (_5.1: &i32); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 - StorageLive(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:+2:13: +2:21 - _10 = _8; // scope 2 at $DIR/inline-closure-borrows-arg.rs:+2:24: +2:27 - _0 = (*_10); // scope 3 at $DIR/inline-closure-borrows-arg.rs:+3:9: +3:18 - StorageDead(_10); // scope 2 at $DIR/inline-closure-borrows-arg.rs:+4:5: +4:6 - StorageDead(_9); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 - StorageDead(_8); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:5: +5:12 - StorageDead(_7); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12 - StorageDead(_6); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12 - StorageDead(_5); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12 - StorageDead(_4); // scope 1 at $DIR/inline-closure-borrows-arg.rs:+5:11: +5:12 - StorageDead(_3); // scope 0 at $DIR/inline-closure-borrows-arg.rs:+6:1: +6:2 - return; // scope 0 at $DIR/inline-closure-borrows-arg.rs:+6:2: +6:2 + 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 + 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 + StorageLive(_6); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:7: +5:8 + _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 + 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 + _9 = move (_5.1: &i32); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 + _0 = (*_8); // scope 3 at $DIR/inline_closure_borrows_arg.rs:+3:9: +3:18 + StorageDead(_9); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 + StorageDead(_8); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 + StorageDead(_7); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 + StorageDead(_6); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 + StorageDead(_5); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 + StorageDead(_4); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 + StorageDead(_3); // scope 0 at $DIR/inline_closure_borrows_arg.rs:+6:1: +6:2 + return; // scope 0 at $DIR/inline_closure_borrows_arg.rs:+6:2: +6:2 } } diff --git a/src/test/mir-opt/inline/inline_closure_borrows_arg.rs b/src/test/mir-opt/inline/inline_closure_borrows_arg.rs new file mode 100644 index 000000000..d76bc33f5 --- /dev/null +++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.rs @@ -0,0 +1,17 @@ +// compile-flags: -Z span_free_formats -Zunsound-mir-opts + +// Tests that MIR inliner can handle closure arguments, +// even when (#45894) + +fn main() { + println!("{}", foo(0, &14)); +} + +// EMIT_MIR inline_closure_borrows_arg.foo.Inline.after.mir +fn foo(_t: T, q: &i32) -> i32 { + let x = |r: &i32, _s: &i32| { + let variable = &*r; + *variable + }; + x(q, q) +} diff --git a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index a2234e7c1..fd19c2886 100644 --- a/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -1,65 +1,65 @@ // MIR for `foo` after Inline fn foo(_1: T, _2: i32) -> (i32, T) { - debug t => _1; // in scope 0 at $DIR/inline-closure-captures.rs:+0:17: +0:18 - debug q => _2; // in scope 0 at $DIR/inline-closure-captures.rs:+0:23: +0:24 - let mut _0: (i32, T); // return place in scope 0 at $DIR/inline-closure-captures.rs:+0:34: +0:42 - let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-captures.rs:+1:9: +1:10 - let mut _4: &i32; // in scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24 - let mut _5: &T; // in scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24 - let mut _6: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline-closure-captures.rs:+2:5: +2:6 - let mut _7: (i32,); // in scope 0 at $DIR/inline-closure-captures.rs:+2:5: +2:9 - let mut _8: i32; // in scope 0 at $DIR/inline-closure-captures.rs:+2:7: +2:8 - let mut _9: i32; // in scope 0 at $DIR/inline-closure-captures.rs:+2:5: +2:9 + debug t => _1; // in scope 0 at $DIR/inline_closure_captures.rs:+0:17: +0:18 + debug q => _2; // in scope 0 at $DIR/inline_closure_captures.rs:+0:23: +0:24 + let mut _0: (i32, T); // return place in scope 0 at $DIR/inline_closure_captures.rs:+0:34: +0:42 + let _3: [closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_captures.rs:+1:9: +1:10 + let mut _4: &i32; // in scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 + let mut _5: &T; // in scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 + let mut _6: &[closure@foo::{closure#0}]; // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:6 + let mut _7: (i32,); // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:9 + let mut _8: i32; // in scope 0 at $DIR/inline_closure_captures.rs:+2:7: +2:8 + let mut _9: i32; // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:9 scope 1 { - debug x => _3; // in scope 1 at $DIR/inline-closure-captures.rs:+1:9: +1:10 - scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline-closure-captures.rs:12:5: 12:9 - debug _q => _9; // in scope 2 at $DIR/inline-closure-captures.rs:+1:14: +1:16 - debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:+0:23: +0:24 - debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:+0:17: +0:18 - let mut _10: i32; // in scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20 - let mut _11: T; // in scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23 - let mut _12: &i32; // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:24 - let mut _13: &T; // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:24 + debug x => _3; // in scope 1 at $DIR/inline_closure_captures.rs:+1:9: +1:10 + scope 2 (inlined foo::::{closure#0}) { // at $DIR/inline_closure_captures.rs:12:5: 12:9 + debug _q => _9; // in scope 2 at $DIR/inline_closure_captures.rs:+1:14: +1:16 + debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:23: +0:24 + debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:17: +0:18 + let mut _10: i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 + let mut _11: T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 + let mut _12: &i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24 + let mut _13: &T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24 } } bb0: { - StorageLive(_3); // scope 0 at $DIR/inline-closure-captures.rs:+1:9: +1:10 - StorageLive(_4); // scope 0 at $DIR/inline-closure-captures.rs:+1:13: +1:24 - _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 - 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 - _6 = &_3; // scope 1 at $DIR/inline-closure-captures.rs:+2:5: +2:6 - 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 - 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 - _12 = deref_copy ((*_6).0: &i32); // scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20 - _10 = (*_12); // scope 2 at $DIR/inline-closure-captures.rs:+1:19: +1:20 - 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 - 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 - StorageDead(_8); // scope 1 at $DIR/inline-closure-captures.rs:+2:8: +2:9 - StorageDead(_7); // scope 1 at $DIR/inline-closure-captures.rs:+2:8: +2:9 - StorageDead(_6); // scope 1 at $DIR/inline-closure-captures.rs:+2:8: +2:9 - StorageDead(_3); // scope 0 at $DIR/inline-closure-captures.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline-closure-captures.rs:+3:2: +3:2 + StorageLive(_3); // scope 0 at $DIR/inline_closure_captures.rs:+1:9: +1:10 + StorageLive(_4); // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 + _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 + 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 + _6 = &_3; // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:6 + 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 + 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 + _12 = deref_copy ((*_6).0: &i32); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 + _10 = (*_12); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 + 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 + 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 + StorageDead(_8); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9 + StorageDead(_7); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9 + StorageDead(_6); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9 + StorageDead(_3); // scope 0 at $DIR/inline_closure_captures.rs:+3:1: +3:2 + return; // scope 0 at $DIR/inline_closure_captures.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/inline/inline_closure_captures.rs b/src/test/mir-opt/inline/inline_closure_captures.rs new file mode 100644 index 000000000..52b6817e4 --- /dev/null +++ b/src/test/mir-opt/inline/inline_closure_captures.rs @@ -0,0 +1,13 @@ +// compile-flags: -Z span_free_formats + +// Tests that MIR inliner can handle closure captures. + +fn main() { + println!("{:?}", foo(0, 14)); +} + +// EMIT_MIR inline_closure_captures.foo.Inline.after.mir +fn foo(t: T, q: i32) -> (i32, T) { + let x = |_q| (q, t); + x(q) +} diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff index cf800ba11..e30a5e116 100644 --- a/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff @@ -2,23 +2,23 @@ + // MIR for `inlined_no_sanitize` after Inline fn inlined_no_sanitize() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:+0:37: +0:37 - let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18 -+ scope 1 (inlined no_sanitize) { // at $DIR/inline-compatibility.rs:24:5: 24:18 + let mut _0: (); // return place in scope 0 at $DIR/inline_compatibility.rs:+0:37: +0:37 + let _1: (); // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18 ++ scope 1 (inlined no_sanitize) { // at $DIR/inline_compatibility.rs:24:5: 24:18 + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18 -- _1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18 + StorageLive(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18 +- _1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18 - // mir::Constant -- // + span: $DIR/inline-compatibility.rs:24:5: 24:16 +- // + span: $DIR/inline_compatibility.rs:24:5: 24:16 - // + literal: Const { ty: unsafe fn() {no_sanitize}, val: Value() } - } - - bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:18: +1:19 - _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:+0:37: +2:2 - return; // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:18: +1:19 + _0 = const (); // scope 0 at $DIR/inline_compatibility.rs:+0:37: +2:2 + return; // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff index a45f95902..c2b3c46a3 100644 --- a/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff @@ -2,23 +2,23 @@ + // MIR for `inlined_target_feature` after Inline fn inlined_target_feature() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:+0:40: +0:40 - let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21 -+ scope 1 (inlined target_feature) { // at $DIR/inline-compatibility.rs:13:5: 13:21 + let mut _0: (); // return place in scope 0 at $DIR/inline_compatibility.rs:+0:40: +0:40 + let _1: (); // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21 ++ scope 1 (inlined target_feature) { // at $DIR/inline_compatibility.rs:13:5: 13:21 + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21 -- _1 = target_feature() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21 + StorageLive(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21 +- _1 = target_feature() -> bb1; // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21 - // mir::Constant -- // + span: $DIR/inline-compatibility.rs:13:5: 13:19 +- // + span: $DIR/inline_compatibility.rs:13:5: 13:19 - // + literal: Const { ty: unsafe fn() {target_feature}, val: Value() } - } - - bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:21: +1:22 - _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:+0:40: +2:2 - return; // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:21: +1:22 + _0 = const (); // scope 0 at $DIR/inline_compatibility.rs:+0:40: +2:2 + return; // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff index 49aea431e..0ca5a5f70 100644 --- a/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff @@ -2,24 +2,24 @@ + // MIR for `not_inlined_c_variadic` after Inline fn not_inlined_c_variadic() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:+0:40: +0:40 - let _1: u32; // in scope 0 at $DIR/inline-compatibility.rs:+1:9: +1:10 + let mut _0: (); // return place in scope 0 at $DIR/inline_compatibility.rs:+0:40: +0:40 + let _1: u32; // in scope 0 at $DIR/inline_compatibility.rs:+1:9: +1:10 scope 1 { - debug s => _1; // in scope 1 at $DIR/inline-compatibility.rs:+1:9: +1:10 + debug s => _1; // in scope 1 at $DIR/inline_compatibility.rs:+1:9: +1:10 } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:9: +1:10 - _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> bb1; // scope 0 at $DIR/inline-compatibility.rs:+1:13: +1:52 + StorageLive(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:9: +1:10 + _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> bb1; // scope 0 at $DIR/inline_compatibility.rs:+1:13: +1:52 // mir::Constant - // + span: $DIR/inline-compatibility.rs:42:13: 42:16 + // + span: $DIR/inline_compatibility.rs:42:13: 42:16 // + literal: Const { ty: unsafe extern "C" fn(u32, ...) -> u32 {sum}, val: Value() } } bb1: { - _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:+0:40: +2:2 - StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:+2:1: +2:2 - return; // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2 + _0 = const (); // scope 0 at $DIR/inline_compatibility.rs:+0:40: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_compatibility.rs:+2:1: +2:2 + return; // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff index 94ce574a9..00d405c77 100644 --- a/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff @@ -2,21 +2,21 @@ + // MIR for `not_inlined_no_sanitize` after Inline fn not_inlined_no_sanitize() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:+0:41: +0:41 - let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18 + let mut _0: (); // return place in scope 0 at $DIR/inline_compatibility.rs:+0:41: +0:41 + let _1: (); // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18 bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18 - _1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:18 + StorageLive(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18 + _1 = no_sanitize() -> bb1; // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:18 // mir::Constant - // + span: $DIR/inline-compatibility.rs:29:5: 29:16 + // + span: $DIR/inline_compatibility.rs:29:5: 29:16 // + literal: Const { ty: unsafe fn() {no_sanitize}, val: Value() } } bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:18: +1:19 - _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:+0:41: +2:2 - return; // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:18: +1:19 + _0 = const (); // scope 0 at $DIR/inline_compatibility.rs:+0:41: +2:2 + return; // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff index 8506e257b..8b9c86f55 100644 --- a/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff +++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff @@ -2,21 +2,21 @@ + // MIR for `not_inlined_target_feature` after Inline fn not_inlined_target_feature() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-compatibility.rs:+0:44: +0:44 - let _1: (); // in scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21 + let mut _0: (); // return place in scope 0 at $DIR/inline_compatibility.rs:+0:44: +0:44 + let _1: (); // in scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21 bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21 - _1 = target_feature() -> bb1; // scope 0 at $DIR/inline-compatibility.rs:+1:5: +1:21 + StorageLive(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21 + _1 = target_feature() -> bb1; // scope 0 at $DIR/inline_compatibility.rs:+1:5: +1:21 // mir::Constant - // + span: $DIR/inline-compatibility.rs:18:5: 18:19 + // + span: $DIR/inline_compatibility.rs:18:5: 18:19 // + literal: Const { ty: unsafe fn() {target_feature}, val: Value() } } bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:21: +1:22 - _0 = const (); // scope 0 at $DIR/inline-compatibility.rs:+0:44: +2:2 - return; // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_compatibility.rs:+1:21: +1:22 + _0 = const (); // scope 0 at $DIR/inline_compatibility.rs:+0:44: +2:2 + return; // scope 0 at $DIR/inline_compatibility.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_compatibility.rs b/src/test/mir-opt/inline/inline_compatibility.rs new file mode 100644 index 000000000..30aff0a64 --- /dev/null +++ b/src/test/mir-opt/inline/inline_compatibility.rs @@ -0,0 +1,55 @@ +// Checks that only functions with compatible attributes are inlined. +// +// only-x86_64 + +#![crate_type = "lib"] +#![feature(no_sanitize)] +#![feature(target_feature_11)] +#![feature(c_variadic)] + +// EMIT_MIR inline_compatibility.inlined_target_feature.Inline.diff +#[target_feature(enable = "sse2")] +pub unsafe fn inlined_target_feature() { + target_feature(); +} + +// EMIT_MIR inline_compatibility.not_inlined_target_feature.Inline.diff +pub unsafe fn not_inlined_target_feature() { + target_feature(); +} + +// EMIT_MIR inline_compatibility.inlined_no_sanitize.Inline.diff +#[no_sanitize(address)] +pub unsafe fn inlined_no_sanitize() { + no_sanitize(); +} + +// EMIT_MIR inline_compatibility.not_inlined_no_sanitize.Inline.diff +pub unsafe fn not_inlined_no_sanitize() { + no_sanitize(); +} + +#[inline] +#[target_feature(enable = "sse2")] +pub unsafe fn target_feature() {} + +#[inline] +#[no_sanitize(address)] +pub unsafe fn no_sanitize() {} + +// EMIT_MIR inline_compatibility.not_inlined_c_variadic.Inline.diff +pub unsafe fn not_inlined_c_variadic() { + let s = sum(4u32, 4u32, 30u32, 200u32, 1000u32); +} + +#[no_mangle] +#[inline(always)] +unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 { + let mut s = 0; + let mut i = 0; + while i != n { + s += vs.arg::(); + i += 1; + } + s +} diff --git a/src/test/mir-opt/inline/inline_cycle.one.Inline.diff b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff index a4d706de0..f54a1a747 100644 --- a/src/test/mir-opt/inline/inline_cycle.one.Inline.diff +++ b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff @@ -2,29 +2,26 @@ + // MIR for `one` after Inline fn one() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-cycle.rs:+0:10: +0:10 - let _1: (); // in scope 0 at $DIR/inline-cycle.rs:+1:5: +1:24 -+ scope 1 (inlined ::call) { // at $DIR/inline-cycle.rs:14:5: 14:24 -+ scope 2 (inlined as Call>::call) { // at $DIR/inline-cycle.rs:43:9: 43:23 -+ scope 3 (inlined as Call>::call) { // at $DIR/inline-cycle.rs:28:9: 28:31 -+ } -+ } + let mut _0: (); // return place in scope 0 at $DIR/inline_cycle.rs:+0:10: +0:10 + let _1: (); // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 ++ scope 1 (inlined ::call) { // at $DIR/inline_cycle.rs:14:5: 14:24 + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:24 -- _1 = ::call() -> bb1; // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:24 -+ _1 = ::call() -> bb1; // scope 3 at $DIR/inline-cycle.rs:36:9: 36:28 + StorageLive(_1); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 +- _1 = ::call() -> bb1; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 ++ _1 = as Call>::call() -> bb1; // scope 1 at $DIR/inline_cycle.rs:43:9: 43:23 // mir::Constant -- // + span: $DIR/inline-cycle.rs:14:5: 14:22 -+ // + span: $DIR/inline-cycle.rs:36:9: 36:26 - // + literal: Const { ty: fn() {::call}, val: Value() } +- // + span: $DIR/inline_cycle.rs:14:5: 14:22 +- // + literal: Const { ty: fn() {::call}, val: Value() } ++ // + span: $DIR/inline_cycle.rs:43:9: 43:21 ++ // + literal: Const { ty: fn() { as Call>::call}, val: Value() } } bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-cycle.rs:+1:24: +1:25 - _0 = const (); // scope 0 at $DIR/inline-cycle.rs:+0:10: +2:2 - return; // scope 0 at $DIR/inline-cycle.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_cycle.rs:+1:24: +1:25 + _0 = const (); // scope 0 at $DIR/inline_cycle.rs:+0:10: +2:2 + return; // scope 0 at $DIR/inline_cycle.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_cycle.rs b/src/test/mir-opt/inline/inline_cycle.rs new file mode 100644 index 000000000..63ad57de1 --- /dev/null +++ b/src/test/mir-opt/inline/inline_cycle.rs @@ -0,0 +1,60 @@ +// Check that inliner handles various forms of recursion and doesn't fall into +// an infinite inlining cycle. The particular outcome of inlining is not +// crucial otherwise. +// +// Regression test for issue #78573. + +fn main() { + one(); + two(); +} + +// EMIT_MIR inline_cycle.one.Inline.diff +fn one() { + ::call(); +} + +pub trait Call { + fn call(); +} + +pub struct A(T); +pub struct B(T); +pub struct C; + +impl Call for A { + #[inline] + fn call() { + as Call>::call() + } +} + + +impl Call for B { + #[inline] + fn call() { + ::call() + } +} + +impl Call for C { + #[inline] + fn call() { + A::::call() + } +} + +// EMIT_MIR inline_cycle.two.Inline.diff +fn two() { + call(f); +} + +#[inline] +fn call(f: F) { + f(); +} + +#[inline] +fn f() { + call(f); +} diff --git a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff index b1a5b62ef..a940848c2 100644 --- a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff +++ b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff @@ -2,54 +2,41 @@ + // MIR for `two` after Inline fn two() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-cycle.rs:+0:10: +0:10 - let _1: (); // in scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12 -+ let mut _2: fn() {f}; // in scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12 -+ scope 1 (inlined call::) { // at $DIR/inline-cycle.rs:49:5: 49:12 -+ debug f => _2; // in scope 1 at $DIR/inline-cycle.rs:53:22: 53:23 -+ let _3: (); // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:8 -+ let mut _4: fn() {f}; // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:6 -+ let mut _5: (); // in scope 1 at $DIR/inline-cycle.rs:54:5: 54:8 -+ scope 2 (inlined >::call_once - shim(fn() {f})) { // at $DIR/inline-cycle.rs:54:5: 54:8 -+ scope 3 (inlined f) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL -+ let _6: (); // in scope 3 at $DIR/inline-cycle.rs:59:5: 59:12 -+ } -+ } + let mut _0: (); // return place in scope 0 at $DIR/inline_cycle.rs:+0:10: +0:10 + let _1: (); // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 ++ let mut _2: fn() {f}; // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 ++ scope 1 (inlined call::) { // at $DIR/inline_cycle.rs:49:5: 49:12 ++ debug f => _2; // in scope 1 at $DIR/inline_cycle.rs:53:22: 53:23 ++ let _3: (); // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 ++ let mut _4: (); // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12 -- _1 = call::(f) -> bb1; // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12 -+ StorageLive(_2); // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12 -+ _2 = f; // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12 + StorageLive(_1); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 +- _1 = call::(f) -> bb1; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 ++ StorageLive(_2); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 ++ _2 = f; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 // mir::Constant -- // + span: $DIR/inline-cycle.rs:49:5: 49:9 -+ // + span: $DIR/inline-cycle.rs:49:10: 49:11 -+ // + literal: Const { ty: fn() {f}, val: Value() } -+ StorageLive(_3); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8 -+ StorageLive(_4); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:6 -+ _4 = move _2; // scope 1 at $DIR/inline-cycle.rs:54:5: 54:6 -+ StorageLive(_5); // scope 1 at $DIR/inline-cycle.rs:54:5: 54:8 -+ StorageLive(_6); // scope 3 at $DIR/inline-cycle.rs:59:5: 59:12 -+ _6 = call::(f) -> bb1; // scope 3 at $DIR/inline-cycle.rs:59:5: 59:12 -+ // mir::Constant -+ // + span: $DIR/inline-cycle.rs:59:5: 59:9 - // + literal: Const { ty: fn(fn() {f}) {call::}, val: Value() } - // mir::Constant -- // + span: $DIR/inline-cycle.rs:49:10: 49:11 -+ // + span: $DIR/inline-cycle.rs:59:10: 59:11 +- // + span: $DIR/inline_cycle.rs:49:5: 49:9 +- // + literal: Const { ty: fn(fn() {f}) {call::}, val: Value() } +- // mir::Constant + // + span: $DIR/inline_cycle.rs:49:10: 49:11 // + literal: Const { ty: fn() {f}, val: Value() } ++ StorageLive(_3); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 ++ StorageLive(_4); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 ++ _3 = >::call_once(move _2, move _4) -> bb1; // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 ++ // mir::Constant ++ // + span: $DIR/inline_cycle.rs:54:5: 54:6 ++ // + literal: Const { ty: extern "rust-call" fn(fn() {f}, ()) -> >::Output {>::call_once}, val: Value() } } bb1: { -+ StorageDead(_6); // scope 3 at $DIR/inline-cycle.rs:59:12: 59:13 -+ StorageDead(_5); // scope 1 at $DIR/inline-cycle.rs:54:7: 54:8 -+ StorageDead(_4); // scope 1 at $DIR/inline-cycle.rs:54:7: 54:8 -+ StorageDead(_3); // scope 1 at $DIR/inline-cycle.rs:54:8: 54:9 -+ StorageDead(_2); // scope 0 at $DIR/inline-cycle.rs:+1:5: +1:12 - StorageDead(_1); // scope 0 at $DIR/inline-cycle.rs:+1:12: +1:13 - _0 = const (); // scope 0 at $DIR/inline-cycle.rs:+0:10: +2:2 - return; // scope 0 at $DIR/inline-cycle.rs:+2:2: +2:2 ++ StorageDead(_4); // scope 1 at $DIR/inline_cycle.rs:54:7: 54:8 ++ StorageDead(_3); // scope 1 at $DIR/inline_cycle.rs:54:8: 54:9 ++ StorageDead(_2); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + StorageDead(_1); // scope 0 at $DIR/inline_cycle.rs:+1:12: +1:13 + _0 = const (); // scope 0 at $DIR/inline_cycle.rs:+0:10: +2:2 + return; // scope 0 at $DIR/inline_cycle.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff b/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff index fc5d57ce8..04de3e61e 100644 --- a/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff @@ -2,31 +2,28 @@ + // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-cycle-generic.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/inline-cycle-generic.rs:+1:5: +1:24 -+ scope 1 (inlined ::call) { // at $DIR/inline-cycle-generic.rs:9:5: 9:24 -+ scope 2 (inlined as Call>::call) { // at $DIR/inline-cycle-generic.rs:38:9: 38:31 -+ scope 3 (inlined ::call) { // at $DIR/inline-cycle-generic.rs:31:9: 31:28 -+ scope 4 (inlined as Call>::call) { // at $DIR/inline-cycle-generic.rs:23:9: 23:31 -+ } -+ } + let mut _0: (); // return place in scope 0 at $DIR/inline_cycle_generic.rs:+0:11: +0:11 + let _1: (); // in scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 ++ scope 1 (inlined ::call) { // at $DIR/inline_cycle_generic.rs:9:5: 9:24 ++ scope 2 (inlined as Call>::call) { // at $DIR/inline_cycle_generic.rs:38:9: 38:31 + } + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-cycle-generic.rs:+1:5: +1:24 -- _1 = ::call() -> bb1; // scope 0 at $DIR/inline-cycle-generic.rs:+1:5: +1:24 -+ _1 = ::call() -> bb1; // scope 4 at $DIR/inline-cycle-generic.rs:31:9: 31:28 + StorageLive(_1); // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 +- _1 = ::call() -> bb1; // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 ++ _1 = ::call() -> bb1; // scope 2 at $DIR/inline_cycle_generic.rs:31:9: 31:28 // mir::Constant -- // + span: $DIR/inline-cycle-generic.rs:9:5: 9:22 -+ // + span: $DIR/inline-cycle-generic.rs:31:9: 31:26 - // + literal: Const { ty: fn() {::call}, val: Value() } +- // + span: $DIR/inline_cycle_generic.rs:9:5: 9:22 +- // + literal: Const { ty: fn() {::call}, val: Value() } ++ // + span: $DIR/inline_cycle_generic.rs:31:9: 31:26 ++ // + literal: Const { ty: fn() {::call}, val: Value() } } bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-cycle-generic.rs:+1:24: +1:25 - _0 = const (); // scope 0 at $DIR/inline-cycle-generic.rs:+0:11: +2:2 - return; // scope 0 at $DIR/inline-cycle-generic.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_cycle_generic.rs:+1:24: +1:25 + _0 = const (); // scope 0 at $DIR/inline_cycle_generic.rs:+0:11: +2:2 + return; // scope 0 at $DIR/inline_cycle_generic.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_cycle_generic.rs b/src/test/mir-opt/inline/inline_cycle_generic.rs new file mode 100644 index 000000000..24b4f3793 --- /dev/null +++ b/src/test/mir-opt/inline/inline_cycle_generic.rs @@ -0,0 +1,40 @@ +// Check that inliner handles various forms of recursion and doesn't fall into +// an infinite inlining cycle. The particular outcome of inlining is not +// crucial otherwise. +// +// Regression test for issue #78573. + +// EMIT_MIR inline_cycle_generic.main.Inline.diff +fn main() { + ::call(); +} + +pub trait Call { + fn call(); +} + +pub struct A; +pub struct B(T); +pub struct C; + +impl Call for A { + #[inline] + fn call() { + as Call>::call() + } +} + + +impl Call for B { + #[inline] + fn call() { + ::call() + } +} + +impl Call for C { + #[inline] + fn call() { + as Call>::call() + } +} diff --git a/src/test/mir-opt/inline/inline_diverging.f.Inline.diff b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff index cef4cfc67..b49191f49 100644 --- a/src/test/mir-opt/inline/inline_diverging.f.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff @@ -2,23 +2,23 @@ + // MIR for `f` after Inline fn f() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-diverging.rs:+0:12: +0:12 - let mut _1: !; // in scope 0 at $DIR/inline-diverging.rs:+0:12: +2:2 - let _2: !; // in scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12 -+ scope 1 (inlined sleep) { // at $DIR/inline-diverging.rs:8:5: 8:12 + let mut _0: (); // return place in scope 0 at $DIR/inline_diverging.rs:+0:12: +0:12 + let mut _1: !; // in scope 0 at $DIR/inline_diverging.rs:+0:12: +2:2 + let _2: !; // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12 ++ scope 1 (inlined sleep) { // at $DIR/inline_diverging.rs:8:5: 8:12 + } bb0: { - StorageLive(_2); // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12 -- _2 = sleep(); // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12 + StorageLive(_2); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12 +- _2 = sleep(); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12 - // mir::Constant -- // + span: $DIR/inline-diverging.rs:8:5: 8:10 +- // + span: $DIR/inline_diverging.rs:8:5: 8:10 - // + literal: Const { ty: fn() -> ! {sleep}, val: Value() } -+ goto -> bb1; // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:12 ++ goto -> bb1; // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12 + } + + bb1: { -+ goto -> bb1; // scope 1 at $DIR/inline-diverging.rs:39:5: 39:12 ++ goto -> bb1; // scope 1 at $DIR/inline_diverging.rs:39:5: 39:12 } } diff --git a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff index a71baad3e..1e703a8fd 100644 --- a/src/test/mir-opt/inline/inline_diverging.g.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff @@ -2,42 +2,42 @@ + // MIR for `g` after Inline fn g(_1: i32) -> u32 { - debug i => _1; // in scope 0 at $DIR/inline-diverging.rs:+0:10: +0:11 - let mut _0: u32; // return place in scope 0 at $DIR/inline-diverging.rs:+0:21: +0:24 - let mut _2: bool; // in scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13 - let mut _3: i32; // in scope 0 at $DIR/inline-diverging.rs:+1:8: +1:9 - let mut _4: i32; // in scope 0 at $DIR/inline-diverging.rs:+2:9: +2:10 - let mut _5: !; // in scope 0 at $DIR/inline-diverging.rs:+3:12: +5:6 - let _6: !; // in scope 0 at $DIR/inline-diverging.rs:+4:9: +4:16 -+ scope 1 (inlined panic) { // at $DIR/inline-diverging.rs:16:9: 16:16 + debug i => _1; // in scope 0 at $DIR/inline_diverging.rs:+0:10: +0:11 + let mut _0: u32; // return place in scope 0 at $DIR/inline_diverging.rs:+0:21: +0:24 + let mut _2: bool; // in scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13 + let mut _3: i32; // in scope 0 at $DIR/inline_diverging.rs:+1:8: +1:9 + let mut _4: i32; // in scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10 + let mut _5: !; // in scope 0 at $DIR/inline_diverging.rs:+3:12: +5:6 + let _6: !; // in scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 ++ scope 1 (inlined panic) { // at $DIR/inline_diverging.rs:16:9: 16:16 + let mut _7: !; // in scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + } bb0: { - StorageLive(_2); // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13 - StorageLive(_3); // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:9 - _3 = _1; // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:9 - _2 = Gt(move _3, const 0_i32); // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13 - StorageDead(_3); // scope 0 at $DIR/inline-diverging.rs:+1:12: +1:13 - switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/inline-diverging.rs:+1:8: +1:13 + StorageLive(_2); // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13 + StorageLive(_3); // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:9 + _3 = _1; // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:9 + _2 = Gt(move _3, const 0_i32); // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13 + StorageDead(_3); // scope 0 at $DIR/inline_diverging.rs:+1:12: +1:13 + switchInt(move _2) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13 } bb1: { - StorageLive(_4); // scope 0 at $DIR/inline-diverging.rs:+2:9: +2:10 - _4 = _1; // scope 0 at $DIR/inline-diverging.rs:+2:9: +2:10 - _0 = move _4 as u32 (IntToInt); // scope 0 at $DIR/inline-diverging.rs:+2:9: +2:17 - StorageDead(_4); // scope 0 at $DIR/inline-diverging.rs:+2:16: +2:17 - StorageDead(_2); // scope 0 at $DIR/inline-diverging.rs:+5:5: +5:6 - return; // scope 0 at $DIR/inline-diverging.rs:+6:2: +6:2 + StorageLive(_4); // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10 + _4 = _1; // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10 + _0 = move _4 as u32 (IntToInt); // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:17 + StorageDead(_4); // scope 0 at $DIR/inline_diverging.rs:+2:16: +2:17 + StorageDead(_2); // scope 0 at $DIR/inline_diverging.rs:+5:5: +5:6 + return; // scope 0 at $DIR/inline_diverging.rs:+6:2: +6:2 } bb2: { - StorageLive(_6); // scope 0 at $DIR/inline-diverging.rs:+4:9: +4:16 -- _6 = panic(); // scope 0 at $DIR/inline-diverging.rs:+4:9: +4:16 + StorageLive(_6); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 +- _6 = panic(); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 + StorageLive(_7); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL + _7 = begin_panic::<&str>(const "explicit panic"); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL // mir::Constant -- // + span: $DIR/inline-diverging.rs:16:9: 16:14 +- // + span: $DIR/inline_diverging.rs:16:9: 16:14 - // + literal: Const { ty: fn() -> ! {panic}, val: Value() } + // + span: $SRC_DIR/std/src/panic.rs:LL:COL + // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value() } diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff index 6569ab24c..a01bcf164 100644 --- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -2,55 +2,87 @@ + // MIR for `h` after Inline fn h() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-diverging.rs:+0:12: +0:12 - let _1: (!, !); // in scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22 -+ let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22 -+ scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline-diverging.rs:22:5: 22:22 -+ debug f => _2; // in scope 1 at $DIR/inline-diverging.rs:26:36: 26:37 -+ let _3: !; // in scope 1 at $DIR/inline-diverging.rs:27:9: 27:10 -+ let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:27:13: 27:14 -+ let mut _5: (); // in scope 1 at $DIR/inline-diverging.rs:27:13: 27:16 -+ let mut _7: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:28:13: 28:14 -+ let mut _8: (); // in scope 1 at $DIR/inline-diverging.rs:28:13: 28:16 -+ let mut _9: !; // in scope 1 at $DIR/inline-diverging.rs:29:6: 29:7 -+ let mut _10: !; // in scope 1 at $DIR/inline-diverging.rs:29:9: 29:10 + let mut _0: (); // return place in scope 0 at $DIR/inline_diverging.rs:+0:12: +0:12 + let _1: (!, !); // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline_diverging.rs:22:5: 22:22 ++ debug f => _2; // in scope 1 at $DIR/inline_diverging.rs:26:36: 26:37 ++ let _3: !; // in scope 1 at $DIR/inline_diverging.rs:27:9: 27:10 ++ let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 ++ let mut _5: (); // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 ++ let mut _6: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:14 ++ let mut _7: (); // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:16 ++ let mut _8: !; // in scope 1 at $DIR/inline_diverging.rs:29:6: 29:7 ++ let mut _9: !; // in scope 1 at $DIR/inline_diverging.rs:29:9: 29:10 + scope 2 { -+ debug a => _3; // in scope 2 at $DIR/inline-diverging.rs:27:9: 27:10 -+ let _6: !; // in scope 2 at $DIR/inline-diverging.rs:28:9: 28:10 ++ debug a => _3; // in scope 2 at $DIR/inline_diverging.rs:27:9: 27:10 + scope 3 { -+ debug b => _6; // in scope 3 at $DIR/inline-diverging.rs:28:9: 28:10 -+ } -+ scope 6 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:28:13: 28:16 -+ scope 7 (inlined sleep) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL -+ } -+ } -+ } -+ scope 4 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:27:13: 27:16 -+ scope 5 (inlined sleep) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ debug b => _9; // in scope 3 at $DIR/inline_diverging.rs:28:9: 28:10 + } + } + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22 -- _1 = call_twice:: ! {sleep}>(sleep); // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22 -+ StorageLive(_2); // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22 -+ _2 = sleep; // scope 0 at $DIR/inline-diverging.rs:+1:5: +1:22 + StorageLive(_1); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 +- _1 = call_twice:: ! {sleep}>(sleep); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ StorageLive(_2); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ _2 = sleep; // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 // mir::Constant -- // + span: $DIR/inline-diverging.rs:22:5: 22:15 +- // + span: $DIR/inline_diverging.rs:22:5: 22:15 - // + literal: Const { ty: fn(fn() -> ! {sleep}) -> (!, !) {call_twice:: ! {sleep}>}, val: Value() } - // mir::Constant - // + span: $DIR/inline-diverging.rs:22:16: 22:21 + // + span: $DIR/inline_diverging.rs:22:16: 22:21 // + literal: Const { ty: fn() -> ! {sleep}, val: Value() } -+ StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:27:9: 27:10 -+ StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:27:13: 27:14 -+ _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:27:13: 27:14 -+ StorageLive(_5); // scope 1 at $DIR/inline-diverging.rs:27:13: 27:16 -+ goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:39:5: 39:12 ++ StorageLive(_9); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ StorageLive(_3); // scope 1 at $DIR/inline_diverging.rs:27:9: 27:10 ++ StorageLive(_4); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 ++ _4 = &_2; // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 ++ StorageLive(_5); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 ++ _3 = ! {sleep} as Fn<()>>::call(move _4, move _5) -> [return: bb1, unwind: bb5]; // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 ++ // mir::Constant ++ // + span: $DIR/inline_diverging.rs:27:13: 27:14 ++ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() -> ! {sleep}, ()) -> ! {sleep} as FnOnce<()>>::Output { ! {sleep} as Fn<()>>::call}, val: Value() } + } + + bb1: { -+ goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:39:5: 39:12 ++ StorageDead(_5); // scope 1 at $DIR/inline_diverging.rs:27:15: 27:16 ++ StorageDead(_4); // scope 1 at $DIR/inline_diverging.rs:27:15: 27:16 ++ StorageLive(_6); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 ++ _6 = &_2; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 ++ StorageLive(_7); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 ++ _9 = ! {sleep} as Fn<()>>::call(move _6, move _7) -> [return: bb2, unwind: bb4]; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 ++ // mir::Constant ++ // + span: $DIR/inline_diverging.rs:28:13: 28:14 ++ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() -> ! {sleep}, ()) -> ! {sleep} as FnOnce<()>>::Output { ! {sleep} as Fn<()>>::call}, val: Value() } ++ } ++ ++ bb2: { ++ StorageDead(_7); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 ++ 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 ++ 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) -> bb3; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 ++ } ++ ++ bb3: { ++ unreachable; // scope 0 at $DIR/inline_diverging.rs:30:2: 30:2 ++ } ++ ++ bb4 (cleanup): { ++ drop(_3) -> bb5; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 ++ } ++ ++ bb5 (cleanup): { ++ drop(_2) -> bb6; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 ++ } ++ ++ bb6 (cleanup): { ++ resume; // scope 1 at $DIR/inline_diverging.rs:26:1: 30:2 } } diff --git a/src/test/mir-opt/inline/inline_diverging.rs b/src/test/mir-opt/inline/inline_diverging.rs new file mode 100644 index 000000000..ae6f814c2 --- /dev/null +++ b/src/test/mir-opt/inline/inline_diverging.rs @@ -0,0 +1,40 @@ +// Tests inlining of diverging calls. +// +// ignore-wasm32-bare compiled with panic=abort by default +#![crate_type = "lib"] + +// EMIT_MIR inline_diverging.f.Inline.diff +pub fn f() { + sleep(); +} + +// EMIT_MIR inline_diverging.g.Inline.diff +pub fn g(i: i32) -> u32 { + if i > 0 { + i as u32 + } else { + panic(); + } +} + +// EMIT_MIR inline_diverging.h.Inline.diff +pub fn h() { + call_twice(sleep); +} + +#[inline(always)] +pub fn call_twice R>(f: F) -> (R, R) { + let a = f(); + let b = f(); + (a, b) +} + +#[inline(always)] +fn panic() -> ! { + panic!(); +} + +#[inline(always)] +fn sleep() -> ! { + loop {} +} diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff index 3fd8aad72..91bff3d32 100644 --- a/src/test/mir-opt/inline/inline_generator.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -2,59 +2,56 @@ + // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-generator.rs:+0:11: +0:11 - let _1: std::ops::GeneratorState; // in scope 0 at $DIR/inline-generator.rs:+1:9: +1:11 - 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:14: +1:46 + let mut _0: (); // return place in scope 0 at $DIR/inline_generator.rs:+0:11: +0:11 + let _1: std::ops::GeneratorState; // in scope 0 at $DIR/inline_generator.rs:+1:9: +1:11 + 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:14: +1:46 scope 1 { - debug _r => _1; // in scope 1 at $DIR/inline-generator.rs:+1:9: +1:11 + debug _r => _1; // in scope 1 at $DIR/inline_generator.rs:+1:9: +1:11 } -+ scope 2 (inlined g) { // at $DIR/inline-generator.rs:9:28: 9:31 ++ scope 2 (inlined g) { // at $DIR/inline_generator.rs:9:28: 9:31 + } -+ scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32 ++ 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 ++ 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 ++ 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 ++ 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 + } + } + } -+ scope 6 (inlined g::{closure#0}) { // at $DIR/inline-generator.rs:9:14: 9:46 -+ debug a => _11; // 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: bool; // in scope 6 at $DIR/inline-generator.rs:15:20: 15:21 -+ let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:15:9: 15:9 -+ let _11: bool; // in scope 6 at $DIR/inline-generator.rs:15:6: 15:7 -+ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 -+ let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 -+ let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 -+ let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ scope 6 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:14: 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 ++ 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: { - StorageLive(_1); // scope 0 at $DIR/inline-generator.rs:+1:9: +1:11 - StorageLive(_2); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:32 - StorageLive(_3); // scope 0 at $DIR/inline-generator.rs:+1:23: +1:31 - StorageLive(_4); // scope 0 at $DIR/inline-generator.rs:+1:28: +1:31 -- _4 = g() -> bb1; // scope 0 at $DIR/inline-generator.rs:+1:28: +1:31 + StorageLive(_1); // scope 0 at $DIR/inline_generator.rs:+1:9: +1:11 + StorageLive(_2); // scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 + StorageLive(_3); // scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 + StorageLive(_4); // scope 0 at $DIR/inline_generator.rs:+1:28: +1:31 +- _4 = g() -> bb1; // scope 0 at $DIR/inline_generator.rs:+1:28: +1:31 - // mir::Constant -- // + span: $DIR/inline-generator.rs:9:28: 9:29 +- // + span: $DIR/inline_generator.rs:9:28: 9:29 - // + literal: Const { ty: fn() -> impl Generator {g}, val: Value() } - } - - 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 - _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 ++ 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 + _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 -- // + span: $DIR/inline-generator.rs:9:14: 9:22 +- // + span: $DIR/inline_generator.rs:9:14: 9:22 - // + user_ty: UserType(0) -- // + literal: Const { ty: fn(&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new}, val: Value() } +- // + literal: Const { ty: fn(&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]) -> Pin<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> {Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new}, val: Value() } - } - - bb2: { @@ -63,86 +60,77 @@ + 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 ++ (_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 - 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 + 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:14: +1:46 -+ _7 = const false; // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 -+ StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 -+ StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 -+ _13 = 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 -+ _12 = discriminant((*_13)); // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 -+ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 +- // + 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:14: +1:46 ++ _7 = const false; // scope 0 at $DIR/inline_generator.rs:+1:14: +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_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 } - bb3: { + bb1: { -+ StorageDead(_11); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 -+ StorageDead(_10); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 -+ StorageDead(_7); // scope 0 at $DIR/inline-generator.rs:+1:14: +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 - StorageDead(_1); // scope 0 at $DIR/inline-generator.rs:+2:1: +2:2 - return; // scope 0 at $DIR/inline-generator.rs:+2:2: +2:2 ++ StorageDead(_7); // scope 0 at $DIR/inline_generator.rs:+1:14: +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 + StorageDead(_1); // scope 0 at $DIR/inline_generator.rs:+2:1: +2:2 + return; // scope 0 at $DIR/inline_generator.rs:+2:2: +2:2 } - bb4 (cleanup): { + bb2 (cleanup): { - resume; // scope 0 at $DIR/inline-generator.rs:+0:1: +2:2 + resume; // scope 0 at $DIR/inline_generator.rs:+0:1: +2:2 + } + + bb3: { -+ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 -+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:15:17: 15:39 -+ StorageLive(_9); // scope 6 at $DIR/inline-generator.rs:15:20: 15:21 -+ _9 = _11; // scope 6 at $DIR/inline-generator.rs:15:20: 15:21 -+ switchInt(move _9) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:15:20: 15:21 ++ StorageLive(_8); // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 ++ switchInt(move _7) -> [false: 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 -+ goto -> bb6; // scope 6 at $DIR/inline-generator.rs:15:17: 15:39 ++ _8 = 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 -+ goto -> bb6; // scope 6 at $DIR/inline-generator.rs:15:17: 15:39 ++ _8 = 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: { -+ StorageDead(_9); // scope 6 at $DIR/inline-generator.rs:15:38: 15:39 -+ 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 -+ _14 = 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((*_14)) = 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 ++ 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 ++ 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 -+ _10 = move _7; // 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 _10; // 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 -+ _15 = 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((*_15)) = 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 ++ 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 ++ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:41: 15:41 + } + + bb8: { -+ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 + } + + bb9: { -+ unreachable; // scope 6 at $DIR/inline-generator.rs:15:5: 15:41 ++ unreachable; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 } } diff --git a/src/test/mir-opt/inline/inline_generator.rs b/src/test/mir-opt/inline/inline_generator.rs new file mode 100644 index 000000000..d11b3e548 --- /dev/null +++ b/src/test/mir-opt/inline/inline_generator.rs @@ -0,0 +1,16 @@ +// ignore-wasm32-bare compiled with panic=abort by default +#![feature(generators, generator_trait)] + +use std::ops::Generator; +use std::pin::Pin; + +// EMIT_MIR inline_generator.main.Inline.diff +fn main() { + let _r = Pin::new(&mut g()).resume(false); +} + +#[inline(always)] +pub fn g() -> impl Generator { + #[inline(always)] + |a| { yield if a { 7 } else { 13 } } +} diff --git a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff index 076509df3..f1988ea4b 100644 --- a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -2,43 +2,59 @@ + // MIR for `default` after Inline fn default() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-instruction-set.rs:+0:18: +0:18 - let _1: (); // in scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26 - let _2: (); // in scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26 - let _3: (); // in scope 0 at $DIR/inline-instruction-set.rs:+3:5: +3:30 -+ scope 1 (inlined instruction_set_default) { // at $DIR/inline-instruction-set.rs:53:5: 53:30 + let mut _0: (); // return place in scope 0 at $DIR/inline_instruction_set.rs:+0:18: +0:18 + let _1: (); // in scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + let _2: (); // in scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 + let _3: (); // in scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 + let _4: (); // in scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 ++ scope 1 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:59:5: 59:30 ++ } ++ scope 2 (inlined inline_always_and_using_inline_asm) { // at $DIR/inline_instruction_set.rs:60:5: 60:41 ++ scope 3 { ++ } + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26 + StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 // mir::Constant - // + span: $DIR/inline-instruction-set.rs:51:5: 51:24 + // + span: $DIR/inline_instruction_set.rs:57:5: 57:24 // + literal: Const { ty: fn() {instruction_set_a32}, val: Value() } } bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-instruction-set.rs:+1:26: +1:27 - StorageLive(_2); // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26 - _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26 + StorageDead(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27 + StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 + _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 // mir::Constant - // + span: $DIR/inline-instruction-set.rs:52:5: 52:24 + // + span: $DIR/inline_instruction_set.rs:58:5: 58:24 // + literal: Const { ty: fn() {instruction_set_t32}, val: Value() } } bb2: { - StorageDead(_2); // scope 0 at $DIR/inline-instruction-set.rs:+2:26: +2:27 - StorageLive(_3); // scope 0 at $DIR/inline-instruction-set.rs:+3:5: +3:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline-instruction-set.rs:+3:5: +3:30 + StorageDead(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27 + StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 - // mir::Constant -- // + span: $DIR/inline-instruction-set.rs:53:5: 53:28 +- // + span: $DIR/inline_instruction_set.rs:59:5: 59:28 - // + literal: Const { ty: fn() {instruction_set_default}, val: Value() } - } - - bb3: { - StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:+3:30: +3:31 - _0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:+0:18: +4:2 - return; // scope 0 at $DIR/inline-instruction-set.rs:+4:2: +4:2 + StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 + StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- // mir::Constant +- // + span: $DIR/inline_instruction_set.rs:60:5: 60:39 +- // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value() } ++ asm!("/* do nothing */", options((empty))) -> bb3; // scope 3 at $DIR/inline_instruction_set.rs:43:14: 43:38 + } + +- bb4: { ++ bb3: { + StorageDead(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:41: +4:42 + _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:18: +5:2 + return; // scope 0 at $DIR/inline_instruction_set.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/inline/inline_instruction_set.rs b/src/test/mir-opt/inline/inline_instruction_set.rs new file mode 100644 index 000000000..5dfb04943 --- /dev/null +++ b/src/test/mir-opt/inline/inline_instruction_set.rs @@ -0,0 +1,61 @@ +// Checks that only functions with the compatible instruction_set attributes are inlined. +// +// A function is "compatible" when the *callee* has the same attribute or no attribute. +// +// compile-flags: --target thumbv4t-none-eabi +// needs-llvm-components: arm + +#![crate_type = "lib"] +#![feature(rustc_attrs)] +#![feature(no_core, lang_items)] +#![feature(isa_attribute)] +#![no_core] + +#[rustc_builtin_macro] +#[macro_export] +macro_rules! asm { + ("assembly template", + $(operands,)* + $(options($(option),*))? + ) => { + /* compiler built-in */ + }; +} + +#[lang = "sized"] +trait Sized {} +#[lang = "copy"] +trait Copy {} + +#[instruction_set(arm::a32)] +#[inline] +fn instruction_set_a32() {} + +#[instruction_set(arm::t32)] +#[inline] +fn instruction_set_t32() {} + +#[inline] +fn instruction_set_default() {} + +#[inline(always)] +fn inline_always_and_using_inline_asm() { + unsafe { asm!("/* do nothing */") }; +} + +// EMIT_MIR inline_instruction_set.t32.Inline.diff +#[instruction_set(arm::t32)] +pub fn t32() { + instruction_set_a32(); + instruction_set_t32(); + instruction_set_default(); + inline_always_and_using_inline_asm(); +} + +// EMIT_MIR inline_instruction_set.default.Inline.diff +pub fn default() { + instruction_set_a32(); + instruction_set_t32(); + instruction_set_default(); + inline_always_and_using_inline_asm(); +} diff --git a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff index b275d08e0..e777b2cc2 100644 --- a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -2,45 +2,57 @@ + // MIR for `t32` after Inline fn t32() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-instruction-set.rs:+0:14: +0:14 - let _1: (); // in scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26 - let _2: (); // in scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26 - let _3: (); // in scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30 -+ scope 1 (inlined instruction_set_t32) { // at $DIR/inline-instruction-set.rs:43:5: 43:26 + let mut _0: (); // return place in scope 0 at $DIR/inline_instruction_set.rs:+0:14: +0:14 + let _1: (); // in scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + let _2: (); // in scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 + let _3: (); // in scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 + let _4: (); // in scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 ++ scope 1 (inlined instruction_set_t32) { // at $DIR/inline_instruction_set.rs:50:5: 50:26 ++ } ++ scope 2 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:51:5: 51:30 + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline-instruction-set.rs:+1:5: +1:26 + StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 // mir::Constant - // + span: $DIR/inline-instruction-set.rs:42:5: 42:24 + // + span: $DIR/inline_instruction_set.rs:49:5: 49:24 // + literal: Const { ty: fn() {instruction_set_a32}, val: Value() } } bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-instruction-set.rs:+1:26: +1:27 - StorageLive(_2); // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26 -- _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:+2:5: +2:26 + StorageDead(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27 + StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 +- _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - // mir::Constant -- // + span: $DIR/inline-instruction-set.rs:43:5: 43:24 +- // + span: $DIR/inline_instruction_set.rs:50:5: 50:24 - // + literal: Const { ty: fn() {instruction_set_t32}, val: Value() } - } - - bb2: { - StorageDead(_2); // scope 0 at $DIR/inline-instruction-set.rs:+2:26: +2:27 - StorageLive(_3); // scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30 -+ _3 = instruction_set_default() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:+5:5: +5:30 + StorageDead(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27 + StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- // mir::Constant +- // + span: $DIR/inline_instruction_set.rs:51:5: 51:28 +- // + literal: Const { ty: fn() {instruction_set_default}, val: Value() } +- } +- +- bb3: { + StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 + StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 ++ _4 = inline_always_and_using_inline_asm() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 // mir::Constant - // + span: $DIR/inline-instruction-set.rs:46:5: 46:28 - // + literal: Const { ty: fn() {instruction_set_default}, val: Value() } + // + span: $DIR/inline_instruction_set.rs:52:5: 52:39 + // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value() } } -- bb3: { +- bb4: { + bb2: { - StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:+5:30: +5:31 - _0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:+0:14: +6:2 - return; // scope 0 at $DIR/inline-instruction-set.rs:+6:2: +6:2 + StorageDead(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:41: +4:42 + _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:14: +5:2 + return; // scope 0 at $DIR/inline_instruction_set.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff index 7e017373b..2a4dc9e3e 100644 --- a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.diff @@ -2,45 +2,45 @@ + // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-into-box-place.rs:+0:11: +0:11 - let _1: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:+1:9: +1:11 - let mut _2: usize; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - let mut _3: usize; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - let mut _4: *mut u8; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - let mut _5: std::boxed::Box>; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - let mut _6: (); // in scope 0 at $DIR/inline-into-box-place.rs:+1:42: +1:43 - let mut _7: *const std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 -+ let mut _8: &mut std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 + let mut _0: (); // return place in scope 0 at $DIR/inline_into_box_place.rs:+0:11: +0:11 + let _1: std::boxed::Box>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11 + let mut _2: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + let mut _3: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + let mut _4: *mut u8; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + let mut _5: std::boxed::Box>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + let mut _6: (); // in scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 + let mut _7: *const std::vec::Vec; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 ++ let mut _8: &mut std::vec::Vec; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 scope 1 { - debug _x => _1; // in scope 1 at $DIR/inline-into-box-place.rs:+1:9: +1:11 + debug _x => _1; // in scope 1 at $DIR/inline_into_box_place.rs:+1:9: +1:11 } scope 2 { } -+ scope 3 (inlined Vec::::new) { // at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ scope 3 (inlined Vec::::new) { // at $DIR/inline_into_box_place.rs:8:33: 8:43 + let mut _9: alloc::raw_vec::RawVec; // in scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-into-box-place.rs:+1:9: +1:11 - _2 = SizeOf(std::vec::Vec); // scope 2 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - _3 = AlignOf(std::vec::Vec); // scope 2 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline-into-box-place.rs:+1:29: +1:43 + StorageLive(_1); // scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11 + _2 = SizeOf(std::vec::Vec); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + _3 = AlignOf(std::vec::Vec); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 // mir::Constant - // + span: $DIR/inline-into-box-place.rs:8:29: 8:43 + // + span: $DIR/inline_into_box_place.rs:8:29: 8:43 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } } bb1: { - StorageLive(_5); // scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - _5 = ShallowInitBox(move _4, std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - _7 = (((_5.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 -- (*_7) = Vec::::new() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 -+ StorageLive(_8); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 -+ _8 = &mut (*_7); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 + StorageLive(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + _5 = ShallowInitBox(move _4, std::vec::Vec); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + _7 = (((_5.0: std::ptr::Unique>).0: std::ptr::NonNull>).0: *const std::vec::Vec); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 +- (*_7) = Vec::::new() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 ++ StorageLive(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 ++ _8 = &mut (*_7); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 + StorageLive(_9); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + _9 = const _; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL // mir::Constant -- // + span: $DIR/inline-into-box-place.rs:8:33: 8:41 +- // + span: $DIR/inline_into_box_place.rs:8:33: 8:41 - // + user_ty: UserType(1) - // + literal: Const { ty: fn() -> Vec {Vec::::new}, val: Value() } - } @@ -53,29 +53,29 @@ + ((*_8).0: alloc::raw_vec::RawVec) = move _9; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + ((*_8).1: usize) = const 0_usize; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ StorageDead(_8); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 - _1 = move _5; // scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 - StorageDead(_5); // scope 0 at $DIR/inline-into-box-place.rs:+1:42: +1:43 - _0 = const (); // scope 0 at $DIR/inline-into-box-place.rs:+0:11: +2:2 -- drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:+2:1: +2:2 -+ drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/inline-into-box-place.rs:+2:1: +2:2 ++ StorageDead(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 + _1 = move _5; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + StorageDead(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 + _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 +- drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 ++ drop(_1) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 } - bb3: { + bb2: { - StorageDead(_1); // scope 0 at $DIR/inline-into-box-place.rs:+2:1: +2:2 - return; // scope 0 at $DIR/inline-into-box-place.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 + return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2 } - bb4 (cleanup): { + bb3 (cleanup): { - resume; // scope 0 at $DIR/inline-into-box-place.rs:+0:1: +2:2 + resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2 - } - - bb5 (cleanup): { -- _6 = alloc::alloc::box_free::, std::alloc::Global>(move (_5.0: std::ptr::Unique>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline-into-box-place.rs:+1:42: +1:43 +- _6 = alloc::alloc::box_free::, std::alloc::Global>(move (_5.0: std::ptr::Unique>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 - // mir::Constant -- // + span: $DIR/inline-into-box-place.rs:8:42: 8:43 +- // + span: $DIR/inline_into_box_place.rs:8:42: 8:43 - // + literal: Const { ty: unsafe fn(Unique>, std::alloc::Global) {alloc::alloc::box_free::, std::alloc::Global>}, val: Value() } } } diff --git a/src/test/mir-opt/inline/inline_into_box_place.rs b/src/test/mir-opt/inline/inline_into_box_place.rs new file mode 100644 index 000000000..232bcc7b2 --- /dev/null +++ b/src/test/mir-opt/inline/inline_into_box_place.rs @@ -0,0 +1,9 @@ +// ignore-endian-big +// ignore-wasm32-bare compiled with panic=abort by default +// compile-flags: -Z mir-opt-level=4 + +#![feature(box_syntax)] +// EMIT_MIR inline_into_box_place.main.Inline.diff +fn main() { + let _x: Box> = box Vec::new(); +} diff --git a/src/test/mir-opt/inline/inline_options.main.Inline.after.mir b/src/test/mir-opt/inline/inline_options.main.Inline.after.mir index 361b02715..1c590be94 100644 --- a/src/test/mir-opt/inline/inline_options.main.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_options.main.Inline.after.mir @@ -1,55 +1,55 @@ // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-options.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/inline-options.rs:+1:5: +1:18 - let _2: (); // in scope 0 at $DIR/inline-options.rs:+2:5: +2:21 - scope 1 (inlined inlined::) { // at $DIR/inline-options.rs:10:5: 10:21 - let _3: (); // in scope 1 at $DIR/inline-options.rs:16:23: 16:26 - let _4: (); // in scope 1 at $DIR/inline-options.rs:16:28: 16:31 - let _5: (); // in scope 1 at $DIR/inline-options.rs:16:33: 16:36 + let mut _0: (); // return place in scope 0 at $DIR/inline_options.rs:+0:11: +0:11 + let _1: (); // in scope 0 at $DIR/inline_options.rs:+1:5: +1:18 + let _2: (); // in scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + scope 1 (inlined inlined::) { // at $DIR/inline_options.rs:10:5: 10:21 + let _3: (); // in scope 1 at $DIR/inline_options.rs:16:23: 16:26 + let _4: (); // in scope 1 at $DIR/inline_options.rs:16:28: 16:31 + let _5: (); // in scope 1 at $DIR/inline_options.rs:16:33: 16:36 } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-options.rs:+1:5: +1:18 - _1 = not_inlined() -> bb1; // scope 0 at $DIR/inline-options.rs:+1:5: +1:18 + StorageLive(_1); // scope 0 at $DIR/inline_options.rs:+1:5: +1:18 + _1 = not_inlined() -> bb1; // scope 0 at $DIR/inline_options.rs:+1:5: +1:18 // mir::Constant - // + span: $DIR/inline-options.rs:9:5: 9:16 + // + span: $DIR/inline_options.rs:9:5: 9:16 // + literal: Const { ty: fn() {not_inlined}, val: Value() } } bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-options.rs:+1:18: +1:19 - StorageLive(_2); // scope 0 at $DIR/inline-options.rs:+2:5: +2:21 - StorageLive(_3); // scope 1 at $DIR/inline-options.rs:16:23: 16:26 - _3 = g() -> bb2; // scope 1 at $DIR/inline-options.rs:16:23: 16:26 + StorageDead(_1); // scope 0 at $DIR/inline_options.rs:+1:18: +1:19 + StorageLive(_2); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageLive(_3); // scope 1 at $DIR/inline_options.rs:16:23: 16:26 + _3 = g() -> bb2; // scope 1 at $DIR/inline_options.rs:16:23: 16:26 // mir::Constant - // + span: $DIR/inline-options.rs:16:23: 16:24 + // + span: $DIR/inline_options.rs:16:23: 16:24 // + literal: Const { ty: fn() {g}, val: Value() } } bb2: { - StorageDead(_3); // scope 1 at $DIR/inline-options.rs:16:26: 16:27 - StorageLive(_4); // scope 1 at $DIR/inline-options.rs:16:28: 16:31 - _4 = g() -> bb3; // scope 1 at $DIR/inline-options.rs:16:28: 16:31 + StorageDead(_3); // scope 1 at $DIR/inline_options.rs:16:26: 16:27 + StorageLive(_4); // scope 1 at $DIR/inline_options.rs:16:28: 16:31 + _4 = g() -> bb3; // scope 1 at $DIR/inline_options.rs:16:28: 16:31 // mir::Constant - // + span: $DIR/inline-options.rs:16:28: 16:29 + // + span: $DIR/inline_options.rs:16:28: 16:29 // + literal: Const { ty: fn() {g}, val: Value() } } bb3: { - StorageDead(_4); // scope 1 at $DIR/inline-options.rs:16:31: 16:32 - StorageLive(_5); // scope 1 at $DIR/inline-options.rs:16:33: 16:36 - _5 = g() -> bb4; // scope 1 at $DIR/inline-options.rs:16:33: 16:36 + StorageDead(_4); // scope 1 at $DIR/inline_options.rs:16:31: 16:32 + StorageLive(_5); // scope 1 at $DIR/inline_options.rs:16:33: 16:36 + _5 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:16:33: 16:36 // mir::Constant - // + span: $DIR/inline-options.rs:16:33: 16:34 + // + span: $DIR/inline_options.rs:16:33: 16:34 // + literal: Const { ty: fn() {g}, val: Value() } } bb4: { - StorageDead(_5); // scope 1 at $DIR/inline-options.rs:16:36: 16:37 - StorageDead(_2); // scope 0 at $DIR/inline-options.rs:+2:21: +2:22 - _0 = const (); // scope 0 at $DIR/inline-options.rs:+0:11: +3:2 - return; // scope 0 at $DIR/inline-options.rs:+3:2: +3:2 + StorageDead(_5); // scope 1 at $DIR/inline_options.rs:16:36: 16:37 + StorageDead(_2); // scope 0 at $DIR/inline_options.rs:+2:21: +2:22 + _0 = const (); // scope 0 at $DIR/inline_options.rs:+0:11: +3:2 + return; // scope 0 at $DIR/inline_options.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/inline/inline_options.rs b/src/test/mir-opt/inline/inline_options.rs new file mode 100644 index 000000000..477f050b6 --- /dev/null +++ b/src/test/mir-opt/inline/inline_options.rs @@ -0,0 +1,19 @@ +// Checks that inlining threshold can be controlled with +// inline-mir-threshold and inline-hint-threshold options. +// +// compile-flags: -Zinline-mir-threshold=90 +// compile-flags: -Zinline-mir-hint-threshold=50 + +// EMIT_MIR inline_options.main.Inline.after.mir +fn main() { + not_inlined(); + inlined::(); +} + +// Cost is approximately 3 * 25 + 5 = 80. +#[inline] +pub fn not_inlined() { g(); g(); g(); } +pub fn inlined() { g(); g(); g(); } + +#[inline(never)] +fn g() {} diff --git a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir index 169e7f5c5..60149ff36 100644 --- a/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir @@ -1,72 +1,68 @@ // MIR for `bar` after Inline fn bar() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/inline-retag.rs:+0:13: +0:17 - let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+1:9: +1:10 - let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+2:5: +2:6 - let mut _3: &i32; // in scope 0 at $DIR/inline-retag.rs:+2:7: +2:9 - let _4: &i32; // in scope 0 at $DIR/inline-retag.rs:+2:7: +2:9 - let _5: i32; // in scope 0 at $DIR/inline-retag.rs:+2:8: +2:9 - let mut _6: &i32; // in scope 0 at $DIR/inline-retag.rs:+2:11: +2:14 - let _7: &i32; // in scope 0 at $DIR/inline-retag.rs:+2:11: +2:14 - let _8: i32; // in scope 0 at $DIR/inline-retag.rs:+2:12: +2:14 + let mut _0: bool; // return place in scope 0 at $DIR/inline_retag.rs:+0:13: +0:17 + let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline_retag.rs:+1:9: +1:10 + let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline_retag.rs:+2:5: +2:6 + let mut _3: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:7: +2:9 + let _4: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:7: +2:9 + let _5: i32; // in scope 0 at $DIR/inline_retag.rs:+2:8: +2:9 + let mut _6: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:11: +2:14 + let _7: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:11: +2:14 + let _8: i32; // in scope 0 at $DIR/inline_retag.rs:+2:12: +2:14 scope 1 { - debug f => _1; // in scope 1 at $DIR/inline-retag.rs:+1:9: +1:10 - let mut _9: &i32; // in scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - let mut _10: &i32; // in scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - scope 2 (inlined foo) { // at $DIR/inline-retag.rs:12:5: 12:15 - debug x => _3; // in scope 2 at $DIR/inline-retag.rs:16:8: 16:9 - debug y => _6; // in scope 2 at $DIR/inline-retag.rs:16:17: 16:18 - let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:17:5: 17:7 - let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + debug f => _1; // in scope 1 at $DIR/inline_retag.rs:+1:9: +1:10 + let mut _9: &i32; // in scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 + let mut _10: &i32; // in scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 + scope 2 (inlined foo) { // at $DIR/inline_retag.rs:12:5: 12:15 + debug x => _3; // in scope 2 at $DIR/inline_retag.rs:16:8: 16:9 + debug y => _6; // in scope 2 at $DIR/inline_retag.rs:16:17: 16:18 + let mut _11: i32; // in scope 2 at $DIR/inline_retag.rs:17:5: 17:7 + let mut _12: i32; // in scope 2 at $DIR/inline_retag.rs:17:11: 17:13 } } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-retag.rs:+1:9: +1:10 - _1 = foo; // scope 0 at $DIR/inline-retag.rs:+1:13: +1:16 + StorageLive(_1); // scope 0 at $DIR/inline_retag.rs:+1:9: +1:10 + _1 = foo; // scope 0 at $DIR/inline_retag.rs:+1:13: +1:16 // mir::Constant - // + span: $DIR/inline-retag.rs:11:13: 11:16 + // + span: $DIR/inline_retag.rs:11:13: 11:16 // + literal: Const { ty: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}, val: Value() } - StorageLive(_2); // scope 1 at $DIR/inline-retag.rs:+2:5: +2:6 - _2 = _1; // scope 1 at $DIR/inline-retag.rs:+2:5: +2:6 - StorageLive(_3); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - StorageLive(_4); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - _10 = const _; // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 + StorageLive(_2); // scope 1 at $DIR/inline_retag.rs:+2:5: +2:6 + _2 = _1; // scope 1 at $DIR/inline_retag.rs:+2:5: +2:6 + StorageLive(_3); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 + StorageLive(_4); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 + _10 = const _; // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 // mir::Constant - // + span: $DIR/inline-retag.rs:12:7: 12:9 + // + span: $DIR/inline_retag.rs:12:7: 12:9 // + literal: Const { ty: &i32, val: Unevaluated(bar, [], Some(promoted[1])) } - Retag(_10); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - _4 = &(*_10); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - Retag(_4); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - _3 = &(*_4); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - Retag(_3); // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 - StorageLive(_6); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - StorageLive(_7); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - _9 = const _; // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 + Retag(_10); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 + _4 = &(*_10); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 + _3 = &(*_4); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 + StorageLive(_6); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 + StorageLive(_7); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 + _9 = const _; // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 // mir::Constant - // + span: $DIR/inline-retag.rs:12:11: 12:14 + // + span: $DIR/inline_retag.rs:12:11: 12:14 // + literal: Const { ty: &i32, val: Unevaluated(bar, [], Some(promoted[0])) } - Retag(_9); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - _7 = &(*_9); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - Retag(_7); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - _6 = &(*_7); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - Retag(_6); // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 - Retag(_3); // scope 2 at $DIR/inline-retag.rs:16:8: 16:9 - Retag(_6); // scope 2 at $DIR/inline-retag.rs:16:17: 16:18 - StorageLive(_11); // scope 2 at $DIR/inline-retag.rs:17:5: 17:7 - _11 = (*_3); // scope 2 at $DIR/inline-retag.rs:17:5: 17:7 - StorageLive(_12); // scope 2 at $DIR/inline-retag.rs:17:11: 17:13 - _12 = (*_6); // scope 2 at $DIR/inline-retag.rs:17:11: 17:13 - _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline-retag.rs:17:5: 17:13 - StorageDead(_12); // scope 2 at $DIR/inline-retag.rs:17:12: 17:13 - StorageDead(_11); // scope 2 at $DIR/inline-retag.rs:17:12: 17:13 - StorageDead(_6); // scope 1 at $DIR/inline-retag.rs:+2:14: +2:15 - StorageDead(_3); // scope 1 at $DIR/inline-retag.rs:+2:14: +2:15 - StorageDead(_2); // scope 1 at $DIR/inline-retag.rs:+2:14: +2:15 - StorageDead(_1); // scope 0 at $DIR/inline-retag.rs:+3:1: +3:2 - StorageDead(_7); // scope 0 at $DIR/inline-retag.rs:+3:1: +3:2 - StorageDead(_4); // scope 0 at $DIR/inline-retag.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline-retag.rs:+3:2: +3:2 + Retag(_9); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 + _7 = &(*_9); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 + _6 = &(*_7); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 + Retag(_3); // scope 2 at $DIR/inline_retag.rs:16:8: 16:9 + Retag(_6); // scope 2 at $DIR/inline_retag.rs:16:17: 16:18 + StorageLive(_11); // scope 2 at $DIR/inline_retag.rs:17:5: 17:7 + _11 = (*_3); // scope 2 at $DIR/inline_retag.rs:17:5: 17:7 + StorageLive(_12); // scope 2 at $DIR/inline_retag.rs:17:11: 17:13 + _12 = (*_6); // scope 2 at $DIR/inline_retag.rs:17:11: 17:13 + _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline_retag.rs:17:5: 17:13 + StorageDead(_12); // scope 2 at $DIR/inline_retag.rs:17:12: 17:13 + StorageDead(_11); // scope 2 at $DIR/inline_retag.rs:17:12: 17:13 + StorageDead(_6); // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15 + StorageDead(_3); // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15 + StorageDead(_2); // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15 + StorageDead(_1); // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2 + StorageDead(_7); // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2 + StorageDead(_4); // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2 + return; // scope 0 at $DIR/inline_retag.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/inline/inline_retag.rs b/src/test/mir-opt/inline/inline_retag.rs new file mode 100644 index 000000000..c6950f269 --- /dev/null +++ b/src/test/mir-opt/inline/inline_retag.rs @@ -0,0 +1,18 @@ +// compile-flags: -Z span_free_formats -Z mir-emit-retag + +// Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag + +fn main() { + println!("{}", bar()); +} + +// EMIT_MIR inline_retag.bar.Inline.after.mir +fn bar() -> bool { + let f = foo; + f(&1, &-1) +} + +#[inline(always)] +fn foo(x: &i32, y: &i32) -> bool { + *x == *y +} diff --git a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff index d691e90b7..969573ba3 100644 --- a/src/test/mir-opt/inline/inline_shims.clone.Inline.diff +++ b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff @@ -2,25 +2,25 @@ + // MIR for `clone` after Inline fn clone(_1: fn(A, B)) -> fn(A, B) { - debug f => _1; // in scope 0 at $DIR/inline-shims.rs:+0:20: +0:21 - let mut _0: fn(A, B); // return place in scope 0 at $DIR/inline-shims.rs:+0:36: +0:44 - let mut _2: &fn(A, B); // in scope 0 at $DIR/inline-shims.rs:+1:5: +1:14 -+ scope 1 (inlined ::clone - shim(fn(A, B))) { // at $DIR/inline-shims.rs:6:5: 6:14 + debug f => _1; // in scope 0 at $DIR/inline_shims.rs:+0:20: +0:21 + let mut _0: fn(A, B); // return place in scope 0 at $DIR/inline_shims.rs:+0:36: +0:44 + let mut _2: &fn(A, B); // in scope 0 at $DIR/inline_shims.rs:+1:5: +1:14 ++ scope 1 (inlined ::clone - shim(fn(A, B))) { // at $DIR/inline_shims.rs:6:5: 6:14 + } bb0: { - StorageLive(_2); // scope 0 at $DIR/inline-shims.rs:+1:5: +1:14 - _2 = &_1; // scope 0 at $DIR/inline-shims.rs:+1:5: +1:14 -- _0 = ::clone(move _2) -> bb1; // scope 0 at $DIR/inline-shims.rs:+1:5: +1:14 + StorageLive(_2); // scope 0 at $DIR/inline_shims.rs:+1:5: +1:14 + _2 = &_1; // scope 0 at $DIR/inline_shims.rs:+1:5: +1:14 +- _0 = ::clone(move _2) -> bb1; // scope 0 at $DIR/inline_shims.rs:+1:5: +1:14 - // mir::Constant -- // + span: $DIR/inline-shims.rs:6:7: 6:12 +- // + span: $DIR/inline_shims.rs:6:7: 6:12 - // + literal: Const { ty: for<'a> fn(&'a fn(A, B)) -> fn(A, B) {::clone}, val: Value() } - } - - bb1: { + _0 = (*_2); // scope 1 at $SRC_DIR/core/src/clone.rs:LL:COL - StorageDead(_2); // scope 0 at $DIR/inline-shims.rs:+1:13: +1:14 - return; // scope 0 at $DIR/inline-shims.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/inline_shims.rs:+1:13: +1:14 + return; // scope 0 at $DIR/inline_shims.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff index f7b1cde80..7a54beca2 100644 --- a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff +++ b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff @@ -2,51 +2,51 @@ + // MIR for `drop` after Inline fn drop(_1: *mut Vec, _2: *mut Option) -> () { - debug a => _1; // in scope 0 at $DIR/inline-shims.rs:+0:19: +0:20 - debug b => _2; // in scope 0 at $DIR/inline-shims.rs:+0:35: +0:36 - let mut _0: (); // return place in scope 0 at $DIR/inline-shims.rs:+0:54: +0:54 - let _3: (); // in scope 0 at $DIR/inline-shims.rs:+1:14: +1:40 - let mut _4: *mut std::vec::Vec; // in scope 0 at $DIR/inline-shims.rs:+1:38: +1:39 - let mut _5: *mut std::option::Option; // in scope 0 at $DIR/inline-shims.rs:+2:38: +2:39 + debug a => _1; // in scope 0 at $DIR/inline_shims.rs:+0:19: +0:20 + debug b => _2; // in scope 0 at $DIR/inline_shims.rs:+0:35: +0:36 + let mut _0: (); // return place in scope 0 at $DIR/inline_shims.rs:+0:54: +0:54 + let _3: (); // in scope 0 at $DIR/inline_shims.rs:+1:14: +1:40 + let mut _4: *mut std::vec::Vec; // in scope 0 at $DIR/inline_shims.rs:+1:38: +1:39 + let mut _5: *mut std::option::Option; // in scope 0 at $DIR/inline_shims.rs:+2:38: +2:39 scope 1 { } scope 2 { -+ scope 3 (inlined std::ptr::drop_in_place::> - shim(Some(Option))) { // at $DIR/inline-shims.rs:12:14: 12:40 ++ scope 3 (inlined std::ptr::drop_in_place::> - shim(Some(Option))) { // at $DIR/inline_shims.rs:12:14: 12:40 + let mut _6: isize; // in scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + } } bb0: { - StorageLive(_3); // scope 0 at $DIR/inline-shims.rs:+1:5: +1:42 - StorageLive(_4); // scope 1 at $DIR/inline-shims.rs:+1:38: +1:39 - _4 = _1; // scope 1 at $DIR/inline-shims.rs:+1:38: +1:39 - _3 = std::ptr::drop_in_place::>(move _4) -> bb1; // scope 1 at $DIR/inline-shims.rs:+1:14: +1:40 + StorageLive(_3); // scope 0 at $DIR/inline_shims.rs:+1:5: +1:42 + StorageLive(_4); // scope 1 at $DIR/inline_shims.rs:+1:38: +1:39 + _4 = _1; // scope 1 at $DIR/inline_shims.rs:+1:38: +1:39 + _3 = std::ptr::drop_in_place::>(move _4) -> bb1; // scope 1 at $DIR/inline_shims.rs:+1:14: +1:40 // mir::Constant - // + span: $DIR/inline-shims.rs:11:14: 11:37 + // + span: $DIR/inline_shims.rs:11:14: 11:37 // + literal: Const { ty: unsafe fn(*mut Vec) {std::ptr::drop_in_place::>}, val: Value() } } bb1: { - StorageDead(_4); // scope 1 at $DIR/inline-shims.rs:+1:39: +1:40 - StorageDead(_3); // scope 0 at $DIR/inline-shims.rs:+1:41: +1:42 - StorageLive(_5); // scope 2 at $DIR/inline-shims.rs:+2:38: +2:39 - _5 = _2; // scope 2 at $DIR/inline-shims.rs:+2:38: +2:39 -- _0 = std::ptr::drop_in_place::>(move _5) -> bb2; // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40 + StorageDead(_4); // scope 1 at $DIR/inline_shims.rs:+1:39: +1:40 + StorageDead(_3); // scope 0 at $DIR/inline_shims.rs:+1:41: +1:42 + StorageLive(_5); // scope 2 at $DIR/inline_shims.rs:+2:38: +2:39 + _5 = _2; // scope 2 at $DIR/inline_shims.rs:+2:38: +2:39 +- _0 = std::ptr::drop_in_place::>(move _5) -> bb2; // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40 - // mir::Constant -- // + span: $DIR/inline-shims.rs:12:14: 12:37 +- // + span: $DIR/inline_shims.rs:12:14: 12:37 - // + literal: Const { ty: unsafe fn(*mut Option) {std::ptr::drop_in_place::>}, val: Value() } -+ StorageLive(_6); // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40 -+ StorageLive(_7); // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40 ++ StorageLive(_6); // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40 ++ StorageLive(_7); // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40 + _6 = discriminant((*_5)); // scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + switchInt(move _6) -> [0_isize: bb2, otherwise: bb3]; // scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL } bb2: { -+ StorageDead(_7); // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40 -+ StorageDead(_6); // scope 2 at $DIR/inline-shims.rs:+2:14: +2:40 - StorageDead(_5); // scope 2 at $DIR/inline-shims.rs:+2:39: +2:40 - return; // scope 0 at $DIR/inline-shims.rs:+3:2: +3:2 ++ StorageDead(_7); // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40 ++ StorageDead(_6); // scope 2 at $DIR/inline_shims.rs:+2:14: +2:40 + StorageDead(_5); // scope 2 at $DIR/inline_shims.rs:+2:39: +2:40 + return; // scope 0 at $DIR/inline_shims.rs:+3:2: +3:2 + } + + bb3: { diff --git a/src/test/mir-opt/inline/inline_shims.rs b/src/test/mir-opt/inline/inline_shims.rs new file mode 100644 index 000000000..7c8618f71 --- /dev/null +++ b/src/test/mir-opt/inline/inline_shims.rs @@ -0,0 +1,13 @@ +// ignore-wasm32-bare compiled with panic=abort by default +#![crate_type = "lib"] + +// EMIT_MIR inline_shims.clone.Inline.diff +pub fn clone(f: fn(A, B)) -> fn(A, B) { + f.clone() +} + +// EMIT_MIR inline_shims.drop.Inline.diff +pub fn drop(a: *mut Vec, b: *mut Option) { + unsafe { std::ptr::drop_in_place(a) } + unsafe { std::ptr::drop_in_place(b) } +} diff --git a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff index fdf2a1e1f..af08296ed 100644 --- a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff +++ b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff @@ -2,27 +2,27 @@ + // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-specialization.rs:+0:11: +0:11 - let _1: u32; // in scope 0 at $DIR/inline-specialization.rs:+1:9: +1:10 + let mut _0: (); // return place in scope 0 at $DIR/inline_specialization.rs:+0:11: +0:11 + let _1: u32; // in scope 0 at $DIR/inline_specialization.rs:+1:9: +1:10 scope 1 { - debug x => _1; // in scope 1 at $DIR/inline-specialization.rs:+1:9: +1:10 + debug x => _1; // in scope 1 at $DIR/inline_specialization.rs:+1:9: +1:10 } -+ scope 2 (inlined as Foo>::bar) { // at $DIR/inline-specialization.rs:5:13: 5:38 ++ scope 2 (inlined as Foo>::bar) { // at $DIR/inline_specialization.rs:5:13: 5:38 + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-specialization.rs:+1:9: +1:10 -- _1 = as Foo>::bar() -> bb1; // scope 0 at $DIR/inline-specialization.rs:+1:13: +1:38 + StorageLive(_1); // scope 0 at $DIR/inline_specialization.rs:+1:9: +1:10 +- _1 = as Foo>::bar() -> bb1; // scope 0 at $DIR/inline_specialization.rs:+1:13: +1:38 - // mir::Constant -- // + span: $DIR/inline-specialization.rs:5:13: 5:36 +- // + span: $DIR/inline_specialization.rs:5:13: 5:36 - // + literal: Const { ty: fn() -> u32 { as Foo>::bar}, val: Value() } - } - - bb1: { -+ _1 = const 123_u32; // scope 2 at $DIR/inline-specialization.rs:14:31: 14:34 - _0 = const (); // scope 0 at $DIR/inline-specialization.rs:+0:11: +2:2 - StorageDead(_1); // scope 0 at $DIR/inline-specialization.rs:+2:1: +2:2 - return; // scope 0 at $DIR/inline-specialization.rs:+2:2: +2:2 ++ _1 = const 123_u32; // scope 2 at $DIR/inline_specialization.rs:14:31: 14:34 + _0 = const (); // scope 0 at $DIR/inline_specialization.rs:+0:11: +2:2 + StorageDead(_1); // scope 0 at $DIR/inline_specialization.rs:+2:1: +2:2 + return; // scope 0 at $DIR/inline_specialization.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_specialization.rs b/src/test/mir-opt/inline/inline_specialization.rs new file mode 100644 index 000000000..87275b4e5 --- /dev/null +++ b/src/test/mir-opt/inline/inline_specialization.rs @@ -0,0 +1,15 @@ +#![feature(specialization)] + +// EMIT_MIR inline_specialization.main.Inline.diff +fn main() { + let x = as Foo>::bar(); +} + +trait Foo { + fn bar() -> u32; +} + +impl Foo for Vec { + #[inline(always)] + default fn bar() -> u32 { 123 } +} diff --git a/src/test/mir-opt/inline/inline_trait_method.rs b/src/test/mir-opt/inline/inline_trait_method.rs new file mode 100644 index 000000000..74be53f55 --- /dev/null +++ b/src/test/mir-opt/inline/inline_trait_method.rs @@ -0,0 +1,22 @@ +// compile-flags: -Z span_free_formats + +fn main() { + println!("{}", test(&())); +} + +// EMIT_MIR inline_trait_method.test.Inline.after.mir +fn test(x: &dyn X) -> u32 { + x.y() +} + +trait X { + fn y(&self) -> u32 { + 1 + } +} + +impl X for () { + fn y(&self) -> u32 { + 2 + } +} diff --git a/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir index 89eefc292..637bf282a 100644 --- a/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir @@ -1,21 +1,21 @@ // MIR for `test` after Inline fn test(_1: &dyn X) -> u32 { - debug x => _1; // in scope 0 at $DIR/inline-trait-method.rs:+0:9: +0:10 - let mut _0: u32; // return place in scope 0 at $DIR/inline-trait-method.rs:+0:23: +0:26 - let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10 + debug x => _1; // in scope 0 at $DIR/inline_trait_method.rs:+0:9: +0:10 + let mut _0: u32; // return place in scope 0 at $DIR/inline_trait_method.rs:+0:23: +0:26 + let mut _2: &dyn X; // in scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10 bb0: { - StorageLive(_2); // scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10 - _2 = &(*_1); // scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10 - _0 = ::y(move _2) -> bb1; // scope 0 at $DIR/inline-trait-method.rs:+1:5: +1:10 + StorageLive(_2); // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10 + _2 = &(*_1); // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10 + _0 = ::y(move _2) -> bb1; // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10 // mir::Constant - // + span: $DIR/inline-trait-method.rs:9:7: 9:8 + // + span: $DIR/inline_trait_method.rs:9:7: 9:8 // + literal: Const { ty: for<'a> fn(&'a dyn X) -> u32 {::y}, val: Value() } } bb1: { - StorageDead(_2); // scope 0 at $DIR/inline-trait-method.rs:+1:9: +1:10 - return; // scope 0 at $DIR/inline-trait-method.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/inline_trait_method.rs:+1:9: +1:10 + return; // scope 0 at $DIR/inline_trait_method.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/inline_trait_method_2.rs b/src/test/mir-opt/inline/inline_trait_method_2.rs new file mode 100644 index 000000000..378e71a25 --- /dev/null +++ b/src/test/mir-opt/inline/inline_trait_method_2.rs @@ -0,0 +1,27 @@ +// compile-flags: -Z span_free_formats -Z mir-opt-level=4 + +// EMIT_MIR inline_trait_method_2.test2.Inline.after.mir +fn test2(x: &dyn X) -> bool { + test(x) +} + +#[inline] +fn test(x: &dyn X) -> bool { + x.y() +} + +trait X { + fn y(&self) -> bool { + false + } +} + +impl X for () { + fn y(&self) -> bool { + true + } +} + +fn main() { + println!("Should be true: {}", test2(&())); +} diff --git a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir index 3d05869fa..73aea719e 100644 --- a/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -1,32 +1,28 @@ // MIR for `test2` after Inline fn test2(_1: &dyn X) -> bool { - debug x => _1; // in scope 0 at $DIR/inline-trait-method_2.rs:+0:10: +0:11 - let mut _0: bool; // return place in scope 0 at $DIR/inline-trait-method_2.rs:+0:24: +0:28 - let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11 - let mut _3: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11 - scope 1 (inlined test) { // at $DIR/inline-trait-method_2.rs:5:5: 5:12 - debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10 - let mut _4: &dyn X; // in scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 + debug x => _1; // in scope 0 at $DIR/inline_trait_method_2.rs:+0:10: +0:11 + let mut _0: bool; // return place in scope 0 at $DIR/inline_trait_method_2.rs:+0:24: +0:28 + let mut _2: &dyn X; // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 + let mut _3: &dyn X; // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 + scope 1 (inlined test) { // at $DIR/inline_trait_method_2.rs:5:5: 5:12 + debug x => _2; // in scope 1 at $DIR/inline_trait_method_2.rs:9:9: 9:10 } bb0: { - StorageLive(_2); // scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11 - StorageLive(_3); // scope 0 at $DIR/inline-trait-method_2.rs:+1:10: +1:11 - _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 - StorageLive(_4); // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 - _4 = _2; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 - _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 + StorageLive(_2); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 + StorageLive(_3); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 + _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 // mir::Constant - // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 + // + span: $DIR/inline_trait_method_2.rs:10:7: 10:8 // + literal: Const { ty: for<'a> fn(&'a dyn X) -> bool {::y}, val: Value() } } bb1: { - StorageDead(_4); // scope 1 at $DIR/inline-trait-method_2.rs:10:9: 10:10 - StorageDead(_2); // scope 0 at $DIR/inline-trait-method_2.rs:+1:11: +1:12 - return; // scope 0 at $DIR/inline-trait-method_2.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/inline_trait_method_2.rs:+1:11: +1:12 + return; // scope 0 at $DIR/inline_trait_method_2.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/issue-58867-inline-as-ref-as-mut.rs b/src/test/mir-opt/inline/issue-58867-inline-as-ref-as-mut.rs deleted file mode 100644 index 94f926d39..000000000 --- a/src/test/mir-opt/inline/issue-58867-inline-as-ref-as-mut.rs +++ /dev/null @@ -1,27 +0,0 @@ -// EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir -pub fn a(x: &mut [T]) -> &mut [T] { - x.as_mut() -} - -// EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir -pub fn b(x: &mut Box) -> &mut T { - x.as_mut() -} - -// EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir -pub fn c(x: &[T]) -> &[T] { - x.as_ref() -} - -// EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir -pub fn d(x: &Box) -> &T { - x.as_ref() -} - -fn main() { - let mut boxed = Box::new(1); - println!("{:?}", a(&mut [1])); - println!("{:?}", b(&mut boxed)); - println!("{:?}", c(&[1])); - println!("{:?}", d(&boxed)); -} diff --git a/src/test/mir-opt/inline/issue-76997-inline-scopes-parenting.rs b/src/test/mir-opt/inline/issue-76997-inline-scopes-parenting.rs deleted file mode 100644 index 76d806acc..000000000 --- a/src/test/mir-opt/inline/issue-76997-inline-scopes-parenting.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997) - -// EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir -fn main() { - let f = |x| { let y = x; y }; - f(()) -} diff --git a/src/test/mir-opt/inline/issue-78442.rs b/src/test/mir-opt/inline/issue-78442.rs deleted file mode 100644 index aa8ede2df..000000000 --- a/src/test/mir-opt/inline/issue-78442.rs +++ /dev/null @@ -1,20 +0,0 @@ -// compile-flags: -Z mir-opt-level=3 -Z inline-mir -// ignore-wasm32-bare compiled with panic=abort by default -#![crate_type = "lib"] - -// EMIT_MIR issue_78442.bar.RevealAll.diff -// EMIT_MIR issue_78442.bar.Inline.diff -pub fn bar

( - // Error won't happen if "bar" is not generic - _baz: P, -) { - hide_foo()(); -} - -fn hide_foo() -> impl Fn() { - // Error won't happen if "iterate" hasn't impl Trait or has generics - foo -} - -fn foo() { // Error won't happen if "foo" isn't used in "iterate" or has generics -} diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir index 5168ae031..777681e1c 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir @@ -1,30 +1,30 @@ // MIR for `a` after Inline fn a(_1: &mut [T]) -> &mut [T] { - debug x => _1; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14 - let mut _0: &mut [T]; // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:29: +0:37 - let mut _2: &mut [T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - let mut _3: &mut [T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - 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:5: 3:15 + debug x => _1; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14 + let mut _0: &mut [T]; // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:29: +0:37 + let mut _2: &mut [T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + let mut _3: &mut [T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + 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:5: 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: { - StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - 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(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + 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 - _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 - StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2 - StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2 - return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2 + _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 + StorageDead(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2 + StorageDead(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2 + return; // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index 06d442ae8..83545c991 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -1,12 +1,12 @@ // MIR for `b` after Inline fn b(_1: &mut Box) -> &mut T { - debug x => _1; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14 - let mut _0: &mut T; // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:32: +0:38 - let mut _2: &mut T; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - let mut _3: &mut T; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - 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:5: 8:15 + debug x => _1; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14 + let mut _0: &mut T; // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:32: +0:38 + let mut _2: &mut T; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + let mut _3: &mut T; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + 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:5: 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 @@ -15,10 +15,10 @@ fn b(_1: &mut Box) -> &mut T { } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - 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(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + 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 @@ -28,11 +28,11 @@ fn b(_1: &mut Box) -> &mut T { _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 - _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 - StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2 - StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2 - return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2 + _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 + StorageDead(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2 + StorageDead(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2 + return; // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir index c7f20ff98..ed4e9927c 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir @@ -1,22 +1,22 @@ // MIR for `c` after Inline fn c(_1: &[T]) -> &[T] { - debug x => _1; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14 - let mut _0: &[T]; // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:25: +0:29 - let _2: &[T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - let mut _3: &[T]; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:13:5: 13:15 + debug x => _1; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14 + let mut _0: &[T]; // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:25: +0:29 + let _2: &[T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + let mut _3: &[T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:13:5: 13:15 debug self => _3; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - _3 = &(*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 + StorageLive(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + _3 = &(*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 _2 = _3; // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - _0 = &(*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:14: +1:15 - StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2 - return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2 + _0 = &(*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + StorageDead(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15 + StorageDead(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2 + return; // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir index d5f06c54a..18a2670be 100644 --- a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -1,26 +1,26 @@ // MIR for `d` after Inline fn d(_1: &Box) -> &T { - debug x => _1; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:13: +0:14 - let mut _0: &T; // return place in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:28: +0:30 - let _2: &T; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - let mut _3: &std::boxed::Box; // in scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - scope 1 (inlined as AsRef>::as_ref) { // at $DIR/issue-58867-inline-as-ref-as-mut.rs:18:5: 18:15 + debug x => _1; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14 + let mut _0: &T; // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:28: +0:30 + let _2: &T; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + let mut _3: &std::boxed::Box; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + scope 1 (inlined as AsRef>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:18:5: 18:15 debug self => _3; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL let mut _4: std::boxed::Box; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL let mut _5: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - StorageLive(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - _3 = &(*_1); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 + StorageLive(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + _3 = &(*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 _4 = deref_copy (*_3); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL _5 = (((_4.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL _2 = &(*_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _0 = &(*_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:5: +1:15 - StorageDead(_3); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+1:14: +1:15 - StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2 - return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2 + _0 = &(*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 + StorageDead(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15 + StorageDead(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2 + return; // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs new file mode 100644 index 000000000..94f926d39 --- /dev/null +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs @@ -0,0 +1,27 @@ +// EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir +pub fn a(x: &mut [T]) -> &mut [T] { + x.as_mut() +} + +// EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +pub fn b(x: &mut Box) -> &mut T { + x.as_mut() +} + +// EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir +pub fn c(x: &[T]) -> &[T] { + x.as_ref() +} + +// EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +pub fn d(x: &Box) -> &T { + x.as_ref() +} + +fn main() { + let mut boxed = Box::new(1); + println!("{:?}", a(&mut [1])); + println!("{:?}", b(&mut boxed)); + println!("{:?}", c(&[1])); + println!("{:?}", d(&boxed)); +} diff --git a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index fca53a72f..d99ae1a6c 100644 --- a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -1,42 +1,42 @@ // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+0:11: +0:11 - let _1: [closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:9: +1:10 - let mut _2: &[closure@$DIR/issue-76997-inline-scopes-parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:6 - let mut _3: ((),); // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10 - let mut _4: (); // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:7: +2:9 - let mut _5: (); // in scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10 + let mut _0: (); // return place in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+0:11: +0:11 + let _1: [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 + let mut _2: &[closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6 + let mut _3: ((),); // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 + let mut _4: (); // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9 + let mut _5: (); // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 scope 1 { - debug f => _1; // in scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:9: +1:10 - scope 2 (inlined main::{closure#0}) { // at $DIR/issue-76997-inline-scopes-parenting.rs:6:5: 6:10 - debug x => _5; // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:14: +1:15 - let _6: (); // in scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:23: +1:24 + debug f => _1; // in scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 + scope 2 (inlined main::{closure#0}) { // at $DIR/issue_76997_inline_scopes_parenting.rs:6:5: 6:10 + debug x => _5; // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:14: +1:15 + let _6: (); // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 scope 3 { - debug y => _6; // in scope 3 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:23: +1:24 + debug y => _6; // in scope 3 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 } } } 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 - 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 - 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 - StorageDead(_6); // scope 2 at $DIR/issue-76997-inline-scopes-parenting.rs:+1:32: +1:33 - StorageDead(_5); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:5: +2:10 - StorageDead(_4); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:9: +2:10 - StorageDead(_3); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:9: +2:10 - StorageDead(_2); // scope 1 at $DIR/issue-76997-inline-scopes-parenting.rs:+2:9: +2:10 - StorageDead(_1); // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+3:1: +3:2 - return; // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+3:2: +3:2 + 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 + 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 + 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 + StorageDead(_6); // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:32: +1:33 + StorageDead(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 + StorageDead(_4); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 + StorageDead(_3); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 + StorageDead(_2); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 + StorageDead(_1); // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+3:1: +3:2 + return; // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.rs b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.rs new file mode 100644 index 000000000..76d806acc --- /dev/null +++ b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.rs @@ -0,0 +1,7 @@ +// Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997) + +// EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir +fn main() { + let f = |x| { let y = x; y }; + f(()) +} diff --git a/src/test/mir-opt/inline/issue_78442.bar.Inline.diff b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff index 4186650df..51a98465f 100644 --- a/src/test/mir-opt/inline/issue_78442.bar.Inline.diff +++ b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff @@ -2,67 +2,67 @@ + // MIR for `bar` after Inline fn bar(_1: P) -> () { - debug _baz => _1; // in scope 0 at $DIR/issue-78442.rs:+2:5: +2:9 - let mut _0: (); // return place in scope 0 at $DIR/issue-78442.rs:+3:3: +3:3 - let _2: (); // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 - let mut _3: &fn() {foo}; // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 - let _4: fn() {foo}; // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 - let mut _5: (); // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 -+ scope 1 (inlined >::call - shim(fn() {foo})) { // at $DIR/issue-78442.rs:11:5: 11:17 + debug _baz => _1; // in scope 0 at $DIR/issue_78442.rs:+2:5: +2:9 + let mut _0: (); // return place in scope 0 at $DIR/issue_78442.rs:+3:3: +3:3 + let _2: (); // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 + let mut _3: &fn() {foo}; // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 + let _4: fn() {foo}; // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 + let mut _5: (); // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 ++ scope 1 (inlined >::call - shim(fn() {foo})) { // at $DIR/issue_78442.rs:11:5: 11:17 + } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 - StorageLive(_3); // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 - StorageLive(_4); // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 -- _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 -+ _4 = hide_foo() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 + StorageLive(_2); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 + StorageLive(_3); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 + StorageLive(_4); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 +- _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 ++ _4 = hide_foo() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 // mir::Constant - // + span: $DIR/issue-78442.rs:11:5: 11:13 + // + span: $DIR/issue_78442.rs:11:5: 11:13 // + literal: Const { ty: fn() -> impl Fn() {hide_foo}, val: Value() } } 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 -- _2 = >::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 + _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 +- _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 +- // + span: $DIR/issue_78442.rs:11:5: 11:15 - // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> >::Output {>::call}, val: Value() } + _2 = move (*_3)() -> [return: bb5, unwind: bb3]; // scope 1 at $SRC_DIR/core/src/ops/function.rs:LL:COL } bb2: { -- StorageDead(_5); // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17 -- StorageDead(_3); // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17 -- StorageDead(_4); // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18 -- StorageDead(_2); // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18 -- _0 = const (); // scope 0 at $DIR/issue-78442.rs:+3:3: +5:2 -- drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2 -+ return; // scope 0 at $DIR/issue-78442.rs:+5:2: +5:2 +- StorageDead(_5); // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17 +- StorageDead(_3); // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17 +- StorageDead(_4); // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18 +- StorageDead(_2); // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18 +- _0 = const (); // scope 0 at $DIR/issue_78442.rs:+3:3: +5:2 +- drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 ++ return; // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2 } - bb3: { -- return; // scope 0 at $DIR/issue-78442.rs:+5:2: +5:2 +- return; // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2 + bb3 (cleanup): { -+ drop(_1) -> bb4; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2 ++ drop(_1) -> bb4; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } bb4 (cleanup): { -- drop(_1) -> bb5; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2 -+ resume; // scope 0 at $DIR/issue-78442.rs:+0:1: +5:2 +- drop(_1) -> bb5; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 ++ resume; // scope 0 at $DIR/issue_78442.rs:+0:1: +5:2 } - bb5 (cleanup): { -- resume; // scope 0 at $DIR/issue-78442.rs:+0:1: +5:2 +- resume; // scope 0 at $DIR/issue_78442.rs:+0:1: +5:2 + bb5: { -+ StorageDead(_5); // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17 -+ StorageDead(_3); // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17 -+ StorageDead(_4); // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18 -+ StorageDead(_2); // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18 -+ _0 = const (); // scope 0 at $DIR/issue-78442.rs:+3:3: +5:2 -+ drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2 ++ StorageDead(_5); // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17 ++ StorageDead(_3); // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17 ++ StorageDead(_4); // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18 ++ StorageDead(_2); // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18 ++ _0 = const (); // scope 0 at $DIR/issue_78442.rs:+3:3: +5:2 ++ drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } } diff --git a/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff index 24e9a3df1..e47466c5e 100644 --- a/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff +++ b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff @@ -2,56 +2,56 @@ + // MIR for `bar` after RevealAll fn bar(_1: P) -> () { - debug _baz => _1; // in scope 0 at $DIR/issue-78442.rs:+2:5: +2:9 - let mut _0: (); // return place in scope 0 at $DIR/issue-78442.rs:+3:3: +3:3 - let _2: (); // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 -- let mut _3: &impl Fn(); // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 -- let _4: impl Fn(); // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 -+ let mut _3: &fn() {foo}; // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 -+ let _4: fn() {foo}; // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 - let mut _5: (); // in scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 + debug _baz => _1; // in scope 0 at $DIR/issue_78442.rs:+2:5: +2:9 + let mut _0: (); // return place in scope 0 at $DIR/issue_78442.rs:+3:3: +3:3 + let _2: (); // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 +- let mut _3: &impl Fn(); // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 +- let _4: impl Fn(); // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 ++ let mut _3: &fn() {foo}; // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 ++ let _4: fn() {foo}; // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 + let mut _5: (); // in scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-78442.rs:+4:5: +4:17 - StorageLive(_3); // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 - StorageLive(_4); // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 - _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue-78442.rs:+4:5: +4:15 + StorageLive(_2); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 + StorageLive(_3); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 + StorageLive(_4); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 + _4 = hide_foo() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:15 // mir::Constant - // + span: $DIR/issue-78442.rs:11:5: 11:13 + // + span: $DIR/issue_78442.rs:11:5: 11:13 // + literal: Const { ty: fn() -> impl Fn() {hide_foo}, val: Value() } } 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 -- _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 + _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 +- _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 - // + span: $DIR/issue-78442.rs:11:5: 11:15 + // + span: $DIR/issue_78442.rs:11:5: 11:15 - // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(), ()) -> >::Output {>::call}, val: Value() } + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> >::Output {>::call}, val: Value() } } bb2: { - StorageDead(_5); // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17 - StorageDead(_3); // scope 0 at $DIR/issue-78442.rs:+4:16: +4:17 - StorageDead(_4); // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18 - StorageDead(_2); // scope 0 at $DIR/issue-78442.rs:+4:17: +4:18 - _0 = const (); // scope 0 at $DIR/issue-78442.rs:+3:3: +5:2 - drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2 + StorageDead(_5); // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17 + StorageDead(_3); // scope 0 at $DIR/issue_78442.rs:+4:16: +4:17 + StorageDead(_4); // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18 + StorageDead(_2); // scope 0 at $DIR/issue_78442.rs:+4:17: +4:18 + _0 = const (); // scope 0 at $DIR/issue_78442.rs:+3:3: +5:2 + drop(_1) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } bb3: { - return; // scope 0 at $DIR/issue-78442.rs:+5:2: +5:2 + return; // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2 } bb4 (cleanup): { - drop(_1) -> bb5; // scope 0 at $DIR/issue-78442.rs:+5:1: +5:2 + drop(_1) -> bb5; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } bb5 (cleanup): { - resume; // scope 0 at $DIR/issue-78442.rs:+0:1: +5:2 + resume; // scope 0 at $DIR/issue_78442.rs:+0:1: +5:2 } } diff --git a/src/test/mir-opt/inline/issue_78442.rs b/src/test/mir-opt/inline/issue_78442.rs new file mode 100644 index 000000000..aa8ede2df --- /dev/null +++ b/src/test/mir-opt/inline/issue_78442.rs @@ -0,0 +1,20 @@ +// compile-flags: -Z mir-opt-level=3 -Z inline-mir +// ignore-wasm32-bare compiled with panic=abort by default +#![crate_type = "lib"] + +// EMIT_MIR issue_78442.bar.RevealAll.diff +// EMIT_MIR issue_78442.bar.Inline.diff +pub fn bar

( + // Error won't happen if "bar" is not generic + _baz: P, +) { + hide_foo()(); +} + +fn hide_foo() -> impl Fn() { + // Error won't happen if "iterate" hasn't impl Trait or has generics + foo +} + +fn foo() { // Error won't happen if "foo" isn't used in "iterate" or has generics +} diff --git a/src/test/mir-opt/inline/polymorphic-recursion.rs b/src/test/mir-opt/inline/polymorphic-recursion.rs deleted file mode 100644 index 7388722b7..000000000 --- a/src/test/mir-opt/inline/polymorphic-recursion.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Make sure that the MIR inliner does not loop indefinitely on polymorphic recursion. -// compile-flags: --crate-type lib - -// Randomize `def_path_hash` by defining them under a module with different names -macro_rules! emit { - ($($m:ident)*) => {$( - pub mod $m { - pub trait Tr { type Next: Tr; } - - pub fn hoge() { - inner::(); - } - - #[inline(always)] - fn inner() - { - inner::(); - inner::(); - } - } - )*}; -} - -// Increase the chance of triggering the bug -emit!(m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19); diff --git a/src/test/mir-opt/inline/polymorphic_recursion.rs b/src/test/mir-opt/inline/polymorphic_recursion.rs new file mode 100644 index 000000000..7388722b7 --- /dev/null +++ b/src/test/mir-opt/inline/polymorphic_recursion.rs @@ -0,0 +1,25 @@ +// Make sure that the MIR inliner does not loop indefinitely on polymorphic recursion. +// compile-flags: --crate-type lib + +// Randomize `def_path_hash` by defining them under a module with different names +macro_rules! emit { + ($($m:ident)*) => {$( + pub mod $m { + pub trait Tr { type Next: Tr; } + + pub fn hoge() { + inner::(); + } + + #[inline(always)] + fn inner() + { + inner::(); + inner::(); + } + } + )*}; +} + +// Increase the chance of triggering the bug +emit!(m00 m01 m02 m03 m04 m05 m06 m07 m08 m09 m10 m11 m12 m13 m14 m15 m16 m17 m18 m19); diff --git a/src/test/mir-opt/issue-101867.rs b/src/test/mir-opt/issue-101867.rs deleted file mode 100644 index 8a357eb79..000000000 --- a/src/test/mir-opt/issue-101867.rs +++ /dev/null @@ -1,7 +0,0 @@ -// EMIT_MIR issue_101867.main.mir_map.0.mir -fn main() { - let x: Option = Some(1); - let Some(y) = x else { - panic!(); - }; -} diff --git a/src/test/mir-opt/issue-101973.rs b/src/test/mir-opt/issue-101973.rs deleted file mode 100644 index 216659a23..000000000 --- a/src/test/mir-opt/issue-101973.rs +++ /dev/null @@ -1,20 +0,0 @@ -// compile-flags: -O -C debug-assertions=on -// This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test". - -#[inline] -pub fn imm8(x: u32) -> u32 { - let mut out = 0u32; - out |= (x >> 0) & 0xff; - out -} - -// EMIT_MIR issue_101973.inner.ConstProp.diff -#[inline(never)] -pub fn inner(fields: u32) -> i64 { - imm8(fields).rotate_right(((fields >> 8) & 0xf) << 1) as i32 as i64 -} - -fn main() { - let val = inner(0xe32cf20f); - assert_eq!(val as u64, 0xfffffffff0000000); -} diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue-38669.rs deleted file mode 100644 index db3f89472..000000000 --- a/src/test/mir-opt/issue-38669.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check that we don't StorageDead booleans before they are used - -// EMIT_MIR issue_38669.main.SimplifyCfg-initial.after.mir -fn main() { - let mut should_break = false; - loop { - if should_break { - break; - } - should_break = true; - } -} diff --git a/src/test/mir-opt/issue-41110.rs b/src/test/mir-opt/issue-41110.rs deleted file mode 100644 index 638dc601e..000000000 --- a/src/test/mir-opt/issue-41110.rs +++ /dev/null @@ -1,30 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default - -// check that we don't emit multiple drop flags when they are not needed. - - -// EMIT_MIR issue_41110.main.ElaborateDrops.after.mir -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 -pub fn test() { - let u = S; - let mut v = S; - drop(v); - v = u; -} - -struct S; -impl Drop for S { - fn drop(&mut self) { - } -} - -impl S { - fn id(self) -> Self { self } - fn other(self, s: Self) {} -} diff --git a/src/test/mir-opt/issue-41697.rs b/src/test/mir-opt/issue-41697.rs deleted file mode 100644 index cbd8633a3..000000000 --- a/src/test/mir-opt/issue-41697.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Regression test for #41697. Using dump-mir was triggering -// artificial cycles: during type-checking, we had to get the MIR for -// the constant expressions in `[u8; 2]`, which in turn would trigger -// an attempt to get the def-path, which in turn would request the -// types of the impl, which would trigger a cycle. We suppressed this -// cycle now by forcing mir-dump to avoid asking for types of an impl. - -#![feature(rustc_attrs)] - -use std::sync::Arc; - -trait Foo { - fn get(&self) -> [u8; 2]; -} - - -// EMIT_MIR issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir -impl Foo for [u8; 1+1] { - fn get(&self) -> [u8; 2] { - *self - } -} - -struct Bar(T); - -fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { - x -} - -fn unsize_nested_fat_ptr(x: Arc) -> Arc { - x -} - -fn main() { - let x: Box> = Box::new(Bar([1,2])); - assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]); - - let x: Arc = Arc::new([3, 4]); - assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]); -} diff --git a/src/test/mir-opt/issue-41888.rs b/src/test/mir-opt/issue-41888.rs deleted file mode 100644 index c1046c14d..000000000 --- a/src/test/mir-opt/issue-41888.rs +++ /dev/null @@ -1,24 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default -// 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 -fn main() { - let e; - if cond() { - e = E::F(K); - if let E::F(_k) = e { - // older versions of rustc used to not clear the - // drop flag for `e` in this path. - } - } -} - -fn cond() -> bool { false } - -struct K; - -enum E { - F(K), - G(Box) -} diff --git a/src/test/mir-opt/issue-49232.rs b/src/test/mir-opt/issue-49232.rs deleted file mode 100644 index 86494c76a..000000000 --- a/src/test/mir-opt/issue-49232.rs +++ /dev/null @@ -1,15 +0,0 @@ -// We must mark a variable whose initialization fails due to an -// abort statement as StorageDead. - -// EMIT_MIR issue_49232.main.mir_map.0.mir -fn main() { - loop { - let beacon = { - match true { - false => 4, - true => break, - } - }; - drop(&beacon); - } -} diff --git a/src/test/mir-opt/issue-62289.rs b/src/test/mir-opt/issue-62289.rs deleted file mode 100644 index 37e3390d5..000000000 --- a/src/test/mir-opt/issue-62289.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check that we don't forget to drop the Box if we early return before -// initializing it -// ignore-wasm32-bare compiled with panic=abort by default - -#![feature(box_syntax)] - -// EMIT_MIR issue_62289.test.ElaborateDrops.before.mir -fn test() -> Option> { - Some(box (None?)) -} - -fn main() { - test(); -} diff --git a/src/test/mir-opt/issue-72181-1.rs b/src/test/mir-opt/issue-72181-1.rs deleted file mode 100644 index 91e98adbe..000000000 --- a/src/test/mir-opt/issue-72181-1.rs +++ /dev/null @@ -1,21 +0,0 @@ -// compile-flags: -Z mir-opt-level=1 -// Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags. - -#![feature(never_type)] -#![allow(unused, invalid_value)] - -enum Void {} - -// EMIT_MIR issue_72181_1.f.mir_map.0.mir -fn f(v: Void) -> ! { - match v {} -} - -// EMIT_MIR issue_72181_1.main.mir_map.0.mir -fn main() { - let v: Void = unsafe { - std::mem::transmute::<(), Void>(()) - }; - - f(v); -} diff --git a/src/test/mir-opt/issue-72181.rs b/src/test/mir-opt/issue-72181.rs deleted file mode 100644 index ebb5f5042..000000000 --- a/src/test/mir-opt/issue-72181.rs +++ /dev/null @@ -1,28 +0,0 @@ -// compile-flags: -Z mir-opt-level=1 -// Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags. - -use std::mem; - -#[derive(Copy, Clone)] -enum Never {} - -union Foo { - a: u64, - b: Never -} - - -// EMIT_MIR issue_72181.foo.mir_map.0.mir -fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 } - -// EMIT_MIR issue_72181.bar.mir_map.0.mir -fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x } - - -// EMIT_MIR issue_72181.main.mir_map.0.mir -fn main() { - let _ = mem::size_of::(); - - let f = [Foo { a: 42 }, Foo { a: 10 }]; - let _ = unsafe { f[0].a }; -} diff --git a/src/test/mir-opt/issue-73223.rs b/src/test/mir-opt/issue-73223.rs deleted file mode 100644 index be114cab7..000000000 --- a/src/test/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/src/test/mir-opt/issue-78192.rs b/src/test/mir-opt/issue-78192.rs deleted file mode 100644 index 39f665402..000000000 --- a/src/test/mir-opt/issue-78192.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: -Zmir-opt-level=1 -Zinline-mir -pub fn f(a: &T) -> *const T { - let b: &*const T = &(a as *const T); - *b -} - -fn main() { - f(&2); -} - -// EMIT_MIR issue_78192.f.InstCombine.diff diff --git a/src/test/mir-opt/issue-91633.rs b/src/test/mir-opt/issue-91633.rs deleted file mode 100644 index 8f6601985..000000000 --- a/src/test/mir-opt/issue-91633.rs +++ /dev/null @@ -1,31 +0,0 @@ -// compile-flags: -Z mir-opt-level=0 -// EMIT_MIR issue_91633.hey.mir_map.0.mir -fn hey (it: &[T]) - where - [T] : std::ops::Index, - { - let _ = &it[0]; - } - -// EMIT_MIR issue_91633.bar.mir_map.0.mir -fn bar (it: Box<[T]>) - where - [T] : std::ops::Index, - { - let _ = it[0]; - } - -// EMIT_MIR issue_91633.fun.mir_map.0.mir -fn fun (it: &[T]) -> &T - { - let f = &it[0]; - f - } - -// EMIT_MIR issue_91633.foo.mir_map.0.mir -fn foo (it: Box<[T]>) -> T - { - let f = it[0].clone(); - f - } - fn main(){} diff --git a/src/test/mir-opt/issue-99325.rs b/src/test/mir-opt/issue-99325.rs deleted file mode 100644 index b79946ea8..000000000 --- a/src/test/mir-opt/issue-99325.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(adt_const_params)] -#![allow(incomplete_features)] - -pub fn function_with_bytes() -> &'static [u8] { - BYTES -} - -// EMIT_MIR issue_99325.main.mir_map.0.mir -pub fn main() { - assert_eq!(function_with_bytes::(), &[0x41, 0x41, 0x41, 0x41]); - assert_eq!(function_with_bytes::<{ &[0x41, 0x41, 0x41, 0x41] }>(), b"AAAA"); -} diff --git a/src/test/mir-opt/issue_101867.main.mir_map.0.mir b/src/test/mir-opt/issue_101867.main.mir_map.0.mir deleted file mode 100644 index 42a9e5587..000000000 --- a/src/test/mir-opt/issue_101867.main.mir_map.0.mir +++ /dev/null @@ -1,75 +0,0 @@ -// MIR for `main` 0 mir_map - -| User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue-101867.rs:3:12: 3:22, inferred_ty: std::option::Option -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option) }, span: $DIR/issue-101867.rs:3:12: 3:22, inferred_ty: std::option::Option -| -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-101867.rs:+0:11: +0:11 - let _1: std::option::Option as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue-101867.rs:+1:9: +1:10 - let mut _2: !; // in scope 0 at $DIR/issue-101867.rs:+2:26: +4:6 - let _3: (); // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL - let mut _4: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL - let mut _6: isize; // in scope 0 at $DIR/issue-101867.rs:+2:9: +2:16 - scope 1 { - debug x => _1; // in scope 1 at $DIR/issue-101867.rs:+1:9: +1:10 - let _5: u8; // in scope 1 at $DIR/issue-101867.rs:+2:14: +2:15 - scope 2 { - debug y => _5; // in scope 2 at $DIR/issue-101867.rs:+2:14: +2:15 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10 - _1 = Option::::Some(const 1_u8); // scope 0 at $DIR/issue-101867.rs:+1:25: +1:32 - FakeRead(ForLet(None), _1); // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10 - AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue-101867.rs:+1:12: +1:22 - StorageLive(_5); // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15 - FakeRead(ForMatchedPlace(None), _1); // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20 - _6 = discriminant(_1); // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20 - switchInt(move _6) -> [1_isize: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16 - } - - bb1: { - StorageLive(_3); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL - StorageLive(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL - _4 = begin_panic::<&str>(const "explicit panic") -> bb7; // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/std/src/panic.rs:LL:COL - // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value() } - // mir::Constant - // + span: $SRC_DIR/std/src/panic.rs:LL:COL - // + literal: Const { ty: &str, val: Value(Slice(..)) } - } - - bb2: { - StorageDead(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL - StorageDead(_3); // scope 1 at $DIR/issue-101867.rs:+3:16: +3:17 - unreachable; // scope 1 at $DIR/issue-101867.rs:+2:26: +4:6 - } - - bb3: { - goto -> bb6; // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20 - } - - bb4: { - falseEdge -> [real: bb5, imaginary: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16 - } - - bb5: { - _5 = ((_1 as Some).0: u8); // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15 - _0 = const (); // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2 - StorageDead(_5); // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2 - StorageDead(_1); // scope 0 at $DIR/issue-101867.rs:+5:1: +5:2 - return; // scope 0 at $DIR/issue-101867.rs:+5:2: +5:2 - } - - bb6: { - StorageDead(_5); // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2 - goto -> bb1; // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2 - } - - bb7 (cleanup): { - resume; // scope 0 at $DIR/issue-101867.rs:+0:1: +5:2 - } -} diff --git a/src/test/mir-opt/issue_101973.inner.ConstProp.diff b/src/test/mir-opt/issue_101973.inner.ConstProp.diff index 281afe4be..8fe60a024 100644 --- a/src/test/mir-opt/issue_101973.inner.ConstProp.diff +++ b/src/test/mir-opt/issue_101973.inner.ConstProp.diff @@ -2,99 +2,94 @@ + // MIR for `inner` after ConstProp fn inner(_1: u32) -> i64 { - debug fields => _1; // in scope 0 at $DIR/issue-101973.rs:+0:14: +0:20 - let mut _0: i64; // return place in scope 0 at $DIR/issue-101973.rs:+0:30: +0:33 - let mut _2: i32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:65 - let mut _3: u32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:58 - let mut _4: u32; // in scope 0 at $DIR/issue-101973.rs:+1:5: +1:17 - let mut _5: u32; // in scope 0 at $DIR/issue-101973.rs:+1:10: +1:16 - let mut _6: u32; // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 - let mut _7: u32; // in scope 0 at $DIR/issue-101973.rs:+1:31: +1:52 - let mut _8: u32; // in scope 0 at $DIR/issue-101973.rs:+1:32: +1:45 - let mut _9: u32; // in scope 0 at $DIR/issue-101973.rs:+1:33: +1:39 - 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 - 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; // in scope 1 at $DIR/issue-101973.rs:7:13: 7:14 - let mut _15: (u32, bool); // in scope 1 at $DIR/issue-101973.rs:7:12: 7:20 + debug fields => _1; // in scope 0 at $DIR/issue_101973.rs:+0:14: +0:20 + let mut _0: i64; // return place in scope 0 at $DIR/issue_101973.rs:+0:30: +0:33 + let mut _2: i32; // in scope 0 at $DIR/issue_101973.rs:+1:5: +1:65 + let mut _3: u32; // in scope 0 at $DIR/issue_101973.rs:+1:5: +1:58 + let mut _4: u32; // in scope 0 at $DIR/issue_101973.rs:+1:5: +1:17 + let mut _5: u32; // in scope 0 at $DIR/issue_101973.rs:+1:10: +1:16 + let mut _6: u32; // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 + let mut _7: u32; // in scope 0 at $DIR/issue_101973.rs:+1:31: +1:52 + let mut _8: u32; // in scope 0 at $DIR/issue_101973.rs:+1:32: +1:45 + let mut _9: u32; // in scope 0 at $DIR/issue_101973.rs:+1:33: +1:39 + 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 + 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 scope 2 { - debug out => _4; // in scope 2 at $DIR/issue-101973.rs:6:9: 6:16 + debug out => _4; // in scope 2 at $DIR/issue_101973.rs:6:9: 6:16 } } - scope 3 (inlined core::num::::rotate_right) { // at $DIR/issue-101973.rs:14:5: 14:58 + scope 3 (inlined core::num::::rotate_right) { // at $DIR/issue_101973.rs:14:5: 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 - let mut _17: 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 - _4 = const 0_u32; // scope 1 at $DIR/issue-101973.rs:6:19: 6:23 - 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 - StorageLive(_14); // scope 2 at $DIR/issue-101973.rs:7:13: 7:14 - _14 = _5; // scope 2 at $DIR/issue-101973.rs:7:13: 7:14 - _15 = CheckedShr(_14, const 0_i32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20 - assert(!move (_15.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 + 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 + 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 - assert(!move (_11.1: bool), "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue-101973.rs:+1:31: +1:57 + _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 + assert(!move (_11.1: bool), "attempt to shift left by `{}`, which would overflow", const 1_i32) -> bb2; // scope 0 at $DIR/issue_101973.rs:+1:31: +1:57 } 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 + _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 = _4; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageLive(_17); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _17 = _6; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - _3 = rotate_right::(move _16, move _17) -> bb4; // 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 // 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() } } bb3: { - _13 = move (_15.0: u32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:20 - StorageDead(_14); // scope 2 at $DIR/issue-101973.rs:7:19: 7:20 - _12 = BitAnd(move _13, const 255_u32); // scope 2 at $DIR/issue-101973.rs:7:12: 7:27 - StorageDead(_13); // scope 2 at $DIR/issue-101973.rs:7:26: 7:27 - _4 = BitOr(_4, 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 - 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 + _13 = move (_14.0: u32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:20 + _12 = BitAnd(move _13, const 255_u32); // scope 2 at $DIR/issue_101973.rs:7:12: 7:27 + 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 + 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(_17); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL StorageDead(_16); // 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 - StorageDead(_3); // scope 0 at $DIR/issue-101973.rs:+1:64: +1:65 - _0 = move _2 as i64 (IntToInt); // scope 0 at $DIR/issue-101973.rs:+1:5: +1:72 - StorageDead(_2); // scope 0 at $DIR/issue-101973.rs:+1:71: +1:72 - return; // scope 0 at $DIR/issue-101973.rs:+2:2: +2:2 + 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 + StorageDead(_3); // scope 0 at $DIR/issue_101973.rs:+1:64: +1:65 + _0 = move _2 as i64 (IntToInt); // scope 0 at $DIR/issue_101973.rs:+1:5: +1:72 + StorageDead(_2); // scope 0 at $DIR/issue_101973.rs:+1:71: +1:72 + return; // scope 0 at $DIR/issue_101973.rs:+2:2: +2:2 } } diff --git a/src/test/mir-opt/issue_101973.rs b/src/test/mir-opt/issue_101973.rs new file mode 100644 index 000000000..216659a23 --- /dev/null +++ b/src/test/mir-opt/issue_101973.rs @@ -0,0 +1,20 @@ +// compile-flags: -O -C debug-assertions=on +// This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test". + +#[inline] +pub fn imm8(x: u32) -> u32 { + let mut out = 0u32; + out |= (x >> 0) & 0xff; + out +} + +// EMIT_MIR issue_101973.inner.ConstProp.diff +#[inline(never)] +pub fn inner(fields: u32) -> i64 { + imm8(fields).rotate_right(((fields >> 8) & 0xf) << 1) as i32 as i64 +} + +fn main() { + let val = inner(0xe32cf20f); + assert_eq!(val as u64, 0xfffffffff0000000); +} diff --git a/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir index b13987f73..822100818 100644 --- a/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/issue_38669.main.SimplifyCfg-initial.after.mir @@ -1,52 +1,52 @@ // MIR for `main` after SimplifyCfg-initial fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-38669.rs:+0:11: +0:11 - let mut _1: bool; // in scope 0 at $DIR/issue-38669.rs:+1:9: +1:25 - let mut _2: (); // in scope 0 at $DIR/issue-38669.rs:+0:1: +8:2 - let _3: (); // in scope 0 at $DIR/issue-38669.rs:+3:9: +5:10 - let mut _4: bool; // in scope 0 at $DIR/issue-38669.rs:+3:12: +3:24 - let mut _5: !; // in scope 0 at $DIR/issue-38669.rs:+3:25: +5:10 + let mut _0: (); // return place in scope 0 at $DIR/issue_38669.rs:+0:11: +0:11 + let mut _1: bool; // in scope 0 at $DIR/issue_38669.rs:+1:9: +1:25 + let mut _2: (); // in scope 0 at $DIR/issue_38669.rs:+0:1: +8:2 + let _3: (); // in scope 0 at $DIR/issue_38669.rs:+3:9: +5:10 + let mut _4: bool; // in scope 0 at $DIR/issue_38669.rs:+3:12: +3:24 + let mut _5: !; // in scope 0 at $DIR/issue_38669.rs:+3:25: +5:10 scope 1 { - debug should_break => _1; // in scope 1 at $DIR/issue-38669.rs:+1:9: +1:25 + debug should_break => _1; // in scope 1 at $DIR/issue_38669.rs:+1:9: +1:25 } bb0: { - StorageLive(_1); // scope 0 at $DIR/issue-38669.rs:+1:9: +1:25 - _1 = const false; // scope 0 at $DIR/issue-38669.rs:+1:28: +1:33 - FakeRead(ForLet(None), _1); // scope 0 at $DIR/issue-38669.rs:+1:9: +1:25 - goto -> bb1; // scope 1 at $DIR/issue-38669.rs:+2:5: +7:6 + StorageLive(_1); // scope 0 at $DIR/issue_38669.rs:+1:9: +1:25 + _1 = const false; // scope 0 at $DIR/issue_38669.rs:+1:28: +1:33 + FakeRead(ForLet(None), _1); // scope 0 at $DIR/issue_38669.rs:+1:9: +1:25 + goto -> bb1; // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6 } bb1: { - falseUnwind -> [real: bb2, cleanup: bb5]; // scope 1 at $DIR/issue-38669.rs:+2:5: +7:6 + falseUnwind -> [real: bb2, cleanup: bb5]; // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6 } bb2: { - StorageLive(_3); // scope 1 at $DIR/issue-38669.rs:+3:9: +5:10 - StorageLive(_4); // scope 1 at $DIR/issue-38669.rs:+3:12: +3:24 - _4 = _1; // scope 1 at $DIR/issue-38669.rs:+3:12: +3:24 - switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-38669.rs:+3:12: +3:24 + StorageLive(_3); // scope 1 at $DIR/issue_38669.rs:+3:9: +5:10 + StorageLive(_4); // scope 1 at $DIR/issue_38669.rs:+3:12: +3:24 + _4 = _1; // scope 1 at $DIR/issue_38669.rs:+3:12: +3:24 + switchInt(move _4) -> [false: bb4, otherwise: bb3]; // scope 1 at $DIR/issue_38669.rs:+3:12: +3:24 } bb3: { - _0 = const (); // scope 1 at $DIR/issue-38669.rs:+4:13: +4:18 - StorageDead(_4); // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10 - StorageDead(_3); // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10 - StorageDead(_1); // scope 0 at $DIR/issue-38669.rs:+8:1: +8:2 - return; // scope 0 at $DIR/issue-38669.rs:+8:2: +8:2 + _0 = const (); // scope 1 at $DIR/issue_38669.rs:+4:13: +4:18 + StorageDead(_4); // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10 + StorageDead(_3); // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10 + StorageDead(_1); // scope 0 at $DIR/issue_38669.rs:+8:1: +8:2 + return; // scope 0 at $DIR/issue_38669.rs:+8:2: +8:2 } bb4: { - _3 = const (); // scope 1 at $DIR/issue-38669.rs:+5:10: +5:10 - StorageDead(_4); // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10 - StorageDead(_3); // scope 1 at $DIR/issue-38669.rs:+5:9: +5:10 - _1 = const true; // scope 1 at $DIR/issue-38669.rs:+6:9: +6:28 - _2 = const (); // scope 1 at $DIR/issue-38669.rs:+2:10: +7:6 - goto -> bb1; // scope 1 at $DIR/issue-38669.rs:+2:5: +7:6 + _3 = const (); // scope 1 at $DIR/issue_38669.rs:+5:10: +5:10 + StorageDead(_4); // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10 + StorageDead(_3); // scope 1 at $DIR/issue_38669.rs:+5:9: +5:10 + _1 = const true; // scope 1 at $DIR/issue_38669.rs:+6:9: +6:28 + _2 = const (); // scope 1 at $DIR/issue_38669.rs:+2:10: +7:6 + goto -> bb1; // scope 1 at $DIR/issue_38669.rs:+2:5: +7:6 } bb5 (cleanup): { - resume; // scope 0 at $DIR/issue-38669.rs:+0:1: +8:2 + resume; // scope 0 at $DIR/issue_38669.rs:+0:1: +8:2 } } diff --git a/src/test/mir-opt/issue_38669.rs b/src/test/mir-opt/issue_38669.rs new file mode 100644 index 000000000..db3f89472 --- /dev/null +++ b/src/test/mir-opt/issue_38669.rs @@ -0,0 +1,12 @@ +// check that we don't StorageDead booleans before they are used + +// EMIT_MIR issue_38669.main.SimplifyCfg-initial.after.mir +fn main() { + let mut should_break = false; + loop { + if should_break { + break; + } + should_break = true; + } +} diff --git a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir index 1d7cb91d6..c573ad5a8 100644 --- a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir @@ -1,70 +1,70 @@ // 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 + 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 + 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 + _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 + // + 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 + 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 + // + 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 + 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 + 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 + 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 + 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 + 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 + drop(_2) -> bb6; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 } bb8 (cleanup): { - switchInt(_5) -> [false: bb6, otherwise: bb7]; // scope 0 at $DIR/issue-41110.rs:+1:27: +1:28 + switchInt(_5) -> [false: bb6, otherwise: bb7]; // scope 0 at $DIR/issue_41110.rs:+1:27: +1:28 } } diff --git a/src/test/mir-opt/issue_41110.rs b/src/test/mir-opt/issue_41110.rs new file mode 100644 index 000000000..638dc601e --- /dev/null +++ b/src/test/mir-opt/issue_41110.rs @@ -0,0 +1,30 @@ +// ignore-wasm32-bare compiled with panic=abort by default + +// check that we don't emit multiple drop flags when they are not needed. + + +// EMIT_MIR issue_41110.main.ElaborateDrops.after.mir +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 +pub fn test() { + let u = S; + let mut v = S; + drop(v); + v = u; +} + +struct S; +impl Drop for S { + fn drop(&mut self) { + } +} + +impl S { + fn id(self) -> Self { self } + fn other(self, s: Self) {} +} diff --git a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir index b0e3496b2..470b03232 100644 --- a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir @@ -1,101 +1,101 @@ // 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 + 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 + 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 + 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 + _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 + // + 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 + 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 + 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 + 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 + 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 + _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 + 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 + 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 + 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 + 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 + 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 + _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 + _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 + drop(_1) -> bb10; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 } bb14 (cleanup): { - switchInt(_6) -> [false: bb10, otherwise: bb13]; // scope 0 at $DIR/issue-41110.rs:+5:1: +5:2 + switchInt(_6) -> [false: bb10, otherwise: bb13]; // scope 0 at $DIR/issue_41110.rs:+5:1: +5:2 } } diff --git a/src/test/mir-opt/issue_41697.rs b/src/test/mir-opt/issue_41697.rs new file mode 100644 index 000000000..cbd8633a3 --- /dev/null +++ b/src/test/mir-opt/issue_41697.rs @@ -0,0 +1,40 @@ +// Regression test for #41697. Using dump-mir was triggering +// artificial cycles: during type-checking, we had to get the MIR for +// the constant expressions in `[u8; 2]`, which in turn would trigger +// an attempt to get the def-path, which in turn would request the +// types of the impl, which would trigger a cycle. We suppressed this +// cycle now by forcing mir-dump to avoid asking for types of an impl. + +#![feature(rustc_attrs)] + +use std::sync::Arc; + +trait Foo { + fn get(&self) -> [u8; 2]; +} + + +// EMIT_MIR issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir +impl Foo for [u8; 1+1] { + fn get(&self) -> [u8; 2] { + *self + } +} + +struct Bar(T); + +fn unsize_fat_ptr<'a>(x: &'a Bar) -> &'a Bar { + x +} + +fn unsize_nested_fat_ptr(x: Arc) -> Arc { + x +} + +fn main() { + let x: Box> = Box::new(Bar([1,2])); + assert_eq!(unsize_fat_ptr(&*x).0.get(), [1, 2]); + + let x: Arc = Arc::new([3, 4]); + assert_eq!(unsize_nested_fat_ptr(x).get(), [3, 4]); +} diff --git a/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir b/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir index 047b24db4..8af087d84 100644 --- a/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir +++ b/src/test/mir-opt/issue_41697.{impl#0}-{constant#0}.SimplifyCfg-promote-consts.after.mir @@ -1,20 +1,20 @@ -// MIR for `::{constant#0}` after SimplifyCfg-promote-consts +// MIR for `::{constant#0}` after SimplifyCfg-promote-consts -::{constant#0}: usize = { - let mut _0: usize; // return place in scope 0 at $DIR/issue-41697.rs:+0:19: +0:22 - let mut _1: (usize, bool); // in scope 0 at $DIR/issue-41697.rs:+0:19: +0:22 +::{constant#0}: usize = { + let mut _0: usize; // return place in scope 0 at $DIR/issue_41697.rs:+0:19: +0:22 + let mut _1: (usize, bool); // in scope 0 at $DIR/issue_41697.rs:+0:19: +0:22 bb0: { - _1 = CheckedAdd(const 1_usize, const 1_usize); // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22 - assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_usize, const 1_usize) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22 + _1 = CheckedAdd(const 1_usize, const 1_usize); // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22 + assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_usize, const 1_usize) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22 } bb1: { - _0 = move (_1.0: usize); // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22 - return; // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22 + _0 = move (_1.0: usize); // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22 + return; // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22 } bb2 (cleanup): { - resume; // scope 0 at $DIR/issue-41697.rs:+0:19: +0:22 + resume; // scope 0 at $DIR/issue_41697.rs:+0:19: +0:22 } } diff --git a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir index f95a0a1c0..73372c97b 100644 --- a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir @@ -1,152 +1,152 @@ // 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 + 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 + 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 + 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 + _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 + // + span: $DIR/issue_41888.rs:8:8: 8:12 // + literal: Const { ty: fn() -> bool {cond}, val: Value() } } bb1: { - switchInt(move _2) -> [false: bb7, otherwise: bb2]; // scope 1 at $DIR/issue-41888.rs:+2:8: +2:14 + switchInt(move _2) -> [false: 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 + 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 + 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_isize: bb5, otherwise: bb6]; // scope 2 at $DIR/issue-41888.rs:+4:16: +4:24 + 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_isize: 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 + 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 + _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 + _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 + 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 + _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 + 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 + 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 + 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 + _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 + _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 + _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 + 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 + 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 + 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_isize: bb15, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2 + _10 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + switchInt(move _10) -> [0_isize: bb15, otherwise: bb17]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 } bb20: { - switchInt(_7) -> [false: bb15, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2 + switchInt(_7) -> [false: 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_isize: bb16, otherwise: bb18]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2 + _11 = discriminant(_1); // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 + switchInt(move _11) -> [0_isize: bb16, otherwise: bb18]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 } bb22 (cleanup): { - switchInt(_7) -> [false: bb12, otherwise: bb21]; // scope 0 at $DIR/issue-41888.rs:+9:1: +9:2 + switchInt(_7) -> [false: bb12, otherwise: bb21]; // scope 0 at $DIR/issue_41888.rs:+9:1: +9:2 } } diff --git a/src/test/mir-opt/issue_41888.rs b/src/test/mir-opt/issue_41888.rs new file mode 100644 index 000000000..c1046c14d --- /dev/null +++ b/src/test/mir-opt/issue_41888.rs @@ -0,0 +1,24 @@ +// ignore-wasm32-bare compiled with panic=abort by default +// 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 +fn main() { + let e; + if cond() { + e = E::F(K); + if let E::F(_k) = e { + // older versions of rustc used to not clear the + // drop flag for `e` in this path. + } + } +} + +fn cond() -> bool { false } + +struct K; + +enum E { + F(K), + G(Box) +} diff --git a/src/test/mir-opt/issue_49232.main.mir_map.0.mir b/src/test/mir-opt/issue_49232.main.mir_map.0.mir deleted file mode 100644 index 821323b5e..000000000 --- a/src/test/mir-opt/issue_49232.main.mir_map.0.mir +++ /dev/null @@ -1,82 +0,0 @@ -// MIR for `main` 0 mir_map - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-49232.rs:+0:11: +0:11 - let mut _1: (); // in scope 0 at $DIR/issue-49232.rs:+0:1: +10:2 - let _2: i32; // in scope 0 at $DIR/issue-49232.rs:+2:13: +2:19 - let mut _3: bool; // in scope 0 at $DIR/issue-49232.rs:+3:19: +3:23 - let mut _4: !; // in scope 0 at $DIR/issue-49232.rs:+5:25: +5:30 - let _5: (); // in scope 0 at $DIR/issue-49232.rs:+8:9: +8:22 - let mut _6: &i32; // in scope 0 at $DIR/issue-49232.rs:+8:14: +8:21 - scope 1 { - debug beacon => _2; // in scope 1 at $DIR/issue-49232.rs:+2:13: +2:19 - } - - bb0: { - goto -> bb1; // scope 0 at $DIR/issue-49232.rs:+1:5: +9:6 - } - - bb1: { - falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/issue-49232.rs:+1:5: +9:6 - } - - bb2: { - StorageLive(_2); // scope 0 at $DIR/issue-49232.rs:+2:13: +2:19 - StorageLive(_3); // scope 0 at $DIR/issue-49232.rs:+3:19: +3:23 - _3 = const true; // scope 0 at $DIR/issue-49232.rs:+3:19: +3:23 - FakeRead(ForMatchedPlace(None), _3); // scope 0 at $DIR/issue-49232.rs:+3:19: +3:23 - switchInt(_3) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/issue-49232.rs:+3:13: +3:23 - } - - bb3: { - falseEdge -> [real: bb5, imaginary: bb4]; // scope 0 at $DIR/issue-49232.rs:+4:17: +4:22 - } - - bb4: { - _0 = const (); // scope 0 at $DIR/issue-49232.rs:+5:25: +5:30 - goto -> bb10; // scope 0 at $DIR/issue-49232.rs:+5:25: +5:30 - } - - bb5: { - _2 = const 4_i32; // scope 0 at $DIR/issue-49232.rs:+4:26: +4:27 - goto -> bb8; // scope 0 at $DIR/issue-49232.rs:+4:26: +4:27 - } - - bb6: { - unreachable; // scope 0 at $DIR/issue-49232.rs:+5:25: +5:30 - } - - bb7: { - goto -> bb8; // scope 0 at $DIR/issue-49232.rs:+6:13: +6:14 - } - - bb8: { - FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue-49232.rs:+2:13: +2:19 - StorageDead(_3); // scope 0 at $DIR/issue-49232.rs:+7:10: +7:11 - StorageLive(_5); // scope 1 at $DIR/issue-49232.rs:+8:9: +8:22 - StorageLive(_6); // scope 1 at $DIR/issue-49232.rs:+8:14: +8:21 - _6 = &_2; // scope 1 at $DIR/issue-49232.rs:+8:14: +8:21 - _5 = std::mem::drop::<&i32>(move _6) -> [return: bb9, unwind: bb11]; // scope 1 at $DIR/issue-49232.rs:+8:9: +8:22 - // mir::Constant - // + span: $DIR/issue-49232.rs:13:9: 13:13 - // + literal: Const { ty: fn(&i32) {std::mem::drop::<&i32>}, val: Value() } - } - - bb9: { - StorageDead(_6); // scope 1 at $DIR/issue-49232.rs:+8:21: +8:22 - StorageDead(_5); // scope 1 at $DIR/issue-49232.rs:+8:22: +8:23 - _1 = const (); // scope 0 at $DIR/issue-49232.rs:+1:10: +9:6 - StorageDead(_2); // scope 0 at $DIR/issue-49232.rs:+9:5: +9:6 - goto -> bb1; // scope 0 at $DIR/issue-49232.rs:+1:5: +9:6 - } - - bb10: { - StorageDead(_3); // scope 0 at $DIR/issue-49232.rs:+7:10: +7:11 - StorageDead(_2); // scope 0 at $DIR/issue-49232.rs:+9:5: +9:6 - return; // scope 0 at $DIR/issue-49232.rs:+10:2: +10:2 - } - - bb11 (cleanup): { - resume; // scope 0 at $DIR/issue-49232.rs:+0:1: +10:2 - } -} diff --git a/src/test/mir-opt/issue_62289.rs b/src/test/mir-opt/issue_62289.rs new file mode 100644 index 000000000..37e3390d5 --- /dev/null +++ b/src/test/mir-opt/issue_62289.rs @@ -0,0 +1,14 @@ +// check that we don't forget to drop the Box if we early return before +// initializing it +// ignore-wasm32-bare compiled with panic=abort by default + +#![feature(box_syntax)] + +// EMIT_MIR issue_62289.test.ElaborateDrops.before.mir +fn test() -> Option> { + Some(box (None?)) +} + +fn main() { + test(); +} diff --git a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir index 72603dc5d..6969a66ac 100644 --- a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir +++ b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir @@ -1,122 +1,122 @@ // MIR for `test` before ElaborateDrops fn test() -> Option> { - let mut _0: std::option::Option>; // return place in scope 0 at $DIR/issue-62289.rs:+0:14: +0:30 - let mut _1: std::boxed::Box; // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - let mut _2: usize; // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - let mut _3: usize; // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - let mut _4: *mut u8; // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - let mut _5: std::boxed::Box; // in scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - let mut _6: std::ops::ControlFlow, u32>; // in scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 - let mut _7: std::option::Option; // in scope 0 at $DIR/issue-62289.rs:+1:15: +1:19 - let mut _8: isize; // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - let _9: std::option::Option; // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - let mut _10: !; // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - let mut _11: std::option::Option; // in scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - let _12: u32; // in scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 + let mut _0: std::option::Option>; // return place in scope 0 at $DIR/issue_62289.rs:+0:14: +0:30 + let mut _1: std::boxed::Box; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + let mut _2: usize; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + let mut _3: usize; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + let mut _4: *mut u8; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + let mut _5: std::boxed::Box; // in scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + let mut _6: std::ops::ControlFlow, u32>; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + let mut _7: std::option::Option; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 + let mut _8: isize; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + let _9: std::option::Option; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + let mut _10: !; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + let mut _11: std::option::Option; // in scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + let _12: u32; // in scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 scope 1 { } scope 2 { - debug residual => _9; // in scope 2 at $DIR/issue-62289.rs:+1:19: +1:20 + debug residual => _9; // in scope 2 at $DIR/issue_62289.rs:+1:19: +1:20 scope 3 { } } scope 4 { - debug val => _12; // in scope 4 at $DIR/issue-62289.rs:+1:15: +1:20 + debug val => _12; // in scope 4 at $DIR/issue_62289.rs:+1:15: +1:20 scope 5 { } } bb0: { - StorageLive(_1); // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - _2 = SizeOf(u32); // scope 1 at $DIR/issue-62289.rs:+1:10: +1:21 - _3 = AlignOf(u32); // scope 1 at $DIR/issue-62289.rs:+1:10: +1:21 - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue-62289.rs:+1:10: +1:21 + StorageLive(_1); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + _2 = SizeOf(u32); // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21 + _3 = AlignOf(u32); // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21 + _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 1 at $DIR/issue_62289.rs:+1:10: +1:21 // mir::Constant - // + span: $DIR/issue-62289.rs:9:10: 9:21 + // + span: $DIR/issue_62289.rs:9:10: 9:21 // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } } bb1: { - StorageLive(_5); // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - _5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - StorageLive(_6); // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 - StorageLive(_7); // scope 0 at $DIR/issue-62289.rs:+1:15: +1:19 - _7 = Option::::None; // scope 0 at $DIR/issue-62289.rs:+1:15: +1:19 - _6 = as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 + StorageLive(_5); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + _5 = ShallowInitBox(move _4, u32); // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + StorageLive(_6); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + StorageLive(_7); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 + _7 = Option::::None; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:19 + _6 = as Try>::branch(move _7) -> [return: bb2, unwind: bb12]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 // mir::Constant - // + span: $DIR/issue-62289.rs:9:15: 9:20 + // + span: $DIR/issue_62289.rs:9:15: 9:20 // + literal: Const { ty: fn(Option) -> ControlFlow< as Try>::Residual, as Try>::Output> { as Try>::branch}, val: Value() } } bb2: { - StorageDead(_7); // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - _8 = discriminant(_6); // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 - switchInt(move _8) -> [0_isize: bb3, 1_isize: bb5, otherwise: bb4]; // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 + StorageDead(_7); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + _8 = discriminant(_6); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + switchInt(move _8) -> [0_isize: bb3, 1_isize: bb5, otherwise: bb4]; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 } bb3: { - StorageLive(_12); // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 - _12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 - (*_5) = _12; // scope 5 at $DIR/issue-62289.rs:+1:15: +1:20 - StorageDead(_12); // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - _1 = move _5; // scope 0 at $DIR/issue-62289.rs:+1:10: +1:21 - drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21 + StorageLive(_12); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + _12 = ((_6 as Continue).0: u32); // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 + (*_5) = _12; // scope 5 at $DIR/issue_62289.rs:+1:15: +1:20 + StorageDead(_12); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + _1 = move _5; // scope 0 at $DIR/issue_62289.rs:+1:10: +1:21 + drop(_5) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 } bb4: { - unreachable; // scope 0 at $DIR/issue-62289.rs:+1:15: +1:20 + unreachable; // scope 0 at $DIR/issue_62289.rs:+1:15: +1:20 } bb5: { - StorageLive(_9); // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - _9 = ((_6 as Break).0: std::option::Option); // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - StorageLive(_11); // scope 3 at $DIR/issue-62289.rs:+1:19: +1:20 - _11 = _9; // scope 3 at $DIR/issue-62289.rs:+1:19: +1:20 - _0 = > as FromResidual>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue-62289.rs:+1:15: +1:20 + StorageLive(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + _9 = ((_6 as Break).0: std::option::Option); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + StorageLive(_11); // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 + _11 = _9; // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 + _0 = > as FromResidual>>::from_residual(move _11) -> [return: bb6, unwind: bb12]; // scope 3 at $DIR/issue_62289.rs:+1:15: +1:20 // mir::Constant - // + span: $DIR/issue-62289.rs:9:19: 9:20 + // + span: $DIR/issue_62289.rs:9:19: 9:20 // + literal: Const { ty: fn(Option) -> Option> {> as FromResidual>>::from_residual}, val: Value() } } bb6: { - StorageDead(_11); // scope 3 at $DIR/issue-62289.rs:+1:19: +1:20 - StorageDead(_9); // scope 0 at $DIR/issue-62289.rs:+1:19: +1:20 - drop(_5) -> bb9; // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21 + StorageDead(_11); // scope 3 at $DIR/issue_62289.rs:+1:19: +1:20 + StorageDead(_9); // scope 0 at $DIR/issue_62289.rs:+1:19: +1:20 + drop(_5) -> bb9; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 } bb7: { - StorageDead(_5); // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21 - _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:+1:5: +1:22 - drop(_1) -> bb8; // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22 + StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 + _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue_62289.rs:+1:5: +1:22 + drop(_1) -> bb8; // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 } bb8: { - StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22 - StorageDead(_6); // scope 0 at $DIR/issue-62289.rs:+2:1: +2:2 - goto -> bb10; // scope 0 at $DIR/issue-62289.rs:+2:2: +2:2 + StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 + StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2 + goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 } bb9: { - StorageDead(_5); // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21 - StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22 - StorageDead(_6); // scope 0 at $DIR/issue-62289.rs:+2:1: +2:2 - goto -> bb10; // scope 0 at $DIR/issue-62289.rs:+2:2: +2:2 + StorageDead(_5); // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 + StorageDead(_1); // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 + StorageDead(_6); // scope 0 at $DIR/issue_62289.rs:+2:1: +2:2 + goto -> bb10; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 } bb10: { - return; // scope 0 at $DIR/issue-62289.rs:+2:2: +2:2 + return; // scope 0 at $DIR/issue_62289.rs:+2:2: +2:2 } bb11 (cleanup): { - drop(_1) -> bb13; // scope 0 at $DIR/issue-62289.rs:+1:21: +1:22 + drop(_1) -> bb13; // scope 0 at $DIR/issue_62289.rs:+1:21: +1:22 } bb12 (cleanup): { - drop(_5) -> bb13; // scope 0 at $DIR/issue-62289.rs:+1:20: +1:21 + drop(_5) -> bb13; // scope 0 at $DIR/issue_62289.rs:+1:20: +1:21 } bb13 (cleanup): { - resume; // scope 0 at $DIR/issue-62289.rs:+0:1: +2:2 + resume; // scope 0 at $DIR/issue_62289.rs:+0:1: +2:2 } } diff --git a/src/test/mir-opt/issue_72181.bar.built.after.mir b/src/test/mir-opt/issue_72181.bar.built.after.mir new file mode 100644 index 000000000..ebee89001 --- /dev/null +++ b/src/test/mir-opt/issue_72181.bar.built.after.mir @@ -0,0 +1,17 @@ +// MIR for `bar` after built + +fn bar(_1: [(Never, u32); 1]) -> u32 { + let mut _0: u32; // return place in scope 0 at $DIR/issue_72181.rs:+0:40: +0:43 + let _2: u32; // in scope 0 at $DIR/issue_72181.rs:+0:13: +0:14 + scope 1 { + debug x => _2; // in scope 1 at $DIR/issue_72181.rs:+0:13: +0:14 + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_72181.rs:+0:13: +0:14 + _2 = (_1[0 of 1].1: u32); // scope 0 at $DIR/issue_72181.rs:+0:13: +0:14 + _0 = _2; // scope 1 at $DIR/issue_72181.rs:+0:46: +0:47 + StorageDead(_2); // scope 0 at $DIR/issue_72181.rs:+0:48: +0:49 + return; // scope 0 at $DIR/issue_72181.rs:+0:49: +0:49 + } +} diff --git a/src/test/mir-opt/issue_72181.bar.mir_map.0.mir b/src/test/mir-opt/issue_72181.bar.mir_map.0.mir deleted file mode 100644 index 972ce1d50..000000000 --- a/src/test/mir-opt/issue_72181.bar.mir_map.0.mir +++ /dev/null @@ -1,17 +0,0 @@ -// MIR for `bar` 0 mir_map - -fn bar(_1: [(Never, u32); 1]) -> u32 { - let mut _0: u32; // return place in scope 0 at $DIR/issue-72181.rs:+0:40: +0:43 - let _2: u32; // in scope 0 at $DIR/issue-72181.rs:+0:13: +0:14 - scope 1 { - debug x => _2; // in scope 1 at $DIR/issue-72181.rs:+0:13: +0:14 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-72181.rs:+0:13: +0:14 - _2 = (_1[0 of 1].1: u32); // scope 0 at $DIR/issue-72181.rs:+0:13: +0:14 - _0 = _2; // scope 1 at $DIR/issue-72181.rs:+0:46: +0:47 - StorageDead(_2); // scope 0 at $DIR/issue-72181.rs:+0:48: +0:49 - return; // scope 0 at $DIR/issue-72181.rs:+0:49: +0:49 - } -} diff --git a/src/test/mir-opt/issue_72181.foo.built.after.mir b/src/test/mir-opt/issue_72181.foo.built.after.mir new file mode 100644 index 000000000..90c978520 --- /dev/null +++ b/src/test/mir-opt/issue_72181.foo.built.after.mir @@ -0,0 +1,27 @@ +// MIR for `foo` after built + +fn foo(_1: [(Never, u32); 1]) -> u32 { + debug xs => _1; // in scope 0 at $DIR/issue_72181.rs:+0:8: +0:10 + let mut _0: u32; // return place in scope 0 at $DIR/issue_72181.rs:+0:34: +0:37 + let _2: usize; // in scope 0 at $DIR/issue_72181.rs:+0:43: +0:44 + let mut _3: usize; // in scope 0 at $DIR/issue_72181.rs:+0:40: +0:45 + let mut _4: bool; // in scope 0 at $DIR/issue_72181.rs:+0:40: +0:45 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_72181.rs:+0:43: +0:44 + _2 = const 0_usize; // scope 0 at $DIR/issue_72181.rs:+0:43: +0:44 + _3 = Len(_1); // scope 0 at $DIR/issue_72181.rs:+0:40: +0:45 + _4 = Lt(_2, _3); // scope 0 at $DIR/issue_72181.rs:+0:40: +0:45 + assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue_72181.rs:+0:40: +0:45 + } + + bb1: { + _0 = (_1[_2].1: u32); // scope 0 at $DIR/issue_72181.rs:+0:40: +0:47 + StorageDead(_2); // scope 0 at $DIR/issue_72181.rs:+0:48: +0:49 + return; // scope 0 at $DIR/issue_72181.rs:+0:49: +0:49 + } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/issue_72181.rs:+0:1: +0:49 + } +} diff --git a/src/test/mir-opt/issue_72181.foo.mir_map.0.mir b/src/test/mir-opt/issue_72181.foo.mir_map.0.mir deleted file mode 100644 index 534f131ea..000000000 --- a/src/test/mir-opt/issue_72181.foo.mir_map.0.mir +++ /dev/null @@ -1,27 +0,0 @@ -// MIR for `foo` 0 mir_map - -fn foo(_1: [(Never, u32); 1]) -> u32 { - debug xs => _1; // in scope 0 at $DIR/issue-72181.rs:+0:8: +0:10 - let mut _0: u32; // return place in scope 0 at $DIR/issue-72181.rs:+0:34: +0:37 - let _2: usize; // in scope 0 at $DIR/issue-72181.rs:+0:43: +0:44 - let mut _3: usize; // in scope 0 at $DIR/issue-72181.rs:+0:40: +0:45 - let mut _4: bool; // in scope 0 at $DIR/issue-72181.rs:+0:40: +0:45 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-72181.rs:+0:43: +0:44 - _2 = const 0_usize; // scope 0 at $DIR/issue-72181.rs:+0:43: +0:44 - _3 = Len(_1); // scope 0 at $DIR/issue-72181.rs:+0:40: +0:45 - _4 = Lt(_2, _3); // scope 0 at $DIR/issue-72181.rs:+0:40: +0:45 - assert(move _4, "index out of bounds: the length is {} but the index is {}", move _3, _2) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue-72181.rs:+0:40: +0:45 - } - - bb1: { - _0 = (_1[_2].1: u32); // scope 0 at $DIR/issue-72181.rs:+0:40: +0:47 - StorageDead(_2); // scope 0 at $DIR/issue-72181.rs:+0:48: +0:49 - return; // scope 0 at $DIR/issue-72181.rs:+0:49: +0:49 - } - - bb2 (cleanup): { - resume; // scope 0 at $DIR/issue-72181.rs:+0:1: +0:49 - } -} diff --git a/src/test/mir-opt/issue_72181.main.built.after.mir b/src/test/mir-opt/issue_72181.main.built.after.mir new file mode 100644 index 000000000..e86836927 --- /dev/null +++ b/src/test/mir-opt/issue_72181.main.built.after.mir @@ -0,0 +1,62 @@ +// MIR for `main` after built + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_72181.rs:+0:11: +0:11 + let mut _1: usize; // in scope 0 at $DIR/issue_72181.rs:+1:13: +1:34 + let mut _3: Foo; // in scope 0 at $DIR/issue_72181.rs:+3:14: +3:27 + let mut _4: Foo; // in scope 0 at $DIR/issue_72181.rs:+3:29: +3:42 + let mut _5: u64; // in scope 0 at $DIR/issue_72181.rs:+4:13: +4:30 + let _6: usize; // in scope 0 at $DIR/issue_72181.rs:+4:24: +4:25 + let mut _7: usize; // in scope 0 at $DIR/issue_72181.rs:+4:22: +4:26 + let mut _8: bool; // in scope 0 at $DIR/issue_72181.rs:+4:22: +4:26 + scope 1 { + let _2: [Foo; 2]; // in scope 1 at $DIR/issue_72181.rs:+3:9: +3:10 + scope 2 { + debug f => _2; // in scope 2 at $DIR/issue_72181.rs:+3:9: +3:10 + scope 3 { + } + scope 4 { + } + } + } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/issue_72181.rs:+1:13: +1:34 + _1 = std::mem::size_of::() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue_72181.rs:+1:13: +1:34 + // mir::Constant + // + span: $DIR/issue_72181.rs:24:13: 24:32 + // + literal: Const { ty: fn() -> usize {std::mem::size_of::}, val: Value() } + } + + bb1: { + StorageDead(_1); // scope 0 at $DIR/issue_72181.rs:+1:34: +1:35 + StorageLive(_2); // scope 1 at $DIR/issue_72181.rs:+3:9: +3:10 + StorageLive(_3); // scope 1 at $DIR/issue_72181.rs:+3:14: +3:27 + _3 = Foo { a: const 42_u64 }; // scope 1 at $DIR/issue_72181.rs:+3:14: +3:27 + StorageLive(_4); // scope 1 at $DIR/issue_72181.rs:+3:29: +3:42 + _4 = Foo { a: const 10_u64 }; // scope 1 at $DIR/issue_72181.rs:+3:29: +3:42 + _2 = [move _3, move _4]; // scope 1 at $DIR/issue_72181.rs:+3:13: +3:43 + StorageDead(_4); // scope 1 at $DIR/issue_72181.rs:+3:42: +3:43 + StorageDead(_3); // scope 1 at $DIR/issue_72181.rs:+3:42: +3:43 + FakeRead(ForLet(None), _2); // scope 1 at $DIR/issue_72181.rs:+3:9: +3:10 + StorageLive(_5); // scope 2 at $DIR/issue_72181.rs:+4:13: +4:30 + StorageLive(_6); // scope 4 at $DIR/issue_72181.rs:+4:24: +4:25 + _6 = const 0_usize; // scope 4 at $DIR/issue_72181.rs:+4:24: +4:25 + _7 = Len(_2); // scope 4 at $DIR/issue_72181.rs:+4:22: +4:26 + _8 = Lt(_6, _7); // scope 4 at $DIR/issue_72181.rs:+4:22: +4:26 + assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb2, unwind: bb3]; // scope 4 at $DIR/issue_72181.rs:+4:22: +4:26 + } + + bb2: { + _5 = (_2[_6].0: u64); // scope 4 at $DIR/issue_72181.rs:+4:22: +4:28 + StorageDead(_6); // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31 + StorageDead(_5); // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31 + _0 = const (); // scope 0 at $DIR/issue_72181.rs:+0:11: +5:2 + StorageDead(_2); // scope 1 at $DIR/issue_72181.rs:+5:1: +5:2 + return; // scope 0 at $DIR/issue_72181.rs:+5:2: +5:2 + } + + bb3 (cleanup): { + resume; // scope 0 at $DIR/issue_72181.rs:+0:1: +5:2 + } +} diff --git a/src/test/mir-opt/issue_72181.main.mir_map.0.mir b/src/test/mir-opt/issue_72181.main.mir_map.0.mir deleted file mode 100644 index 425906f84..000000000 --- a/src/test/mir-opt/issue_72181.main.mir_map.0.mir +++ /dev/null @@ -1,62 +0,0 @@ -// MIR for `main` 0 mir_map - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-72181.rs:+0:11: +0:11 - let mut _1: usize; // in scope 0 at $DIR/issue-72181.rs:+1:13: +1:34 - let mut _3: Foo; // in scope 0 at $DIR/issue-72181.rs:+3:14: +3:27 - let mut _4: Foo; // in scope 0 at $DIR/issue-72181.rs:+3:29: +3:42 - let mut _5: u64; // in scope 0 at $DIR/issue-72181.rs:+4:13: +4:30 - let _6: usize; // in scope 0 at $DIR/issue-72181.rs:+4:24: +4:25 - let mut _7: usize; // in scope 0 at $DIR/issue-72181.rs:+4:22: +4:26 - let mut _8: bool; // in scope 0 at $DIR/issue-72181.rs:+4:22: +4:26 - scope 1 { - let _2: [Foo; 2]; // in scope 1 at $DIR/issue-72181.rs:+3:9: +3:10 - scope 2 { - debug f => _2; // in scope 2 at $DIR/issue-72181.rs:+3:9: +3:10 - scope 3 { - } - scope 4 { - } - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/issue-72181.rs:+1:13: +1:34 - _1 = std::mem::size_of::() -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-72181.rs:+1:13: +1:34 - // mir::Constant - // + span: $DIR/issue-72181.rs:24:13: 24:32 - // + literal: Const { ty: fn() -> usize {std::mem::size_of::}, val: Value() } - } - - bb1: { - StorageDead(_1); // scope 0 at $DIR/issue-72181.rs:+1:34: +1:35 - StorageLive(_2); // scope 1 at $DIR/issue-72181.rs:+3:9: +3:10 - StorageLive(_3); // scope 1 at $DIR/issue-72181.rs:+3:14: +3:27 - _3 = Foo { a: const 42_u64 }; // scope 1 at $DIR/issue-72181.rs:+3:14: +3:27 - StorageLive(_4); // scope 1 at $DIR/issue-72181.rs:+3:29: +3:42 - _4 = Foo { a: const 10_u64 }; // scope 1 at $DIR/issue-72181.rs:+3:29: +3:42 - _2 = [move _3, move _4]; // scope 1 at $DIR/issue-72181.rs:+3:13: +3:43 - StorageDead(_4); // scope 1 at $DIR/issue-72181.rs:+3:42: +3:43 - StorageDead(_3); // scope 1 at $DIR/issue-72181.rs:+3:42: +3:43 - FakeRead(ForLet(None), _2); // scope 1 at $DIR/issue-72181.rs:+3:9: +3:10 - StorageLive(_5); // scope 2 at $DIR/issue-72181.rs:+4:13: +4:30 - StorageLive(_6); // scope 4 at $DIR/issue-72181.rs:+4:24: +4:25 - _6 = const 0_usize; // scope 4 at $DIR/issue-72181.rs:+4:24: +4:25 - _7 = Len(_2); // scope 4 at $DIR/issue-72181.rs:+4:22: +4:26 - _8 = Lt(_6, _7); // scope 4 at $DIR/issue-72181.rs:+4:22: +4:26 - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb2, unwind: bb3]; // scope 4 at $DIR/issue-72181.rs:+4:22: +4:26 - } - - bb2: { - _5 = (_2[_6].0: u64); // scope 4 at $DIR/issue-72181.rs:+4:22: +4:28 - StorageDead(_6); // scope 2 at $DIR/issue-72181.rs:+4:30: +4:31 - StorageDead(_5); // scope 2 at $DIR/issue-72181.rs:+4:30: +4:31 - _0 = const (); // scope 0 at $DIR/issue-72181.rs:+0:11: +5:2 - StorageDead(_2); // scope 1 at $DIR/issue-72181.rs:+5:1: +5:2 - return; // scope 0 at $DIR/issue-72181.rs:+5:2: +5:2 - } - - bb3 (cleanup): { - resume; // scope 0 at $DIR/issue-72181.rs:+0:1: +5:2 - } -} diff --git a/src/test/mir-opt/issue_72181.rs b/src/test/mir-opt/issue_72181.rs new file mode 100644 index 000000000..6a32d4bbe --- /dev/null +++ b/src/test/mir-opt/issue_72181.rs @@ -0,0 +1,28 @@ +// compile-flags: -Z mir-opt-level=1 +// Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags. + +use std::mem; + +#[derive(Copy, Clone)] +enum Never {} + +union Foo { + a: u64, + b: Never +} + + +// EMIT_MIR issue_72181.foo.built.after.mir +fn foo(xs: [(Never, u32); 1]) -> u32 { xs[0].1 } + +// EMIT_MIR issue_72181.bar.built.after.mir +fn bar([(_, x)]: [(Never, u32); 1]) -> u32 { x } + + +// EMIT_MIR issue_72181.main.built.after.mir +fn main() { + let _ = mem::size_of::(); + + let f = [Foo { a: 42 }, Foo { a: 10 }]; + let _ = unsafe { f[0].a }; +} diff --git a/src/test/mir-opt/issue_72181_1.f.built.after.mir b/src/test/mir-opt/issue_72181_1.f.built.after.mir new file mode 100644 index 000000000..4086da520 --- /dev/null +++ b/src/test/mir-opt/issue_72181_1.f.built.after.mir @@ -0,0 +1,29 @@ +// MIR for `f` after built + +fn f(_1: Void) -> ! { + debug v => _1; // in scope 0 at $DIR/issue_72181_1.rs:+0:6: +0:7 + let mut _0: !; // return place in scope 0 at $DIR/issue_72181_1.rs:+0:18: +0:19 + let mut _2: !; // in scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 + let mut _3: !; // in scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 + StorageLive(_3); // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 + FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12 + unreachable; // scope 0 at $DIR/issue_72181_1.rs:+1:11: +1:12 + } + + bb1: { + unreachable; // scope 0 at $DIR/issue_72181_1.rs:+1:5: +1:15 + } + + bb2: { + StorageDead(_3); // scope 0 at $DIR/issue_72181_1.rs:+1:14: +1:15 + unreachable; // scope 0 at $DIR/issue_72181_1.rs:+0:20: +2:2 + } + + bb3: { + StorageDead(_2); // scope 0 at $DIR/issue_72181_1.rs:+2:1: +2:2 + return; // scope 0 at $DIR/issue_72181_1.rs:+2:2: +2:2 + } +} diff --git a/src/test/mir-opt/issue_72181_1.f.mir_map.0.mir b/src/test/mir-opt/issue_72181_1.f.mir_map.0.mir deleted file mode 100644 index e1a35d88b..000000000 --- a/src/test/mir-opt/issue_72181_1.f.mir_map.0.mir +++ /dev/null @@ -1,29 +0,0 @@ -// MIR for `f` 0 mir_map - -fn f(_1: Void) -> ! { - debug v => _1; // in scope 0 at $DIR/issue-72181-1.rs:+0:6: +0:7 - let mut _0: !; // return place in scope 0 at $DIR/issue-72181-1.rs:+0:18: +0:19 - let mut _2: !; // in scope 0 at $DIR/issue-72181-1.rs:+0:20: +2:2 - let mut _3: !; // in scope 0 at $DIR/issue-72181-1.rs:+1:5: +1:15 - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-72181-1.rs:+0:20: +2:2 - StorageLive(_3); // scope 0 at $DIR/issue-72181-1.rs:+1:5: +1:15 - FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/issue-72181-1.rs:+1:11: +1:12 - unreachable; // scope 0 at $DIR/issue-72181-1.rs:+1:11: +1:12 - } - - bb1: { - unreachable; // scope 0 at $DIR/issue-72181-1.rs:+1:5: +1:15 - } - - bb2: { - StorageDead(_3); // scope 0 at $DIR/issue-72181-1.rs:+1:14: +1:15 - unreachable; // scope 0 at $DIR/issue-72181-1.rs:+0:20: +2:2 - } - - bb3: { - StorageDead(_2); // scope 0 at $DIR/issue-72181-1.rs:+2:1: +2:2 - return; // scope 0 at $DIR/issue-72181-1.rs:+2:2: +2:2 - } -} diff --git a/src/test/mir-opt/issue_72181_1.main.built.after.mir b/src/test/mir-opt/issue_72181_1.main.built.after.mir new file mode 100644 index 000000000..2172f3aa9 --- /dev/null +++ b/src/test/mir-opt/issue_72181_1.main.built.after.mir @@ -0,0 +1,57 @@ +// MIR for `main` after built + +| User Type Annotations +| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void +| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue_72181_1.rs:16:12: 16:16, inferred_ty: Void +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_72181_1.rs:+0:11: +0:11 + let mut _1: !; // in scope 0 at $DIR/issue_72181_1.rs:+0:11: +6:2 + let _2: Void as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue_72181_1.rs:+1:9: +1:10 + let mut _3: (); // in scope 0 at $DIR/issue_72181_1.rs:+2:41: +2:43 + let _4: !; // in scope 0 at $DIR/issue_72181_1.rs:+5:5: +5:9 + let mut _5: Void; // in scope 0 at $DIR/issue_72181_1.rs:+5:7: +5:8 + scope 1 { + debug v => _2; // in scope 1 at $DIR/issue_72181_1.rs:+1:9: +1:10 + } + scope 2 { + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_72181_1.rs:+1:9: +1:10 + StorageLive(_3); // scope 2 at $DIR/issue_72181_1.rs:+2:41: +2:43 + _3 = (); // scope 2 at $DIR/issue_72181_1.rs:+2:41: +2:43 + _2 = transmute::<(), Void>(move _3) -> bb4; // scope 2 at $DIR/issue_72181_1.rs:+2:9: +2:44 + // mir::Constant + // + span: $DIR/issue_72181_1.rs:17:9: 17:40 + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(()) -> Void {transmute::<(), Void>}, val: Value() } + } + + bb1: { + StorageDead(_3); // scope 2 at $DIR/issue_72181_1.rs:+2:43: +2:44 + FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue_72181_1.rs:+1:9: +1:10 + AscribeUserType(_2, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue_72181_1.rs:+1:12: +1:16 + StorageLive(_4); // scope 1 at $DIR/issue_72181_1.rs:+5:5: +5:9 + StorageLive(_5); // scope 1 at $DIR/issue_72181_1.rs:+5:7: +5:8 + _5 = move _2; // scope 1 at $DIR/issue_72181_1.rs:+5:7: +5:8 + _4 = f(move _5) -> bb4; // scope 1 at $DIR/issue_72181_1.rs:+5:5: +5:9 + // mir::Constant + // + span: $DIR/issue_72181_1.rs:20:5: 20:6 + // + literal: Const { ty: fn(Void) -> ! {f}, val: Value() } + } + + bb2: { + StorageDead(_5); // scope 1 at $DIR/issue_72181_1.rs:+5:8: +5:9 + StorageDead(_4); // scope 1 at $DIR/issue_72181_1.rs:+5:9: +5:10 + StorageDead(_2); // scope 0 at $DIR/issue_72181_1.rs:+6:1: +6:2 + unreachable; // scope 0 at $DIR/issue_72181_1.rs:+0:11: +6:2 + } + + bb3: { + return; // scope 0 at $DIR/issue_72181_1.rs:+6:2: +6:2 + } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/issue_72181_1.rs:+0:1: +6:2 + } +} diff --git a/src/test/mir-opt/issue_72181_1.main.mir_map.0.mir b/src/test/mir-opt/issue_72181_1.main.mir_map.0.mir deleted file mode 100644 index 336693337..000000000 --- a/src/test/mir-opt/issue_72181_1.main.mir_map.0.mir +++ /dev/null @@ -1,57 +0,0 @@ -// MIR for `main` 0 mir_map - -| User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue-72181-1.rs:16:12: 16:16, inferred_ty: Void -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(Void) }, span: $DIR/issue-72181-1.rs:16:12: 16:16, inferred_ty: Void -| -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-72181-1.rs:+0:11: +0:11 - let mut _1: !; // in scope 0 at $DIR/issue-72181-1.rs:+0:11: +6:2 - let _2: Void as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue-72181-1.rs:+1:9: +1:10 - let mut _3: (); // in scope 0 at $DIR/issue-72181-1.rs:+2:41: +2:43 - let _4: !; // in scope 0 at $DIR/issue-72181-1.rs:+5:5: +5:9 - let mut _5: Void; // in scope 0 at $DIR/issue-72181-1.rs:+5:7: +5:8 - scope 1 { - debug v => _2; // in scope 1 at $DIR/issue-72181-1.rs:+1:9: +1:10 - } - scope 2 { - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-72181-1.rs:+1:9: +1:10 - StorageLive(_3); // scope 2 at $DIR/issue-72181-1.rs:+2:41: +2:43 - _3 = (); // scope 2 at $DIR/issue-72181-1.rs:+2:41: +2:43 - _2 = transmute::<(), Void>(move _3) -> bb4; // scope 2 at $DIR/issue-72181-1.rs:+2:9: +2:44 - // mir::Constant - // + span: $DIR/issue-72181-1.rs:17:9: 17:40 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(()) -> Void {transmute::<(), Void>}, val: Value() } - } - - bb1: { - StorageDead(_3); // scope 2 at $DIR/issue-72181-1.rs:+2:43: +2:44 - FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue-72181-1.rs:+1:9: +1:10 - AscribeUserType(_2, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue-72181-1.rs:+1:12: +1:16 - StorageLive(_4); // scope 1 at $DIR/issue-72181-1.rs:+5:5: +5:9 - StorageLive(_5); // scope 1 at $DIR/issue-72181-1.rs:+5:7: +5:8 - _5 = move _2; // scope 1 at $DIR/issue-72181-1.rs:+5:7: +5:8 - _4 = f(move _5) -> bb4; // scope 1 at $DIR/issue-72181-1.rs:+5:5: +5:9 - // mir::Constant - // + span: $DIR/issue-72181-1.rs:20:5: 20:6 - // + literal: Const { ty: fn(Void) -> ! {f}, val: Value() } - } - - bb2: { - StorageDead(_5); // scope 1 at $DIR/issue-72181-1.rs:+5:8: +5:9 - StorageDead(_4); // scope 1 at $DIR/issue-72181-1.rs:+5:9: +5:10 - StorageDead(_2); // scope 0 at $DIR/issue-72181-1.rs:+6:1: +6:2 - unreachable; // scope 0 at $DIR/issue-72181-1.rs:+0:11: +6:2 - } - - bb3: { - return; // scope 0 at $DIR/issue-72181-1.rs:+6:2: +6:2 - } - - bb4 (cleanup): { - resume; // scope 0 at $DIR/issue-72181-1.rs:+0:1: +6:2 - } -} diff --git a/src/test/mir-opt/issue_72181_1.rs b/src/test/mir-opt/issue_72181_1.rs new file mode 100644 index 000000000..8ae2599ec --- /dev/null +++ b/src/test/mir-opt/issue_72181_1.rs @@ -0,0 +1,21 @@ +// compile-flags: -Z mir-opt-level=1 +// Regression test for #72181, this ICE requires `-Z mir-opt-level=1` flags. + +#![feature(never_type)] +#![allow(unused, invalid_value)] + +enum Void {} + +// EMIT_MIR issue_72181_1.f.built.after.mir +fn f(v: Void) -> ! { + match v {} +} + +// EMIT_MIR issue_72181_1.main.built.after.mir +fn main() { + let v: Void = unsafe { + std::mem::transmute::<(), Void>(()) + }; + + f(v); +} diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff index 269e4e326..b88cdfcbc 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.diff @@ -2,18 +2,18 @@ + // 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 _5: !; // in scope 0 at $DIR/issue-73223.rs:+3:17: +3:23 - let mut _7: i32; // in scope 0 at $DIR/issue-73223.rs:+6:22: +6:27 + 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 _5: !; // in scope 0 at $DIR/issue_73223.rs:+3:17: +3:23 + let mut _7: i32; // in scope 0 at $DIR/issue_73223.rs:+6:22: +6:27 let _8: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _9: (&i32, &i32); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _10: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _11: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _12: i32; // in scope 0 at $DIR/issue-73223.rs:+7:23: +7:24 + let _12: i32; // in scope 0 at $DIR/issue_73223.rs:+7:23: +7:24 let mut _15: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _16: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _17: i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -26,11 +26,13 @@ let mut _25: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _26: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _27: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _29: &i32; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _30: &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 _6: std::option::Option; // in scope 1 at $DIR/issue-73223.rs:+6:9: +6:14 + debug split => _1; // in scope 1 at $DIR/issue_73223.rs:+1:9: +1:14 + let _6: std::option::Option; // in scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 scope 3 { - debug _prev => _6; // in scope 3 at $DIR/issue-73223.rs:+6:9: +6:14 + debug _prev => _6; // in scope 3 at $DIR/issue_73223.rs:+6:9: +6:14 let _13: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let _14: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL let mut _28: &i32; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -45,45 +47,46 @@ } } scope 2 { - debug v => _4; // in scope 2 at $DIR/issue-73223.rs:+2:14: +2:15 + 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 + 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: { - nop; // scope 0 at $DIR/issue-73223.rs:+3:17: +3:23 - 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 + nop; // scope 0 at $DIR/issue_73223.rs:+3:17: +3:23 + 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 + 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(_6); // scope 1 at $DIR/issue-73223.rs:+6:9: +6:14 - StorageLive(_7); // scope 1 at $DIR/issue-73223.rs:+6:22: +6:27 - _7 = _1; // scope 1 at $DIR/issue-73223.rs:+6:22: +6:27 - Deinit(_6); // scope 1 at $DIR/issue-73223.rs:+6:17: +6:28 - ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue-73223.rs:+6:17: +6:28 - discriminant(_6) = 1; // scope 1 at $DIR/issue-73223.rs:+6:17: +6:28 - StorageDead(_7); // scope 1 at $DIR/issue-73223.rs:+6:27: +6:28 + 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(_6); // scope 1 at $DIR/issue_73223.rs:+6:9: +6:14 + StorageLive(_7); // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 + _7 = _1; // scope 1 at $DIR/issue_73223.rs:+6:22: +6:27 + Deinit(_6); // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 + ((_6 as Some).0: i32) = move _7; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 + discriminant(_6) = 1; // scope 1 at $DIR/issue_73223.rs:+6:17: +6:28 + StorageDead(_7); // scope 1 at $DIR/issue_73223.rs:+6:27: +6:28 StorageLive(_8); // 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 + StorageLive(_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_30); // 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 = &_1; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -92,15 +95,16 @@ // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } _11 = _28; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Deinit(_9); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_9.0: &i32) = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - (_9.1: &i32) = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + Deinit(_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + Deinit(_30); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _29 = move _10; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _30 = move _11; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_11); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_10); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_13); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = (_9.0: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = _29; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _14 = (_9.1: &i32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _14 = _30; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_16); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_17); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL @@ -150,12 +154,13 @@ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_14); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageDead(_13); // 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(_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_30); // 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 - nop; // scope 0 at $DIR/issue-73223.rs:+0:11: +8:2 - StorageDead(_6); // 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 + nop; // scope 0 at $DIR/issue_73223.rs:+0:11: +8:2 + StorageDead(_6); // 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/src/test/mir-opt/issue_73223.rs b/src/test/mir-opt/issue_73223.rs new file mode 100644 index 000000000..be114cab7 --- /dev/null +++ b/src/test/mir-opt/issue_73223.rs @@ -0,0 +1,12 @@ +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/src/test/mir-opt/issue_78192.f.InstCombine.diff b/src/test/mir-opt/issue_78192.f.InstCombine.diff index 8ec94d65f..116ca304c 100644 --- a/src/test/mir-opt/issue_78192.f.InstCombine.diff +++ b/src/test/mir-opt/issue_78192.f.InstCombine.diff @@ -2,28 +2,28 @@ + // MIR for `f` after InstCombine fn f(_1: &T) -> *const T { - debug a => _1; // in scope 0 at $DIR/issue-78192.rs:+0:13: +0:14 - let mut _0: *const T; // return place in scope 0 at $DIR/issue-78192.rs:+0:23: +0:31 - let _2: &*const T; // in scope 0 at $DIR/issue-78192.rs:+1:9: +1:10 - let _3: &*const T; // in scope 0 at $DIR/issue-78192.rs:+1:24: +1:40 - let _4: *const T; // in scope 0 at $DIR/issue-78192.rs:+1:25: +1:40 + debug a => _1; // in scope 0 at $DIR/issue_78192.rs:+0:13: +0:14 + let mut _0: *const T; // return place in scope 0 at $DIR/issue_78192.rs:+0:23: +0:31 + let _2: &*const T; // in scope 0 at $DIR/issue_78192.rs:+1:9: +1:10 + let _3: &*const T; // in scope 0 at $DIR/issue_78192.rs:+1:24: +1:40 + let _4: *const T; // in scope 0 at $DIR/issue_78192.rs:+1:25: +1:40 scope 1 { - debug b => _2; // in scope 1 at $DIR/issue-78192.rs:+1:9: +1:10 + debug b => _2; // in scope 1 at $DIR/issue_78192.rs:+1:9: +1:10 } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-78192.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40 - StorageLive(_4); // scope 0 at $DIR/issue-78192.rs:+1:25: +1:40 - _4 = &raw const (*_1); // scope 0 at $DIR/issue-78192.rs:+1:26: +1:27 - _3 = &_4; // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40 -- _2 = &(*_3); // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40 -+ _2 = _3; // scope 0 at $DIR/issue-78192.rs:+1:24: +1:40 - StorageDead(_3); // scope 0 at $DIR/issue-78192.rs:+1:40: +1:41 - _0 = (*_2); // scope 1 at $DIR/issue-78192.rs:+2:5: +2:7 - StorageDead(_4); // scope 0 at $DIR/issue-78192.rs:+3:1: +3:2 - StorageDead(_2); // scope 0 at $DIR/issue-78192.rs:+3:1: +3:2 - return; // scope 0 at $DIR/issue-78192.rs:+3:2: +3:2 + StorageLive(_2); // scope 0 at $DIR/issue_78192.rs:+1:9: +1:10 + StorageLive(_3); // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40 + StorageLive(_4); // scope 0 at $DIR/issue_78192.rs:+1:25: +1:40 + _4 = &raw const (*_1); // scope 0 at $DIR/issue_78192.rs:+1:26: +1:27 + _3 = &_4; // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40 +- _2 = &(*_3); // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40 ++ _2 = _3; // scope 0 at $DIR/issue_78192.rs:+1:24: +1:40 + StorageDead(_3); // scope 0 at $DIR/issue_78192.rs:+1:40: +1:41 + _0 = (*_2); // scope 1 at $DIR/issue_78192.rs:+2:5: +2:7 + StorageDead(_4); // scope 0 at $DIR/issue_78192.rs:+3:1: +3:2 + StorageDead(_2); // scope 0 at $DIR/issue_78192.rs:+3:1: +3:2 + return; // scope 0 at $DIR/issue_78192.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/issue_78192.rs b/src/test/mir-opt/issue_78192.rs new file mode 100644 index 000000000..39f665402 --- /dev/null +++ b/src/test/mir-opt/issue_78192.rs @@ -0,0 +1,11 @@ +// compile-flags: -Zmir-opt-level=1 -Zinline-mir +pub fn f(a: &T) -> *const T { + let b: &*const T = &(a as *const T); + *b +} + +fn main() { + f(&2); +} + +// EMIT_MIR issue_78192.f.InstCombine.diff diff --git a/src/test/mir-opt/issue_91633.bar.built.after.mir b/src/test/mir-opt/issue_91633.bar.built.after.mir new file mode 100644 index 000000000..c3fb90e84 --- /dev/null +++ b/src/test/mir-opt/issue_91633.bar.built.after.mir @@ -0,0 +1,39 @@ +// MIR for `bar` after built + +fn bar(_1: Box<[T]>) -> () { + debug it => _1; // in scope 0 at $DIR/issue_91633.rs:+0:12: +0:14 + let mut _0: (); // return place in scope 0 at $DIR/issue_91633.rs:+1:2: +1:2 + let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue_91633.rs:+4:14: +4:19 + let mut _3: &[T]; // in scope 0 at $DIR/issue_91633.rs:+4:14: +4:16 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:19 + StorageLive(_3); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:16 + _3 = &(*_1); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:16 + _2 = <[T] as Index>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue_91633.rs:+4:14: +4:19 + // mir::Constant + // + span: $DIR/issue_91633.rs:15:14: 15:19 + // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() } + } + + bb1: { + StorageDead(_3); // scope 0 at $DIR/issue_91633.rs:+4:18: +4:19 + StorageDead(_2); // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20 + _0 = const (); // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3 + drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3 + } + + bb2: { + return; // scope 0 at $DIR/issue_91633.rs:+5:3: +5:3 + } + + bb3 (cleanup): { + drop(_1) -> bb4; // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3 + } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/issue_91633.rs:+0:1: +5:3 + } +} diff --git a/src/test/mir-opt/issue_91633.bar.mir_map.0.mir b/src/test/mir-opt/issue_91633.bar.mir_map.0.mir deleted file mode 100644 index 625f6c736..000000000 --- a/src/test/mir-opt/issue_91633.bar.mir_map.0.mir +++ /dev/null @@ -1,39 +0,0 @@ -// MIR for `bar` 0 mir_map - -fn bar(_1: Box<[T]>) -> () { - debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 - let mut _0: (); // return place in scope 0 at $DIR/issue-91633.rs:+1:2: +1:2 - let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:19 - let mut _3: &[T]; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:16 - scope 1 { - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:19 - StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:16 - _3 = &(*_1); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:16 - _2 = <[T] as Index>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-91633.rs:+4:14: +4:19 - // mir::Constant - // + span: $DIR/issue-91633.rs:15:14: 15:19 - // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() } - } - - bb1: { - StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+4:18: +4:19 - StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:19: +4:20 - _0 = const (); // scope 0 at $DIR/issue-91633.rs:+3:2: +5:3 - drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3 - } - - bb2: { - return; // scope 0 at $DIR/issue-91633.rs:+5:3: +5:3 - } - - bb3 (cleanup): { - drop(_1) -> bb4; // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3 - } - - bb4 (cleanup): { - resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +5:3 - } -} diff --git a/src/test/mir-opt/issue_91633.foo.built.after.mir b/src/test/mir-opt/issue_91633.foo.built.after.mir new file mode 100644 index 000000000..4e3dd365e --- /dev/null +++ b/src/test/mir-opt/issue_91633.foo.built.after.mir @@ -0,0 +1,57 @@ +// MIR for `foo` after built + +fn foo(_1: Box<[T]>) -> T { + debug it => _1; // in scope 0 at $DIR/issue_91633.rs:+0:19: +0:21 + let mut _0: T; // return place in scope 0 at $DIR/issue_91633.rs:+0:36: +0:37 + let _2: T; // in scope 0 at $DIR/issue_91633.rs:+2:10: +2:11 + let mut _3: &T; // in scope 0 at $DIR/issue_91633.rs:+2:14: +2:27 + let _4: usize; // in scope 0 at $DIR/issue_91633.rs:+2:17: +2:18 + let mut _5: usize; // in scope 0 at $DIR/issue_91633.rs:+2:14: +2:19 + let mut _6: bool; // in scope 0 at $DIR/issue_91633.rs:+2:14: +2:19 + scope 1 { + debug f => _2; // in scope 1 at $DIR/issue_91633.rs:+2:10: +2:11 + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11 + StorageLive(_3); // scope 0 at $DIR/issue_91633.rs:+2:14: +2:27 + StorageLive(_4); // scope 0 at $DIR/issue_91633.rs:+2:17: +2:18 + _4 = const 0_usize; // scope 0 at $DIR/issue_91633.rs:+2:17: +2:18 + _5 = Len((*_1)); // scope 0 at $DIR/issue_91633.rs:+2:14: +2:19 + _6 = Lt(_4, _5); // scope 0 at $DIR/issue_91633.rs:+2:14: +2:19 + assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind: bb5]; // scope 0 at $DIR/issue_91633.rs:+2:14: +2:19 + } + + bb1: { + _3 = &(*_1)[_4]; // scope 0 at $DIR/issue_91633.rs:+2:14: +2:27 + _2 = ::clone(move _3) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/issue_91633.rs:+2:14: +2:27 + // mir::Constant + // + span: $DIR/issue_91633.rs:28:20: 28:25 + // + literal: Const { ty: for<'a> fn(&'a T) -> T {::clone}, val: Value() } + } + + bb2: { + StorageDead(_3); // scope 0 at $DIR/issue_91633.rs:+2:26: +2:27 + FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11 + StorageDead(_4); // scope 0 at $DIR/issue_91633.rs:+2:27: +2:28 + _0 = move _2; // scope 1 at $DIR/issue_91633.rs:+3:6: +3:7 + drop(_2) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 + } + + bb3: { + StorageDead(_2); // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 + drop(_1) -> [return: bb4, unwind: bb6]; // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 + } + + bb4: { + return; // scope 0 at $DIR/issue_91633.rs:+4:3: +4:3 + } + + bb5 (cleanup): { + drop(_1) -> bb6; // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 + } + + bb6 (cleanup): { + resume; // scope 0 at $DIR/issue_91633.rs:+0:1: +4:3 + } +} diff --git a/src/test/mir-opt/issue_91633.foo.mir_map.0.mir b/src/test/mir-opt/issue_91633.foo.mir_map.0.mir deleted file mode 100644 index 9903e203a..000000000 --- a/src/test/mir-opt/issue_91633.foo.mir_map.0.mir +++ /dev/null @@ -1,57 +0,0 @@ -// MIR for `foo` 0 mir_map - -fn foo(_1: Box<[T]>) -> T { - debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:19: +0:21 - let mut _0: T; // return place in scope 0 at $DIR/issue-91633.rs:+0:36: +0:37 - let _2: T; // in scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 - let mut _3: &T; // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 - let _4: usize; // in scope 0 at $DIR/issue-91633.rs:+2:17: +2:18 - let mut _5: usize; // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 - let mut _6: bool; // in scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 - scope 1 { - debug f => _2; // in scope 1 at $DIR/issue-91633.rs:+2:10: +2:11 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 - StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 - StorageLive(_4); // scope 0 at $DIR/issue-91633.rs:+2:17: +2:18 - _4 = const 0_usize; // scope 0 at $DIR/issue-91633.rs:+2:17: +2:18 - _5 = Len((*_1)); // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 - _6 = Lt(_4, _5); // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:19 - } - - bb1: { - _3 = &(*_1)[_4]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 - _2 = ::clone(move _3) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:27 - // mir::Constant - // + span: $DIR/issue-91633.rs:28:20: 28:25 - // + literal: Const { ty: for<'a> fn(&'a T) -> T {::clone}, val: Value() } - } - - bb2: { - StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+2:26: +2:27 - FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 - StorageDead(_4); // scope 0 at $DIR/issue-91633.rs:+2:27: +2:28 - _0 = move _2; // scope 1 at $DIR/issue-91633.rs:+3:6: +3:7 - drop(_2) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 - } - - bb3: { - StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 - drop(_1) -> [return: bb4, unwind: bb6]; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 - } - - bb4: { - return; // scope 0 at $DIR/issue-91633.rs:+4:3: +4:3 - } - - bb5 (cleanup): { - drop(_1) -> bb6; // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 - } - - bb6 (cleanup): { - resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +4:3 - } -} diff --git a/src/test/mir-opt/issue_91633.fun.built.after.mir b/src/test/mir-opt/issue_91633.fun.built.after.mir new file mode 100644 index 000000000..42486d3a5 --- /dev/null +++ b/src/test/mir-opt/issue_91633.fun.built.after.mir @@ -0,0 +1,35 @@ +// MIR for `fun` after built + +fn fun(_1: &[T]) -> &T { + debug it => _1; // in scope 0 at $DIR/issue_91633.rs:+0:12: +0:14 + let mut _0: &T; // return place in scope 0 at $DIR/issue_91633.rs:+0:25: +0:27 + let _2: &T; // in scope 0 at $DIR/issue_91633.rs:+2:10: +2:11 + let _3: usize; // in scope 0 at $DIR/issue_91633.rs:+2:18: +2:19 + let mut _4: usize; // in scope 0 at $DIR/issue_91633.rs:+2:15: +2:20 + let mut _5: bool; // in scope 0 at $DIR/issue_91633.rs:+2:15: +2:20 + scope 1 { + debug f => _2; // in scope 1 at $DIR/issue_91633.rs:+2:10: +2:11 + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11 + StorageLive(_3); // scope 0 at $DIR/issue_91633.rs:+2:18: +2:19 + _3 = const 0_usize; // scope 0 at $DIR/issue_91633.rs:+2:18: +2:19 + _4 = Len((*_1)); // scope 0 at $DIR/issue_91633.rs:+2:15: +2:20 + _5 = Lt(_3, _4); // scope 0 at $DIR/issue_91633.rs:+2:15: +2:20 + assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue_91633.rs:+2:15: +2:20 + } + + bb1: { + _2 = &(*_1)[_3]; // scope 0 at $DIR/issue_91633.rs:+2:14: +2:20 + FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue_91633.rs:+2:10: +2:11 + _0 = &(*_2); // scope 1 at $DIR/issue_91633.rs:+3:6: +3:7 + StorageDead(_3); // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 + StorageDead(_2); // scope 0 at $DIR/issue_91633.rs:+4:2: +4:3 + return; // scope 0 at $DIR/issue_91633.rs:+4:3: +4:3 + } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/issue_91633.rs:+0:1: +4:3 + } +} diff --git a/src/test/mir-opt/issue_91633.fun.mir_map.0.mir b/src/test/mir-opt/issue_91633.fun.mir_map.0.mir deleted file mode 100644 index ded9a4cf7..000000000 --- a/src/test/mir-opt/issue_91633.fun.mir_map.0.mir +++ /dev/null @@ -1,35 +0,0 @@ -// MIR for `fun` 0 mir_map - -fn fun(_1: &[T]) -> &T { - debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 - let mut _0: &T; // return place in scope 0 at $DIR/issue-91633.rs:+0:25: +0:27 - let _2: &T; // in scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 - let _3: usize; // in scope 0 at $DIR/issue-91633.rs:+2:18: +2:19 - let mut _4: usize; // in scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 - let mut _5: bool; // in scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 - scope 1 { - debug f => _2; // in scope 1 at $DIR/issue-91633.rs:+2:10: +2:11 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 - StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+2:18: +2:19 - _3 = const 0_usize; // scope 0 at $DIR/issue-91633.rs:+2:18: +2:19 - _4 = Len((*_1)); // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 - _5 = Lt(_3, _4); // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+2:15: +2:20 - } - - bb1: { - _2 = &(*_1)[_3]; // scope 0 at $DIR/issue-91633.rs:+2:14: +2:20 - FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue-91633.rs:+2:10: +2:11 - _0 = &(*_2); // scope 1 at $DIR/issue-91633.rs:+3:6: +3:7 - StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 - StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:2: +4:3 - return; // scope 0 at $DIR/issue-91633.rs:+4:3: +4:3 - } - - bb2 (cleanup): { - resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +4:3 - } -} diff --git a/src/test/mir-opt/issue_91633.hey.built.after.mir b/src/test/mir-opt/issue_91633.hey.built.after.mir new file mode 100644 index 000000000..ccb06dd59 --- /dev/null +++ b/src/test/mir-opt/issue_91633.hey.built.after.mir @@ -0,0 +1,35 @@ +// MIR for `hey` after built + +fn hey(_1: &[T]) -> () { + debug it => _1; // in scope 0 at $DIR/issue_91633.rs:+0:12: +0:14 + let mut _0: (); // return place in scope 0 at $DIR/issue_91633.rs:+1:2: +1:2 + let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue_91633.rs:+4:14: +4:20 + let _3: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue_91633.rs:+4:15: +4:20 + let mut _4: &[T]; // in scope 0 at $DIR/issue_91633.rs:+4:15: +4:17 + scope 1 { + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20 + StorageLive(_3); // scope 0 at $DIR/issue_91633.rs:+4:15: +4:20 + StorageLive(_4); // scope 0 at $DIR/issue_91633.rs:+4:15: +4:17 + _4 = &(*_1); // scope 0 at $DIR/issue_91633.rs:+4:15: +4:17 + _3 = <[T] as Index>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/issue_91633.rs:+4:15: +4:20 + // mir::Constant + // + span: $DIR/issue_91633.rs:7:15: 7:20 + // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() } + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/issue_91633.rs:+4:19: +4:20 + _2 = &(*_3); // scope 0 at $DIR/issue_91633.rs:+4:14: +4:20 + StorageDead(_2); // scope 0 at $DIR/issue_91633.rs:+4:20: +4:21 + _0 = const (); // scope 0 at $DIR/issue_91633.rs:+3:2: +5:3 + StorageDead(_3); // scope 0 at $DIR/issue_91633.rs:+5:2: +5:3 + return; // scope 0 at $DIR/issue_91633.rs:+5:3: +5:3 + } + + bb2 (cleanup): { + resume; // scope 0 at $DIR/issue_91633.rs:+0:1: +5:3 + } +} diff --git a/src/test/mir-opt/issue_91633.hey.mir_map.0.mir b/src/test/mir-opt/issue_91633.hey.mir_map.0.mir deleted file mode 100644 index 37c3b3fca..000000000 --- a/src/test/mir-opt/issue_91633.hey.mir_map.0.mir +++ /dev/null @@ -1,35 +0,0 @@ -// MIR for `hey` 0 mir_map - -fn hey(_1: &[T]) -> () { - debug it => _1; // in scope 0 at $DIR/issue-91633.rs:+0:12: +0:14 - let mut _0: (); // return place in scope 0 at $DIR/issue-91633.rs:+1:2: +1:2 - let mut _2: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 - let _3: &<[T] as std::ops::Index>::Output; // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 - let mut _4: &[T]; // in scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 - scope 1 { - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 - StorageLive(_3); // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 - StorageLive(_4); // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 - _4 = &(*_1); // scope 0 at $DIR/issue-91633.rs:+4:15: +4:17 - _3 = <[T] as Index>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/issue-91633.rs:+4:15: +4:20 - // mir::Constant - // + span: $DIR/issue-91633.rs:7:15: 7:20 - // + literal: Const { ty: for<'a> fn(&'a [T], usize) -> &'a <[T] as Index>::Output {<[T] as Index>::index}, val: Value() } - } - - bb1: { - StorageDead(_4); // scope 0 at $DIR/issue-91633.rs:+4:19: +4:20 - _2 = &(*_3); // scope 0 at $DIR/issue-91633.rs:+4:14: +4:20 - StorageDead(_2); // scope 0 at $DIR/issue-91633.rs:+4:20: +4:21 - _0 = const (); // scope 0 at $DIR/issue-91633.rs:+3:2: +5:3 - StorageDead(_3); // scope 0 at $DIR/issue-91633.rs:+5:2: +5:3 - return; // scope 0 at $DIR/issue-91633.rs:+5:3: +5:3 - } - - bb2 (cleanup): { - resume; // scope 0 at $DIR/issue-91633.rs:+0:1: +5:3 - } -} diff --git a/src/test/mir-opt/issue_91633.rs b/src/test/mir-opt/issue_91633.rs new file mode 100644 index 000000000..9127cacc9 --- /dev/null +++ b/src/test/mir-opt/issue_91633.rs @@ -0,0 +1,31 @@ +// compile-flags: -Z mir-opt-level=0 +// EMIT_MIR issue_91633.hey.built.after.mir +fn hey (it: &[T]) + where + [T] : std::ops::Index, + { + let _ = &it[0]; + } + +// EMIT_MIR issue_91633.bar.built.after.mir +fn bar (it: Box<[T]>) + where + [T] : std::ops::Index, + { + let _ = it[0]; + } + +// EMIT_MIR issue_91633.fun.built.after.mir +fn fun (it: &[T]) -> &T + { + let f = &it[0]; + f + } + +// EMIT_MIR issue_91633.foo.built.after.mir +fn foo (it: Box<[T]>) -> T + { + let f = it[0].clone(); + f + } + fn main(){} diff --git a/src/test/mir-opt/issue_99325.main.built.after.mir b/src/test/mir-opt/issue_99325.main.built.after.mir new file mode 100644 index 000000000..3db40412b --- /dev/null +++ b/src/test/mir-opt/issue_99325.main.built.after.mir @@ -0,0 +1,295 @@ +// MIR for `main` after built + +| User Type Annotations +| 0: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }) }, span: $DIR/issue_99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| 1: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated(UnevaluatedConst { def: WithOptConstParam { did: DefId(0:8 ~ issue_99325[8f58]::main::{constant#1}), const_param_did: Some(DefId(0:4 ~ issue_99325[8f58]::function_with_bytes::BYTES)) }, substs: [] }) }], user_self_ty: None }) }, span: $DIR/issue_99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue_99325.rs:+0:15: +0:15 + let _1: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _2: (&&[u8], &&[u8; 4]); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _3: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _4: &[u8]; // in scope 0 at $DIR/issue_99325.rs:+1:16: +1:48 + let mut _5: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _6: &[u8; 4]; // in scope 0 at $DIR/issue_99325.rs:+1:50: +1:75 + let _7: [u8; 4]; // in scope 0 at $DIR/issue_99325.rs:+1:51: +1:75 + let _8: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _9: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _10: bool; // 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: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _13: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _14: !; // 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: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _19: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _20: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _21: &&[u8; 4]; // 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 _23: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _24: (&&[u8], &&[u8; 4]); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _25: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _26: &[u8]; // in scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 + let mut _27: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _28: &[u8; 4]; // in scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 + let _29: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _30: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _31: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _32: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _33: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _34: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _35: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _37: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _38: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _39: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _40: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _41: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _42: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let mut _43: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 1 { + debug left_val => _8; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _9; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _15: core::panicking::AssertKind; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 2 { + debug kind => _15; // in scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + } + scope 3 { + debug left_val => _29; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + debug right_val => _30; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + let _36: core::panicking::AssertKind; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 4 { + debug kind => _36; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + } + + bb0: { + StorageLive(_1); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_3); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_4); // scope 0 at $DIR/issue_99325.rs:+1:16: +1:48 + _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb19]; // scope 0 at $DIR/issue_99325.rs:+1:16: +1:48 + // mir::Constant + // + span: $DIR/issue_99325.rs:10:16: 10:46 + // + user_ty: UserType(0) + // + literal: Const { ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}, val: Value() } + } + + bb1: { + _3 = &_4; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_5); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_6); // scope 0 at $DIR/issue_99325.rs:+1:50: +1:75 + StorageLive(_7); // scope 0 at $DIR/issue_99325.rs:+1:51: +1:75 + _7 = [const 65_u8, const 65_u8, const 65_u8, const 65_u8]; // scope 0 at $DIR/issue_99325.rs:+1:51: +1:75 + _6 = &_7; // scope 0 at $DIR/issue_99325.rs:+1:50: +1:75 + _5 = &_6; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _2 = (move _3, move _5); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_5); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_3); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + FakeRead(ForMatchedPlace(None), _2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_8); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _8 = (_2.0: &&[u8]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_9); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _9 = (_2.1: &&[u8; 4]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_10); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_11); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_12); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _12 = &(*_8); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_13); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _13 = &(*_9); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _11 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _12, move _13) -> [return: bb2, unwind: bb19]; // scope 1 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> fn(&'a &[u8], &'b &[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } + } + + bb2: { + StorageDead(_13); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_12); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _10 = Not(move _11); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_11); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _10) -> [false: bb4, otherwise: bb3]; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb3: { + StorageLive(_15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _15 = core::panicking::AssertKind::Eq; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + FakeRead(ForLet(None), _15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_16); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_17); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _17 = move _15; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_18); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _19 = &(*_8); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _18 = &(*_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_20); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _21 = &(*_9); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _20 = &(*_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_22); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _22 = Option::>::None; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _16 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _17, move _18, move _20, move _22) -> bb19; // scope 2 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 &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } + } + + bb4: { + goto -> bb7; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb5: { + StorageDead(_22); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_20); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_18); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_17); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_16); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + unreachable; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb6: { + goto -> bb8; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb7: { + _1 = const (); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + goto -> bb8; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb8: { + StorageDead(_10); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_9); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_8); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + goto -> bb9; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb9: { + StorageDead(_7); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_6); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_4); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_1); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_23); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_25); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_26); // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 + _26 = function_with_bytes::<&*b"AAAA">() -> [return: bb10, unwind: bb19]; // scope 0 at $DIR/issue_99325.rs:+2:16: +2:70 + // mir::Constant + // + span: $DIR/issue_99325.rs:11:16: 11:68 + // + user_ty: UserType(1) + // + literal: Const { ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}, val: Value() } + } + + bb10: { + _25 = &_26; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_28); // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 + _28 = const b"AAAA"; // scope 0 at $DIR/issue_99325.rs:+2:72: +2:79 + // mir::Constant + // + span: $DIR/issue_99325.rs:11:72: 11:79 + // + literal: Const { ty: &[u8; 4], val: Value(Scalar(alloc4)) } + _27 = &_28; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _24 = (move _25, move _27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_25); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + FakeRead(ForMatchedPlace(None), _24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _29 = (_24.0: &&[u8]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_30); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _30 = (_24.1: &&[u8; 4]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_31); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_33); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _33 = &(*_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_34); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _34 = &(*_30); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _32 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _33, move _34) -> [return: bb11, unwind: bb19]; // 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: for<'a, 'b> fn(&'a &[u8], &'b &[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } + } + + bb11: { + StorageDead(_34); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_33); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _31 = Not(move _32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + switchInt(move _31) -> [false: bb13, otherwise: bb12]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb12: { + StorageLive(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _36 = core::panicking::AssertKind::Eq; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + FakeRead(ForLet(None), _36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_38); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _38 = move _36; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_39); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _40 = &(*_29); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _39 = &(*_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_41); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _42 = &(*_30); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _41 = &(*_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageLive(_43); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _43 = Option::>::None; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _37 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _38, move _39, move _41, move _43) -> bb19; // scope 4 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 &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } + } + + bb13: { + goto -> bb16; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb14: { + StorageDead(_43); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_41); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_39); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_38); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + unreachable; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb15: { + goto -> bb17; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb16: { + _23 = const (); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + goto -> bb17; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb17: { + StorageDead(_31); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_30); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + goto -> bb18; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + } + + bb18: { + StorageDead(_28); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_26); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + StorageDead(_23); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _0 = const (); // scope 0 at $DIR/issue_99325.rs:+0:15: +3:2 + return; // scope 0 at $DIR/issue_99325.rs:+3:2: +3:2 + } + + bb19 (cleanup): { + resume; // scope 0 at $DIR/issue_99325.rs:+0:1: +3:2 + } +} + +alloc4 (size: 4, align: 1) { + 41 41 41 41 │ AAAA +} diff --git a/src/test/mir-opt/issue_99325.main.mir_map.0.mir b/src/test/mir-opt/issue_99325.main.mir_map.0.mir deleted file mode 100644 index 165efa9df..000000000 --- a/src/test/mir-opt/issue_99325.main.mir_map.0.mir +++ /dev/null @@ -1,295 +0,0 @@ -// MIR for `main` 0 mir_map - -| User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Value(Branch([Leaf(0x41), Leaf(0x41), Leaf(0x41), Leaf(0x41)])) }], user_self_ty: None }) }, span: $DIR/issue-99325.rs:10:16: 10:46, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ issue_99325[8f58]::function_with_bytes), UserSubsts { substs: [Const { ty: &'static [u8; 4], kind: Unevaluated(UnevaluatedConst { def: WithOptConstParam { did: DefId(0:8 ~ issue_99325[8f58]::main::{constant#1}), const_param_did: Some(DefId(0:4 ~ issue_99325[8f58]::function_with_bytes::BYTES)) }, substs: [] }) }], user_self_ty: None }) }, span: $DIR/issue-99325.rs:11:16: 11:68, inferred_ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">} -| -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue-99325.rs:+0:15: +0:15 - let _1: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _2: (&&[u8], &&[u8; 4]); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _3: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _4: &[u8]; // in scope 0 at $DIR/issue-99325.rs:+1:16: +1:48 - let mut _5: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _6: &[u8; 4]; // in scope 0 at $DIR/issue-99325.rs:+1:50: +1:75 - let _7: [u8; 4]; // in scope 0 at $DIR/issue-99325.rs:+1:51: +1:75 - let _8: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _9: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _10: bool; // 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: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _13: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _14: !; // 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: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _19: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _20: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _21: &&[u8; 4]; // 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 _23: (); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _24: (&&[u8], &&[u8; 4]); // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _25: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _26: &[u8]; // in scope 0 at $DIR/issue-99325.rs:+2:16: +2:70 - let mut _27: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _28: &[u8; 4]; // in scope 0 at $DIR/issue-99325.rs:+2:72: +2:79 - let _29: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _30: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _31: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _32: bool; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _33: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _34: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _35: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _37: !; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _38: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _39: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _40: &&[u8]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _41: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _42: &&[u8; 4]; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let mut _43: std::option::Option>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 1 { - debug left_val => _8; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _9; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _15: core::panicking::AssertKind; // in scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 2 { - debug kind => _15; // in scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - } - scope 3 { - debug left_val => _29; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - debug right_val => _30; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - let _36: core::panicking::AssertKind; // in scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 4 { - debug kind => _36; // in scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - } - - bb0: { - StorageLive(_1); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_3); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_4); // scope 0 at $DIR/issue-99325.rs:+1:16: +1:48 - _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb19]; // scope 0 at $DIR/issue-99325.rs:+1:16: +1:48 - // mir::Constant - // + span: $DIR/issue-99325.rs:10:16: 10:46 - // + user_ty: UserType(0) - // + literal: Const { ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}, val: Value() } - } - - bb1: { - _3 = &_4; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_5); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_6); // scope 0 at $DIR/issue-99325.rs:+1:50: +1:75 - StorageLive(_7); // scope 0 at $DIR/issue-99325.rs:+1:51: +1:75 - _7 = [const 65_u8, const 65_u8, const 65_u8, const 65_u8]; // scope 0 at $DIR/issue-99325.rs:+1:51: +1:75 - _6 = &_7; // scope 0 at $DIR/issue-99325.rs:+1:50: +1:75 - _5 = &_6; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _2 = (move _3, move _5); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_5); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_3); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - FakeRead(ForMatchedPlace(None), _2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_8); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _8 = (_2.0: &&[u8]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_9); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _9 = (_2.1: &&[u8; 4]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_10); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_11); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_12); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = &(*_8); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_13); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _13 = &(*_9); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _11 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _12, move _13) -> [return: bb2, unwind: bb19]; // scope 1 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> fn(&'a &[u8], &'b &[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } - } - - bb2: { - StorageDead(_13); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_12); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _10 = Not(move _11); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_11); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _10) -> [false: bb4, otherwise: bb3]; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb3: { - StorageLive(_15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _15 = core::panicking::AssertKind::Eq; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - FakeRead(ForLet(None), _15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_16); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_17); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _17 = move _15; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_18); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _19 = &(*_8); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _18 = &(*_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_20); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _21 = &(*_9); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _20 = &(*_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_22); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _22 = Option::>::None; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _16 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _17, move _18, move _20, move _22) -> bb19; // scope 2 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 &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } - } - - bb4: { - goto -> bb7; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb5: { - StorageDead(_22); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_20); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_18); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_17); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_21); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_19); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_16); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_15); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - unreachable; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb6: { - goto -> bb8; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb7: { - _1 = const (); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - goto -> bb8; // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb8: { - StorageDead(_10); // scope 1 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_9); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_8); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - goto -> bb9; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb9: { - StorageDead(_7); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_6); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_4); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_2); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_1); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_23); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_25); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_26); // scope 0 at $DIR/issue-99325.rs:+2:16: +2:70 - _26 = function_with_bytes::<&*b"AAAA">() -> [return: bb10, unwind: bb19]; // scope 0 at $DIR/issue-99325.rs:+2:16: +2:70 - // mir::Constant - // + span: $DIR/issue-99325.rs:11:16: 11:68 - // + user_ty: UserType(1) - // + literal: Const { ty: fn() -> &'static [u8] {function_with_bytes::<&*b"AAAA">}, val: Value() } - } - - bb10: { - _25 = &_26; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_28); // scope 0 at $DIR/issue-99325.rs:+2:72: +2:79 - _28 = const b"AAAA"; // scope 0 at $DIR/issue-99325.rs:+2:72: +2:79 - // mir::Constant - // + span: $DIR/issue-99325.rs:11:72: 11:79 - // + literal: Const { ty: &[u8; 4], val: Value(Scalar(alloc4)) } - _27 = &_28; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _24 = (move _25, move _27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_27); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_25); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - FakeRead(ForMatchedPlace(None), _24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _29 = (_24.0: &&[u8]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_30); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _30 = (_24.1: &&[u8; 4]); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_31); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_33); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _33 = &(*_29); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_34); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _34 = &(*_30); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _32 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _33, move _34) -> [return: bb11, unwind: bb19]; // 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: for<'a, 'b> fn(&'a &[u8], &'b &[u8; 4]) -> bool {<&[u8] as PartialEq<&[u8; 4]>>::eq}, val: Value() } - } - - bb11: { - StorageDead(_34); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_33); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _31 = Not(move _32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_32); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - switchInt(move _31) -> [false: bb13, otherwise: bb12]; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb12: { - StorageLive(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _36 = core::panicking::AssertKind::Eq; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - FakeRead(ForLet(None), _36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_38); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _38 = move _36; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_39); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _40 = &(*_29); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _39 = &(*_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_41); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _42 = &(*_30); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _41 = &(*_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageLive(_43); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _43 = Option::>::None; // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _37 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _38, move _39, move _41, move _43) -> bb19; // scope 4 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 &[u8], &'b &[u8; 4], Option>) -> ! {core::panicking::assert_failed::<&[u8], &[u8; 4]>}, val: Value() } - } - - bb13: { - goto -> bb16; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb14: { - StorageDead(_43); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_41); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_39); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_38); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_42); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_40); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_37); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_36); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - unreachable; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb15: { - goto -> bb17; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb16: { - _23 = const (); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - goto -> bb17; // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb17: { - StorageDead(_31); // scope 3 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_30); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_29); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - goto -> bb18; // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - } - - bb18: { - StorageDead(_28); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_26); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_24); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - StorageDead(_23); // scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _0 = const (); // scope 0 at $DIR/issue-99325.rs:+0:15: +3:2 - return; // scope 0 at $DIR/issue-99325.rs:+3:2: +3:2 - } - - bb19 (cleanup): { - resume; // scope 0 at $DIR/issue-99325.rs:+0:1: +3:2 - } -} - -alloc4 (size: 4, align: 1) { - 41 41 41 41 │ AAAA -} diff --git a/src/test/mir-opt/issue_99325.rs b/src/test/mir-opt/issue_99325.rs new file mode 100644 index 000000000..fe819cddb --- /dev/null +++ b/src/test/mir-opt/issue_99325.rs @@ -0,0 +1,12 @@ +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +pub fn function_with_bytes() -> &'static [u8] { + BYTES +} + +// EMIT_MIR issue_99325.main.built.after.mir +pub fn main() { + assert_eq!(function_with_bytes::(), &[0x41, 0x41, 0x41, 0x41]); + assert_eq!(function_with_bytes::<{ &[0x41, 0x41, 0x41, 0x41] }>(), b"AAAA"); +} diff --git a/src/test/mir-opt/issues/issue-59352.rs b/src/test/mir-opt/issues/issue-59352.rs deleted file mode 100644 index 1e0045555..000000000 --- a/src/test/mir-opt/issues/issue-59352.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This test is a mirror of codegen/issue-59352.rs. -// The LLVM inliner doesn't inline `char::method::is_digit()` and so it doesn't recognize this case -// as effectively `if x.is_some() { x.unwrap() } else { 0 }`. -// -// Currently, the MIR optimizer isn't capable of removing the unreachable panic in this test case. -// Once the optimizer can do that, this test case will need to be updated and codegen/issue-59352.rs -// removed. - -// EMIT_MIR issue_59352.num_to_digit.PreCodegen.after.mir -// compile-flags: -Z mir-opt-level=3 -Z span_free_formats - -pub fn num_to_digit(num: char) -> u32 { - // CHECK-NOT: panic - if num.is_digit(8) { num.to_digit(8).unwrap() } else { 0 } -} - -pub fn main() { - num_to_digit('2'); -} diff --git a/src/test/mir-opt/issues/issue-75439.rs b/src/test/mir-opt/issues/issue-75439.rs deleted file mode 100644 index ae2e03631..000000000 --- a/src/test/mir-opt/issues/issue-75439.rs +++ /dev/null @@ -1,18 +0,0 @@ -// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff - -use std::mem::transmute; - -pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> { - // big endian `u32`s - let dwords: [u32; 4] = unsafe { transmute(bytes) }; - const FF: u32 = 0x0000_ffff_u32.to_be(); - if let [0, 0, 0 | FF, ip] = dwords { - Some(unsafe { transmute(ip) }) - } else { - None - } -} - -fn main() { - let _ = foo([0; 16]); -} diff --git a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index f46c10711..5a2f4feff 100644 --- a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -1,90 +1,77 @@ // MIR for `num_to_digit` after PreCodegen fn num_to_digit(_1: char) -> u32 { - debug num => _1; // in scope 0 at $DIR/issue-59352.rs:+0:21: +0:24 - let mut _0: u32; // return place in scope 0 at $DIR/issue-59352.rs:+0:35: +0:38 - let mut _2: char; // in scope 0 at $DIR/issue-59352.rs:+2:8: +2:11 - let mut _3: std::option::Option; // in scope 0 at $DIR/issue-59352.rs:+2:26: +2:41 - let mut _4: char; // in scope 0 at $DIR/issue-59352.rs:+2:26: +2:29 - let mut _5: u32; // in scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - let mut _12: 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:8: 14:23 - debug self => _2; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug radix => _5; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _6: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let _7: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _8: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug num => _1; // in scope 0 at $DIR/issue_59352.rs:+0:21: +0:24 + 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:8: +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:8: 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 => _6; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _9: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _4; // 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:26: 14:50 - debug self => _3; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _10: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _11: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:26: 14:50 + debug self => _2; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _8: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL scope 4 { debug val => _0; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL } } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:11 - _2 = _1; // scope 0 at $DIR/issue-59352.rs:+2:8: +2:11 - StorageLive(_5); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 + StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:8: +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 - StorageLive(_7); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageLive(_8); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _8 = _2; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _7 = char::methods::::to_digit(move _8, const 8_u32) -> bb5; // 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 // 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() } } bb1: { - StorageDead(_12); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - StorageLive(_3); // scope 0 at $DIR/issue-59352.rs:+2:26: +2:41 - StorageLive(_4); // scope 0 at $DIR/issue-59352.rs:+2:26: +2:29 - _4 = _1; // scope 0 at $DIR/issue-59352.rs:+2:26: +2:29 - _3 = char::methods::::to_digit(move _4, const 8_u32) -> bb2; // scope 0 at $DIR/issue-59352.rs:+2:26: +2:41 + 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 // mir::Constant - // + span: $DIR/issue-59352.rs:14:30: 14:38 + // + span: $DIR/issue_59352.rs:14:30: 14:38 // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } } bb2: { - StorageDead(_4); // scope 0 at $DIR/issue-59352.rs:+2:40: +2:41 - _10 = discriminant(_3); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _10) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _7 = discriminant(_2); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _7) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL } bb3: { - StorageDead(_12); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - _0 = const 0_u32; // scope 0 at $DIR/issue-59352.rs:+2:60: +2:61 - goto -> bb4; // scope 0 at $DIR/issue-59352.rs:+2:5: +2:63 + _0 = const 0_u32; // scope 0 at $DIR/issue_59352.rs:+2:60: +2:61 + goto -> bb4; // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63 } bb4: { - return; // scope 0 at $DIR/issue-59352.rs:+3:2: +3:2 + return; // scope 0 at $DIR/issue_59352.rs:+3:2: +3:2 } bb5: { - _6 = &_7; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_8); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _9 = discriminant((*_6)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - StorageLive(_12); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = move _9; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _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 - StorageDead(_7); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_5); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - StorageDead(_2); // scope 0 at $DIR/issue-59352.rs:+2:22: +2:23 - switchInt(move _12) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 + _9 = 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:8: +2:23 + switchInt(move _9) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 } bb6: { - StorageLive(_11); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - _11 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _8 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/option.rs:LL:COL // + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value() } @@ -98,8 +85,8 @@ fn num_to_digit(_1: char) -> u32 { } bb8: { - _0 = move ((_3 as Some).0: u32); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:+2:49: +2:50 - goto -> bb4; // scope 0 at $DIR/issue-59352.rs:+2:5: +2:63 + _0 = move ((_2 as Some).0: u32); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_2); // scope 0 at $DIR/issue_59352.rs:+2:49: +2:50 + goto -> bb4; // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63 } } diff --git a/src/test/mir-opt/issues/issue_59352.rs b/src/test/mir-opt/issues/issue_59352.rs new file mode 100644 index 000000000..1e0045555 --- /dev/null +++ b/src/test/mir-opt/issues/issue_59352.rs @@ -0,0 +1,19 @@ +// This test is a mirror of codegen/issue-59352.rs. +// The LLVM inliner doesn't inline `char::method::is_digit()` and so it doesn't recognize this case +// as effectively `if x.is_some() { x.unwrap() } else { 0 }`. +// +// Currently, the MIR optimizer isn't capable of removing the unreachable panic in this test case. +// Once the optimizer can do that, this test case will need to be updated and codegen/issue-59352.rs +// removed. + +// EMIT_MIR issue_59352.num_to_digit.PreCodegen.after.mir +// compile-flags: -Z mir-opt-level=3 -Z span_free_formats + +pub fn num_to_digit(num: char) -> u32 { + // CHECK-NOT: panic + if num.is_digit(8) { num.to_digit(8).unwrap() } else { 0 } +} + +pub fn main() { + num_to_digit('2'); +} diff --git a/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff b/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff index 2ee4332ad..87066cc62 100644 --- a/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff +++ b/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff @@ -2,17 +2,17 @@ + // MIR for `foo` after MatchBranchSimplification fn foo(_1: [u8; 16]) -> Option<[u8; 4]> { - debug bytes => _1; // in scope 0 at $DIR/issue-75439.rs:+0:12: +0:17 - let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:+0:32: +0:47 - let _2: [u32; 4]; // in scope 0 at $DIR/issue-75439.rs:+2:9: +2:15 - let mut _3: [u8; 16]; // in scope 0 at $DIR/issue-75439.rs:+2:47: +2:52 - let mut _5: [u8; 4]; // in scope 0 at $DIR/issue-75439.rs:+5:14: +5:38 - let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:+5:33: +5:35 + debug bytes => _1; // in scope 0 at $DIR/issue_75439.rs:+0:12: +0:17 + let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue_75439.rs:+0:32: +0:47 + let _2: [u32; 4]; // in scope 0 at $DIR/issue_75439.rs:+2:9: +2:15 + let mut _3: [u8; 16]; // in scope 0 at $DIR/issue_75439.rs:+2:47: +2:52 + let mut _5: [u8; 4]; // in scope 0 at $DIR/issue_75439.rs:+5:14: +5:38 + let mut _6: u32; // in scope 0 at $DIR/issue_75439.rs:+5:33: +5:35 scope 1 { - debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:+2:9: +2:15 + debug dwords => _2; // in scope 1 at $DIR/issue_75439.rs:+2:9: +2:15 scope 3 { - debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - let _4: u32; // in scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 + debug ip => _4; // in scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + let _4: u32; // in scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 scope 4 { } } @@ -21,69 +21,69 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-75439.rs:+2:9: +2:15 - StorageLive(_3); // scope 2 at $DIR/issue-75439.rs:+2:47: +2:52 - _3 = _1; // scope 2 at $DIR/issue-75439.rs:+2:47: +2:52 - _2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:+2:37: +2:53 + StorageLive(_2); // scope 0 at $DIR/issue_75439.rs:+2:9: +2:15 + StorageLive(_3); // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52 + _3 = _1; // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52 + _2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue_75439.rs:+2:37: +2:53 // mir::Constant - // + span: $DIR/issue-75439.rs:7:37: 7:46 + // + span: $DIR/issue_75439.rs:7:37: 7:46 // + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {transmute::<[u8; 16], [u32; 4]>}, val: Value() } } bb1: { - StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:+2:52: +2:53 - switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + StorageDead(_3); // scope 2 at $DIR/issue_75439.rs:+2:52: +2:53 + switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb2: { - switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb3: { - switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb4: { - StorageLive(_5); // scope 3 at $DIR/issue-75439.rs:+5:14: +5:38 - StorageLive(_6); // scope 4 at $DIR/issue-75439.rs:+5:33: +5:35 - _6 = _4; // scope 4 at $DIR/issue-75439.rs:+5:33: +5:35 - _5 = transmute::(move _6) -> bb7; // scope 4 at $DIR/issue-75439.rs:+5:23: +5:36 + StorageLive(_5); // scope 3 at $DIR/issue_75439.rs:+5:14: +5:38 + StorageLive(_6); // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35 + _6 = _4; // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35 + _5 = transmute::(move _6) -> bb7; // scope 4 at $DIR/issue_75439.rs:+5:23: +5:36 // mir::Constant - // + span: $DIR/issue-75439.rs:10:23: 10:32 + // + span: $DIR/issue_75439.rs:10:23: 10:32 // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {transmute::}, val: Value() } } bb5: { - StorageLive(_4); // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - _4 = _2[3 of 4]; // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - goto -> bb4; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + StorageLive(_4); // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + _4 = _2[3 of 4]; // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + goto -> bb4; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb6: { - StorageLive(_4); // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - _4 = _2[3 of 4]; // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - goto -> bb4; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + StorageLive(_4); // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + _4 = _2[3 of 4]; // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + goto -> bb4; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } 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 - 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 + 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 + 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 - goto -> bb9; // scope 1 at $DIR/issue-75439.rs:+4:5: +8:6 + 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 + goto -> bb9; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 } bb9: { - StorageDead(_2); // scope 0 at $DIR/issue-75439.rs:+9:1: +9:2 - return; // scope 0 at $DIR/issue-75439.rs:+9:2: +9:2 + StorageDead(_2); // scope 0 at $DIR/issue_75439.rs:+9:1: +9:2 + return; // scope 0 at $DIR/issue_75439.rs:+9:2: +9:2 } } diff --git a/src/test/mir-opt/issues/issue_75439.rs b/src/test/mir-opt/issues/issue_75439.rs new file mode 100644 index 000000000..ae2e03631 --- /dev/null +++ b/src/test/mir-opt/issues/issue_75439.rs @@ -0,0 +1,18 @@ +// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff + +use std::mem::transmute; + +pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> { + // big endian `u32`s + let dwords: [u32; 4] = unsafe { transmute(bytes) }; + const FF: u32 = 0x0000_ffff_u32.to_be(); + if let [0, 0, 0 | FF, ip] = dwords { + Some(unsafe { transmute(ip) }) + } else { + None + } +} + +fn main() { + let _ = foo([0; 16]); +} diff --git a/src/test/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir b/src/test/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir index 2c6c93cb1..9b1b07f38 100644 --- a/src/test/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir +++ b/src/test/mir-opt/lower_array_len_e2e.array_bound.PreCodegen.after.mir @@ -7,9 +7,8 @@ fn array_bound(_1: usize, _2: &[u8; N]) -> u8 { 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 _6: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:15: +2:20 - let mut _7: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - let mut _8: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 + 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 @@ -24,16 +23,13 @@ fn array_bound(_1: usize, _2: &[u8; N]) -> u8 { } bb1: { - StorageLive(_6); // scope 0 at $DIR/lower_array_len_e2e.rs:+2:15: +2:20 - _6 = _1; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:15: +2:20 - _7 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - _8 = Lt(_6, _7); // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb2; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 + _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)[_6]; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - StorageDead(_6); // scope 0 at $DIR/lower_array_len_e2e.rs:+3:5: +3:6 + _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 } diff --git a/src/test/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir b/src/test/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir index aee3a8242..29e379777 100644 --- a/src/test/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir +++ b/src/test/mir-opt/lower_array_len_e2e.array_bound_mut.PreCodegen.after.mir @@ -7,12 +7,11 @@ fn array_bound_mut(_1: usize, _2: &mut [u8; N]) -> u8 { 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 _6: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:15: +2:20 - let mut _7: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - let mut _8: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - let _9: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+4:15: +4:16 - let mut _10: usize; // in scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - let mut _11: bool; // in scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 + 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 @@ -27,30 +26,27 @@ fn array_bound_mut(_1: usize, _2: &mut [u8; N]) -> u8 { } bb1: { - StorageLive(_6); // scope 0 at $DIR/lower_array_len_e2e.rs:+2:15: +2:20 - _6 = _1; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:15: +2:20 - _7 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - _8 = Lt(_6, _7); // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb2; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 + _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)[_6]; // scope 0 at $DIR/lower_array_len_e2e.rs:+2:9: +2:21 - StorageDead(_6); // scope 0 at $DIR/lower_array_len_e2e.rs:+3:5: +3:6 + _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(_9); // scope 0 at $DIR/lower_array_len_e2e.rs:+4:15: +4:16 - _9 = const 0_usize; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:15: +4:16 - _10 = const N; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - _11 = Lt(const 0_usize, _10); // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 - assert(move _11, "index out of bounds: the length is {} but the index is {}", move _10, const 0_usize) -> bb4; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:17 + 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)[_9] = const 42_u8; // scope 0 at $DIR/lower_array_len_e2e.rs:+4:9: +4:22 - StorageDead(_9); // scope 0 at $DIR/lower_array_len_e2e.rs:+4:22: +4:23 + (*_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 } diff --git a/src/test/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir b/src/test/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir index 8e185323e..f6d8bdd74 100644 --- a/src/test/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir +++ b/src/test/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir @@ -6,25 +6,20 @@ fn f_u64() -> () { scope 1 (inlined f_dispatch::) { // at $DIR/lower_intrinsics_e2e.rs:15:5: 15:21 debug t => _1; // in scope 1 at $DIR/lower_intrinsics_e2e.rs:19:22: 19:23 let _2: (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 - let mut _3: u64; // in scope 1 at $DIR/lower_intrinsics_e2e.rs:23:19: 23:20 scope 2 (inlined std::mem::size_of::) { // at $DIR/lower_intrinsics_e2e.rs:20:8: 20:32 } } bb0: { StorageLive(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 - _1 = const 0_u64; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 StorageLive(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:19: 23:20 - _3 = move _1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:19: 23:20 - _2 = f_non_zst::(move _3) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 + _2 = f_non_zst::(const 0_u64) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 // mir::Constant // + span: $DIR/lower_intrinsics_e2e.rs:23:9: 23:18 // + literal: Const { ty: fn(u64) {f_non_zst::}, val: Value() } } bb1: { - StorageDead(_3); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:20: 23:21 StorageDead(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:21: 23:22 StorageDead(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 diff --git a/src/test/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir b/src/test/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir index a5b396ca0..b672e1a6e 100644 --- a/src/test/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir +++ b/src/test/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir @@ -6,7 +6,6 @@ fn f_unit() -> () { scope 1 (inlined f_dispatch::<()>) { // at $DIR/lower_intrinsics_e2e.rs:9:5: 9:19 debug t => _1; // in scope 1 at $DIR/lower_intrinsics_e2e.rs:19:22: 19:23 let _2: (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 - let mut _3: (); // in scope 1 at $DIR/lower_intrinsics_e2e.rs:21:15: 21:16 scope 2 (inlined std::mem::size_of::<()>) { // at $DIR/lower_intrinsics_e2e.rs:20:8: 20:32 } } @@ -14,15 +13,13 @@ fn f_unit() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:16: +1:18 StorageLive(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 - StorageLive(_3); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:15: 21:16 - _2 = f_zst::<()>(move _3) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 + _2 = f_zst::<()>(move _1) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 // mir::Constant // + span: $DIR/lower_intrinsics_e2e.rs:21:9: 21:14 // + literal: Const { ty: fn(()) {f_zst::<()>}, val: Value() } } bb1: { - StorageDead(_3); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:16: 21:17 StorageDead(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:17: 21:18 StorageDead(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:18: +1:19 return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 diff --git a/src/test/mir-opt/match-arm-scopes.rs b/src/test/mir-opt/match-arm-scopes.rs deleted file mode 100644 index 7b7de7788..000000000 --- a/src/test/mir-opt/match-arm-scopes.rs +++ /dev/null @@ -1,35 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default -// Test that StorageDead and Drops are generated properly for bindings in -// matches: -// * The MIR should only contain a single drop of `s` and `t`: at the end -// of their respective arms. -// * StorageDead and StorageLive statements are correctly matched up on -// non-unwind paths. -// * The visibility scopes of the match arms should be disjoint, and contain. -// all of the bindings for that scope. -// * No drop flags are used. - -// EMIT_MIR match_arm_scopes.complicated_match SimplifyCfg-initial.after ElaborateDrops.after -fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 { - match items { - (false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1, - (true, b, t) | (false, b, t) => 2, - } -} - -const CASES: &[(bool, bool, bool, i32)] = &[ - (false, false, false, 2), - (false, false, true, 1), - (false, true, false, 1), - (false, true, true, 2), - (true, false, false, 3), - (true, false, true, 3), - (true, true, false, 3), - (true, true, true, 2), -]; - -fn main() { - for &(cond, items_1, items_2, result) in CASES { - assert_eq!(complicated_match(cond, (items_1, items_2, String::new())), result,); - } -} diff --git a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff index 25ab0c9f7..d3db3b182 100644 --- a/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -2,271 +2,271 @@ + // MIR for `complicated_match` after ElaborateDrops fn complicated_match(_1: bool, _2: (bool, bool, String)) -> i32 { - debug cond => _1; // in scope 0 at $DIR/match-arm-scopes.rs:+0:22: +0:26 - debug items => _2; // in scope 0 at $DIR/match-arm-scopes.rs:+0:34: +0:39 - let mut _0: i32; // return place in scope 0 at $DIR/match-arm-scopes.rs:+0:66: +0:69 - let mut _3: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16 - let mut _4: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16 - let _5: bool; // in scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - let _6: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - let _7: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21 - let _8: &std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21 - let mut _9: bool; // in scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 - let mut _10: bool; // in scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 - let mut _11: !; // in scope 0 at $DIR/match-arm-scopes.rs:+2:52: +2:60 - let mut _12: bool; // in scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 - let mut _13: bool; // in scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 - let mut _14: !; // in scope 0 at $DIR/match-arm-scopes.rs:+2:52: +2:60 - let _15: bool; // in scope 0 at $DIR/match-arm-scopes.rs:+3:16: +3:17 - let _16: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:+3:19: +3:20 + debug cond => _1; // in scope 0 at $DIR/match_arm_scopes.rs:+0:22: +0:26 + debug items => _2; // in scope 0 at $DIR/match_arm_scopes.rs:+0:34: +0:39 + let mut _0: i32; // return place in scope 0 at $DIR/match_arm_scopes.rs:+0:66: +0:69 + let mut _3: &bool; // in scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16 + let mut _4: &bool; // in scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16 + let _5: bool; // in scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + let _6: &bool; // in scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + let _7: std::string::String; // in scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21 + let _8: &std::string::String; // in scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21 + let mut _9: bool; // in scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 + let mut _10: bool; // in scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 + let mut _11: !; // in scope 0 at $DIR/match_arm_scopes.rs:+2:52: +2:60 + let mut _12: bool; // in scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 + let mut _13: bool; // in scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 + let mut _14: !; // in scope 0 at $DIR/match_arm_scopes.rs:+2:52: +2:60 + let _15: bool; // in scope 0 at $DIR/match_arm_scopes.rs:+3:16: +3:17 + let _16: std::string::String; // in scope 0 at $DIR/match_arm_scopes.rs:+3:19: +3:20 scope 1 { - debug a => _5; // in scope 1 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - debug a => _6; // in scope 1 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - debug s => _7; // in scope 1 at $DIR/match-arm-scopes.rs:+2:20: +2:21 - debug s => _8; // in scope 1 at $DIR/match-arm-scopes.rs:+2:20: +2:21 + debug a => _5; // in scope 1 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + debug a => _6; // in scope 1 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + debug s => _7; // in scope 1 at $DIR/match_arm_scopes.rs:+2:20: +2:21 + debug s => _8; // in scope 1 at $DIR/match_arm_scopes.rs:+2:20: +2:21 } scope 2 { - debug b => _15; // in scope 2 at $DIR/match-arm-scopes.rs:+3:16: +3:17 - debug t => _16; // in scope 2 at $DIR/match-arm-scopes.rs:+3:19: +3:20 + debug b => _15; // in scope 2 at $DIR/match_arm_scopes.rs:+3:16: +3:17 + debug t => _16; // in scope 2 at $DIR/match_arm_scopes.rs:+3:19: +3:20 } bb0: { -- FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16 -- switchInt((_2.0: bool)) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16 -+ switchInt((_2.0: bool)) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16 +- FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16 +- switchInt((_2.0: bool)) -> [false: bb1, otherwise: bb2]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16 ++ switchInt((_2.0: bool)) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16 } bb1: { -- falseEdge -> [real: bb8, imaginary: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:+2:9: +2:22 -+ switchInt((_2.1: bool)) -> [false: bb10, otherwise: bb2]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16 +- falseEdge -> [real: bb8, imaginary: bb3]; // scope 0 at $DIR/match_arm_scopes.rs:+2:9: +2:22 ++ switchInt((_2.1: bool)) -> [false: bb10, otherwise: bb2]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16 } bb2: { -- switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16 -+ switchInt((_2.0: bool)) -> [false: bb3, otherwise: bb17]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16 +- switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb4]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16 ++ switchInt((_2.0: bool)) -> [false: bb3, otherwise: bb17]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16 } bb3: { -- falseEdge -> [real: bb13, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:+2:25: +2:38 +- falseEdge -> [real: bb13, imaginary: bb5]; // scope 0 at $DIR/match_arm_scopes.rs:+2:25: +2:38 - } - - bb4: { -- switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +1:16 +- switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +1:16 - } - - bb5: { -- falseEdge -> [real: bb20, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:+3:9: +3:21 +- falseEdge -> [real: bb20, imaginary: bb6]; // scope 0 at $DIR/match_arm_scopes.rs:+3:9: +3:21 - } - - bb6: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:+3:32: +3:33 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:+3:32: +3:33 - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:+3:35: +3:36 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+3:35: +3:36 -- goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 -+ goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 + StorageLive(_15); // scope 0 at $DIR/match_arm_scopes.rs:+3:32: +3:33 + _15 = (_2.1: bool); // scope 0 at $DIR/match_arm_scopes.rs:+3:32: +3:33 + StorageLive(_16); // scope 0 at $DIR/match_arm_scopes.rs:+3:35: +3:36 + _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+3:35: +3:36 +- goto -> bb19; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 ++ goto -> bb16; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 } - bb7: { + bb4: { - _0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:+2:77: +2:78 -- drop(_7) -> [return: bb18, unwind: bb25]; // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 -+ drop(_7) -> [return: bb15, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 + _0 = const 1_i32; // scope 1 at $DIR/match_arm_scopes.rs:+2:77: +2:78 +- drop(_7) -> [return: bb18, unwind: bb25]; // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 ++ drop(_7) -> [return: bb15, unwind: bb22]; // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 } - bb8: { + bb5: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - _6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21 -- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16 -- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16 - StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 - StorageLive(_10); // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 - _10 = _1; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 -- switchInt(move _10) -> [false: bb10, otherwise: bb9]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 -+ switchInt(move _10) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 + StorageLive(_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + _6 = &(_2.1: bool); // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + StorageLive(_8); // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21 + _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21 +- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16 +- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16 + StorageLive(_9); // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 + StorageLive(_10); // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 + _10 = _1; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 +- switchInt(move _10) -> [false: bb10, otherwise: bb9]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 ++ switchInt(move _10) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 } - bb9: { + bb6: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:+2:59: +2:60 - StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 + _0 = const 3_i32; // scope 0 at $DIR/match_arm_scopes.rs:+2:59: +2:60 + StorageDead(_10); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_9); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 - goto -> bb23; // scope 0 at no-location + goto -> bb20; // scope 0 at no-location } - bb10: { + bb7: { - _9 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:70: +2:71 -- switchInt(move _9) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 -+ switchInt(move _9) -> [false: bb9, otherwise: bb8]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 + _9 = (*_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:70: +2:71 +- switchInt(move _9) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 ++ switchInt(move _9) -> [false: bb9, otherwise: bb8]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 } - bb11: { + bb8: { - StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:+2:17: +2:18 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:20: +2:21 -- goto -> bb7; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 -+ goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 + StorageDead(_10); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_9); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageLive(_5); // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + _5 = (_2.1: bool); // scope 0 at $DIR/match_arm_scopes.rs:+2:17: +2:18 + StorageLive(_7); // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21 + _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:20: +2:21 +- goto -> bb7; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 ++ goto -> bb4; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 } - bb12: { + bb9: { - StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 -- falseEdge -> [real: bb2, imaginary: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 -+ goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 + StorageDead(_10); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_9); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_8); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 + StorageDead(_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 +- falseEdge -> [real: bb2, imaginary: bb3]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 ++ goto -> bb1; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 } - bb13: { + bb10: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27 - _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27 - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37 -- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16 -- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:+1:11: +1:16 - StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 - StorageLive(_13); // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 - _13 = _1; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 -- switchInt(move _13) -> [false: bb15, otherwise: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 -+ switchInt(move _13) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:+2:45: +2:49 + StorageLive(_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27 + _6 = &(_2.0: bool); // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27 + StorageLive(_8); // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37 + _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37 +- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16 +- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match_arm_scopes.rs:+1:11: +1:16 + StorageLive(_12); // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 + StorageLive(_13); // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 + _13 = _1; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 +- switchInt(move _13) -> [false: bb15, otherwise: bb14]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 ++ switchInt(move _13) -> [false: bb12, otherwise: bb11]; // scope 0 at $DIR/match_arm_scopes.rs:+2:45: +2:49 } - bb14: { + bb11: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:+2:59: +2:60 - StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 + _0 = const 3_i32; // scope 0 at $DIR/match_arm_scopes.rs:+2:59: +2:60 + StorageDead(_13); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_12); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 - goto -> bb23; // scope 0 at no-location + goto -> bb20; // scope 0 at no-location } - bb15: { + bb12: { - _12 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:70: +2:71 -- switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 -+ switchInt(move _12) -> [false: bb14, otherwise: bb13]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 + _12 = (*_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:70: +2:71 +- switchInt(move _12) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 ++ switchInt(move _12) -> [false: bb14, otherwise: bb13]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 } - bb16: { + bb13: { - StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 -- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27 - _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:+2:26: +2:27 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+2:36: +2:37 -- goto -> bb7; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 -+ goto -> bb4; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 + StorageDead(_13); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_12); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 +- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageLive(_5); // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27 + _5 = (_2.0: bool); // scope 0 at $DIR/match_arm_scopes.rs:+2:26: +2:27 + StorageLive(_7); // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37 + _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+2:36: +2:37 +- goto -> bb7; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 ++ goto -> bb4; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 } - bb17: { + bb14: { - StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:+2:72: +2:73 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 -- falseEdge -> [real: bb4, imaginary: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 -+ goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:+2:42: +2:73 + StorageDead(_13); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_12); // scope 0 at $DIR/match_arm_scopes.rs:+2:72: +2:73 + StorageDead(_8); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 + StorageDead(_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 +- falseEdge -> [real: bb4, imaginary: bb5]; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 ++ goto -> bb2; // scope 0 at $DIR/match_arm_scopes.rs:+2:42: +2:73 } - bb18: { + bb15: { - StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 - StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 -- goto -> bb22; // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 -+ goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 + StorageDead(_7); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 + StorageDead(_5); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 + StorageDead(_8); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 + StorageDead(_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 +- goto -> bb22; // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 ++ goto -> bb19; // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 } - bb19: { + bb16: { - _0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:+3:41: +3:42 -- drop(_16) -> [return: bb21, unwind: bb25]; // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42 -+ drop(_16) -> [return: bb18, unwind: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42 + _0 = const 2_i32; // scope 2 at $DIR/match_arm_scopes.rs:+3:41: +3:42 +- drop(_16) -> [return: bb21, unwind: bb25]; // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42 ++ drop(_16) -> [return: bb18, unwind: bb22]; // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42 } - bb20: { + bb17: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:+3:16: +3:17 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:+3:16: +3:17 - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:+3:19: +3:20 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:+3:19: +3:20 -- goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 -+ goto -> bb16; // scope 0 at $DIR/match-arm-scopes.rs:+1:5: +4:6 + StorageLive(_15); // scope 0 at $DIR/match_arm_scopes.rs:+3:16: +3:17 + _15 = (_2.1: bool); // scope 0 at $DIR/match_arm_scopes.rs:+3:16: +3:17 + StorageLive(_16); // scope 0 at $DIR/match_arm_scopes.rs:+3:19: +3:20 + _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match_arm_scopes.rs:+3:19: +3:20 +- goto -> bb19; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 ++ goto -> bb16; // scope 0 at $DIR/match_arm_scopes.rs:+1:5: +4:6 } - bb21: { + bb18: { - StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42 - StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42 -- goto -> bb22; // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42 -+ goto -> bb19; // scope 0 at $DIR/match-arm-scopes.rs:+3:41: +3:42 + StorageDead(_16); // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42 + StorageDead(_15); // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42 +- goto -> bb22; // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42 ++ goto -> bb19; // scope 0 at $DIR/match_arm_scopes.rs:+3:41: +3:42 } - bb22: { -- drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 +- drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 + bb19: { -+ goto -> bb26; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 ++ goto -> bb26; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 } - bb23: { + bb20: { - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:+2:77: +2:78 -- drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 -+ drop(_2) -> [return: bb21, unwind: bb23]; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 + StorageDead(_8); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 + StorageDead(_6); // scope 0 at $DIR/match_arm_scopes.rs:+2:77: +2:78 +- drop(_2) -> [return: bb24, unwind: bb26]; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 ++ drop(_2) -> [return: bb21, unwind: bb23]; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 } - bb24: { + bb21: { - return; // scope 0 at $DIR/match-arm-scopes.rs:+5:2: +5:2 + return; // scope 0 at $DIR/match_arm_scopes.rs:+5:2: +5:2 } - bb25 (cleanup): { -- drop(_2) -> bb26; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 +- drop(_2) -> bb26; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 + bb22 (cleanup): { -+ goto -> bb27; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 ++ goto -> bb27; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 } - bb26 (cleanup): { + bb23 (cleanup): { - resume; // scope 0 at $DIR/match-arm-scopes.rs:+0:1: +5:2 + resume; // scope 0 at $DIR/match_arm_scopes.rs:+0:1: +5:2 + } + + bb24: { -+ goto -> bb21; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 ++ goto -> bb21; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 + } + + bb25 (cleanup): { -+ goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 ++ goto -> bb23; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 + } + + bb26: { -+ goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 ++ goto -> bb24; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 + } + + bb27 (cleanup): { -+ goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:+5:1: +5:2 ++ goto -> bb23; // scope 0 at $DIR/match_arm_scopes.rs:+5:1: +5:2 } } diff --git a/src/test/mir-opt/match_arm_scopes.rs b/src/test/mir-opt/match_arm_scopes.rs new file mode 100644 index 000000000..7b7de7788 --- /dev/null +++ b/src/test/mir-opt/match_arm_scopes.rs @@ -0,0 +1,35 @@ +// ignore-wasm32-bare compiled with panic=abort by default +// Test that StorageDead and Drops are generated properly for bindings in +// matches: +// * The MIR should only contain a single drop of `s` and `t`: at the end +// of their respective arms. +// * StorageDead and StorageLive statements are correctly matched up on +// non-unwind paths. +// * The visibility scopes of the match arms should be disjoint, and contain. +// all of the bindings for that scope. +// * No drop flags are used. + +// EMIT_MIR match_arm_scopes.complicated_match SimplifyCfg-initial.after ElaborateDrops.after +fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 { + match items { + (false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1, + (true, b, t) | (false, b, t) => 2, + } +} + +const CASES: &[(bool, bool, bool, i32)] = &[ + (false, false, false, 2), + (false, false, true, 1), + (false, true, false, 1), + (false, true, true, 2), + (true, false, false, 3), + (true, false, true, 3), + (true, true, false, 3), + (true, true, true, 2), +]; + +fn main() { + for &(cond, items_1, items_2, result) in CASES { + assert_eq!(complicated_match(cond, (items_1, items_2, String::new())), result,); + } +} diff --git a/src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir b/src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir deleted file mode 100644 index b193a8d76..000000000 --- a/src/test/mir-opt/match_false_edges.full_tested_match.PromoteTemps.after.mir +++ /dev/null @@ -1,113 +0,0 @@ -// MIR for `full_tested_match` after PromoteTemps - -fn full_tested_match() -> () { - let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:28: +0:28 - let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 - let mut _2: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 - let mut _4: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36 - let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 - let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:24: +3:25 - let mut _11: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - scope 1 { - } - scope 2 { - debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 - debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 - } - scope 3 { - debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:+3:14: +3:15 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 - StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - _2 = Option::::Some(const 42_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - switchInt(move _3) -> [0_isize: bb1, 1_isize: bb2, otherwise: bb4]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:27 - } - - bb1: { - _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23 - } - - bb2: { - falseEdge -> [real: bb5, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 - } - - bb3: { - falseEdge -> [real: bb9, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16 - } - - bb4: { - unreachable; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - } - - bb5: { - StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - _11 = const _; // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - // mir::Constant - // + span: $DIR/match_false_edges.rs:14:14: 14:15 - // + literal: Const { ty: &Option, val: Unevaluated(full_tested_match, [], Some(promoted[0])) } - _6 = &(((*_11) as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - _7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - // mir::Constant - // + span: $DIR/match_false_edges.rs:14:20: 14:25 - // + literal: Const { ty: fn() -> bool {guard}, val: Value() } - } - - bb6: { - switchInt(move _7) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - } - - bb7: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - _5 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - StorageLive(_8); // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 - _8 = _5; // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 - _1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:+2:31: +2:37 - StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37 - StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - } - - bb8: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - goto -> bb3; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - } - - bb9: { - StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 - _9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15 - StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25 - _10 = _9; // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25 - _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+3:20: +3:26 - StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+3:25: +3:26 - StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26 - } - - bb10: { - StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 - StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 - _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2 - return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2 - } - - bb11 (cleanup): { - resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2 - } -} diff --git a/src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir deleted file mode 100644 index 145ed878f..000000000 --- a/src/test/mir-opt/match_false_edges.full_tested_match2.PromoteTemps.before.mir +++ /dev/null @@ -1,108 +0,0 @@ -// MIR for `full_tested_match2` before PromoteTemps - -fn full_tested_match2() -> () { - let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:29: +0:29 - let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 - let mut _2: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 - let mut _4: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36 - let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:24: +4:25 - scope 1 { - } - scope 2 { - debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 - debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15 - } - scope 3 { - debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:+4:14: +4:15 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6 - StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - _2 = Option::::Some(const 42_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - switchInt(move _3) -> [0_isize: bb1, 1_isize: bb2, otherwise: bb4]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:27 - } - - bb1: { - falseEdge -> [real: bb9, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13 - } - - bb2: { - falseEdge -> [real: bb5, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16 - } - - bb3: { - StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - _9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+4:24: +4:25 - _10 = _9; // scope 3 at $DIR/match_false_edges.rs:+4:24: +4:25 - _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+4:20: +4:26 - StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+4:25: +4:26 - StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26 - } - - bb4: { - unreachable; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - } - - bb5: { - StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - _6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27 - StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - _7 = guard() -> [return: bb6, unwind: bb11]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - // mir::Constant - // + span: $DIR/match_false_edges.rs:25:20: 25:25 - // + literal: Const { ty: fn() -> bool {guard}, val: Value() } - } - - bb6: { - switchInt(move _7) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - } - - bb7: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - _5 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15 - StorageLive(_8); // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 - _8 = _5; // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36 - _1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:+2:31: +2:37 - StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37 - StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - } - - bb8: { - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37 - falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27 - } - - bb9: { - _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23 - goto -> bb10; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23 - } - - bb10: { - StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 - StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7 - _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2 - return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2 - } - - bb11 (cleanup): { - resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2 - } -} diff --git a/src/test/mir-opt/match_false_edges.main.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges.main.PromoteTemps.before.mir deleted file mode 100644 index 8f40e8a88..000000000 --- a/src/test/mir-opt/match_false_edges.main.PromoteTemps.before.mir +++ /dev/null @@ -1,153 +0,0 @@ -// MIR for `main` before PromoteTemps - -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:11: +0:11 - let mut _1: i32; // in scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6 - let mut _2: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16 - let mut _4: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17 - let mut _5: &std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - let _6: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 - let _7: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 - let mut _8: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 - let _9: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 - let _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - let _11: &i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - let mut _12: bool; // in scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 - let mut _13: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 - let _14: std::option::Option; // in scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 - scope 1 { - } - scope 2 { - debug _w => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:16 - debug _w => _7; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:16 - } - scope 3 { - debug _x => _9; // in scope 3 at $DIR/match_false_edges.rs:+3:9: +3:11 - } - scope 4 { - debug y => _10; // in scope 4 at $DIR/match_false_edges.rs:+4:14: +4:15 - debug y => _11; // in scope 4 at $DIR/match_false_edges.rs:+4:14: +4:15 - } - scope 5 { - debug _z => _14; // in scope 5 at $DIR/match_false_edges.rs:+5:9: +5:11 - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6 - StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - _2 = Option::::Some(const 1_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - _4 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - switchInt(move _4) -> [1_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26 - } - - bb1: { - falseEdge -> [real: bb9, imaginary: bb4]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 - } - - bb2: { - falseEdge -> [real: bb5, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17 - } - - bb3: { - StorageLive(_14); // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 - _14 = _2; // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11 - _1 = const 4_i32; // scope 5 at $DIR/match_false_edges.rs:+5:15: +5:16 - StorageDead(_14); // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16 - } - - bb4: { - falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16 - } - - bb5: { - StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 - _7 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 - _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - StorageLive(_8); // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 - _8 = guard() -> [return: bb6, unwind: bb15]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 - // mir::Constant - // + span: $DIR/match_false_edges.rs:34:21: 34:26 - // + literal: Const { ty: fn() -> bool {guard}, val: Value() } - } - - bb6: { - switchInt(move _8) -> [false: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 - } - - bb7: { - StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 - FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 - FakeRead(ForGuardBinding, _7); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 - StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 - _6 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16 - _1 = const 1_i32; // scope 2 at $DIR/match_false_edges.rs:+2:32: +2:33 - StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 - } - - bb8: { - StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28 - StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33 - falseEdge -> [real: bb1, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28 - } - - bb9: { - StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 - _9 = _2; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11 - _1 = const 2_i32; // scope 3 at $DIR/match_false_edges.rs:+3:15: +3:16 - StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16 - } - - bb10: { - StorageLive(_11); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - _11 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26 - StorageLive(_12); // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 - StorageLive(_13); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 - _13 = (*_11); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28 - _12 = guard2(move _13) -> [return: bb11, unwind: bb15]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 - // mir::Constant - // + span: $DIR/match_false_edges.rs:36:20: 36:26 - // + literal: Const { ty: fn(i32) -> bool {guard2}, val: Value() } - } - - bb11: { - switchInt(move _12) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 - } - - bb12: { - StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 - StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 - FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 - FakeRead(ForGuardBinding, _11); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 - StorageLive(_10); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - _10 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15 - _1 = const 3_i32; // scope 4 at $DIR/match_false_edges.rs:+4:33: +4:34 - StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 - StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 - goto -> bb14; // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 - } - - bb13: { - StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 - StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29 - StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34 - falseEdge -> [real: bb3, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29 - } - - bb14: { - StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 - StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7 - _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2 - return; // scope 0 at $DIR/match_false_edges.rs:+7:2: +7:2 - } - - bb15 (cleanup): { - resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +7:2 - } -} diff --git a/src/test/mir-opt/match_false_edges.rs b/src/test/mir-opt/match_false_edges.rs deleted file mode 100644 index 3603253da..000000000 --- a/src/test/mir-opt/match_false_edges.rs +++ /dev/null @@ -1,39 +0,0 @@ -fn guard() -> bool { - false -} - -fn guard2(_: i32) -> bool { - true -} - -// no_mangle to make sure this gets instantiated even in an executable. -#[no_mangle] -// EMIT_MIR match_false_edges.full_tested_match.PromoteTemps.after.mir -pub fn full_tested_match() { - let _ = match Some(42) { - Some(x) if guard() => (1, x), - Some(y) => (2, y), - None => (3, 3), - }; -} - -// no_mangle to make sure this gets instantiated even in an executable. -#[no_mangle] -// EMIT_MIR match_false_edges.full_tested_match2.PromoteTemps.before.mir -pub fn full_tested_match2() { - let _ = match Some(42) { - Some(x) if guard() => (1, x), - None => (3, 3), - Some(y) => (2, y), - }; -} - -// EMIT_MIR match_false_edges.main.PromoteTemps.before.mir -fn main() { - let _ = match Some(1) { - Some(_w) if guard() => 1, - _x => 2, - Some(y) if guard2(y) => 3, - _z => 4, - }; -} diff --git a/src/test/mir-opt/nll/named-lifetimes-basic.rs b/src/test/mir-opt/nll/named-lifetimes-basic.rs deleted file mode 100644 index 843716033..000000000 --- a/src/test/mir-opt/nll/named-lifetimes-basic.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Basic test for named lifetime translation. Check that we -// instantiate the types that appear in function arguments with -// suitable variables and that we setup the outlives relationship -// between R0 and R1 properly. - -// compile-flags: -Zverbose -// ^^^^^^^^^ force compiler to dump more region information - -#![allow(warnings)] - -// EMIT_MIR named_lifetimes_basic.use_x.nll.0.mir -fn use_x<'a, 'b: 'a, 'c>(w: &'a mut i32, x: &'b u32, y: &'a u32, z: &'c u32) -> bool { true } - -fn main() { -} diff --git a/src/test/mir-opt/nll/named_lifetimes_basic.rs b/src/test/mir-opt/nll/named_lifetimes_basic.rs new file mode 100644 index 000000000..843716033 --- /dev/null +++ b/src/test/mir-opt/nll/named_lifetimes_basic.rs @@ -0,0 +1,15 @@ +// Basic test for named lifetime translation. Check that we +// instantiate the types that appear in function arguments with +// suitable variables and that we setup the outlives relationship +// between R0 and R1 properly. + +// compile-flags: -Zverbose +// ^^^^^^^^^ force compiler to dump more region information + +#![allow(warnings)] + +// EMIT_MIR named_lifetimes_basic.use_x.nll.0.mir +fn use_x<'a, 'b: 'a, 'c>(w: &'a mut i32, x: &'b u32, y: &'a u32, z: &'c u32) -> bool { true } + +fn main() { +} diff --git a/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir b/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir index 0ab9d712d..6cd6d8b77 100644 --- a/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir +++ b/src/test/mir-opt/nll/named_lifetimes_basic.use_x.nll.0.mir @@ -24,24 +24,24 @@ | '_#2r live at {bb0[0..=1]} | '_#3r live at {bb0[0..=1]} | '_#4r live at {bb0[0..=1]} -| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0) -| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0) -| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0) -| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0) -| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) ($DIR/named-lifetimes-basic.rs:12:26: 12:27 (#0) -| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) ($DIR/named-lifetimes-basic.rs:12:42: 12:43 (#0) -| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) ($DIR/named-lifetimes-basic.rs:12:54: 12:55 (#0) -| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) ($DIR/named-lifetimes-basic.rs:12:66: 12:67 (#0) +| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) +| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) +| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) +| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) +| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:26: 12:27) ($DIR/named_lifetimes_basic.rs:12:26: 12:27 (#0) +| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:42: 12:43) ($DIR/named_lifetimes_basic.rs:12:42: 12:43 (#0) +| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:54: 12:55) ($DIR/named_lifetimes_basic.rs:12:54: 12:55 (#0) +| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named_lifetimes_basic.rs:12:66: 12:67) ($DIR/named_lifetimes_basic.rs:12:66: 12:67 (#0) | fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool { - debug w => _1; // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:26: +0:27 - debug x => _2; // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:42: +0:43 - debug y => _3; // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:54: +0:55 - debug z => _4; // in scope 0 at $DIR/named-lifetimes-basic.rs:+0:66: +0:67 - let mut _0: bool; // return place in scope 0 at $DIR/named-lifetimes-basic.rs:+0:81: +0:85 + debug w => _1; // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:26: +0:27 + debug x => _2; // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:42: +0:43 + debug y => _3; // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:54: +0:55 + debug z => _4; // in scope 0 at $DIR/named_lifetimes_basic.rs:+0:66: +0:67 + let mut _0: bool; // return place in scope 0 at $DIR/named_lifetimes_basic.rs:+0:81: +0:85 bb0: { - _0 = const ConstValue(Scalar(0x01): bool); // bb0[0]: scope 0 at $DIR/named-lifetimes-basic.rs:+0:88: +0:92 - return; // bb0[1]: scope 0 at $DIR/named-lifetimes-basic.rs:+0:94: +0:94 + _0 = const ConstValue(Scalar(0x01): bool); // bb0[0]: scope 0 at $DIR/named_lifetimes_basic.rs:+0:88: +0:92 + return; // bb0[1]: scope 0 at $DIR/named_lifetimes_basic.rs:+0:94: +0:94 } } diff --git a/src/test/mir-opt/nll/region-subtyping-basic.rs b/src/test/mir-opt/nll/region-subtyping-basic.rs deleted file mode 100644 index 64332f302..000000000 --- a/src/test/mir-opt/nll/region-subtyping-basic.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Basic test for liveness constraints: the region (`R1`) that appears -// in the type of `p` includes the points after `&v[0]` up to (but not -// including) the call to `use_x`. The `else` branch is not included. - -// compile-flags:-Zverbose -// ^^^^^^^^^ force compiler to dump more region information - -#![allow(warnings)] - -fn use_x(_: usize) -> bool { - true -} - -// EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR region_subtyping_basic.main.nll.0.mir -fn main() { - let mut v = [1, 2, 3]; - let p = &v[0]; - let q = p; - if true { - use_x(*q); - } else { - use_x(22); - } -} diff --git a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir index 36705d18e..3e3fda614 100644 --- a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir +++ b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.32bit.mir @@ -17,95 +17,95 @@ | '_#2r live at {bb1[0]} | '_#3r live at {bb1[1..=3]} | '_#4r live at {bb1[4..=7], bb2[0..=2]} -| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region-subtyping-basic.rs:18:13: 18:18 (#0) -| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region-subtyping-basic.rs:19:13: 19:14 (#0) +| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) +| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) | fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/region-subtyping-basic.rs:+0:11: +0:11 - let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - let _3: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:+2:16: +2:17 - let mut _4: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - let mut _5: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - let mut _7: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 - let _8: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+5:9: +5:18 - let mut _9: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:+5:15: +5:17 - let _10: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+7:9: +7:18 + let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11 + let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x00000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 + let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + let mut _7: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 + let _8: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+5:9: +5:18 + let mut _9: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+5:15: +5:17 + let _10: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 scope 1 { - debug v => _1; // in scope 1 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - let _2: &'_#3r usize; // in scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 + debug v => _1; // in scope 1 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let _2: &'_#3r usize; // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 scope 2 { - debug p => _2; // in scope 2 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 - let _6: &'_#4r usize; // in scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 + debug p => _2; // in scope 2 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + let _6: &'_#4r usize; // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 scope 3 { - debug q => _6; // in scope 3 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 + debug q => _6; // in scope 3 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 } } } bb0: { - StorageLive(_1); // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - _1 = [const ConstValue(Scalar(0x00000001): usize), const ConstValue(Scalar(0x00000002): usize), const ConstValue(Scalar(0x00000003): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:+1:17: +1:26 - FakeRead(ForLet(None), _1); // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - StorageLive(_2); // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 - StorageLive(_3); // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17 - _3 = const ConstValue(Scalar(0x00000000): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17 - _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 + StorageLive(_1); // bb0[0]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + _1 = [const ConstValue(Scalar(0x00000001): usize), const ConstValue(Scalar(0x00000002): usize), const ConstValue(Scalar(0x00000003): usize)]; // bb0[1]: scope 0 at $DIR/region_subtyping_basic.rs:+1:17: +1:26 + FakeRead(ForLet(None), _1); // bb0[2]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 + _3 = const ConstValue(Scalar(0x00000000): usize); // bb0[5]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 + _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 } bb1: { - _2 = &'_#2r _1[_3]; // bb1[0]: scope 1 at $DIR/region-subtyping-basic.rs:+2:13: +2:18 - FakeRead(ForLet(None), _2); // bb1[1]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 - StorageLive(_6); // bb1[2]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 - _6 = _2; // bb1[3]: scope 2 at $DIR/region-subtyping-basic.rs:+3:13: +3:14 - FakeRead(ForLet(None), _6); // bb1[4]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 - StorageLive(_7); // bb1[5]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 - _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 - switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 + _2 = &'_#2r _1[_3]; // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18 + FakeRead(ForLet(None), _2); // bb1[1]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + StorageLive(_6); // bb1[2]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 + _6 = _2; // bb1[3]: scope 2 at $DIR/region_subtyping_basic.rs:+3:13: +3:14 + FakeRead(ForLet(None), _6); // bb1[4]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 + StorageLive(_7); // bb1[5]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 + _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 + switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 } bb2: { - StorageLive(_8); // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18 - StorageLive(_9); // bb2[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17 - _9 = (*_6); // bb2[2]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17 - _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18 + StorageLive(_8); // bb2[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18 + StorageLive(_9); // bb2[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17 + _9 = (*_6); // bb2[2]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17 + _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18 // mir::Constant - // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 + // + span: $DIR/region_subtyping_basic.rs:21:9: 21:14 // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() } } bb3: { - StorageDead(_9); // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:17: +5:18 - StorageDead(_8); // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:18: +5:19 - _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:13: +6:6 - goto -> bb6; // bb3[3]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6 + StorageDead(_9); // bb3[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:17: +5:18 + StorageDead(_8); // bb3[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:18: +5:19 + _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:13: +6:6 + goto -> bb6; // bb3[3]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6 } bb4: { - StorageLive(_10); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18 - _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x00000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18 + StorageLive(_10); // bb4[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 + _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x00000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 // mir::Constant - // + span: $DIR/region-subtyping-basic.rs:23:9: 23:14 + // + span: $DIR/region_subtyping_basic.rs:23:9: 23:14 // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() } } bb5: { - StorageDead(_10); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:18: +7:19 - _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:+6:12: +8:6 - goto -> bb6; // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6 + StorageDead(_10); // bb5[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:18: +7:19 + _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region_subtyping_basic.rs:+6:12: +8:6 + goto -> bb6; // bb5[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6 } bb6: { - StorageDead(_7); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:+8:5: +8:6 - StorageDead(_6); // bb6[1]: scope 2 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - StorageDead(_3); // bb6[2]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - StorageDead(_2); // bb6[3]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - StorageDead(_1); // bb6[4]: scope 0 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - return; // bb6[5]: scope 0 at $DIR/region-subtyping-basic.rs:+9:2: +9:2 + StorageDead(_7); // bb6[0]: scope 3 at $DIR/region_subtyping_basic.rs:+8:5: +8:6 + StorageDead(_6); // bb6[1]: scope 2 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + StorageDead(_3); // bb6[2]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + StorageDead(_2); // bb6[3]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + StorageDead(_1); // bb6[4]: scope 0 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + return; // bb6[5]: scope 0 at $DIR/region_subtyping_basic.rs:+9:2: +9:2 } bb7 (cleanup): { - resume; // bb7[0]: scope 0 at $DIR/region-subtyping-basic.rs:+0:1: +9:2 + resume; // bb7[0]: scope 0 at $DIR/region_subtyping_basic.rs:+0:1: +9:2 } } diff --git a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir index 4f6256a67..39a53702a 100644 --- a/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir +++ b/src/test/mir-opt/nll/region_subtyping_basic.main.nll.0.64bit.mir @@ -17,95 +17,95 @@ | '_#2r live at {bb1[0]} | '_#3r live at {bb1[1..=3]} | '_#4r live at {bb1[4..=7], bb2[0..=2]} -| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region-subtyping-basic.rs:18:13: 18:18 (#0) -| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region-subtyping-basic.rs:19:13: 19:14 (#0) +| '_#2r: '_#3r due to Assignment at Single(bb1[0]) ($DIR/region_subtyping_basic.rs:18:13: 18:18 (#0) +| '_#3r: '_#4r due to Assignment at Single(bb1[3]) ($DIR/region_subtyping_basic.rs:19:13: 19:14 (#0) | fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/region-subtyping-basic.rs:+0:11: +0:11 - let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - let _3: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:+2:16: +2:17 - let mut _4: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - let mut _5: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - let mut _7: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 - let _8: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+5:9: +5:18 - let mut _9: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:+5:15: +5:17 - let _10: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:+7:9: +7:18 + let mut _0: (); // return place in scope 0 at $DIR/region_subtyping_basic.rs:+0:11: +0:11 + let mut _1: [usize; Const { ty: usize, kind: Value(Leaf(0x0000000000000003)) }]; // in scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let _3: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 + let mut _4: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + let mut _5: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + let mut _7: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 + let _8: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+5:9: +5:18 + let mut _9: usize; // in scope 0 at $DIR/region_subtyping_basic.rs:+5:15: +5:17 + let _10: bool; // in scope 0 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 scope 1 { - debug v => _1; // in scope 1 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - let _2: &'_#3r usize; // in scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 + debug v => _1; // in scope 1 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + let _2: &'_#3r usize; // in scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 scope 2 { - debug p => _2; // in scope 2 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 - let _6: &'_#4r usize; // in scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 + debug p => _2; // in scope 2 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + let _6: &'_#4r usize; // in scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 scope 3 { - debug q => _6; // in scope 3 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 + debug q => _6; // in scope 3 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 } } } bb0: { - StorageLive(_1); // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - _1 = [const ConstValue(Scalar(0x0000000000000001): usize), const ConstValue(Scalar(0x0000000000000002): usize), const ConstValue(Scalar(0x0000000000000003): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:+1:17: +1:26 - FakeRead(ForLet(None), _1); // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:+1:9: +1:14 - StorageLive(_2); // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 - StorageLive(_3); // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17 - _3 = const ConstValue(Scalar(0x0000000000000000): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:+2:16: +2:17 - _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:+2:14: +2:18 + StorageLive(_1); // bb0[0]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + _1 = [const ConstValue(Scalar(0x0000000000000001): usize), const ConstValue(Scalar(0x0000000000000002): usize), const ConstValue(Scalar(0x0000000000000003): usize)]; // bb0[1]: scope 0 at $DIR/region_subtyping_basic.rs:+1:17: +1:26 + FakeRead(ForLet(None), _1); // bb0[2]: scope 0 at $DIR/region_subtyping_basic.rs:+1:9: +1:14 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 + _3 = const ConstValue(Scalar(0x0000000000000000): usize); // bb0[5]: scope 1 at $DIR/region_subtyping_basic.rs:+2:16: +2:17 + _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 + assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind: bb7]; // bb0[8]: scope 1 at $DIR/region_subtyping_basic.rs:+2:14: +2:18 } bb1: { - _2 = &'_#2r _1[_3]; // bb1[0]: scope 1 at $DIR/region-subtyping-basic.rs:+2:13: +2:18 - FakeRead(ForLet(None), _2); // bb1[1]: scope 1 at $DIR/region-subtyping-basic.rs:+2:9: +2:10 - StorageLive(_6); // bb1[2]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 - _6 = _2; // bb1[3]: scope 2 at $DIR/region-subtyping-basic.rs:+3:13: +3:14 - FakeRead(ForLet(None), _6); // bb1[4]: scope 2 at $DIR/region-subtyping-basic.rs:+3:9: +3:10 - StorageLive(_7); // bb1[5]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 - _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 - switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region-subtyping-basic.rs:+4:8: +4:12 + _2 = &'_#2r _1[_3]; // bb1[0]: scope 1 at $DIR/region_subtyping_basic.rs:+2:13: +2:18 + FakeRead(ForLet(None), _2); // bb1[1]: scope 1 at $DIR/region_subtyping_basic.rs:+2:9: +2:10 + StorageLive(_6); // bb1[2]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 + _6 = _2; // bb1[3]: scope 2 at $DIR/region_subtyping_basic.rs:+3:13: +3:14 + FakeRead(ForLet(None), _6); // bb1[4]: scope 2 at $DIR/region_subtyping_basic.rs:+3:9: +3:10 + StorageLive(_7); // bb1[5]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 + _7 = const ConstValue(Scalar(0x01): bool); // bb1[6]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 + switchInt(move _7) -> [ConstValue(Scalar(0x00): bool): bb4, otherwise: bb2]; // bb1[7]: scope 3 at $DIR/region_subtyping_basic.rs:+4:8: +4:12 } bb2: { - StorageLive(_8); // bb2[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18 - StorageLive(_9); // bb2[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17 - _9 = (*_6); // bb2[2]: scope 3 at $DIR/region-subtyping-basic.rs:+5:15: +5:17 - _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region-subtyping-basic.rs:+5:9: +5:18 + StorageLive(_8); // bb2[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18 + StorageLive(_9); // bb2[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17 + _9 = (*_6); // bb2[2]: scope 3 at $DIR/region_subtyping_basic.rs:+5:15: +5:17 + _8 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(move _9) -> [return: bb3, unwind: bb7]; // bb2[3]: scope 3 at $DIR/region_subtyping_basic.rs:+5:9: +5:18 // mir::Constant - // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 + // + span: $DIR/region_subtyping_basic.rs:21:9: 21:14 // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() } } bb3: { - StorageDead(_9); // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:+5:17: +5:18 - StorageDead(_8); // bb3[1]: scope 3 at $DIR/region-subtyping-basic.rs:+5:18: +5:19 - _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:13: +6:6 - goto -> bb6; // bb3[3]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6 + StorageDead(_9); // bb3[0]: scope 3 at $DIR/region_subtyping_basic.rs:+5:17: +5:18 + StorageDead(_8); // bb3[1]: scope 3 at $DIR/region_subtyping_basic.rs:+5:18: +5:19 + _0 = const ConstValue(ZeroSized: ()); // bb3[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:13: +6:6 + goto -> bb6; // bb3[3]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6 } bb4: { - StorageLive(_10); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18 - _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:+7:9: +7:18 + StorageLive(_10); // bb4[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 + _10 = ConstValue(ZeroSized: fn(usize) -> bool {use_x})(const ConstValue(Scalar(0x0000000000000016): usize)) -> [return: bb5, unwind: bb7]; // bb4[1]: scope 3 at $DIR/region_subtyping_basic.rs:+7:9: +7:18 // mir::Constant - // + span: $DIR/region-subtyping-basic.rs:23:9: 23:14 + // + span: $DIR/region_subtyping_basic.rs:23:9: 23:14 // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value() } } bb5: { - StorageDead(_10); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:+7:18: +7:19 - _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:+6:12: +8:6 - goto -> bb6; // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:+4:5: +8:6 + StorageDead(_10); // bb5[0]: scope 3 at $DIR/region_subtyping_basic.rs:+7:18: +7:19 + _0 = const ConstValue(ZeroSized: ()); // bb5[1]: scope 3 at $DIR/region_subtyping_basic.rs:+6:12: +8:6 + goto -> bb6; // bb5[2]: scope 3 at $DIR/region_subtyping_basic.rs:+4:5: +8:6 } bb6: { - StorageDead(_7); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:+8:5: +8:6 - StorageDead(_6); // bb6[1]: scope 2 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - StorageDead(_3); // bb6[2]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - StorageDead(_2); // bb6[3]: scope 1 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - StorageDead(_1); // bb6[4]: scope 0 at $DIR/region-subtyping-basic.rs:+9:1: +9:2 - return; // bb6[5]: scope 0 at $DIR/region-subtyping-basic.rs:+9:2: +9:2 + StorageDead(_7); // bb6[0]: scope 3 at $DIR/region_subtyping_basic.rs:+8:5: +8:6 + StorageDead(_6); // bb6[1]: scope 2 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + StorageDead(_3); // bb6[2]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + StorageDead(_2); // bb6[3]: scope 1 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + StorageDead(_1); // bb6[4]: scope 0 at $DIR/region_subtyping_basic.rs:+9:1: +9:2 + return; // bb6[5]: scope 0 at $DIR/region_subtyping_basic.rs:+9:2: +9:2 } bb7 (cleanup): { - resume; // bb7[0]: scope 0 at $DIR/region-subtyping-basic.rs:+0:1: +9:2 + resume; // bb7[0]: scope 0 at $DIR/region_subtyping_basic.rs:+0:1: +9:2 } } diff --git a/src/test/mir-opt/nll/region_subtyping_basic.rs b/src/test/mir-opt/nll/region_subtyping_basic.rs new file mode 100644 index 000000000..64332f302 --- /dev/null +++ b/src/test/mir-opt/nll/region_subtyping_basic.rs @@ -0,0 +1,25 @@ +// Basic test for liveness constraints: the region (`R1`) that appears +// in the type of `p` includes the points after `&v[0]` up to (but not +// including) the call to `use_x`. The `else` branch is not included. + +// compile-flags:-Zverbose +// ^^^^^^^^^ force compiler to dump more region information + +#![allow(warnings)] + +fn use_x(_: usize) -> bool { + true +} + +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR region_subtyping_basic.main.nll.0.mir +fn main() { + let mut v = [1, 2, 3]; + let p = &v[0]; + let q = p; + if true { + use_x(*q); + } else { + use_x(22); + } +} diff --git a/src/test/mir-opt/no-drop-for-inactive-variant.rs b/src/test/mir-opt/no-drop-for-inactive-variant.rs deleted file mode 100644 index 34e2b1a13..000000000 --- a/src/test/mir-opt/no-drop-for-inactive-variant.rs +++ /dev/null @@ -1,16 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default - -// Ensure that there are no drop terminators in `unwrap` (except the one along the cleanup -// path). - -// EMIT_MIR no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir -fn unwrap(opt: Option) -> T { - match opt { - Some(x) => x, - None => panic!(), - } -} - -fn main() { - let _ = unwrap(Some(1i32)); -} diff --git a/src/test/mir-opt/no-spurious-drop-after-call.rs b/src/test/mir-opt/no-spurious-drop-after-call.rs deleted file mode 100644 index bb5bb9aa4..000000000 --- a/src/test/mir-opt/no-spurious-drop-after-call.rs +++ /dev/null @@ -1,10 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default - -// Test that after the call to `std::mem::drop` we do not generate a -// MIR drop of the argument. (We used to have a `DROP(_2)` in the code -// below, as part of bb3.) - -// EMIT_MIR no_spurious_drop_after_call.main.ElaborateDrops.before.mir -fn main() { - std::mem::drop("".to_string()); -} diff --git a/src/test/mir-opt/no_drop_for_inactive_variant.rs b/src/test/mir-opt/no_drop_for_inactive_variant.rs new file mode 100644 index 000000000..34e2b1a13 --- /dev/null +++ b/src/test/mir-opt/no_drop_for_inactive_variant.rs @@ -0,0 +1,16 @@ +// ignore-wasm32-bare compiled with panic=abort by default + +// Ensure that there are no drop terminators in `unwrap` (except the one along the cleanup +// path). + +// EMIT_MIR no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir +fn unwrap(opt: Option) -> T { + match opt { + Some(x) => x, + None => panic!(), + } +} + +fn main() { + let _ = unwrap(Some(1i32)); +} diff --git a/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir index 50fd98ff1..e708255ce 100644 --- a/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.mir @@ -1,21 +1,21 @@ // MIR for `unwrap` after SimplifyCfg-elaborate-drops fn unwrap(_1: Option) -> T { - debug opt => _1; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+0:14: +0:17 - let mut _0: T; // return place in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+0:33: +0:34 - let mut _2: isize; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:9: +2:16 - let _3: T; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15 + debug opt => _1; // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+0:14: +0:17 + let mut _0: T; // return place in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+0:33: +0:34 + let mut _2: isize; // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:9: +2:16 + let _3: T; // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15 let mut _4: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL - let mut _5: isize; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2 - let mut _6: isize; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2 - let mut _7: isize; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2 + let mut _5: isize; // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2 + let mut _6: isize; // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2 + let mut _7: isize; // in scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2 scope 1 { - debug x => _3; // in scope 1 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15 + debug x => _3; // in scope 1 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15 } bb0: { - _2 = discriminant(_1); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+1:11: +1:14 - switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+1:5: +1:14 + _2 = discriminant(_1); // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+1:11: +1:14 + switchInt(move _2) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+1:5: +1:14 } bb1: { @@ -30,20 +30,20 @@ fn unwrap(_1: Option) -> T { } bb2: { - unreachable; // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+1:11: +1:14 + unreachable; // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+1:11: +1:14 } bb3: { - StorageLive(_3); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15 - _3 = move ((_1 as Some).0: T); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:14: +2:15 - _0 = move _3; // scope 1 at $DIR/no-drop-for-inactive-variant.rs:+2:20: +2:21 - StorageDead(_3); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+2:20: +2:21 - _5 = discriminant(_1); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2 - return; // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:2: +5:2 + StorageLive(_3); // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15 + _3 = move ((_1 as Some).0: T); // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:14: +2:15 + _0 = move _3; // scope 1 at $DIR/no_drop_for_inactive_variant.rs:+2:20: +2:21 + StorageDead(_3); // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+2:20: +2:21 + _5 = discriminant(_1); // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2 + return; // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:2: +5:2 } bb4 (cleanup): { - _7 = discriminant(_1); // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+5:1: +5:2 - resume; // scope 0 at $DIR/no-drop-for-inactive-variant.rs:+0:1: +5:2 + _7 = discriminant(_1); // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+5:1: +5:2 + resume; // scope 0 at $DIR/no_drop_for_inactive_variant.rs:+0:1: +5:2 } } diff --git a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir index 963e7cde6..0cb34a2f2 100644 --- a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir +++ b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir @@ -1,49 +1,49 @@ // MIR for `main` before ElaborateDrops fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/no-spurious-drop-after-call.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:5: +1:35 - let mut _2: std::string::String; // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34 - let mut _3: &str; // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34 - let _4: &str; // in scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:22 + let mut _0: (); // return place in scope 0 at $DIR/no_spurious_drop_after_call.rs:+0:11: +0:11 + let _1: (); // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:5: +1:35 + let mut _2: std::string::String; // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34 + let mut _3: &str; // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34 + let _4: &str; // in scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:22 bb0: { - StorageLive(_1); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:5: +1:35 - StorageLive(_2); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34 - StorageLive(_3); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34 - StorageLive(_4); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:22 - _4 = const ""; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:22 + StorageLive(_1); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:5: +1:35 + StorageLive(_2); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34 + StorageLive(_3); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34 + StorageLive(_4); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:22 + _4 = const ""; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:22 // mir::Constant - // + span: $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + // + span: $DIR/no_spurious_drop_after_call.rs:9:20: 9:22 // + literal: Const { ty: &str, val: Value(Slice(..)) } - _3 = &(*_4); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34 - _2 = ::to_string(move _3) -> bb1; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:20: +1:34 + _3 = &(*_4); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34 + _2 = ::to_string(move _3) -> bb1; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:20: +1:34 // mir::Constant - // + span: $DIR/no-spurious-drop-after-call.rs:9:23: 9:32 + // + span: $DIR/no_spurious_drop_after_call.rs:9:23: 9:32 // + literal: Const { ty: for<'a> fn(&'a str) -> String {::to_string}, val: Value() } } bb1: { - StorageDead(_3); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:33: +1:34 - _1 = std::mem::drop::(move _2) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:5: +1:35 + StorageDead(_3); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:33: +1:34 + _1 = std::mem::drop::(move _2) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:5: +1:35 // mir::Constant - // + span: $DIR/no-spurious-drop-after-call.rs:9:5: 9:19 + // + span: $DIR/no_spurious_drop_after_call.rs:9:5: 9:19 // + literal: Const { ty: fn(String) {std::mem::drop::}, val: Value() } } bb2: { - StorageDead(_2); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:34: +1:35 - StorageDead(_4); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:35: +1:36 - StorageDead(_1); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:35: +1:36 - _0 = const (); // scope 0 at $DIR/no-spurious-drop-after-call.rs:+0:11: +2:2 - return; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+2:2: +2:2 + StorageDead(_2); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:34: +1:35 + StorageDead(_4); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:35: +1:36 + StorageDead(_1); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:35: +1:36 + _0 = const (); // scope 0 at $DIR/no_spurious_drop_after_call.rs:+0:11: +2:2 + return; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+2:2: +2:2 } bb3 (cleanup): { - drop(_2) -> bb4; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+1:34: +1:35 + drop(_2) -> bb4; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+1:34: +1:35 } bb4 (cleanup): { - resume; // scope 0 at $DIR/no-spurious-drop-after-call.rs:+0:1: +2:2 + resume; // scope 0 at $DIR/no_spurious_drop_after_call.rs:+0:1: +2:2 } } diff --git a/src/test/mir-opt/no_spurious_drop_after_call.rs b/src/test/mir-opt/no_spurious_drop_after_call.rs new file mode 100644 index 000000000..bb5bb9aa4 --- /dev/null +++ b/src/test/mir-opt/no_spurious_drop_after_call.rs @@ -0,0 +1,10 @@ +// ignore-wasm32-bare compiled with panic=abort by default + +// Test that after the call to `std::mem::drop` we do not generate a +// MIR drop of the argument. (We used to have a `DROP(_2)` in the code +// below, as part of bb3.) + +// EMIT_MIR no_spurious_drop_after_call.main.ElaborateDrops.before.mir +fn main() { + std::mem::drop("".to_string()); +} diff --git a/src/test/mir-opt/nrvo-simple.rs b/src/test/mir-opt/nrvo-simple.rs deleted file mode 100644 index 5786ae621..000000000 --- a/src/test/mir-opt/nrvo-simple.rs +++ /dev/null @@ -1,12 +0,0 @@ -// unit-test: RenameReturnPlace - -// EMIT_MIR nrvo_simple.nrvo.RenameReturnPlace.diff -fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] { - let mut buf = [0; 1024]; - init(&mut buf); - buf -} - -fn main() { - let _ = nrvo(|buf| { buf[4] = 4; }); -} diff --git a/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff b/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff index ce35f920b..61a16065b 100644 --- a/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff +++ b/src/test/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.diff @@ -2,42 +2,42 @@ + // MIR for `nrvo` after RenameReturnPlace fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] { - debug init => _1; // in scope 0 at $DIR/nrvo-simple.rs:+0:9: +0:13 -- let mut _0: [u8; 1024]; // return place in scope 0 at $DIR/nrvo-simple.rs:+0:39: +0:49 -+ let mut _0: [u8; 1024]; // return place in scope 0 at $DIR/nrvo-simple.rs:+1:9: +1:16 - let mut _2: [u8; 1024]; // in scope 0 at $DIR/nrvo-simple.rs:+1:9: +1:16 - let _3: (); // in scope 0 at $DIR/nrvo-simple.rs:+2:5: +2:19 - let mut _4: for<'a> fn(&'a mut [u8; 1024]); // in scope 0 at $DIR/nrvo-simple.rs:+2:5: +2:9 - let mut _5: &mut [u8; 1024]; // in scope 0 at $DIR/nrvo-simple.rs:+2:10: +2:18 - let mut _6: &mut [u8; 1024]; // in scope 0 at $DIR/nrvo-simple.rs:+2:10: +2:18 + debug init => _1; // in scope 0 at $DIR/nrvo_simple.rs:+0:9: +0:13 +- let mut _0: [u8; 1024]; // return place in scope 0 at $DIR/nrvo_simple.rs:+0:39: +0:49 ++ let mut _0: [u8; 1024]; // return place in scope 0 at $DIR/nrvo_simple.rs:+1:9: +1:16 + let mut _2: [u8; 1024]; // in scope 0 at $DIR/nrvo_simple.rs:+1:9: +1:16 + let _3: (); // in scope 0 at $DIR/nrvo_simple.rs:+2:5: +2:19 + let mut _4: for<'a> fn(&'a mut [u8; 1024]); // in scope 0 at $DIR/nrvo_simple.rs:+2:5: +2:9 + let mut _5: &mut [u8; 1024]; // in scope 0 at $DIR/nrvo_simple.rs:+2:10: +2:18 + let mut _6: &mut [u8; 1024]; // in scope 0 at $DIR/nrvo_simple.rs:+2:10: +2:18 scope 1 { -- debug buf => _2; // in scope 1 at $DIR/nrvo-simple.rs:+1:9: +1:16 -+ debug buf => _0; // in scope 1 at $DIR/nrvo-simple.rs:+1:9: +1:16 +- debug buf => _2; // in scope 1 at $DIR/nrvo_simple.rs:+1:9: +1:16 ++ debug buf => _0; // in scope 1 at $DIR/nrvo_simple.rs:+1:9: +1:16 } bb0: { -- StorageLive(_2); // scope 0 at $DIR/nrvo-simple.rs:+1:9: +1:16 -- _2 = [const 0_u8; 1024]; // scope 0 at $DIR/nrvo-simple.rs:+1:19: +1:28 -+ _0 = [const 0_u8; 1024]; // scope 0 at $DIR/nrvo-simple.rs:+1:19: +1:28 - StorageLive(_3); // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:19 - StorageLive(_4); // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:9 - _4 = _1; // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:9 - StorageLive(_5); // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18 - StorageLive(_6); // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18 -- _6 = &mut _2; // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18 -+ _6 = &mut _0; // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18 - _5 = &mut (*_6); // scope 1 at $DIR/nrvo-simple.rs:+2:10: +2:18 - _3 = move _4(move _5) -> bb1; // scope 1 at $DIR/nrvo-simple.rs:+2:5: +2:19 +- StorageLive(_2); // scope 0 at $DIR/nrvo_simple.rs:+1:9: +1:16 +- _2 = [const 0_u8; 1024]; // scope 0 at $DIR/nrvo_simple.rs:+1:19: +1:28 ++ _0 = [const 0_u8; 1024]; // scope 0 at $DIR/nrvo_simple.rs:+1:19: +1:28 + StorageLive(_3); // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:19 + StorageLive(_4); // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:9 + _4 = _1; // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:9 + StorageLive(_5); // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18 + StorageLive(_6); // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18 +- _6 = &mut _2; // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18 ++ _6 = &mut _0; // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18 + _5 = &mut (*_6); // scope 1 at $DIR/nrvo_simple.rs:+2:10: +2:18 + _3 = move _4(move _5) -> bb1; // scope 1 at $DIR/nrvo_simple.rs:+2:5: +2:19 } bb1: { - StorageDead(_5); // scope 1 at $DIR/nrvo-simple.rs:+2:18: +2:19 - StorageDead(_4); // scope 1 at $DIR/nrvo-simple.rs:+2:18: +2:19 - StorageDead(_6); // scope 1 at $DIR/nrvo-simple.rs:+2:19: +2:20 - StorageDead(_3); // scope 1 at $DIR/nrvo-simple.rs:+2:19: +2:20 -- _0 = _2; // scope 1 at $DIR/nrvo-simple.rs:+3:5: +3:8 -- StorageDead(_2); // scope 0 at $DIR/nrvo-simple.rs:+4:1: +4:2 - return; // scope 0 at $DIR/nrvo-simple.rs:+4:2: +4:2 + StorageDead(_5); // scope 1 at $DIR/nrvo_simple.rs:+2:18: +2:19 + StorageDead(_4); // scope 1 at $DIR/nrvo_simple.rs:+2:18: +2:19 + StorageDead(_6); // scope 1 at $DIR/nrvo_simple.rs:+2:19: +2:20 + StorageDead(_3); // scope 1 at $DIR/nrvo_simple.rs:+2:19: +2:20 +- _0 = _2; // scope 1 at $DIR/nrvo_simple.rs:+3:5: +3:8 +- StorageDead(_2); // scope 0 at $DIR/nrvo_simple.rs:+4:1: +4:2 + return; // scope 0 at $DIR/nrvo_simple.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/nrvo_simple.rs b/src/test/mir-opt/nrvo_simple.rs new file mode 100644 index 000000000..5786ae621 --- /dev/null +++ b/src/test/mir-opt/nrvo_simple.rs @@ -0,0 +1,12 @@ +// unit-test: RenameReturnPlace + +// EMIT_MIR nrvo_simple.nrvo.RenameReturnPlace.diff +fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] { + let mut buf = [0; 1024]; + init(&mut buf); + buf +} + +fn main() { + let _ = nrvo(|buf| { buf[4] = 4; }); +} diff --git a/src/test/mir-opt/packed-struct-drop-aligned.rs b/src/test/mir-opt/packed-struct-drop-aligned.rs deleted file mode 100644 index cb6524260..000000000 --- a/src/test/mir-opt/packed-struct-drop-aligned.rs +++ /dev/null @@ -1,17 +0,0 @@ -// ignore-wasm32-bare compiled with panic=abort by default - - -// EMIT_MIR packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir -fn main() { - let mut x = Packed(Aligned(Droppy(0))); - x.0 = Aligned(Droppy(0)); -} - -struct Aligned(Droppy); -#[repr(packed)] -struct Packed(Aligned); - -struct Droppy(usize); -impl Drop for Droppy { - fn drop(&mut self) {} -} diff --git a/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir index f9ed1036f..e52253486 100644 --- a/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir @@ -1,60 +1,60 @@ // MIR for `main` after SimplifyCfg-elaborate-drops fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/packed-struct-drop-aligned.rs:+0:11: +0:11 - let mut _1: Packed; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:9: +1:14 - let mut _2: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:24: +1:42 - let mut _3: Droppy; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+1:32: +1:41 - let mut _4: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+2:11: +2:29 - let mut _5: Droppy; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+2:19: +2:28 - let mut _6: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8 + let mut _0: (); // return place in scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:11: +0:11 + let mut _1: Packed; // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:9: +1:14 + let mut _2: Aligned; // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:24: +1:42 + let mut _3: Droppy; // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+1:32: +1:41 + let mut _4: Aligned; // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+2:11: +2:29 + let mut _5: Droppy; // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+2:19: +2:28 + let mut _6: Aligned; // in scope 0 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 scope 1 { - debug x => _1; // in scope 1 at $DIR/packed-struct-drop-aligned.rs:+1:9: +1:14 + debug x => _1; // in scope 1 at $DIR/packed_struct_drop_aligned.rs:+1:9: +1:14 } bb0: { - 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 - 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 - 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 - 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 - drop(_6) -> [return: bb4, unwind: bb3]; // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8 + 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 + 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 + 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 + 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 + drop(_6) -> [return: bb4, unwind: bb3]; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 } bb1: { - StorageDead(_1); // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:1: +3:2 - return; // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:2: +3:2 + StorageDead(_1); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 + return; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:2: +3:2 } bb2 (cleanup): { - resume; // scope 0 at $DIR/packed-struct-drop-aligned.rs:+0:1: +3:2 + resume; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:1: +3:2 } bb3 (cleanup): { - (_1.0: Aligned) = move _4; // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8 - drop(_1) -> bb2; // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:1: +3:2 + (_1.0: Aligned) = move _4; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 + drop(_1) -> bb2; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 } bb4: { - StorageDead(_6); // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8 - (_1.0: Aligned) = move _4; // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:5: +2:8 - StorageDead(_4); // scope 1 at $DIR/packed-struct-drop-aligned.rs:+2:28: +2:29 - _0 = const (); // scope 0 at $DIR/packed-struct-drop-aligned.rs:+0:11: +3:2 - drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/packed-struct-drop-aligned.rs:+3:1: +3:2 + StorageDead(_6); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 + (_1.0: Aligned) = move _4; // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:5: +2:8 + StorageDead(_4); // scope 1 at $DIR/packed_struct_drop_aligned.rs:+2:28: +2:29 + _0 = const (); // scope 0 at $DIR/packed_struct_drop_aligned.rs:+0:11: +3:2 + drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/packed_struct_drop_aligned.rs:+3:1: +3:2 } } diff --git a/src/test/mir-opt/packed_struct_drop_aligned.rs b/src/test/mir-opt/packed_struct_drop_aligned.rs new file mode 100644 index 000000000..cb6524260 --- /dev/null +++ b/src/test/mir-opt/packed_struct_drop_aligned.rs @@ -0,0 +1,17 @@ +// ignore-wasm32-bare compiled with panic=abort by default + + +// EMIT_MIR packed_struct_drop_aligned.main.SimplifyCfg-elaborate-drops.after.mir +fn main() { + let mut x = Packed(Aligned(Droppy(0))); + x.0 = Aligned(Droppy(0)); +} + +struct Aligned(Droppy); +#[repr(packed)] +struct Packed(Aligned); + +struct Droppy(usize); +impl Drop for Droppy { + fn drop(&mut self) {} +} diff --git a/src/test/mir-opt/receiver-ptr-mutability.rs b/src/test/mir-opt/receiver-ptr-mutability.rs deleted file mode 100644 index 8e2ff0451..000000000 --- a/src/test/mir-opt/receiver-ptr-mutability.rs +++ /dev/null @@ -1,20 +0,0 @@ -// EMIT_MIR receiver_ptr_mutability.main.mir_map.0.mir - -#![feature(arbitrary_self_types)] - -struct Test {} - -impl Test { - fn x(self: *const Self) { - println!("x called"); - } -} - -fn main() { - let ptr: *mut Test = std::ptr::null_mut(); - ptr.x(); - - // Test autoderefs - let ptr_ref: &&&&*mut Test = &&&&ptr; - ptr_ref.x(); -} diff --git a/src/test/mir-opt/receiver_ptr_mutability.main.mir_map.0.mir b/src/test/mir-opt/receiver_ptr_mutability.main.mir_map.0.mir deleted file mode 100644 index 45797ec06..000000000 --- a/src/test/mir-opt/receiver_ptr_mutability.main.mir_map.0.mir +++ /dev/null @@ -1,96 +0,0 @@ -// MIR for `main` 0 mir_map - -| User Type Annotations -| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:14:14: 14:23, inferred_ty: *mut Test -| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:14:14: 14:23, inferred_ty: *mut Test -| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test -| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver-ptr-mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test -| -fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/receiver-ptr-mutability.rs:+0:11: +0:11 - let _1: *mut Test as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12 - let _2: (); // in scope 0 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12 - let mut _3: *const Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12 - let mut _4: *mut Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:8 - let _6: &&&&*mut Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41 - let _7: &&&*mut Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:35: +5:41 - let _8: &&*mut Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:36: +5:41 - let _9: &*mut Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+5:37: +5:41 - let _10: (); // in scope 0 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - let mut _11: *const Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - let mut _12: *mut Test; // in scope 0 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - scope 1 { - debug ptr => _1; // in scope 1 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12 - let _5: &&&&*mut Test as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 1 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16 - scope 2 { - debug ptr_ref => _5; // in scope 2 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16 - } - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12 - _1 = null_mut::() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:26: +1:46 - // mir::Constant - // + span: $DIR/receiver-ptr-mutability.rs:14:26: 14:44 - // + literal: Const { ty: fn() -> *mut Test {null_mut::}, val: Value() } - } - - bb1: { - FakeRead(ForLet(None), _1); // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:9: +1:12 - AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/receiver-ptr-mutability.rs:+1:14: +1:23 - StorageLive(_2); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12 - StorageLive(_3); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12 - StorageLive(_4); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:8 - _4 = _1; // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:8 - _3 = move _4 as *const Test (Pointer(MutToConstPointer)); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12 - StorageDead(_4); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:7: +2:8 - _2 = Test::x(move _3) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:5: +2:12 - // mir::Constant - // + span: $DIR/receiver-ptr-mutability.rs:15:9: 15:10 - // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value() } - } - - bb2: { - StorageDead(_3); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:11: +2:12 - StorageDead(_2); // scope 1 at $DIR/receiver-ptr-mutability.rs:+2:12: +2:13 - StorageLive(_5); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16 - StorageLive(_6); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41 - StorageLive(_7); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:35: +5:41 - StorageLive(_8); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:36: +5:41 - StorageLive(_9); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:37: +5:41 - _9 = &_1; // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:37: +5:41 - _8 = &_9; // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:36: +5:41 - _7 = &_8; // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:35: +5:41 - _6 = &_7; // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41 - _5 = &(*_6); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:34: +5:41 - FakeRead(ForLet(None), _5); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:9: +5:16 - AscribeUserType(_5, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:18: +5:31 - StorageDead(_6); // scope 1 at $DIR/receiver-ptr-mutability.rs:+5:41: +5:42 - StorageLive(_10); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - StorageLive(_11); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - StorageLive(_12); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - _12 = (*(*(*(*_5)))); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - _11 = move _12 as *const Test (Pointer(MutToConstPointer)); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - StorageDead(_12); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:11: +6:12 - _10 = Test::x(move _11) -> [return: bb3, unwind: bb4]; // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:5: +6:16 - // mir::Constant - // + span: $DIR/receiver-ptr-mutability.rs:19:13: 19:14 - // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value() } - } - - bb3: { - StorageDead(_11); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:15: +6:16 - StorageDead(_10); // scope 2 at $DIR/receiver-ptr-mutability.rs:+6:16: +6:17 - _0 = const (); // scope 0 at $DIR/receiver-ptr-mutability.rs:+0:11: +7:2 - StorageDead(_9); // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2 - StorageDead(_8); // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2 - StorageDead(_7); // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2 - StorageDead(_5); // scope 1 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2 - StorageDead(_1); // scope 0 at $DIR/receiver-ptr-mutability.rs:+7:1: +7:2 - return; // scope 0 at $DIR/receiver-ptr-mutability.rs:+7:2: +7:2 - } - - bb4 (cleanup): { - resume; // scope 0 at $DIR/receiver-ptr-mutability.rs:+0:1: +7:2 - } -} diff --git a/src/test/mir-opt/remove-never-const.rs b/src/test/mir-opt/remove-never-const.rs deleted file mode 100644 index 16095cfdd..000000000 --- a/src/test/mir-opt/remove-never-const.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This was originally a regression test for #66975 - ensure that we do not generate never typed -// consts in codegen. We also have tests for this that catches the error, see -// src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs. - -// Force generation of optimized mir for functions that do not reach codegen. -// compile-flags: --emit mir,link - -#![feature(never_type)] - -struct PrintName(T); - -impl PrintName { - const VOID: ! = panic!(); -} - -// EMIT_MIR remove_never_const.no_codegen.PreCodegen.after.mir -fn no_codegen() { - let _ = PrintName::::VOID; -} - -fn main() {} diff --git a/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir b/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir index 76bdd23be..8eb0e9c8f 100644 --- a/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir +++ b/src/test/mir-opt/remove_never_const.no_codegen.PreCodegen.after.mir @@ -1,11 +1,11 @@ // MIR for `no_codegen` after PreCodegen fn no_codegen() -> () { - let mut _0: (); // return place in scope 0 at $DIR/remove-never-const.rs:+0:20: +0:20 + let mut _0: (); // return place in scope 0 at $DIR/remove_never_const.rs:+0:20: +0:20 scope 1 { } bb0: { - unreachable; // scope 0 at $DIR/remove-never-const.rs:+1:13: +1:33 + unreachable; // scope 0 at $DIR/remove_never_const.rs:+1:13: +1:33 } } diff --git a/src/test/mir-opt/remove_never_const.rs b/src/test/mir-opt/remove_never_const.rs new file mode 100644 index 000000000..16095cfdd --- /dev/null +++ b/src/test/mir-opt/remove_never_const.rs @@ -0,0 +1,21 @@ +// This was originally a regression test for #66975 - ensure that we do not generate never typed +// consts in codegen. We also have tests for this that catches the error, see +// src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs. + +// Force generation of optimized mir for functions that do not reach codegen. +// compile-flags: --emit mir,link + +#![feature(never_type)] + +struct PrintName(T); + +impl PrintName { + const VOID: ! = panic!(); +} + +// EMIT_MIR remove_never_const.no_codegen.PreCodegen.after.mir +fn no_codegen() { + let _ = PrintName::::VOID; +} + +fn main() {} diff --git a/src/test/mir-opt/remove_zsts.get_union.PreCodegen.after.mir b/src/test/mir-opt/remove_zsts.get_union.PreCodegen.after.mir new file mode 100644 index 000000000..12e914e25 --- /dev/null +++ b/src/test/mir-opt/remove_zsts.get_union.PreCodegen.after.mir @@ -0,0 +1,10 @@ +// MIR for `get_union` after PreCodegen + +fn get_union() -> Foo { + let mut _0: Foo; // return place in scope 0 at $DIR/remove_zsts.rs:+0:19: +0:22 + + bb0: { + Deinit(_0); // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 + return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2:2 + } +} diff --git a/src/test/mir-opt/remove_zsts.get_union.RemoveZsts.diff b/src/test/mir-opt/remove_zsts.get_union.RemoveZsts.diff new file mode 100644 index 000000000..169b7b105 --- /dev/null +++ b/src/test/mir-opt/remove_zsts.get_union.RemoveZsts.diff @@ -0,0 +1,19 @@ +- // MIR for `get_union` before RemoveZsts ++ // MIR for `get_union` after RemoveZsts + + 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: { + 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 ++ 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 + 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/src/test/mir-opt/remove_zsts.rs b/src/test/mir-opt/remove_zsts.rs new file mode 100644 index 000000000..1cf7ad6e3 --- /dev/null +++ b/src/test/mir-opt/remove_zsts.rs @@ -0,0 +1,14 @@ +union Foo { + x: (), + y: u64, +} + +// EMIT_MIR remove_zsts.get_union.RemoveZsts.diff +// EMIT_MIR remove_zsts.get_union.PreCodegen.after.mir +fn get_union() -> Foo { + Foo { x: () } +} + +fn main() { + get_union(); +} diff --git a/src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir b/src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir deleted file mode 100644 index 7d9e60462..000000000 --- a/src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir +++ /dev/null @@ -1,15 +0,0 @@ -// MIR for `get_union` after RemoveZsts - -fn get_union() -> Foo { - let mut _0: Foo; // return place in scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+0:19: +0:22 - let mut _1: (); // in scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+1:14: +1:16 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+1:14: +1:16 - nop; // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+1:14: +1:16 - Deinit(_0); // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+1:5: +1:18 - (_0.0: ()) = move _1; // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+1:5: +1:18 - StorageDead(_1); // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+1:17: +1:18 - return; // scope 0 at $DIR/remove_zsts_dont_touch_unions.rs:+2:2: +2:2 - } -} diff --git a/src/test/mir-opt/remove_zsts_dont_touch_unions.rs b/src/test/mir-opt/remove_zsts_dont_touch_unions.rs deleted file mode 100644 index 8b9de9b4d..000000000 --- a/src/test/mir-opt/remove_zsts_dont_touch_unions.rs +++ /dev/null @@ -1,19 +0,0 @@ -// unit-test: RemoveZsts - -// Ensure RemoveZsts doesn't remove ZST assignments to union fields, -// which causes problems in Miri. - -union Foo { - x: (), - y: u64, -} - -// EMIT_MIR remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir -fn get_union() -> Foo { - Foo { x: () } -} - - -fn main() { - get_union(); -} diff --git a/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir index fe57e32a7..7b69b3e07 100644 --- a/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir @@ -68,9 +68,7 @@ fn array_casts() -> () { StorageLive(_3); // scope 1 at $DIR/retag.rs:+2:13: +2:19 StorageLive(_4); // scope 1 at $DIR/retag.rs:+2:13: +2:19 _4 = &mut _1; // scope 1 at $DIR/retag.rs:+2:13: +2:19 - Retag(_4); // scope 1 at $DIR/retag.rs:+2:13: +2:19 _3 = &raw mut (*_4); // scope 1 at $DIR/retag.rs:+2:13: +2:19 - Retag([raw] _3); // scope 1 at $DIR/retag.rs:+2:13: +2:19 _2 = move _3 as *mut usize (Pointer(ArrayToPointer)); // scope 1 at $DIR/retag.rs:+2:13: +2:33 StorageDead(_3); // scope 1 at $DIR/retag.rs:+2:32: +2:33 StorageDead(_4); // scope 1 at $DIR/retag.rs:+2:33: +2:34 @@ -96,9 +94,7 @@ fn array_casts() -> () { StorageLive(_10); // scope 4 at $DIR/retag.rs:+6:13: +6:15 StorageLive(_11); // scope 4 at $DIR/retag.rs:+6:13: +6:15 _11 = &_8; // scope 4 at $DIR/retag.rs:+6:13: +6:15 - Retag(_11); // scope 4 at $DIR/retag.rs:+6:13: +6:15 _10 = &raw const (*_11); // scope 4 at $DIR/retag.rs:+6:13: +6:15 - Retag([raw] _10); // scope 4 at $DIR/retag.rs:+6:13: +6:15 _9 = move _10 as *const usize (Pointer(ArrayToPointer)); // scope 4 at $DIR/retag.rs:+6:13: +6:31 StorageDead(_10); // scope 4 at $DIR/retag.rs:+6:30: +6:31 StorageDead(_11); // scope 4 at $DIR/retag.rs:+6:31: +6:32 @@ -119,7 +115,6 @@ fn array_casts() -> () { StorageDead(_17); // scope 6 at $DIR/retag.rs:+7:33: +7:34 _15 = (*_16); // scope 6 at $DIR/retag.rs:+7:25: +7:34 _14 = &_15; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Retag(_14); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_18); // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _35 = const _; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL // mir::Constant @@ -127,7 +122,6 @@ 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 - Retag(_18); // 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 @@ -164,15 +158,11 @@ fn array_casts() -> () { StorageLive(_30); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_31); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _31 = &(*_20); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Retag(_31); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _30 = &(*_31); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Retag(_30); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_32); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL StorageLive(_33); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL _33 = &(*_21); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - Retag(_33); // 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 - Retag(_32); // 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 diff --git a/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir b/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir index cdc413c56..14f297e94 100644 --- a/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir +++ b/src/test/mir-opt/retag.core.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir @@ -6,7 +6,6 @@ fn std::ptr::drop_in_place(_1: *mut Test) -> () { let mut _3: (); // in scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 bb0: { - Retag([raw] _1); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 _2 = &mut (*_1); // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 _3 = ::drop(move _2) -> bb1; // scope 0 at $SRC_DIR/core/src/ptr/mod.rs:+0:1: +0:56 // mir::Constant diff --git a/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir index 96fc7e649..9e5c119a2 100644 --- a/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag.main-{closure#0}.SimplifyCfg-elaborate-drops.after.mir @@ -15,7 +15,6 @@ fn main::{closure#0}(_1: &[closure@main::{closure#0}], _2: &i32) -> &i32 { _3 = _2; // scope 0 at $DIR/retag.rs:+1:18: +1:19 Retag(_3); // scope 0 at $DIR/retag.rs:+1:18: +1:19 _0 = &(*_2); // scope 1 at $DIR/retag.rs:+2:9: +2:10 - Retag(_0); // scope 1 at $DIR/retag.rs:+2:9: +2:10 StorageDead(_3); // scope 0 at $DIR/retag.rs:+3:5: +3:6 return; // scope 0 at $DIR/retag.rs:+3:6: +3:6 } diff --git a/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir index 81225b44e..b853e4505 100644 --- a/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir @@ -65,13 +65,10 @@ fn main() -> () { 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 _4 = &_5; // scope 1 at $DIR/retag.rs:+3:17: +3:36 - Retag(_4); // 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 _7 = &mut _1; // scope 1 at $DIR/retag.rs:+3:29: +3:35 - Retag(_7); // scope 1 at $DIR/retag.rs:+3:29: +3:35 _6 = &mut (*_7); // scope 1 at $DIR/retag.rs:+3:29: +3:35 - Retag([2phase] _6); // scope 1 at $DIR/retag.rs:+3:29: +3:35 _3 = Test::foo(move _4, move _6) -> [return: bb1, unwind: bb8]; // scope 1 at $DIR/retag.rs:+3:17: +3:36 // mir::Constant // + span: $DIR/retag.rs:33:25: 33:28 @@ -93,7 +90,6 @@ fn main() -> () { _9 = move _3; // scope 2 at $DIR/retag.rs:+4:19: +4:20 Retag(_9); // scope 2 at $DIR/retag.rs:+4:19: +4:20 _8 = &mut (*_9); // scope 2 at $DIR/retag.rs:+4:19: +4:20 - Retag(_8); // scope 2 at $DIR/retag.rs:+4:19: +4:20 StorageDead(_9); // scope 2 at $DIR/retag.rs:+4:22: +4:23 StorageLive(_10); // scope 3 at $DIR/retag.rs:+5:13: +5:14 _10 = move _8; // scope 3 at $DIR/retag.rs:+5:17: +5:18 @@ -101,7 +97,6 @@ fn main() -> () { StorageLive(_11); // scope 4 at $DIR/retag.rs:+7:13: +7:15 StorageLive(_12); // scope 4 at $DIR/retag.rs:+7:18: +7:29 _12 = &raw mut (*_10); // scope 4 at $DIR/retag.rs:+7:18: +7:19 - Retag([raw] _12); // scope 4 at $DIR/retag.rs:+7:18: +7:19 _11 = _12; // scope 4 at $DIR/retag.rs:+7:18: +7:29 StorageDead(_12); // scope 4 at $DIR/retag.rs:+7:29: +7:30 _2 = const (); // scope 1 at $DIR/retag.rs:+2:5: +8:6 @@ -122,9 +117,7 @@ fn main() -> () { StorageLive(_17); // scope 6 at $DIR/retag.rs:+15:16: +15:18 StorageLive(_18); // scope 6 at $DIR/retag.rs:+15:16: +15:18 _18 = &_1; // scope 6 at $DIR/retag.rs:+15:16: +15:18 - Retag(_18); // scope 6 at $DIR/retag.rs:+15:16: +15:18 _17 = &(*_18); // scope 6 at $DIR/retag.rs:+15:16: +15:18 - Retag(_17); // scope 6 at $DIR/retag.rs:+15:16: +15:18 _15 = move _16(move _17) -> bb3; // scope 6 at $DIR/retag.rs:+15:14: +15:19 } @@ -139,7 +132,6 @@ fn main() -> () { 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 _20 = &_21; // scope 7 at $DIR/retag.rs:+18:5: +18:24 - Retag(_20); // 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 _28 = const _; // scope 7 at $DIR/retag.rs:+18:21: +18:23 @@ -148,9 +140,7 @@ fn main() -> () { // + literal: Const { ty: &i32, val: Unevaluated(main, [], Some(promoted[0])) } Retag(_28); // scope 7 at $DIR/retag.rs:+18:21: +18:23 _23 = &(*_28); // scope 7 at $DIR/retag.rs:+18:21: +18:23 - Retag(_23); // scope 7 at $DIR/retag.rs:+18:21: +18:23 _22 = &(*_23); // scope 7 at $DIR/retag.rs:+18:21: +18:23 - Retag(_22); // scope 7 at $DIR/retag.rs:+18:21: +18:23 _19 = Test::foo_shr(move _20, move _22) -> [return: bb4, unwind: bb7]; // scope 7 at $DIR/retag.rs:+18:5: +18:24 // mir::Constant // + span: $DIR/retag.rs:48:13: 48:20 @@ -171,7 +161,6 @@ fn main() -> () { StorageLive(_25); // scope 7 at $DIR/retag.rs:+21:9: +21:11 StorageLive(_26); // scope 7 at $DIR/retag.rs:+21:14: +21:28 _26 = &raw const (*_15); // scope 7 at $DIR/retag.rs:+21:14: +21:16 - Retag([raw] _26); // scope 7 at $DIR/retag.rs:+21:14: +21:16 _25 = _26; // scope 7 at $DIR/retag.rs:+21:14: +21:28 StorageDead(_26); // scope 7 at $DIR/retag.rs:+21:28: +21:29 StorageLive(_27); // scope 8 at $DIR/retag.rs:+23:5: +23:18 diff --git a/src/test/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir index 08fd655ae..4b50205fa 100644 --- a/src/test/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir +++ b/src/test/mir-opt/retag.{impl#0}-foo.SimplifyCfg-elaborate-drops.after.mir @@ -11,9 +11,7 @@ fn ::foo(_1: &Test, _2: &mut i32) -> &mut i32 Retag([fn entry] _2); // scope 0 at $DIR/retag.rs:+0:23: +0:24 StorageLive(_3); // scope 0 at $DIR/retag.rs:+1:9: +1:10 _3 = &mut (*_2); // scope 0 at $DIR/retag.rs:+1:9: +1:10 - Retag(_3); // scope 0 at $DIR/retag.rs:+1:9: +1:10 _0 = &mut (*_3); // scope 0 at $DIR/retag.rs:+1:9: +1:10 - Retag(_0); // scope 0 at $DIR/retag.rs:+1:9: +1:10 StorageDead(_3); // scope 0 at $DIR/retag.rs:+2:5: +2:6 return; // scope 0 at $DIR/retag.rs:+2:6: +2:6 } diff --git a/src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff b/src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff deleted file mode 100644 index c3e503bf2..000000000 --- a/src/test/mir-opt/rustc.try_identity.DestinationPropagation.diff +++ /dev/null @@ -1,72 +0,0 @@ -- // MIR for `try_identity` before DestinationPropagation -+ // MIR for `try_identity` after DestinationPropagation - - fn try_identity(_1: std::result::Result) -> std::result::Result { - debug x => _1; // in scope 0 at $DIR/simplify_try.rs:6:17: 6:18 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:6:41: 6:57 - let _2: u32; // in scope 0 at $DIR/simplify_try.rs:7:9: 7:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:7:13: 7:15 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:7:13: 7:14 - let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15 - let _6: i32; // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15 - let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15 - let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15 - let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:7:14: 7:15 - let _10: u32; // in scope 0 at $DIR/simplify_try.rs:7:13: 7:15 - let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:8:8: 8:9 - scope 1 { - debug y => _2; // in scope 1 at $DIR/simplify_try.rs:7:9: 7:10 - } - scope 2 { - debug err => _6; // in scope 2 at $DIR/simplify_try.rs:7:14: 7:15 - scope 3 { - scope 7 { - debug t => _9; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL - } - scope 8 { - debug v => _8; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL - let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:7:14: 7:15 - } - } - } - scope 4 { - debug val => _10; // in scope 4 at $DIR/simplify_try.rs:7:13: 7:15 - scope 5 { - } - } - scope 6 { -- debug self => _4; // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL -+ debug self => _0; // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify_try.rs:7:9: 7:10 -- StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:7:13: 7:15 -- StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:7:13: 7:14 -- _4 = _1; // scope 0 at $DIR/simplify_try.rs:7:13: 7:14 -- _3 = move _4; // scope 6 at $SRC_DIR/libcore/result.rs:LL:COL -- StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:7:14: 7:15 -- _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:7:14: 7:15 -+ nop; // scope 0 at $DIR/simplify_try.rs:7:13: 7:15 -+ nop; // scope 0 at $DIR/simplify_try.rs:7:13: 7:14 -+ _0 = _1; // scope 0 at $DIR/simplify_try.rs:7:13: 7:14 -+ nop; // scope 6 at $SRC_DIR/libcore/result.rs:LL:COL -+ nop; // scope 0 at $DIR/simplify_try.rs:7:14: 7:15 -+ _5 = discriminant(_0); // scope 0 at $DIR/simplify_try.rs:7:14: 7:15 - goto -> bb1; // scope 0 at $DIR/simplify_try.rs:7:14: 7:15 - } - - bb1: { -- _0 = move _3; // scope 1 at $DIR/simplify_try.rs:8:5: 8:10 -- StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:7:15: 7:16 -+ nop; // scope 1 at $DIR/simplify_try.rs:8:5: 8:10 -+ nop; // scope 0 at $DIR/simplify_try.rs:7:15: 7:16 - StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:9:1: 9:2 - goto -> bb2; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2 - } - - bb2: { - return; // scope 0 at $DIR/simplify_try.rs:9:2: 9:2 - } - } - diff --git a/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index f25b3ce72..b28c6f687 100644 --- a/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/src/test/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -22,9 +22,6 @@ let mut _18: 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 - 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 - } } } } @@ -95,18 +92,11 @@ 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 - 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 - 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 +- _17 = >::from(move _18) -> bb8; // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL ++ _17 = >::from(move _18) -> bb7; // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/result.rs:LL:COL + // + literal: Const { ty: fn(i32) -> i32 {>::from}, val: Value() } } - bb5: { @@ -152,5 +142,20 @@ + _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 } + +- bb8: { ++ bb7: { + 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 + 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 + 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 + } } diff --git a/src/test/mir-opt/simple-match.rs b/src/test/mir-opt/simple-match.rs deleted file mode 100644 index 103033c4e..000000000 --- a/src/test/mir-opt/simple-match.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Test that we don't generate unnecessarily large MIR for very simple matches - - -// EMIT_MIR simple_match.match_bool.mir_map.0.mir -fn match_bool(x: bool) -> usize { - match x { - true => 10, - _ => 20, - } -} - -fn main() {} diff --git a/src/test/mir-opt/simple_match.match_bool.mir_map.0.mir b/src/test/mir-opt/simple_match.match_bool.mir_map.0.mir deleted file mode 100644 index 3bef6aa05..000000000 --- a/src/test/mir-opt/simple_match.match_bool.mir_map.0.mir +++ /dev/null @@ -1,29 +0,0 @@ -// MIR for `match_bool` 0 mir_map - -fn match_bool(_1: bool) -> usize { - debug x => _1; // in scope 0 at $DIR/simple-match.rs:+0:15: +0:16 - let mut _0: usize; // return place in scope 0 at $DIR/simple-match.rs:+0:27: +0:32 - - bb0: { - FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/simple-match.rs:+1:11: +1:12 - switchInt(_1) -> [false: bb2, otherwise: bb1]; // scope 0 at $DIR/simple-match.rs:+1:5: +1:12 - } - - bb1: { - falseEdge -> [real: bb3, imaginary: bb2]; // scope 0 at $DIR/simple-match.rs:+2:9: +2:13 - } - - bb2: { - _0 = const 20_usize; // scope 0 at $DIR/simple-match.rs:+3:14: +3:16 - goto -> bb4; // scope 0 at $DIR/simple-match.rs:+3:14: +3:16 - } - - bb3: { - _0 = const 10_usize; // scope 0 at $DIR/simple-match.rs:+2:17: +2:19 - goto -> bb4; // scope 0 at $DIR/simple-match.rs:+2:17: +2:19 - } - - bb4: { - return; // scope 0 at $DIR/simple-match.rs:+5:2: +5:2 - } -} diff --git a/src/test/mir-opt/simplify-arm-identity.rs b/src/test/mir-opt/simplify-arm-identity.rs deleted file mode 100644 index cf6ff57aa..000000000 --- a/src/test/mir-opt/simplify-arm-identity.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Checks that `SimplifyArmIdentity` is not applied if enums have incompatible layouts. -// Regression test for issue #66856. -// -// compile-flags: -Zmir-opt-level=3 -// EMIT_MIR_FOR_EACH_BIT_WIDTH - -// This pass is broken since deaggregation changed -// ignore-test - -enum Src { - Foo(u8), - Bar, -} - -enum Dst { - Foo(u8), -} - -// EMIT_MIR simplify_arm_identity.main.SimplifyArmIdentity.diff -fn main() { - let e: Src = Src::Foo(0); - let _: Dst = match e { - Src::Foo(x) => Dst::Foo(x), - Src::Bar => Dst::Foo(0), - }; -} diff --git a/src/test/mir-opt/simplify-arm.rs b/src/test/mir-opt/simplify-arm.rs deleted file mode 100644 index c247872e2..000000000 --- a/src/test/mir-opt/simplify-arm.rs +++ /dev/null @@ -1,50 +0,0 @@ -// compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts -// EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_result.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff - -// This pass is broken since deaggregation changed -// ignore-test - -fn id(o: Option) -> Option { - match o { - Some(v) => Some(v), - None => None, - } -} - -fn id_result(r: Result) -> Result { - match r { - Ok(x) => Ok(x), - Err(y) => Err(y), - } -} - -fn into_result(r: Result) -> Result { - r -} - -fn from_error(e: E) -> Result { - Err(e) -} - -// This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure, -// so the relevant desugar is copied inline in order to keep the test testing the same thing. -// FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR -// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not. -fn id_try(r: Result) -> Result { - let x = match into_result(r) { - Err(e) => return from_error(From::from(e)), - Ok(v) => v, - }; - Ok(x) -} - -fn main() { - id(None); - id_result(Ok(4)); - id_try(Ok(4)); -} diff --git a/src/test/mir-opt/simplify-locals-fixedpoint.rs b/src/test/mir-opt/simplify-locals-fixedpoint.rs deleted file mode 100644 index 78b1f9f55..000000000 --- a/src/test/mir-opt/simplify-locals-fixedpoint.rs +++ /dev/null @@ -1,15 +0,0 @@ -// compile-flags: -Zmir-opt-level=1 - -fn foo() { - if let (Some(a), None) = (Option::::None, Option::::None) { - if a > 42u8 { - - } - } -} - -fn main() { - foo::<()>(); -} - -// EMIT_MIR simplify_locals_fixedpoint.foo.SimplifyLocals.diff diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts.rs b/src/test/mir-opt/simplify-locals-removes-unused-consts.rs deleted file mode 100644 index 39b7911d4..000000000 --- a/src/test/mir-opt/simplify-locals-removes-unused-consts.rs +++ /dev/null @@ -1,18 +0,0 @@ -// unit-test: SimplifyLocals -// compile-flags: -C overflow-checks=no - -fn use_zst(_: ((), ())) {} - -struct Temp { - x: u8, -} - -fn use_u8(_: u8) {} - -// EMIT_MIR simplify_locals_removes_unused_consts.main.SimplifyLocals.diff -fn main() { - let ((), ()) = ((), ()); - use_zst(((), ())); - - use_u8((Temp { x: 40 }).x + 2); -} diff --git a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs b/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs deleted file mode 100644 index d09bd92c4..000000000 --- a/src/test/mir-opt/simplify-locals-removes-unused-discriminant-reads.rs +++ /dev/null @@ -1,14 +0,0 @@ -// unit-test: SimplifyLocals - -fn map(x: Option>) -> Option> { - match x { - None => None, - Some(x) => Some(x), - } -} - -fn main() { - map(None); -} - -// EMIT_MIR simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff diff --git a/src/test/mir-opt/simplify-locals.rs b/src/test/mir-opt/simplify-locals.rs deleted file mode 100644 index 89d9391f8..000000000 --- a/src/test/mir-opt/simplify-locals.rs +++ /dev/null @@ -1,81 +0,0 @@ -// unit-test: SimplifyLocals - - -#![feature(thread_local)] - -#[derive(Copy, Clone)] -enum E { - A, - B, -} - -// EMIT_MIR simplify_locals.c.SimplifyLocals.diff -fn c() { - let bytes = [0u8; 10]; - // Unused cast - let _: &[u8] = &bytes; -} - -// EMIT_MIR simplify_locals.d1.SimplifyLocals.diff -fn d1() { - // Unused set discriminant - let _ = E::A; -} - -// EMIT_MIR simplify_locals.d2.SimplifyLocals.diff -fn d2() { - // Unused set discriminant - {(10, E::A)}.1 = E::B; -} - -// EMIT_MIR simplify_locals.r.SimplifyLocals.diff -fn r() { - let mut a = 1; - // Unused references - let _ = &a; - let _ = &mut a; -} - -#[thread_local] static mut X: u32 = 0; - -// EMIT_MIR simplify_locals.t1.SimplifyLocals.diff -fn t1() { - // Unused thread local - unsafe { X }; -} - -// EMIT_MIR simplify_locals.t2.SimplifyLocals.diff -fn t2() { - // Unused thread local - unsafe { &mut X }; -} - -// EMIT_MIR simplify_locals.t3.SimplifyLocals.diff -fn t3() { - // Unused thread local - unsafe { *&mut X }; -} - -// EMIT_MIR simplify_locals.t4.SimplifyLocals.diff -fn t4() -> u32 { - // Used thread local - unsafe { X + 1 } -} - -// EMIT_MIR simplify_locals.expose_addr.SimplifyLocals.diff -fn expose_addr(p: *const usize) { - // Used pointer to address cast. Has a side effect of exposing the provenance. - p as usize; -} - -fn main() { - c(); - d1(); - d2(); - r(); - t1(); - t2(); - t3(); - t4(); - expose_addr(&0); -} diff --git a/src/test/mir-opt/simplify_arm.rs b/src/test/mir-opt/simplify_arm.rs new file mode 100644 index 000000000..c247872e2 --- /dev/null +++ b/src/test/mir-opt/simplify_arm.rs @@ -0,0 +1,50 @@ +// compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts +// EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff +// EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff +// EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff +// EMIT_MIR simplify_arm.id_result.SimplifyBranchSame.diff +// EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff +// EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff + +// This pass is broken since deaggregation changed +// ignore-test + +fn id(o: Option) -> Option { + match o { + Some(v) => Some(v), + None => None, + } +} + +fn id_result(r: Result) -> Result { + match r { + Ok(x) => Ok(x), + Err(y) => Err(y), + } +} + +fn into_result(r: Result) -> Result { + r +} + +fn from_error(e: E) -> Result { + Err(e) +} + +// This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure, +// so the relevant desugar is copied inline in order to keep the test testing the same thing. +// FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR +// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not. +fn id_try(r: Result) -> Result { + let x = match into_result(r) { + Err(e) => return from_error(From::from(e)), + Ok(v) => v, + }; + Ok(x) +} + +fn main() { + id(None); + id_result(Ok(4)); + id_try(Ok(4)); +} diff --git a/src/test/mir-opt/simplify_arm_identity.rs b/src/test/mir-opt/simplify_arm_identity.rs new file mode 100644 index 000000000..cf6ff57aa --- /dev/null +++ b/src/test/mir-opt/simplify_arm_identity.rs @@ -0,0 +1,26 @@ +// Checks that `SimplifyArmIdentity` is not applied if enums have incompatible layouts. +// Regression test for issue #66856. +// +// compile-flags: -Zmir-opt-level=3 +// EMIT_MIR_FOR_EACH_BIT_WIDTH + +// This pass is broken since deaggregation changed +// ignore-test + +enum Src { + Foo(u8), + Bar, +} + +enum Dst { + Foo(u8), +} + +// EMIT_MIR simplify_arm_identity.main.SimplifyArmIdentity.diff +fn main() { + let e: Src = Src::Foo(0); + let _: Dst = match e { + Src::Foo(x) => Dst::Foo(x), + Src::Bar => Dst::Foo(0), + }; +} diff --git a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff index 5d7517e4e..1a5143aa0 100644 --- a/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.c.SimplifyLocals.diff @@ -2,32 +2,32 @@ + // MIR for `c` after SimplifyLocals fn c() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:8: +0:8 - let _1: [u8; 10]; // in scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14 -- let mut _2: &[u8]; // in scope 0 at $DIR/simplify-locals.rs:+3:20: +3:26 -- let mut _3: &[u8; 10]; // in scope 0 at $DIR/simplify-locals.rs:+3:20: +3:26 -- let _4: &[u8; 10]; // in scope 0 at $DIR/simplify-locals.rs:+3:20: +3:26 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:8: +0:8 + let _1: [u8; 10]; // in scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14 +- let mut _2: &[u8]; // in scope 0 at $DIR/simplify_locals.rs:+3:20: +3:26 +- let mut _3: &[u8; 10]; // in scope 0 at $DIR/simplify_locals.rs:+3:20: +3:26 +- let _4: &[u8; 10]; // in scope 0 at $DIR/simplify_locals.rs:+3:20: +3:26 scope 1 { - debug bytes => _1; // in scope 1 at $DIR/simplify-locals.rs:+1:9: +1:14 + debug bytes => _1; // in scope 1 at $DIR/simplify_locals.rs:+1:9: +1:14 scope 2 { } } bb0: { - StorageLive(_1); // scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14 - _1 = [const 0_u8; 10]; // scope 0 at $DIR/simplify-locals.rs:+1:17: +1:26 -- StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26 -- StorageLive(_3); // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26 -- StorageLive(_4); // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26 -- _4 = &_1; // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26 -- _3 = &(*_4); // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26 -- _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 1 at $DIR/simplify-locals.rs:+3:20: +3:26 -- StorageDead(_3); // scope 1 at $DIR/simplify-locals.rs:+3:25: +3:26 -- StorageDead(_4); // scope 1 at $DIR/simplify-locals.rs:+3:26: +3:27 -- StorageDead(_2); // scope 1 at $DIR/simplify-locals.rs:+3:26: +3:27 - _0 = const (); // scope 0 at $DIR/simplify-locals.rs:+0:8: +4:2 - StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:+4:1: +4:2 - return; // scope 0 at $DIR/simplify-locals.rs:+4:2: +4:2 + StorageLive(_1); // scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14 + _1 = [const 0_u8; 10]; // scope 0 at $DIR/simplify_locals.rs:+1:17: +1:26 +- StorageLive(_2); // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26 +- StorageLive(_3); // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26 +- StorageLive(_4); // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26 +- _4 = &_1; // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26 +- _3 = &(*_4); // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26 +- _2 = move _3 as &[u8] (Pointer(Unsize)); // scope 1 at $DIR/simplify_locals.rs:+3:20: +3:26 +- StorageDead(_3); // scope 1 at $DIR/simplify_locals.rs:+3:25: +3:26 +- StorageDead(_4); // scope 1 at $DIR/simplify_locals.rs:+3:26: +3:27 +- StorageDead(_2); // scope 1 at $DIR/simplify_locals.rs:+3:26: +3:27 + _0 = const (); // scope 0 at $DIR/simplify_locals.rs:+0:8: +4:2 + StorageDead(_1); // scope 0 at $DIR/simplify_locals.rs:+4:1: +4:2 + return; // scope 0 at $DIR/simplify_locals.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff index a9ea8869a..6426bf926 100644 --- a/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.d1.SimplifyLocals.diff @@ -2,18 +2,18 @@ + // MIR for `d1` after SimplifyLocals fn d1() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9 -- let mut _1: E; // in scope 0 at $DIR/simplify-locals.rs:+2:13: +2:17 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 +- let mut _1: E; // in scope 0 at $DIR/simplify_locals.rs:+2:13: +2:17 scope 1 { } 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 -- 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 +- 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 +- 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/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff index 6a89e4584..db5ab182d 100644 --- a/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.d2.SimplifyLocals.diff @@ -2,28 +2,28 @@ + // MIR for `d2` after SimplifyLocals fn d2() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9 -- let mut _1: E; // in scope 0 at $DIR/simplify-locals.rs:+2:22: +2:26 -- let mut _2: (i32, E); // in scope 0 at $DIR/simplify-locals.rs:+2:5: +2:17 -- let mut _3: E; // in scope 0 at $DIR/simplify-locals.rs:+2:11: +2:15 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 +- let mut _1: E; // in scope 0 at $DIR/simplify_locals.rs:+2:22: +2:26 +- let mut _2: (i32, E); // in scope 0 at $DIR/simplify_locals.rs:+2:5: +2:17 +- let mut _3: E; // in scope 0 at $DIR/simplify_locals.rs:+2:11: +2:15 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 -- 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 -- 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 -- StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:+2:26: +2:27 - _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 +- 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 +- 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 +- 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 +- StorageDead(_2); // scope 0 at $DIR/simplify_locals.rs:+2:26: +2:27 + _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/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff index 204a1bffc..c707b0da0 100644 --- a/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.expose_addr.SimplifyLocals.diff @@ -2,20 +2,20 @@ + // MIR for `expose_addr` after SimplifyLocals fn expose_addr(_1: *const usize) -> () { - debug p => _1; // in scope 0 at $DIR/simplify-locals.rs:+0:16: +0:17 - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:33: +0:33 - let _2: usize; // in scope 0 at $DIR/simplify-locals.rs:+2:5: +2:15 - let mut _3: *const usize; // in scope 0 at $DIR/simplify-locals.rs:+2:5: +2:6 + debug p => _1; // in scope 0 at $DIR/simplify_locals.rs:+0:16: +0:17 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:33: +0:33 + let _2: usize; // in scope 0 at $DIR/simplify_locals.rs:+2:5: +2:15 + let mut _3: *const usize; // in scope 0 at $DIR/simplify_locals.rs:+2:5: +2:6 bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:15 - StorageLive(_3); // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:6 - _3 = _1; // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:6 - _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:15 - StorageDead(_3); // scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15 - StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:+2:15: +2:16 - _0 = const (); // scope 0 at $DIR/simplify-locals.rs:+0:33: +3:2 - return; // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2 + StorageLive(_2); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:15 + StorageLive(_3); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:6 + _3 = _1; // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:6 + _2 = move _3 as usize (PointerExposeAddress); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:15 + StorageDead(_3); // scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15 + StorageDead(_2); // scope 0 at $DIR/simplify_locals.rs:+2:15: +2:16 + _0 = const (); // scope 0 at $DIR/simplify_locals.rs:+0:33: +3:2 + return; // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff index 329e2a65a..ff6eb2cff 100644 --- a/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.r.SimplifyLocals.diff @@ -2,12 +2,12 @@ + // MIR for `r` after SimplifyLocals fn r() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:8: +0:8 - let mut _1: i32; // in scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14 -- let mut _2: &i32; // in scope 0 at $DIR/simplify-locals.rs:+3:13: +3:15 -- let mut _3: &mut i32; // in scope 0 at $DIR/simplify-locals.rs:+4:13: +4:19 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:8: +0:8 + let mut _1: i32; // in scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14 +- let mut _2: &i32; // in scope 0 at $DIR/simplify_locals.rs:+3:13: +3:15 +- let mut _3: &mut i32; // in scope 0 at $DIR/simplify_locals.rs:+4:13: +4:19 scope 1 { - debug a => _1; // in scope 1 at $DIR/simplify-locals.rs:+1:9: +1:14 + debug a => _1; // in scope 1 at $DIR/simplify_locals.rs:+1:9: +1:14 scope 2 { scope 3 { } @@ -15,17 +15,17 @@ } bb0: { - StorageLive(_1); // scope 0 at $DIR/simplify-locals.rs:+1:9: +1:14 - _1 = const 1_i32; // scope 0 at $DIR/simplify-locals.rs:+1:17: +1:18 -- StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:+3:13: +3:15 -- _2 = &_1; // scope 1 at $DIR/simplify-locals.rs:+3:13: +3:15 -- StorageDead(_2); // scope 1 at $DIR/simplify-locals.rs:+3:15: +3:16 -- StorageLive(_3); // scope 2 at $DIR/simplify-locals.rs:+4:13: +4:19 -- _3 = &mut _1; // scope 2 at $DIR/simplify-locals.rs:+4:13: +4:19 -- StorageDead(_3); // scope 2 at $DIR/simplify-locals.rs:+4:19: +4:20 - _0 = const (); // scope 0 at $DIR/simplify-locals.rs:+0:8: +5:2 - StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:+5:1: +5:2 - return; // scope 0 at $DIR/simplify-locals.rs:+5:2: +5:2 + StorageLive(_1); // scope 0 at $DIR/simplify_locals.rs:+1:9: +1:14 + _1 = const 1_i32; // scope 0 at $DIR/simplify_locals.rs:+1:17: +1:18 +- StorageLive(_2); // scope 1 at $DIR/simplify_locals.rs:+3:13: +3:15 +- _2 = &_1; // scope 1 at $DIR/simplify_locals.rs:+3:13: +3:15 +- StorageDead(_2); // scope 1 at $DIR/simplify_locals.rs:+3:15: +3:16 +- StorageLive(_3); // scope 2 at $DIR/simplify_locals.rs:+4:13: +4:19 +- _3 = &mut _1; // scope 2 at $DIR/simplify_locals.rs:+4:13: +4:19 +- StorageDead(_3); // scope 2 at $DIR/simplify_locals.rs:+4:19: +4:20 + _0 = const (); // scope 0 at $DIR/simplify_locals.rs:+0:8: +5:2 + StorageDead(_1); // scope 0 at $DIR/simplify_locals.rs:+5:1: +5:2 + return; // scope 0 at $DIR/simplify_locals.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/simplify_locals.rs b/src/test/mir-opt/simplify_locals.rs new file mode 100644 index 000000000..89d9391f8 --- /dev/null +++ b/src/test/mir-opt/simplify_locals.rs @@ -0,0 +1,81 @@ +// unit-test: SimplifyLocals + + +#![feature(thread_local)] + +#[derive(Copy, Clone)] +enum E { + A, + B, +} + +// EMIT_MIR simplify_locals.c.SimplifyLocals.diff +fn c() { + let bytes = [0u8; 10]; + // Unused cast + let _: &[u8] = &bytes; +} + +// EMIT_MIR simplify_locals.d1.SimplifyLocals.diff +fn d1() { + // Unused set discriminant + let _ = E::A; +} + +// EMIT_MIR simplify_locals.d2.SimplifyLocals.diff +fn d2() { + // Unused set discriminant + {(10, E::A)}.1 = E::B; +} + +// EMIT_MIR simplify_locals.r.SimplifyLocals.diff +fn r() { + let mut a = 1; + // Unused references + let _ = &a; + let _ = &mut a; +} + +#[thread_local] static mut X: u32 = 0; + +// EMIT_MIR simplify_locals.t1.SimplifyLocals.diff +fn t1() { + // Unused thread local + unsafe { X }; +} + +// EMIT_MIR simplify_locals.t2.SimplifyLocals.diff +fn t2() { + // Unused thread local + unsafe { &mut X }; +} + +// EMIT_MIR simplify_locals.t3.SimplifyLocals.diff +fn t3() { + // Unused thread local + unsafe { *&mut X }; +} + +// EMIT_MIR simplify_locals.t4.SimplifyLocals.diff +fn t4() -> u32 { + // Used thread local + unsafe { X + 1 } +} + +// EMIT_MIR simplify_locals.expose_addr.SimplifyLocals.diff +fn expose_addr(p: *const usize) { + // Used pointer to address cast. Has a side effect of exposing the provenance. + p as usize; +} + +fn main() { + c(); + d1(); + d2(); + r(); + t1(); + t2(); + t3(); + t4(); + expose_addr(&0); +} diff --git a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff index b31156ad6..49db77479 100644 --- a/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t1.SimplifyLocals.diff @@ -2,21 +2,21 @@ + // MIR for `t1` after SimplifyLocals fn t1() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9 -- let _1: u32; // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15 -- let mut _2: *mut u32; // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 +- let _1: u32; // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15 +- let mut _2: *mut u32; // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15 scope 1 { } bb0: { -- StorageLive(_1); // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:17 -- StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15 -- _2 = &/*tls*/ mut X; // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15 -- _1 = (*_2); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15 -- StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:+2:17: +2:18 -- 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 +- StorageLive(_1); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:17 +- StorageLive(_2); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15 +- _2 = &/*tls*/ mut X; // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15 +- _1 = (*_2); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15 +- StorageDead(_2); // scope 0 at $DIR/simplify_locals.rs:+2:17: +2:18 +- 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/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff index 66b6d8d64..e3f4ae370 100644 --- a/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t2.SimplifyLocals.diff @@ -2,21 +2,21 @@ + // MIR for `t2` after SimplifyLocals fn t2() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9 -- let _1: &mut u32; // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:20 -- let mut _2: *mut u32; // in scope 0 at $DIR/simplify-locals.rs:+2:19: +2:20 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 +- let _1: &mut u32; // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:20 +- let mut _2: *mut u32; // in scope 0 at $DIR/simplify_locals.rs:+2:19: +2:20 scope 1 { } bb0: { -- StorageLive(_1); // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:22 -- StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:+2:19: +2:20 -- _2 = &/*tls*/ mut X; // scope 1 at $DIR/simplify-locals.rs:+2:19: +2:20 -- _1 = &mut (*_2); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:20 -- StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:+2:22: +2:23 -- StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:+2:22: +2:23 - _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 +- StorageLive(_1); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:22 +- StorageLive(_2); // scope 1 at $DIR/simplify_locals.rs:+2:19: +2:20 +- _2 = &/*tls*/ mut X; // scope 1 at $DIR/simplify_locals.rs:+2:19: +2:20 +- _1 = &mut (*_2); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:20 +- StorageDead(_2); // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:23 +- StorageDead(_1); // scope 0 at $DIR/simplify_locals.rs:+2:22: +2:23 + _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/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff index f6b6b78cd..f1ce7778e 100644 --- a/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t3.SimplifyLocals.diff @@ -2,25 +2,25 @@ + // MIR for `t3` after SimplifyLocals fn t3() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals.rs:+0:9: +0:9 -- let _1: u32; // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:21 -- let mut _2: &mut u32; // in scope 0 at $DIR/simplify-locals.rs:+2:15: +2:21 -- let mut _3: *mut u32; // in scope 0 at $DIR/simplify-locals.rs:+2:20: +2:21 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals.rs:+0:9: +0:9 +- let _1: u32; // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:21 +- let mut _2: &mut u32; // in scope 0 at $DIR/simplify_locals.rs:+2:15: +2:21 +- let mut _3: *mut u32; // in scope 0 at $DIR/simplify_locals.rs:+2:20: +2:21 scope 1 { } bb0: { -- StorageLive(_1); // scope 0 at $DIR/simplify-locals.rs:+2:5: +2:23 -- StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:+2:15: +2:21 -- StorageLive(_3); // scope 1 at $DIR/simplify-locals.rs:+2:20: +2:21 -- _3 = &/*tls*/ mut X; // scope 1 at $DIR/simplify-locals.rs:+2:20: +2:21 -- _2 = &mut (*_3); // scope 1 at $DIR/simplify-locals.rs:+2:15: +2:21 -- _1 = (*_2); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:21 -- StorageDead(_3); // scope 0 at $DIR/simplify-locals.rs:+2:23: +2:24 -- StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:+2:23: +2:24 -- StorageDead(_1); // scope 0 at $DIR/simplify-locals.rs:+2:23: +2:24 - _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 +- StorageLive(_1); // scope 0 at $DIR/simplify_locals.rs:+2:5: +2:23 +- StorageLive(_2); // scope 1 at $DIR/simplify_locals.rs:+2:15: +2:21 +- StorageLive(_3); // scope 1 at $DIR/simplify_locals.rs:+2:20: +2:21 +- _3 = &/*tls*/ mut X; // scope 1 at $DIR/simplify_locals.rs:+2:20: +2:21 +- _2 = &mut (*_3); // scope 1 at $DIR/simplify_locals.rs:+2:15: +2:21 +- _1 = (*_2); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:21 +- StorageDead(_3); // scope 0 at $DIR/simplify_locals.rs:+2:23: +2:24 +- StorageDead(_2); // scope 0 at $DIR/simplify_locals.rs:+2:23: +2:24 +- StorageDead(_1); // scope 0 at $DIR/simplify_locals.rs:+2:23: +2:24 + _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/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff index 1c1da29aa..71cf9594b 100644 --- a/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals.t4.SimplifyLocals.diff @@ -2,21 +2,21 @@ + // MIR for `t4` after SimplifyLocals fn t4() -> u32 { - let mut _0: u32; // return place in scope 0 at $DIR/simplify-locals.rs:+0:12: +0:15 - let mut _1: u32; // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15 - let mut _2: *mut u32; // in scope 0 at $DIR/simplify-locals.rs:+2:14: +2:15 + let mut _0: u32; // return place in scope 0 at $DIR/simplify_locals.rs:+0:12: +0:15 + let mut _1: u32; // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15 + let mut _2: *mut u32; // in scope 0 at $DIR/simplify_locals.rs:+2:14: +2:15 scope 1 { } bb0: { - StorageLive(_1); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15 - StorageLive(_2); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15 - _2 = &/*tls*/ mut X; // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15 - _1 = (*_2); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:15 - _0 = Add(move _1, const 1_u32); // scope 1 at $DIR/simplify-locals.rs:+2:14: +2:19 - StorageDead(_1); // scope 1 at $DIR/simplify-locals.rs:+2:18: +2:19 - StorageDead(_2); // scope 0 at $DIR/simplify-locals.rs:+3:1: +3:2 - return; // scope 0 at $DIR/simplify-locals.rs:+3:2: +3:2 + StorageLive(_1); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15 + StorageLive(_2); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15 + _2 = &/*tls*/ mut X; // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15 + _1 = (*_2); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:15 + _0 = Add(move _1, const 1_u32); // scope 1 at $DIR/simplify_locals.rs:+2:14: +2:19 + StorageDead(_1); // scope 1 at $DIR/simplify_locals.rs:+2:18: +2:19 + StorageDead(_2); // scope 0 at $DIR/simplify_locals.rs:+3:1: +3:2 + return; // scope 0 at $DIR/simplify_locals.rs:+3:2: +3:2 } } diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff index ac7a47ba5..8feddcef2 100644 --- a/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals.diff @@ -2,61 +2,61 @@ + // MIR for `foo` after SimplifyLocals fn foo() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+0:13: +0:13 - let mut _1: (std::option::Option, std::option::Option); // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:30: +1:69 - let mut _2: std::option::Option; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:31: +1:49 - let mut _3: std::option::Option; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:51: +1:68 - let mut _4: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:22: +1:26 - let mut _5: isize; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+1:13: +1:20 -- let mut _7: bool; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:20 -- let mut _8: u8; // in scope 0 at $DIR/simplify-locals-fixedpoint.rs:+2:12: +2:13 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+0:13: +0:13 + let mut _1: (std::option::Option, std::option::Option); // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:30: +1:69 + let mut _2: std::option::Option; // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:31: +1:49 + let mut _3: std::option::Option; // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:51: +1:68 + let mut _4: isize; // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:22: +1:26 + let mut _5: isize; // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:13: +1:20 +- let mut _7: bool; // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:20 +- let mut _8: u8; // in scope 0 at $DIR/simplify_locals_fixedpoint.rs:+2:12: +2:13 scope 1 { - debug a => _6; // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:18: +1:19 - let _6: u8; // in scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:18: +1:19 + debug a => _6; // in scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19 + let _6: u8; // in scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:18: +1:19 } 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 - 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 - 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 - switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:12: +1:27 + 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 + 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 + 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 + switchInt(move _5) -> [1_isize: bb1, otherwise: bb3]; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27 } bb1: { - _4 = discriminant((_1.1: std::option::Option)); // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:12: +1:27 - switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 1 at $DIR/simplify-locals-fixedpoint.rs:+1:12: +1:27 + _4 = discriminant((_1.1: std::option::Option)); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27 + switchInt(move _4) -> [0_isize: bb2, otherwise: bb3]; // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+1:12: +1:27 } 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 -- 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 + 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 +- 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 } bb3: { - drop(_1) -> bb4; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+6:1: +6:2 + drop(_1) -> bb4; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:1: +6:2 } bb4: { - StorageDead(_1); // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+6:1: +6:2 - return; // scope 0 at $DIR/simplify-locals-fixedpoint.rs:+6:2: +6:2 + StorageDead(_1); // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:1: +6:2 + return; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:2: +6:2 } } diff --git a/src/test/mir-opt/simplify_locals_fixedpoint.rs b/src/test/mir-opt/simplify_locals_fixedpoint.rs new file mode 100644 index 000000000..78b1f9f55 --- /dev/null +++ b/src/test/mir-opt/simplify_locals_fixedpoint.rs @@ -0,0 +1,15 @@ +// compile-flags: -Zmir-opt-level=1 + +fn foo() { + if let (Some(a), None) = (Option::::None, Option::::None) { + if a > 42u8 { + + } + } +} + +fn main() { + foo::<()>(); +} + +// EMIT_MIR simplify_locals_fixedpoint.foo.SimplifyLocals.diff diff --git a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff index b41527ba0..78272272b 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_consts.main.SimplifyLocals.diff @@ -2,108 +2,108 @@ + // MIR for `main` after SimplifyLocals fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+0:11: +0:11 -- let mut _1: ((), ()); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:20: +1:28 -- let mut _2: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:21: +1:23 -- let mut _3: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+1:25: +1:27 -- let _4: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22 -- let mut _5: ((), ()); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21 -- let mut _6: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16 -- let mut _7: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20 -- let _8: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35 -- let mut _9: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34 -- let mut _10: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30 -- let mut _11: Temp; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28 -+ let _1: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:5: +2:22 -+ let mut _2: ((), ()); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:13: +2:21 -+ let mut _3: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:14: +2:16 -+ let mut _4: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+2:18: +2:20 -+ let _5: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35 -+ let mut _6: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:34 -+ let mut _7: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:30 -+ let mut _8: Temp; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+4:12: +4:28 + let mut _0: (); // return place in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+0:11: +0:11 +- let mut _1: ((), ()); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:20: +1:28 +- let mut _2: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:21: +1:23 +- let mut _3: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+1:25: +1:27 +- let _4: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22 +- let mut _5: ((), ()); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 +- let mut _6: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 +- let mut _7: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 +- let _8: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35 +- let mut _9: u8; // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34 +- let mut _10: u8; // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30 +- let mut _11: Temp; // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 ++ let _1: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:5: +2:22 ++ let mut _2: ((), ()); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:13: +2:21 ++ let mut _3: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:14: +2:16 ++ let mut _4: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+2:18: +2:20 ++ let _5: (); // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35 ++ let mut _6: u8; // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:34 ++ let mut _7: u8; // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:30 ++ let mut _8: Temp; // in scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+4:12: +4:28 scope 1 { } 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 -- 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 -- 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 -- 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 -- 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 -+ 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 -+ 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 +- 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 +- 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 +- 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 +- 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 +- 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 ++ 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 ++ 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 // mir::Constant - // + span: $DIR/simplify-locals-removes-unused-consts.rs:15:5: 15:12 + // + span: $DIR/simplify_locals_removes_unused_consts.rs:15:5: 15:12 // + literal: Const { ty: fn(((), ())) {use_zst}, val: Value() } } bb1: { -- StorageDead(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:21: +2:22 -- StorageDead(_4); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:22: +2:23 -- StorageLive(_8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35 -- 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 -- _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 -- _8 = use_u8(move _9) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35 -+ StorageDead(_2); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:21: +2:22 -+ StorageDead(_1); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+2:22: +2:23 -+ StorageLive(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35 -+ 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 -+ _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 -+ _5 = use_u8(move _6) -> bb2; // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:5: +4:35 +- StorageDead(_5); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:21: +2:22 +- StorageDead(_4); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:22: +2:23 +- StorageLive(_8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35 +- 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 +- _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 +- _8 = use_u8(move _9) -> bb2; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35 ++ StorageDead(_2); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:21: +2:22 ++ StorageDead(_1); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+2:22: +2:23 ++ StorageLive(_5); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35 ++ 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 ++ _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 ++ _5 = use_u8(move _6) -> bb2; // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:5: +4:35 // mir::Constant - // + span: $DIR/simplify-locals-removes-unused-consts.rs:17:5: 17:11 + // + span: $DIR/simplify_locals_removes_unused_consts.rs:17:5: 17:11 // + literal: Const { ty: fn(u8) {use_u8}, val: Value() } } bb2: { -- StorageDead(_9); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:34: +4:35 -- StorageDead(_11); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36 -+ StorageDead(_6); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:34: +4:35 - StorageDead(_8); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36 -+ StorageDead(_5); // scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:+4:35: +4:36 - _0 = const (); // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+0:11: +5:2 - return; // scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:+5:2: +5:2 +- StorageDead(_9); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:34: +4:35 +- StorageDead(_11); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:35: +4:36 ++ StorageDead(_6); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:34: +4:35 + StorageDead(_8); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:35: +4:36 ++ StorageDead(_5); // scope 1 at $DIR/simplify_locals_removes_unused_consts.rs:+4:35: +4:36 + _0 = const (); // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+0:11: +5:2 + return; // scope 0 at $DIR/simplify_locals_removes_unused_consts.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/simplify_locals_removes_unused_consts.rs b/src/test/mir-opt/simplify_locals_removes_unused_consts.rs new file mode 100644 index 000000000..39b7911d4 --- /dev/null +++ b/src/test/mir-opt/simplify_locals_removes_unused_consts.rs @@ -0,0 +1,18 @@ +// unit-test: SimplifyLocals +// compile-flags: -C overflow-checks=no + +fn use_zst(_: ((), ())) {} + +struct Temp { + x: u8, +} + +fn use_u8(_: u8) {} + +// EMIT_MIR simplify_locals_removes_unused_consts.main.SimplifyLocals.diff +fn main() { + let ((), ()) = ((), ()); + use_zst(((), ())); + + use_u8((Temp { x: 40 }).x + 2); +} diff --git a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff index 51d26b08b..6e7294003 100644 --- a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff @@ -2,51 +2,51 @@ + // MIR for `map` after SimplifyLocals fn map(_1: Option>) -> Option> { - debug x => _1; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+0:8: +0:9 - let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+0:31: +0:46 - let mut _2: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:9: +2:13 - let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15 - let mut _4: std::boxed::Box<()>; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:25: +3:26 -- let mut _5: bool; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2 -- let mut _6: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2 -- let mut _7: isize; // in scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2 + debug x => _1; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+0:8: +0:9 + let mut _0: std::option::Option>; // return place in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+0:31: +0:46 + let mut _2: isize; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:9: +2:13 + let _3: std::boxed::Box<()>; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15 + let mut _4: std::boxed::Box<()>; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:25: +3:26 +- let mut _5: bool; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2 +- let mut _6: isize; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2 +- let mut _7: isize; // in scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2 scope 1 { - debug x => _3; // in scope 1 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15 + debug x => _3; // in scope 1 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15 } bb0: { -- _5 = const false; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12 -- _5 = const true; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12 - _2 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12 - switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:5: +1:12 +- _5 = const false; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12 +- _5 = const true; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12 + _2 = discriminant(_1); // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12 + switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:5: +1:12 } bb1: { - StorageLive(_3); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+3:14: +3:15 - _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 - 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 + StorageLive(_3); // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+3:14: +3:15 + _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 + 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 } bb2: { - unreachable; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+1:11: +1:12 + unreachable; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+1:11: +1:12 } 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 - goto -> bb4; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+2:17: +2:21 + 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 + goto -> bb4; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+2:17: +2:21 } bb4: { -- _6 = discriminant(_1); // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:1: +5:2 - return; // scope 0 at $DIR/simplify-locals-removes-unused-discriminant-reads.rs:+5:2: +5:2 +- _6 = discriminant(_1); // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:1: +5:2 + return; // scope 0 at $DIR/simplify_locals_removes_unused_discriminant_reads.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs new file mode 100644 index 000000000..d09bd92c4 --- /dev/null +++ b/src/test/mir-opt/simplify_locals_removes_unused_discriminant_reads.rs @@ -0,0 +1,14 @@ +// unit-test: SimplifyLocals + +fn map(x: Option>) -> Option> { + match x { + None => None, + Some(x) => Some(x), + } +} + +fn main() { + map(None); +} + +// EMIT_MIR simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals.diff diff --git a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff deleted file mode 100644 index 83b91309b..000000000 --- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff +++ /dev/null @@ -1,106 +0,0 @@ -- // MIR for `try_identity` before DestinationPropagation -+ // MIR for `try_identity` after DestinationPropagation - - fn try_identity(_1: Result) -> Result { - debug x => _1; // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57 - let _2: u32; // in scope 0 at $DIR/simplify_try.rs:+1:9: +1:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15 - let _6: i32; // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:+2:19: +2:51 - let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50 - let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49 - let _10: u32; // in scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:+5:8: +5:9 - scope 1 { -- debug y => _2; // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10 -+ debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10 - } - scope 2 { - debug e => _6; // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14 - scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50 - debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51 - debug e => _8; // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22 - } - } - scope 3 { -- debug v => _10; // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13 -+ debug v => ((_0 as Ok).0: u32); // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 -- debug r => _4; // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23 -+ debug r => _3; // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23 - } - - bb0: { -- StorageLive(_2); // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10 -- StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 -- StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 -- _4 = _1; // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 -- _3 = move _4; // scope 4 at $DIR/simplify_try.rs:9:5: 9:6 -- StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33 -+ nop; // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10 -+ nop; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 -+ nop; // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 -+ _3 = _1; // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 -+ nop; // scope 4 at $DIR/simplify_try.rs:9:5: 9:6 -+ nop; // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33 - } - - bb1: { -- StorageLive(_10); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 -- _10 = ((_3 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 -- _2 = _10; // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19 -- StorageDead(_10); // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19 -- StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 -- StorageLive(_11); // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 -- _11 = _2; // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 -+ nop; // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 -+ ((_0 as Ok).0: u32) = ((_3 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 -+ nop; // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19 -+ nop; // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19 -+ nop; // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 -+ nop; // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 -+ nop; // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 - Deinit(_0); // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 -- ((_0 as Ok).0: u32) = move _11; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 -+ nop; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 -- StorageDead(_11); // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10 -- StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 -+ nop; // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10 -+ nop; // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - nop; // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50 - StorageLive(_9); // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49 - nop; // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49 - nop; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_9); // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50 - nop; // scope 6 at $DIR/simplify_try.rs:13:9: 13:10 - Deinit(_0); // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - StorageDead(_8); // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51 - StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51 -- StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 -- StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 -+ nop; // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 -+ nop; // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } - } - diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff deleted file mode 100644 index e025ae7c5..000000000 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff +++ /dev/null @@ -1,85 +0,0 @@ -- // MIR for `try_identity` before SimplifyArmIdentity -+ // MIR for `try_identity` after SimplifyArmIdentity - - fn try_identity(_1: Result) -> Result { - debug x => _1; // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57 - let _2: u32; // in scope 0 at $DIR/simplify_try.rs:+1:9: +1:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15 - let _6: i32; // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:+2:19: +2:51 - let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50 - let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49 - let _10: u32; // in scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:+5:8: +5:9 - scope 1 { - debug y => _2; // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10 - } - scope 2 { - debug e => _6; // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14 - scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50 - debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51 - debug e => _8; // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22 - } - } - scope 3 { - debug v => _10; // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 - debug r => _4; // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - _4 = _1; // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - _3 = move _4; // scope 4 at $DIR/simplify_try.rs:9:5: 9:6 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33 - } - - bb1: { - StorageLive(_10); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - _10 = ((_3 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - _2 = _10; // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19 - StorageDead(_10); // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19 - StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 - StorageLive(_11); // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 - _11 = _2; // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 - Deinit(_0); // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - ((_0 as Ok).0: u32) = move _11; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - StorageDead(_11); // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10 - StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50 - StorageLive(_9); // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49 - _9 = _6; // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49 - _8 = move _9; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_9); // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50 - ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify_try.rs:13:9: 13:10 - Deinit(_0); // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - StorageDead(_8); // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51 - StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51 - StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 - StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } - } - diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir deleted file mode 100644 index eb5af2227..000000000 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir +++ /dev/null @@ -1,83 +0,0 @@ -// MIR for `try_identity` after SimplifyBranchSame - -fn try_identity(_1: Result) -> Result { - debug x => _1; // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57 - let _2: u32; // in scope 0 at $DIR/simplify_try.rs:+1:9: +1:10 - let mut _3: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - let mut _4: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15 - let _6: i32; // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:+2:19: +2:51 - let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50 - let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49 - let _10: u32; // in scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:+5:8: +5:9 - scope 1 { - debug y => _2; // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10 - } - scope 2 { - debug e => _6; // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14 - scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50 - debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51 - debug e => _8; // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22 - } - } - scope 3 { - debug v => _10; // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 - debug r => _4; // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify_try.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - _4 = _1; // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - _3 = move _4; // scope 4 at $DIR/simplify_try.rs:9:5: 9:6 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:+1:32: +1:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33 - } - - bb1: { - StorageLive(_10); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - _10 = ((_3 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - _2 = _10; // scope 3 at $DIR/simplify_try.rs:+3:18: +3:19 - StorageDead(_10); // scope 0 at $DIR/simplify_try.rs:+3:18: +3:19 - StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 - StorageLive(_11); // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 - _11 = _2; // scope 1 at $DIR/simplify_try.rs:+5:8: +5:9 - Deinit(_0); // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - ((_0 as Ok).0: u32) = move _11; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - StorageDead(_11); // scope 1 at $DIR/simplify_try.rs:+5:9: +5:10 - StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - StorageLive(_8); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50 - StorageLive(_9); // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49 - _9 = _6; // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49 - _8 = move _9; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_9); // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50 - ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify_try.rs:13:9: 13:10 - Deinit(_0); // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - StorageDead(_8); // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51 - StorageDead(_6); // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51 - StorageDead(_3); // scope 0 at $DIR/simplify_try.rs:+4:6: +4:7 - StorageDead(_2); // scope 0 at $DIR/simplify_try.rs:+6:1: +6:2 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } -} diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir deleted file mode 100644 index 1efa8a67e..000000000 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir +++ /dev/null @@ -1,58 +0,0 @@ -// MIR for `try_identity` after SimplifyLocals - -fn try_identity(_1: Result) -> Result { - debug x => _1; // in scope 0 at $DIR/simplify_try.rs:+0:17: +0:18 - let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:+0:41: +0:57 - let mut _2: std::result::Result; // in scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - let mut _3: isize; // in scope 0 at $DIR/simplify_try.rs:+2:9: +2:15 - let _4: i32; // in scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - let mut _5: i32; // in scope 0 at $DIR/simplify_try.rs:+2:37: +2:50 - let mut _6: i32; // in scope 0 at $DIR/simplify_try.rs:+2:48: +2:49 - scope 1 { - debug y => ((_0 as Ok).0: u32); // in scope 1 at $DIR/simplify_try.rs:+1:9: +1:10 - } - scope 2 { - debug e => _4; // in scope 2 at $DIR/simplify_try.rs:+2:13: +2:14 - scope 5 (inlined >::from) { // at $DIR/simplify_try.rs:22:37: 22:50 - debug t => _6; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::) { // at $DIR/simplify_try.rs:22:26: 22:51 - debug e => _5; // in scope 6 at $DIR/simplify_try.rs:12:21: 12:22 - } - } - scope 3 { - debug v => ((_0 as Ok).0: u32); // in scope 3 at $DIR/simplify_try.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::) { // at $DIR/simplify_try.rs:21:19: 21:33 - debug r => _2; // in scope 4 at $DIR/simplify_try.rs:8:22: 8:23 - } - - bb0: { - _2 = _1; // scope 0 at $DIR/simplify_try.rs:+1:31: +1:32 - _3 = discriminant(_2); // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - switchInt(move _3) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify_try.rs:+1:13: +1:33 - } - - bb1: { - ((_0 as Ok).0: u32) = ((_2 as Ok).0: u32); // scope 0 at $DIR/simplify_try.rs:+3:12: +3:13 - Deinit(_0); // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify_try.rs:+5:5: +5:10 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify_try.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_4); // scope 0 at $DIR/simplify_try.rs:+2:13: +2:14 - StorageLive(_5); // scope 2 at $DIR/simplify_try.rs:+2:37: +2:50 - StorageLive(_6); // scope 2 at $DIR/simplify_try.rs:+2:48: +2:49 - StorageDead(_6); // scope 2 at $DIR/simplify_try.rs:+2:49: +2:50 - Deinit(_0); // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify_try.rs:13:5: 13:11 - StorageDead(_5); // scope 2 at $DIR/simplify_try.rs:+2:50: +2:51 - StorageDead(_4); // scope 0 at $DIR/simplify_try.rs:+2:50: +2:51 - return; // scope 0 at $DIR/simplify_try.rs:+6:2: +6:2 - } -} diff --git a/src/test/mir-opt/slice-drop-shim.rs b/src/test/mir-opt/slice-drop-shim.rs deleted file mode 100644 index 344c1af2c..000000000 --- a/src/test/mir-opt/slice-drop-shim.rs +++ /dev/null @@ -1,7 +0,0 @@ -// compile-flags: -Zmir-opt-level=0 - - -// EMIT_MIR core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir -fn main() { - let _fn = std::ptr::drop_in_place::<[String]> as unsafe fn(_); -} diff --git a/src/test/mir-opt/slice_drop_shim.rs b/src/test/mir-opt/slice_drop_shim.rs new file mode 100644 index 000000000..344c1af2c --- /dev/null +++ b/src/test/mir-opt/slice_drop_shim.rs @@ -0,0 +1,7 @@ +// compile-flags: -Zmir-opt-level=0 + + +// EMIT_MIR core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir +fn main() { + let _fn = std::ptr::drop_in_place::<[String]> as unsafe fn(_); +} diff --git a/src/test/mir-opt/spanview-block.rs b/src/test/mir-opt/spanview-block.rs deleted file mode 100644 index fc1d6e0ed..000000000 --- a/src/test/mir-opt/spanview-block.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Test spanview block output -// compile-flags: -Z dump-mir-spanview=block - -// EMIT_MIR spanview_block.main.mir_map.0.html -fn main() {} diff --git a/src/test/mir-opt/spanview-statement.rs b/src/test/mir-opt/spanview-statement.rs deleted file mode 100644 index a43ad5e71..000000000 --- a/src/test/mir-opt/spanview-statement.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Test spanview output (the default value for `-Z dump-mir-spanview` is "statement") -// compile-flags: -Z dump-mir-spanview - -// EMIT_MIR spanview_statement.main.mir_map.0.html -fn main() {} diff --git a/src/test/mir-opt/spanview-terminator.rs b/src/test/mir-opt/spanview-terminator.rs deleted file mode 100644 index 92e1411ea..000000000 --- a/src/test/mir-opt/spanview-terminator.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Test spanview terminator output -// compile-flags: -Z dump-mir-spanview=terminator - -// EMIT_MIR spanview_terminator.main.mir_map.0.html -fn main() {} diff --git a/src/test/mir-opt/spanview_block.main.built.after.html b/src/test/mir-opt/spanview_block.main.built.after.html new file mode 100644 index 000000000..b962d80c5 --- /dev/null +++ b/src/test/mir-opt/spanview_block.main.built.after.html @@ -0,0 +1,66 @@ + + + +spanview_block.main.built.after + + + +

fn main() 0⦊{}⦉0
+ + diff --git a/src/test/mir-opt/spanview_block.main.mir_map.0.html b/src/test/mir-opt/spanview_block.main.mir_map.0.html deleted file mode 100644 index 8e5268043..000000000 --- a/src/test/mir-opt/spanview_block.main.mir_map.0.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -spanview_block.main.mir_map.0 - - - -
fn main() 0⦊{}⦉0
- - diff --git a/src/test/mir-opt/spanview_block.rs b/src/test/mir-opt/spanview_block.rs new file mode 100644 index 000000000..0ecf35ad6 --- /dev/null +++ b/src/test/mir-opt/spanview_block.rs @@ -0,0 +1,5 @@ +// Test spanview block output +// compile-flags: -Z dump-mir-spanview=block + +// EMIT_MIR spanview_block.main.built.after.html +fn main() {} diff --git a/src/test/mir-opt/spanview_statement.main.built.after.html b/src/test/mir-opt/spanview_statement.main.built.after.html new file mode 100644 index 000000000..43bff7d09 --- /dev/null +++ b/src/test/mir-opt/spanview_statement.main.built.after.html @@ -0,0 +1,66 @@ + + + +spanview_statement.main.built.after + + + +
fn main() 0[0]⦊{}⦉0[0]0:Return⦊‸⦉0:Return
+ + diff --git a/src/test/mir-opt/spanview_statement.main.mir_map.0.html b/src/test/mir-opt/spanview_statement.main.mir_map.0.html deleted file mode 100644 index abbff2270..000000000 --- a/src/test/mir-opt/spanview_statement.main.mir_map.0.html +++ /dev/null @@ -1,66 +0,0 @@ - - - -spanview_statement.main.mir_map.0 - - - -
fn main() 0[0]⦊{}⦉0[0]0:Return⦊‸⦉0:Return
- - diff --git a/src/test/mir-opt/spanview_statement.rs b/src/test/mir-opt/spanview_statement.rs new file mode 100644 index 000000000..457052617 --- /dev/null +++ b/src/test/mir-opt/spanview_statement.rs @@ -0,0 +1,5 @@ +// Test spanview output (the default value for `-Z dump-mir-spanview` is "statement") +// compile-flags: -Z dump-mir-spanview + +// EMIT_MIR spanview_statement.main.built.after.html +fn main() {} diff --git a/src/test/mir-opt/spanview_terminator.main.built.after.html b/src/test/mir-opt/spanview_terminator.main.built.after.html new file mode 100644 index 000000000..aa7e44c15 --- /dev/null +++ b/src/test/mir-opt/spanview_terminator.main.built.after.html @@ -0,0 +1,65 @@ + + + +spanview_terminator.main.built.after + + + +
fn main() {}0:Return⦊‸⦉0:Return
+ + diff --git a/src/test/mir-opt/spanview_terminator.main.mir_map.0.html b/src/test/mir-opt/spanview_terminator.main.mir_map.0.html deleted file mode 100644 index 55fafd90b..000000000 --- a/src/test/mir-opt/spanview_terminator.main.mir_map.0.html +++ /dev/null @@ -1,65 +0,0 @@ - - - -spanview_terminator.main.mir_map.0 - - - -
fn main() {}0:Return⦊‸⦉0:Return
- - diff --git a/src/test/mir-opt/spanview_terminator.rs b/src/test/mir-opt/spanview_terminator.rs new file mode 100644 index 000000000..76fced188 --- /dev/null +++ b/src/test/mir-opt/spanview_terminator.rs @@ -0,0 +1,5 @@ +// Test spanview terminator output +// compile-flags: -Z dump-mir-spanview=terminator + +// EMIT_MIR spanview_terminator.main.built.after.html +fn main() {} diff --git a/src/test/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff b/src/test/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..eb8830446 --- /dev/null +++ b/src/test/mir-opt/sroa.dropping.ScalarReplacementOfAggregates.diff @@ -0,0 +1,50 @@ +- // MIR for `dropping` before ScalarReplacementOfAggregates ++ // MIR for `dropping` after ScalarReplacementOfAggregates + + fn dropping() -> () { + let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:19: +0:19 + let _1: Tag; // in scope 0 at $DIR/sroa.rs:+1:5: +1:32 + let mut _2: S; // in scope 0 at $DIR/sroa.rs:+1:5: +1:30 + let mut _3: Tag; // in scope 0 at $DIR/sroa.rs:+1:7: +1:13 + let mut _4: Tag; // in scope 0 at $DIR/sroa.rs:+1:15: +1:21 + let mut _5: Tag; // in scope 0 at $DIR/sroa.rs:+1:23: +1:29 + + bb0: { + 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 + 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 + 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 + 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 + _1 = move (_2.1: Tag); // scope 0 at $DIR/sroa.rs:+1:5: +1:32 + drop(_1) -> bb1; // scope 0 at $DIR/sroa.rs:+1:32: +1:33 + } + + bb1: { + drop((_2.0: Tag)) -> bb3; // scope 0 at $DIR/sroa.rs:+1:32: +1:33 + } + + bb2: { + StorageDead(_2); // scope 0 at $DIR/sroa.rs:+1:32: +1:33 + StorageDead(_1); // scope 0 at $DIR/sroa.rs:+1:32: +1:33 + _0 = const (); // scope 0 at $DIR/sroa.rs:+0:19: +2:2 + return; // scope 0 at $DIR/sroa.rs:+2:2: +2:2 + } + + bb3: { + drop((_2.2: Tag)) -> bb2; // scope 0 at $DIR/sroa.rs:+1:32: +1:33 + } + } + diff --git a/src/test/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff b/src/test/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..7c7e87c32 --- /dev/null +++ b/src/test/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff @@ -0,0 +1,45 @@ +- // MIR for `enums` before ScalarReplacementOfAggregates ++ // MIR for `enums` after ScalarReplacementOfAggregates + + fn enums(_1: usize) -> usize { + debug a => _1; // in scope 0 at $DIR/sroa.rs:+0:14: +0:15 + let mut _0: usize; // return place in scope 0 at $DIR/sroa.rs:+0:27: +0:32 + let mut _2: std::option::Option; // in scope 0 at $DIR/sroa.rs:+1:22: +1:29 + let mut _3: usize; // in scope 0 at $DIR/sroa.rs:+1:27: +1:28 + let mut _4: isize; // in scope 0 at $DIR/sroa.rs:+1:12: +1:19 + scope 1 { + debug a => _5; // in scope 1 at $DIR/sroa.rs:+1:17: +1:18 + let _5: usize; // in scope 1 at $DIR/sroa.rs:+1:17: +1:18 + } + + bb0: { + 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 + 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_isize: bb1, otherwise: bb2]; // scope 1 at $DIR/sroa.rs:+1:12: +1:19 + } + + bb1: { + StorageLive(_5); // scope 1 at $DIR/sroa.rs:+1:17: +1:18 + _5 = ((_2 as Some).0: usize); // scope 1 at $DIR/sroa.rs:+1:17: +1:18 + _0 = _5; // scope 1 at $DIR/sroa.rs:+1:32: +1:33 + StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:34: +1:35 + goto -> bb3; // scope 0 at $DIR/sroa.rs:+1:5: +1:46 + } + + bb2: { + _0 = const 0_usize; // scope 0 at $DIR/sroa.rs:+1:43: +1:44 + goto -> bb3; // scope 0 at $DIR/sroa.rs:+1:5: +1:46 + } + + bb3: { + StorageDead(_2); // scope 0 at $DIR/sroa.rs:+2:1: +2:2 + return; // scope 0 at $DIR/sroa.rs:+2:2: +2:2 + } + } + diff --git a/src/test/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff b/src/test/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..64559b58f --- /dev/null +++ b/src/test/mir-opt/sroa.escaping.ScalarReplacementOfAggregates.diff @@ -0,0 +1,47 @@ +- // MIR for `escaping` before ScalarReplacementOfAggregates ++ // MIR for `escaping` after ScalarReplacementOfAggregates + + 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 + + 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 + // 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 + // 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 + } + } + diff --git a/src/test/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff b/src/test/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..d4c04d5e6 --- /dev/null +++ b/src/test/mir-opt/sroa.flat.ScalarReplacementOfAggregates.diff @@ -0,0 +1,87 @@ +- // MIR for `flat` before ScalarReplacementOfAggregates ++ // MIR for `flat` after ScalarReplacementOfAggregates + + fn flat() -> () { + let mut _0: (); // return place in scope 0 at $DIR/sroa.rs:+0:15: +0:15 + let _1: u8; // in scope 0 at $DIR/sroa.rs:+1:15: +1:16 + let _2: (); // in scope 0 at $DIR/sroa.rs:+1:18: +1:19 + let _3: &str; // in scope 0 at $DIR/sroa.rs:+1:21: +1:22 + let _4: std::option::Option; // in scope 0 at $DIR/sroa.rs:+1:24: +1:25 + let mut _5: Foo; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 + let mut _6: (); // in scope 0 at $DIR/sroa.rs:+1:45: +1:47 + let mut _7: std::option::Option; // in scope 0 at $DIR/sroa.rs:+1:60: +1:68 ++ let mut _8: u8; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 ++ let mut _9: (); // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 ++ let mut _10: &str; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 ++ let mut _11: std::option::Option; // in scope 0 at $DIR/sroa.rs:+1:30: +1:70 + scope 1 { + debug a => _1; // in scope 1 at $DIR/sroa.rs:+1:15: +1:16 + debug b => _2; // in scope 1 at $DIR/sroa.rs:+1:18: +1:19 + debug c => _3; // in scope 1 at $DIR/sroa.rs:+1:21: +1:22 + debug d => _4; // in scope 1 at $DIR/sroa.rs:+1:24: +1:25 + scope 2 { + scope 3 { + scope 4 { + scope 5 { + } + } + } + } + } + + bb0: { +- StorageLive(_5); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 ++ StorageLive(_8); // scope 0 at $DIR/sroa.rs:+1:30: +1:70 ++ 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 + StorageLive(_6); // scope 0 at $DIR/sroa.rs:+1:45: +1:47 + Deinit(_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 ++ _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 + // + 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 + 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 +- _1 = (_5.0: u8); // scope 0 at $DIR/sroa.rs:+1:15: +1:16 ++ _1 = _8; // scope 0 at $DIR/sroa.rs:+1:15: +1:16 + StorageLive(_2); // scope 0 at $DIR/sroa.rs:+1:18: +1:19 +- _2 = (_5.1: ()); // scope 0 at $DIR/sroa.rs:+1:18: +1:19 ++ _2 = _9; // scope 0 at $DIR/sroa.rs:+1:18: +1:19 + StorageLive(_3); // scope 0 at $DIR/sroa.rs:+1:21: +1:22 +- _3 = (_5.2: &str); // scope 0 at $DIR/sroa.rs:+1:21: +1:22 ++ _3 = _10; // scope 0 at $DIR/sroa.rs:+1:21: +1:22 + StorageLive(_4); // scope 0 at $DIR/sroa.rs:+1:24: +1:25 +- _4 = (_5.3: std::option::Option); // scope 0 at $DIR/sroa.rs:+1:24: +1:25 +- StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 ++ _4 = _11; // scope 0 at $DIR/sroa.rs:+1:24: +1:25 ++ StorageDead(_8); // scope 0 at $DIR/sroa.rs:+1:70: +1:71 ++ 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 + _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 + StorageDead(_2); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 + StorageDead(_1); // scope 0 at $DIR/sroa.rs:+6:1: +6:2 + return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2 + } + } + diff --git a/src/test/mir-opt/sroa.rs b/src/test/mir-opt/sroa.rs new file mode 100644 index 000000000..ff8deb40d --- /dev/null +++ b/src/test/mir-opt/sroa.rs @@ -0,0 +1,88 @@ +// unit-test: ScalarReplacementOfAggregates +// compile-flags: -Cpanic=abort +// no-prefer-dynamic + +struct Tag(usize); + +#[repr(C)] +struct S(Tag, Tag, Tag); + +impl Drop for Tag { + #[inline(never)] + 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, + a: f32, + } + + U { _foo: 0, a }.a +} + +// EMIT_MIR sroa.unions.ScalarReplacementOfAggregates.diff +pub fn unions(a: f32) -> u32 { + union Repr { + f: f32, + u: u32, + } + unsafe { Repr { f: a }.u } +} + +struct Foo { + a: u8, + b: (), + c: &'static str, + d: Option, +} + +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; + let _ = b; + let _ = c; + let _ = d; +} + +#[repr(C)] +struct Escaping { + a: u32, + b: u32, + c: u32, +} + +fn f(a: *const u32) { + println!("{}", unsafe { *a.add(2) }); +} + +// EMIT_MIR sroa.escaping.ScalarReplacementOfAggregates.diff +pub fn escaping() { + // Verify this struct is not flattened. + f(&Escaping { a: 1, b: 2, c: g() }.a); +} + +fn main() { + dropping(); + enums(5); + structs(5.); + unions(5.); + flat(); + escaping(); +} diff --git a/src/test/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff b/src/test/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..69d74c351 --- /dev/null +++ b/src/test/mir-opt/sroa.structs.ScalarReplacementOfAggregates.diff @@ -0,0 +1,34 @@ +- // MIR for `structs` before ScalarReplacementOfAggregates ++ // MIR for `structs` after ScalarReplacementOfAggregates + + fn structs(_1: f32) -> f32 { + debug a => _1; // in scope 0 at $DIR/sroa.rs:+0:16: +0:17 + let mut _0: f32; // return place in scope 0 at $DIR/sroa.rs:+0:27: +0:30 + let mut _2: structs::U; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21 + let mut _3: f32; // in scope 0 at $DIR/sroa.rs:+6:18: +6:19 ++ let mut _4: usize; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21 ++ let mut _5: f32; // in scope 0 at $DIR/sroa.rs:+6:5: +6:21 + + bb0: { +- 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 + 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 ++ _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 + 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 + return; // scope 0 at $DIR/sroa.rs:+7:2: +7:2 + } + } + diff --git a/src/test/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff b/src/test/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff new file mode 100644 index 000000000..03ca976df --- /dev/null +++ b/src/test/mir-opt/sroa.unions.ScalarReplacementOfAggregates.diff @@ -0,0 +1,24 @@ +- // MIR for `unions` before ScalarReplacementOfAggregates ++ // MIR for `unions` after ScalarReplacementOfAggregates + + fn unions(_1: f32) -> u32 { + debug a => _1; // in scope 0 at $DIR/sroa.rs:+0:15: +0:16 + let mut _0: u32; // return place in scope 0 at $DIR/sroa.rs:+0:26: +0:29 + let mut _2: unions::Repr; // in scope 0 at $DIR/sroa.rs:+5:14: +5:27 + let mut _3: f32; // in scope 0 at $DIR/sroa.rs:+5:24: +5:25 + scope 1 { + } + + bb0: { + 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 + 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 + return; // scope 0 at $DIR/sroa.rs:+6:2: +6:2 + } + } + diff --git a/src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir b/src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir deleted file mode 100644 index e50067ea2..000000000 --- a/src/test/mir-opt/storage_live_dead_in_statics.XXX.mir_map.0.mir +++ /dev/null @@ -1,203 +0,0 @@ -// MIR for `XXX` 0 mir_map - -static XXX: &Foo = { - let mut _0: &Foo; // return place in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:13: +0:25 - let _1: &Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 - let _2: Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2 - let mut _3: &[(u32, u32)]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - let mut _4: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - let _5: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - let _6: [(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6 - let mut _7: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15 - let mut _8: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23 - let mut _9: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31 - let mut _10: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15 - let mut _11: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23 - let mut _12: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31 - let mut _13: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15 - let mut _14: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23 - let mut _15: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31 - let mut _16: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15 - let mut _17: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23 - let mut _18: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31 - let mut _19: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15 - let mut _20: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23 - let mut _21: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31 - let mut _22: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15 - let mut _23: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23 - let mut _24: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31 - let mut _25: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15 - let mut _26: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23 - let mut _27: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31 - let mut _28: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15 - let mut _29: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23 - let mut _30: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31 - let mut _31: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15 - let mut _32: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23 - let mut _33: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31 - let mut _34: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15 - let mut _35: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23 - let mut _36: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31 - let mut _37: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15 - let mut _38: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23 - let mut _39: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31 - let mut _40: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15 - let mut _41: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23 - let mut _42: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31 - let mut _43: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15 - let mut _44: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23 - let mut _45: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31 - let mut _46: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15 - let mut _47: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23 - let mut _48: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31 - - bb0: { - StorageLive(_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 - StorageLive(_2); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2 - StorageLive(_3); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - StorageLive(_4); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - StorageLive(_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - StorageLive(_6); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6 - StorageLive(_7); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15 - _7 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15 - StorageLive(_8); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23 - _8 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23 - StorageLive(_9); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31 - _9 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31 - StorageLive(_10); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15 - _10 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15 - StorageLive(_11); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23 - _11 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23 - StorageLive(_12); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31 - _12 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31 - StorageLive(_13); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15 - _13 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15 - StorageLive(_14); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23 - _14 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23 - StorageLive(_15); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31 - _15 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31 - StorageLive(_16); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15 - _16 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15 - StorageLive(_17); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23 - _17 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23 - StorageLive(_18); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31 - _18 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31 - StorageLive(_19); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15 - _19 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15 - StorageLive(_20); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23 - _20 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23 - StorageLive(_21); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31 - _21 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31 - StorageLive(_22); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15 - _22 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15 - StorageLive(_23); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23 - _23 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23 - StorageLive(_24); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31 - _24 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31 - StorageLive(_25); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15 - _25 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15 - StorageLive(_26); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23 - _26 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23 - StorageLive(_27); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31 - _27 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31 - StorageLive(_28); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15 - _28 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15 - StorageLive(_29); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23 - _29 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23 - StorageLive(_30); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31 - _30 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31 - StorageLive(_31); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15 - _31 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15 - StorageLive(_32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23 - _32 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23 - StorageLive(_33); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31 - _33 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31 - StorageLive(_34); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15 - _34 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15 - StorageLive(_35); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23 - _35 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23 - StorageLive(_36); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31 - _36 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31 - StorageLive(_37); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15 - _37 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15 - StorageLive(_38); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23 - _38 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23 - StorageLive(_39); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31 - _39 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31 - StorageLive(_40); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15 - _40 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15 - StorageLive(_41); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23 - _41 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23 - StorageLive(_42); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31 - _42 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31 - StorageLive(_43); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15 - _43 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15 - StorageLive(_44); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23 - _44 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23 - StorageLive(_45); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31 - _45 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31 - StorageLive(_46); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15 - _46 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15 - StorageLive(_47); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23 - _47 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23 - StorageLive(_48); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31 - _48 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31 - _6 = [move _7, move _8, move _9, move _10, move _11, move _12, move _13, move _14, move _15, move _16, move _17, move _18, move _19, move _20, move _21, move _22, move _23, move _24, move _25, move _26, move _27, move _28, move _29, move _30, move _31, move _32, move _33, move _34, move _35, move _36, move _37, move _38, move _39, move _40, move _41, move _42, move _43, move _44, move _45, move _46, move _47, move _48]; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6 - StorageDead(_48); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_47); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_46); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_45); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_44); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_43); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_42); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_41); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_40); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_39); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_38); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_37); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_36); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_35); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_34); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_33); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_31); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_30); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_29); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_28); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_27); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_26); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_25); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_24); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_23); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_22); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_21); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_20); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_19); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_18); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_17); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_16); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_15); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_14); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_13); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_12); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_11); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_10); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_9); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_8); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - StorageDead(_7); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - _5 = &_6; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - _4 = &(*_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - _3 = move _4 as &[(u32, u32)] (Pointer(Unsize)); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6 - StorageDead(_4); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6 - _2 = Foo { tup: const "hi", data: move _3 }; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2 - // mir::Constant - // + span: $DIR/storage_live_dead_in_statics.rs:6:10: 6:14 - // + literal: Const { ty: &str, val: Value(Slice(..)) } - StorageDead(_3); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 - _1 = &_2; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 - _0 = &(*_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2 - StorageDead(_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 - StorageDead(_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2 - return; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:1: +18:3 - } -} diff --git a/src/test/mir-opt/storage_live_dead_in_statics.rs b/src/test/mir-opt/storage_live_dead_in_statics.rs deleted file mode 100644 index b03de8612..000000000 --- a/src/test/mir-opt/storage_live_dead_in_statics.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Check that when we compile the static `XXX` into MIR, we do not -// generate `StorageStart` or `StorageEnd` statements. - -// EMIT_MIR storage_live_dead_in_statics.XXX.mir_map.0.mir -static XXX: &'static Foo = &Foo { - tup: "hi", - data: &[ - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - (0, 1), (0, 2), (0, 3), - ] -}; - -#[derive(Debug)] -struct Foo { - tup: &'static str, - data: &'static [(u32, u32)] -} - -fn main() { - println!("{:?}", XXX); -} diff --git a/src/test/mir-opt/tls-access.rs b/src/test/mir-opt/tls-access.rs deleted file mode 100644 index 19344c868..000000000 --- a/src/test/mir-opt/tls-access.rs +++ /dev/null @@ -1,14 +0,0 @@ -// EMIT_MIR tls_access.main.PreCodegen.after.mir -// compile-flags: -Zmir-opt-level=0 - -#![feature(thread_local)] - -#[thread_local] -static mut FOO: u8 = 3; - -fn main() { - unsafe { - let a = &FOO; - FOO = 42; - } -} diff --git a/src/test/mir-opt/tls_access.main.PreCodegen.after.mir b/src/test/mir-opt/tls_access.main.PreCodegen.after.mir index b6c36be2b..09453b8ba 100644 --- a/src/test/mir-opt/tls_access.main.PreCodegen.after.mir +++ b/src/test/mir-opt/tls_access.main.PreCodegen.after.mir @@ -1,28 +1,28 @@ // MIR for `main` after PreCodegen fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/tls-access.rs:+0:11: +0:11 - let _2: *mut u8; // in scope 0 at $DIR/tls-access.rs:+2:18: +2:21 - let mut _3: *mut u8; // in scope 0 at $DIR/tls-access.rs:+3:9: +3:12 + let mut _0: (); // return place in scope 0 at $DIR/tls_access.rs:+0:11: +0:11 + let _2: *mut u8; // in scope 0 at $DIR/tls_access.rs:+2:18: +2:21 + let mut _3: *mut u8; // in scope 0 at $DIR/tls_access.rs:+3:9: +3:12 scope 1 { - let _1: &u8; // in scope 1 at $DIR/tls-access.rs:+2:13: +2:14 + let _1: &u8; // in scope 1 at $DIR/tls_access.rs:+2:13: +2:14 scope 2 { - debug a => _1; // in scope 2 at $DIR/tls-access.rs:+2:13: +2:14 + debug a => _1; // in scope 2 at $DIR/tls_access.rs:+2:13: +2:14 } } bb0: { - StorageLive(_1); // scope 1 at $DIR/tls-access.rs:+2:13: +2:14 - StorageLive(_2); // scope 1 at $DIR/tls-access.rs:+2:18: +2:21 - _2 = &/*tls*/ mut FOO; // scope 1 at $DIR/tls-access.rs:+2:18: +2:21 - _1 = &(*_2); // scope 1 at $DIR/tls-access.rs:+2:17: +2:21 - StorageLive(_3); // scope 2 at $DIR/tls-access.rs:+3:9: +3:12 - _3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls-access.rs:+3:9: +3:12 - (*_3) = const 42_u8; // scope 2 at $DIR/tls-access.rs:+3:9: +3:17 - StorageDead(_3); // scope 2 at $DIR/tls-access.rs:+3:17: +3:18 - _0 = const (); // scope 1 at $DIR/tls-access.rs:+1:5: +4:6 - StorageDead(_2); // scope 1 at $DIR/tls-access.rs:+4:5: +4:6 - StorageDead(_1); // scope 1 at $DIR/tls-access.rs:+4:5: +4:6 - return; // scope 0 at $DIR/tls-access.rs:+5:2: +5:2 + StorageLive(_1); // scope 1 at $DIR/tls_access.rs:+2:13: +2:14 + StorageLive(_2); // scope 1 at $DIR/tls_access.rs:+2:18: +2:21 + _2 = &/*tls*/ mut FOO; // scope 1 at $DIR/tls_access.rs:+2:18: +2:21 + _1 = &(*_2); // scope 1 at $DIR/tls_access.rs:+2:17: +2:21 + StorageLive(_3); // scope 2 at $DIR/tls_access.rs:+3:9: +3:12 + _3 = &/*tls*/ mut FOO; // scope 2 at $DIR/tls_access.rs:+3:9: +3:12 + (*_3) = const 42_u8; // scope 2 at $DIR/tls_access.rs:+3:9: +3:17 + StorageDead(_3); // scope 2 at $DIR/tls_access.rs:+3:17: +3:18 + _0 = const (); // scope 1 at $DIR/tls_access.rs:+1:5: +4:6 + StorageDead(_2); // scope 1 at $DIR/tls_access.rs:+4:5: +4:6 + StorageDead(_1); // scope 1 at $DIR/tls_access.rs:+4:5: +4:6 + return; // scope 0 at $DIR/tls_access.rs:+5:2: +5:2 } } diff --git a/src/test/mir-opt/tls_access.rs b/src/test/mir-opt/tls_access.rs new file mode 100644 index 000000000..19344c868 --- /dev/null +++ b/src/test/mir-opt/tls_access.rs @@ -0,0 +1,14 @@ +// EMIT_MIR tls_access.main.PreCodegen.after.mir +// compile-flags: -Zmir-opt-level=0 + +#![feature(thread_local)] + +#[thread_local] +static mut FOO: u8 = 3; + +fn main() { + unsafe { + let a = &FOO; + FOO = 42; + } +} diff --git a/src/test/mir-opt/try_identity_e2e.new.PreCodegen.after.mir b/src/test/mir-opt/try_identity_e2e.new.PreCodegen.after.mir index 330929c58..30185f3ff 100644 --- a/src/test/mir-opt/try_identity_e2e.new.PreCodegen.after.mir +++ b/src/test/mir-opt/try_identity_e2e.new.PreCodegen.after.mir @@ -3,77 +3,56 @@ fn new(_1: Result) -> Result { debug x => _1; // in scope 0 at $DIR/try_identity_e2e.rs:+0:14: +0:15 let mut _0: std::result::Result; // return place in scope 0 at $DIR/try_identity_e2e.rs:+0:34: +0:46 - let mut _2: T; // in scope 0 at $DIR/try_identity_e2e.rs:+2:9: +10:10 - let mut _3: std::ops::ControlFlow; // in scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - let mut _4: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:22 - let _5: T; // in scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 - let mut _6: T; // in scope 0 at $DIR/try_identity_e2e.rs:+4:48: +4:49 - let _7: E; // in scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 - let mut _8: E; // in scope 0 at $DIR/try_identity_e2e.rs:+5:46: +5:47 - let mut _9: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+8:13: +8:37 - let _10: T; // in scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 - let _11: E; // in scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 - let mut _12: E; // in scope 0 at $DIR/try_identity_e2e.rs:+9:49: +9:50 + 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 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 scope 1 { - debug v => _5; // in scope 1 at $DIR/try_identity_e2e.rs:+4:20: +4:21 + debug v => _4; // in scope 1 at $DIR/try_identity_e2e.rs:+4:20: +4:21 } scope 2 { - debug e => _7; // in scope 2 at $DIR/try_identity_e2e.rs:+5:21: +5:22 + debug e => _5; // in scope 2 at $DIR/try_identity_e2e.rs:+5:21: +5:22 } scope 3 { - debug v => _10; // in scope 3 at $DIR/try_identity_e2e.rs:+8:35: +8:36 + debug v => _7; // in scope 3 at $DIR/try_identity_e2e.rs:+8:35: +8:36 } scope 4 { - debug e => _11; // in scope 4 at $DIR/try_identity_e2e.rs:+9:32: +9:33 + debug e => _8; // in scope 4 at $DIR/try_identity_e2e.rs:+9:32: +9:33 } bb0: { - StorageLive(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +10:10 - StorageLive(_3); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - _4 = discriminant(_1); // scope 0 at $DIR/try_identity_e2e.rs:+3:19: +3:20 - switchInt(move _4) -> [0_isize: bb2, 1_isize: bb1, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:20 + 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_isize: bb2, 1_isize: bb1, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:20 } bb1: { - StorageLive(_7); // scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 - _7 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+5:21: +5:22 - StorageLive(_8); // scope 2 at $DIR/try_identity_e2e.rs:+5:46: +5:47 - _8 = move _7; // scope 2 at $DIR/try_identity_e2e.rs:+5:46: +5:47 - Deinit(_3); // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - ((_3 as Break).0: E) = move _8; // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - discriminant(_3) = 1; // scope 2 at $DIR/try_identity_e2e.rs:+5:27: +5:48 - StorageDead(_8); // scope 2 at $DIR/try_identity_e2e.rs:+5:47: +5:48 - StorageDead(_7); // scope 0 at $DIR/try_identity_e2e.rs:+5:47: +5:48 - _9 = discriminant(_3); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - switchInt(move _9) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 + _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_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 } bb2: { - StorageLive(_5); // scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 - _5 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+4:20: +4:21 - StorageLive(_6); // scope 1 at $DIR/try_identity_e2e.rs:+4:48: +4:49 - _6 = move _5; // scope 1 at $DIR/try_identity_e2e.rs:+4:48: +4:49 - Deinit(_3); // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - ((_3 as Continue).0: T) = move _6; // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - discriminant(_3) = 0; // scope 1 at $DIR/try_identity_e2e.rs:+4:26: +4:50 - StorageDead(_6); // scope 1 at $DIR/try_identity_e2e.rs:+4:49: +4:50 - StorageDead(_5); // scope 0 at $DIR/try_identity_e2e.rs:+4:49: +4:50 - _9 = discriminant(_3); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +7:10 - switchInt(move _9) -> [0_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 + _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_isize: bb5, 1_isize: bb3, otherwise: bb4]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +7:10 } bb3: { - StorageLive(_11); // scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 - _11 = move ((_3 as Break).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+9:32: +9:33 - StorageLive(_12); // scope 4 at $DIR/try_identity_e2e.rs:+9:49: +9:50 - _12 = move _11; // scope 4 at $DIR/try_identity_e2e.rs:+9:49: +9:50 + _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 _12; // 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 - StorageDead(_12); // scope 4 at $DIR/try_identity_e2e.rs:+9:50: +9:51 - StorageDead(_11); // scope 0 at $DIR/try_identity_e2e.rs:+9:50: +9:51 - StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+11:5: +11:6 - StorageDead(_3); // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 + 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 } @@ -82,15 +61,11 @@ fn new(_1: Result) -> Result { } bb5: { - StorageLive(_10); // scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 - _10 = move ((_3 as Continue).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+8:35: +8:36 - _2 = move _10; // scope 3 at $DIR/try_identity_e2e.rs:+8:41: +8:42 - StorageDead(_10); // scope 0 at $DIR/try_identity_e2e.rs:+8:41: +8:42 + _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 _2; // 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 - StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+11:5: +11:6 - StorageDead(_3); // scope 0 at $DIR/try_identity_e2e.rs:+12:1: +12:2 + 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/src/test/mir-opt/try_identity_e2e.old.PreCodegen.after.mir b/src/test/mir-opt/try_identity_e2e.old.PreCodegen.after.mir index 18d3e0fb2..2a9c7408c 100644 --- a/src/test/mir-opt/try_identity_e2e.old.PreCodegen.after.mir +++ b/src/test/mir-opt/try_identity_e2e.old.PreCodegen.after.mir @@ -3,35 +3,26 @@ fn old(_1: Result) -> Result { debug x => _1; // in scope 0 at $DIR/try_identity_e2e.rs:+0:14: +0:15 let mut _0: std::result::Result; // return place in scope 0 at $DIR/try_identity_e2e.rs:+0:34: +0:46 - let mut _2: T; // in scope 0 at $DIR/try_identity_e2e.rs:+2:9: +5:10 - let mut _3: isize; // in scope 0 at $DIR/try_identity_e2e.rs:+3:13: +3:18 - let _4: T; // in scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17 - let _5: E; // in scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18 - let mut _6: E; // in scope 0 at $DIR/try_identity_e2e.rs:+4:34: +4:35 + 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 scope 1 { - debug v => _4; // in scope 1 at $DIR/try_identity_e2e.rs:+3:16: +3:17 + debug v => _3; // in scope 1 at $DIR/try_identity_e2e.rs:+3:16: +3:17 } scope 2 { - debug e => _5; // in scope 2 at $DIR/try_identity_e2e.rs:+4:17: +4:18 + debug e => _4; // in scope 2 at $DIR/try_identity_e2e.rs:+4:17: +4:18 } bb0: { - StorageLive(_2); // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +5:10 - _3 = discriminant(_1); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +2:16 - switchInt(move _3) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +2:16 + _2 = discriminant(_1); // scope 0 at $DIR/try_identity_e2e.rs:+2:15: +2:16 + switchInt(move _2) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/try_identity_e2e.rs:+2:9: +2:16 } bb1: { - StorageLive(_5); // scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18 - _5 = move ((_1 as Err).0: E); // scope 0 at $DIR/try_identity_e2e.rs:+4:17: +4:18 - StorageLive(_6); // scope 2 at $DIR/try_identity_e2e.rs:+4:34: +4:35 - _6 = move _5; // scope 2 at $DIR/try_identity_e2e.rs:+4:34: +4:35 + _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 _6; // 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 - StorageDead(_6); // scope 2 at $DIR/try_identity_e2e.rs:+4:35: +4:36 - StorageDead(_5); // scope 0 at $DIR/try_identity_e2e.rs:+4:35: +4:36 - StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+6:5: +6:6 return; // scope 0 at $DIR/try_identity_e2e.rs:+7:1: +7:2 } @@ -40,14 +31,10 @@ fn old(_1: Result) -> Result { } bb3: { - StorageLive(_4); // scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17 - _4 = move ((_1 as Ok).0: T); // scope 0 at $DIR/try_identity_e2e.rs:+3:16: +3:17 - _2 = move _4; // scope 1 at $DIR/try_identity_e2e.rs:+3:22: +3:23 - StorageDead(_4); // scope 0 at $DIR/try_identity_e2e.rs:+3:22: +3:23 + _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 _2; // 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 - StorageDead(_2); // scope 0 at $DIR/try_identity_e2e.rs:+6:5: +6:6 return; // scope 0 at $DIR/try_identity_e2e.rs:+7:1: +7:2 } } diff --git a/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir deleted file mode 100644 index 6a5021139..000000000 --- a/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir +++ /dev/null @@ -1,111 +0,0 @@ -// MIR for `move_out_by_subslice` 0 mir_map - -fn move_out_by_subslice() -> () { - let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +0:27 - let _1: [std::boxed::Box; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let mut _2: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _6: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _7: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _11: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - scope 1 { - debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let _12: [std::boxed::Box; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 - scope 4 { - debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 - } - } - scope 2 { - } - scope 3 { - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:11:14: 11:19 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } - } - - bb1: { - StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - } - - bb2: { - StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:11:21: 11:26 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } - } - - bb3: { - StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - } - - bb4: { - StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27 - drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb5: { - StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb6: { - StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 - _12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12 - _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +3:2 - drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - } - - bb7: { - StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - } - - bb8: { - StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2 - } - - bb9 (cleanup): { - drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - } - - bb10 (cleanup): { - drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb11 (cleanup): { - drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb12 (cleanup): { - resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2 - } -} diff --git a/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir deleted file mode 100644 index 23a50b22a..000000000 --- a/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir +++ /dev/null @@ -1,111 +0,0 @@ -// MIR for `move_out_from_end` 0 mir_map - -fn move_out_from_end() -> () { - let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +0:24 - let _1: [std::boxed::Box; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let mut _2: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _6: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - let mut _7: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - let mut _11: std::boxed::Box; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - scope 1 { - debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - let _12: std::boxed::Box; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 - scope 4 { - debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 - } - } - scope 2 { - } - scope 3 { - } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:5:14: 5:19 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } - } - - bb1: { - StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19 - drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - } - - bb2: { - StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19 - StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - // mir::Constant - // + span: $DIR/uniform_array_move_out.rs:5:21: 5:26 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value() } - } - - bb3: { - StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26 - drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - } - - bb4: { - StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26 - _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27 - drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb5: { - StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb6: { - StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10 - StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 - _12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16 - _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +3:2 - drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - } - - bb7: { - StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - } - - bb8: { - StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2 - } - - bb9 (cleanup): { - drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2 - } - - bb10 (cleanup): { - drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb11 (cleanup): { - drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27 - } - - bb12 (cleanup): { - resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2 - } -} diff --git a/src/test/mir-opt/uniform_array_move_out.rs b/src/test/mir-opt/uniform_array_move_out.rs deleted file mode 100644 index 35e425528..000000000 --- a/src/test/mir-opt/uniform_array_move_out.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(box_syntax)] - -// EMIT_MIR uniform_array_move_out.move_out_from_end.mir_map.0.mir -fn move_out_from_end() { - let a = [box 1, box 2]; - let [.., _y] = a; -} - -// EMIT_MIR uniform_array_move_out.move_out_by_subslice.mir_map.0.mir -fn move_out_by_subslice() { - let a = [box 1, box 2]; - let [_y @ ..] = a; -} - -fn main() { - move_out_by_subslice(); - move_out_from_end(); -} diff --git a/src/test/mir-opt/uninhabited-enum.rs b/src/test/mir-opt/uninhabited-enum.rs deleted file mode 100644 index 97c6e8cd5..000000000 --- a/src/test/mir-opt/uninhabited-enum.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(never_type)] - -pub enum Void {} - -// EMIT_MIR uninhabited_enum.process_never.SimplifyLocals.after.mir -#[no_mangle] -pub fn process_never(input: *const !) { - let _input = unsafe { &*input }; -} - -// EMIT_MIR uninhabited_enum.process_void.SimplifyLocals.after.mir -#[no_mangle] -pub fn process_void(input: *const Void) { - let _input = unsafe { &*input }; - // In the future, this should end with `unreachable`, but we currently only do - // unreachability analysis for `!`. -} - -fn main() {} diff --git a/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir index 6ed53643f..2c0fcc662 100644 --- a/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir +++ b/src/test/mir-opt/uninhabited_enum.process_never.SimplifyLocals.after.mir @@ -1,16 +1,16 @@ // MIR for `process_never` after SimplifyLocals fn process_never(_1: *const !) -> () { - debug input => _1; // in scope 0 at $DIR/uninhabited-enum.rs:+0:22: +0:27 - let mut _0: (); // return place in scope 0 at $DIR/uninhabited-enum.rs:+0:39: +0:39 - let _2: &!; // in scope 0 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug input => _1; // in scope 0 at $DIR/uninhabited_enum.rs:+0:22: +0:27 + let mut _0: (); // return place in scope 0 at $DIR/uninhabited_enum.rs:+0:39: +0:39 + let _2: &!; // in scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 scope 1 { - debug _input => _2; // in scope 1 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug _input => _2; // in scope 1 at $DIR/uninhabited_enum.rs:+1:8: +1:14 } scope 2 { } bb0: { - unreachable; // scope 0 at $DIR/uninhabited-enum.rs:+0:39: +2:2 + unreachable; // scope 0 at $DIR/uninhabited_enum.rs:+0:39: +2:2 } } diff --git a/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir index bbb81724c..ae341a7b9 100644 --- a/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir +++ b/src/test/mir-opt/uninhabited_enum.process_void.SimplifyLocals.after.mir @@ -1,18 +1,18 @@ // MIR for `process_void` after SimplifyLocals fn process_void(_1: *const Void) -> () { - debug input => _1; // in scope 0 at $DIR/uninhabited-enum.rs:+0:21: +0:26 - let mut _0: (); // return place in scope 0 at $DIR/uninhabited-enum.rs:+0:41: +0:41 - let _2: &Void; // in scope 0 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug input => _1; // in scope 0 at $DIR/uninhabited_enum.rs:+0:21: +0:26 + let mut _0: (); // return place in scope 0 at $DIR/uninhabited_enum.rs:+0:41: +0:41 + let _2: &Void; // in scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 scope 1 { - debug _input => _2; // in scope 1 at $DIR/uninhabited-enum.rs:+1:8: +1:14 + debug _input => _2; // in scope 1 at $DIR/uninhabited_enum.rs:+1:8: +1:14 } scope 2 { } bb0: { - StorageLive(_2); // scope 0 at $DIR/uninhabited-enum.rs:+1:8: +1:14 - StorageDead(_2); // scope 0 at $DIR/uninhabited-enum.rs:+4:1: +4:2 - return; // scope 0 at $DIR/uninhabited-enum.rs:+4:2: +4:2 + StorageLive(_2); // scope 0 at $DIR/uninhabited_enum.rs:+1:8: +1:14 + StorageDead(_2); // scope 0 at $DIR/uninhabited_enum.rs:+4:1: +4:2 + return; // scope 0 at $DIR/uninhabited_enum.rs:+4:2: +4:2 } } diff --git a/src/test/mir-opt/uninhabited_enum.rs b/src/test/mir-opt/uninhabited_enum.rs new file mode 100644 index 000000000..97c6e8cd5 --- /dev/null +++ b/src/test/mir-opt/uninhabited_enum.rs @@ -0,0 +1,19 @@ +#![feature(never_type)] + +pub enum Void {} + +// EMIT_MIR uninhabited_enum.process_never.SimplifyLocals.after.mir +#[no_mangle] +pub fn process_never(input: *const !) { + let _input = unsafe { &*input }; +} + +// EMIT_MIR uninhabited_enum.process_void.SimplifyLocals.after.mir +#[no_mangle] +pub fn process_void(input: *const Void) { + let _input = unsafe { &*input }; + // In the future, this should end with `unreachable`, but we currently only do + // unreachability analysis for `!`. +} + +fn main() {} diff --git a/src/test/mir-opt/unusual-item-types.rs b/src/test/mir-opt/unusual-item-types.rs deleted file mode 100644 index 9ef3d8647..000000000 --- a/src/test/mir-opt/unusual-item-types.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Test that we don't ICE when trying to dump MIR for unusual item types and -// that we don't create filenames containing `<` and `>` -// compile-flags: -Zmir-opt-level=0 - - -struct A; - -// EMIT_MIR unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.mir -impl A { - const ASSOCIATED_CONSTANT: i32 = 2; -} - -// See #59021 -// EMIT_MIR unusual_item_types.Test-X-{constructor#0}.mir_map.0.mir -enum Test { - X(usize), - Y { a: usize }, -} - -// EMIT_MIR unusual_item_types.E-V-{constant#0}.mir_map.0.mir -enum E { - V = 5, -} - -fn main() { - let f = Test::X as fn(usize) -> Test; -// EMIT_MIR core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir - let v = Vec::::new(); -} diff --git a/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir b/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir new file mode 100644 index 000000000..5257491f0 --- /dev/null +++ b/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `E::V::{constant#0}` after built + +E::V::{constant#0}: isize = { + let mut _0: isize; // return place in scope 0 at $DIR/unusual_item_types.rs:+0:9: +0:10 + + bb0: { + _0 = const 5_isize; // scope 0 at $DIR/unusual_item_types.rs:+0:9: +0:10 + return; // scope 0 at $DIR/unusual_item_types.rs:+0:9: +0:10 + } +} diff --git a/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.mir_map.0.mir b/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.mir_map.0.mir deleted file mode 100644 index a72e00ecd..000000000 --- a/src/test/mir-opt/unusual_item_types.E-V-{constant#0}.mir_map.0.mir +++ /dev/null @@ -1,10 +0,0 @@ -// MIR for `E::V::{constant#0}` 0 mir_map - -E::V::{constant#0}: isize = { - let mut _0: isize; // return place in scope 0 at $DIR/unusual-item-types.rs:+0:9: +0:10 - - bb0: { - _0 = const 5_isize; // scope 0 at $DIR/unusual-item-types.rs:+0:9: +0:10 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:9: +0:10 - } -} diff --git a/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir b/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir new file mode 100644 index 000000000..ee0296763 --- /dev/null +++ b/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.built.after.mir @@ -0,0 +1,12 @@ +// MIR for `Test::X` after built + +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 + return; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:6 + } +} diff --git a/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.mir_map.0.mir b/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.mir_map.0.mir deleted file mode 100644 index 0686af46e..000000000 --- a/src/test/mir-opt/unusual_item_types.Test-X-{constructor#0}.mir_map.0.mir +++ /dev/null @@ -1,12 +0,0 @@ -// MIR for `Test::X` 0 mir_map - -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 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:6 - } -} diff --git a/src/test/mir-opt/unusual_item_types.rs b/src/test/mir-opt/unusual_item_types.rs new file mode 100644 index 000000000..6dad63641 --- /dev/null +++ b/src/test/mir-opt/unusual_item_types.rs @@ -0,0 +1,29 @@ +// Test that we don't ICE when trying to dump MIR for unusual item types and +// that we don't create filenames containing `<` and `>` +// compile-flags: -Zmir-opt-level=0 + + +struct A; + +// EMIT_MIR unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir +impl A { + const ASSOCIATED_CONSTANT: i32 = 2; +} + +// See #59021 +// EMIT_MIR unusual_item_types.Test-X-{constructor#0}.built.after.mir +enum Test { + X(usize), + Y { a: usize }, +} + +// EMIT_MIR unusual_item_types.E-V-{constant#0}.built.after.mir +enum E { + V = 5, +} + +fn main() { + let f = Test::X as fn(usize) -> Test; +// EMIT_MIR core.ptr-drop_in_place.Vec_i32_.AddMovesForPackedDrops.before.mir + let v = Vec::::new(); +} diff --git a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir new file mode 100644 index 000000000..90444b481 --- /dev/null +++ b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.built.after.mir @@ -0,0 +1,10 @@ +// MIR for `::ASSOCIATED_CONSTANT` after built + +const ::ASSOCIATED_CONSTANT: i32 = { + let mut _0: i32; // return place in scope 0 at $DIR/unusual_item_types.rs:+0:32: +0:35 + + bb0: { + _0 = const 2_i32; // scope 0 at $DIR/unusual_item_types.rs:+0:38: +0:39 + return; // scope 0 at $DIR/unusual_item_types.rs:+0:5: +0:40 + } +} diff --git a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.mir b/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.mir deleted file mode 100644 index 5579d25a1..000000000 --- a/src/test/mir-opt/unusual_item_types.{impl#0}-ASSOCIATED_CONSTANT.mir_map.0.mir +++ /dev/null @@ -1,10 +0,0 @@ -// MIR for `::ASSOCIATED_CONSTANT` 0 mir_map - -const ::ASSOCIATED_CONSTANT: i32 = { - let mut _0: i32; // return place in scope 0 at $DIR/unusual-item-types.rs:+0:32: +0:35 - - bb0: { - _0 = const 2_i32; // scope 0 at $DIR/unusual-item-types.rs:+0:38: +0:39 - return; // scope 0 at $DIR/unusual-item-types.rs:+0:5: +0:40 - } -} diff --git a/src/test/mir-opt/while-storage.rs b/src/test/mir-opt/while-storage.rs deleted file mode 100644 index afd083acb..000000000 --- a/src/test/mir-opt/while-storage.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Test that we correctly generate StorageDead statements for while loop -// conditions on all branches - -fn get_bool(c: bool) -> bool { - c -} - -// EMIT_MIR while_storage.while_loop.PreCodegen.after.mir -fn while_loop(c: bool) { - while get_bool(c) { - if get_bool(c) { - break; - } - } -} - -fn main() { - while_loop(false); -} diff --git a/src/test/mir-opt/while_storage.rs b/src/test/mir-opt/while_storage.rs new file mode 100644 index 000000000..afd083acb --- /dev/null +++ b/src/test/mir-opt/while_storage.rs @@ -0,0 +1,19 @@ +// Test that we correctly generate StorageDead statements for while loop +// conditions on all branches + +fn get_bool(c: bool) -> bool { + c +} + +// EMIT_MIR while_storage.while_loop.PreCodegen.after.mir +fn while_loop(c: bool) { + while get_bool(c) { + if get_bool(c) { + break; + } + } +} + +fn main() { + while_loop(false); +} diff --git a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir index a5e7d6afd..68aa3e5db 100644 --- a/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir +++ b/src/test/mir-opt/while_storage.while_loop.PreCodegen.after.mir @@ -1,56 +1,56 @@ // MIR for `while_loop` after PreCodegen 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 + 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 bb0: { - goto -> bb1; // scope 0 at $DIR/while-storage.rs:+1:5: +5:6 + goto -> bb1; // scope 0 at $DIR/while_storage.rs:+1:5: +5:6 } 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 + 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 // mir::Constant - // + span: $DIR/while-storage.rs:10:11: 10:19 + // + 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) -> [false: bb7, otherwise: bb3]; // scope 0 at $DIR/while-storage.rs:+1:11: +1:22 + StorageDead(_3); // scope 0 at $DIR/while_storage.rs:+1:21: +1:22 + switchInt(move _2) -> [false: 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(_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 // mir::Constant - // + span: $DIR/while-storage.rs:11:12: 11:20 + // + 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) -> [false: bb6, otherwise: bb5]; // scope 0 at $DIR/while-storage.rs:+2:12: +2:23 + StorageDead(_5); // scope 0 at $DIR/while_storage.rs:+2:22: +2:23 + switchInt(move _4) -> [false: 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(_4); // scope 0 at $DIR/while_storage.rs:+4:9: +4:10 goto -> bb8; // scope 0 at no-location } bb6: { - StorageDead(_4); // 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 + StorageDead(_4); // 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 } bb7: { @@ -58,7 +58,7 @@ fn while_loop(_1: bool) -> () { } bb8: { - StorageDead(_2); // scope 0 at $DIR/while-storage.rs:+5:5: +5:6 - return; // scope 0 at $DIR/while-storage.rs:+6:2: +6:2 + StorageDead(_2); // scope 0 at $DIR/while_storage.rs:+5:5: +5:6 + return; // scope 0 at $DIR/while_storage.rs:+6:2: +6:2 } } -- cgit v1.2.3