From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../mir-opt/inline/caller-with-trivial-bound.rs | 26 ++++ .../caller_with_trivial_bound.foo.Inline.diff | 33 +++++ src/test/mir-opt/inline/cycle.f.Inline.diff | 43 ++++++ src/test/mir-opt/inline/cycle.g.Inline.diff | 57 ++++++++ src/test/mir-opt/inline/cycle.main.Inline.diff | 74 ++++++++++ src/test/mir-opt/inline/cycle.rs | 18 +++ src/test/mir-opt/inline/dyn-trait.rs | 35 +++++ .../mir-opt/inline/dyn_trait.get_query.Inline.diff | 62 ++++++++ .../mir-opt/inline/dyn_trait.mk_cycle.Inline.diff | 23 +++ .../inline/dyn_trait.try_execute_query.Inline.diff | 37 +++++ 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 | 44 ++++++ .../inline/inline_closure.foo.Inline.after.mir | 49 +++++++ ...inline_closure_borrows_arg.foo.Inline.after.mir | 56 ++++++++ .../inline_closure_captures.foo.Inline.after.mir | 69 +++++++++ ...e_compatibility.inlined_no_sanitize.Inline.diff | 24 ++++ ...ompatibility.inlined_target_feature.Inline.diff | 24 ++++ ...ompatibility.not_inlined_c_variadic.Inline.diff | 25 ++++ ...mpatibility.not_inlined_no_sanitize.Inline.diff | 22 +++ ...tibility.not_inlined_target_feature.Inline.diff | 22 +++ .../mir-opt/inline/inline_cycle.one.Inline.diff | 30 ++++ .../mir-opt/inline/inline_cycle.two.Inline.diff | 55 ++++++++ .../inline/inline_cycle_generic.main.Inline.diff | 32 +++++ .../mir-opt/inline/inline_diverging.f.Inline.diff | 24 ++++ .../mir-opt/inline/inline_diverging.g.Inline.diff | 49 +++++++ .../mir-opt/inline/inline_diverging.h.Inline.diff | 56 ++++++++ .../inline/inline_generator.main.Inline.diff | 156 +++++++++++++++++++++ .../inline_instruction_set.default.Inline.diff | 44 ++++++ .../inline/inline_instruction_set.t32.Inline.diff | 46 ++++++ .../inline_into_box_place.main.Inline.32bit.diff | 86 ++++++++++++ .../inline_into_box_place.main.Inline.64bit.diff | 86 ++++++++++++ .../inline/inline_options.main.Inline.after.mir | 55 ++++++++ .../inline/inline_retag.bar.Inline.after.mir | 72 ++++++++++ .../mir-opt/inline/inline_shims.clone.Inline.diff | 26 ++++ .../mir-opt/inline/inline_shims.drop.Inline.diff | 56 ++++++++ .../inline/inline_specialization.main.Inline.diff | 28 ++++ .../inline_trait_method.test.Inline.after.mir | 21 +++ .../inline_trait_method_2.test2.Inline.after.mir | 32 +++++ .../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 | 30 ++++ ...e_58867_inline_as_ref_as_mut.b.Inline.after.mir | 42 ++++++ ...e_58867_inline_as_ref_as_mut.c.Inline.after.mir | 22 +++ ...e_58867_inline_as_ref_as_mut.d.Inline.after.mir | 30 ++++ ...7_inline_scopes_parenting.main.Inline.after.mir | 42 ++++++ .../mir-opt/inline/issue_78442.bar.Inline.diff | 68 +++++++++ .../mir-opt/inline/issue_78442.bar.RevealAll.diff | 57 ++++++++ 65 files changed, 2509 insertions(+) create mode 100644 src/test/mir-opt/inline/caller-with-trivial-bound.rs create mode 100644 src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff create mode 100644 src/test/mir-opt/inline/cycle.f.Inline.diff create mode 100644 src/test/mir-opt/inline/cycle.g.Inline.diff create mode 100644 src/test/mir-opt/inline/cycle.main.Inline.diff create mode 100644 src/test/mir-opt/inline/cycle.rs create mode 100644 src/test/mir-opt/inline/dyn-trait.rs create mode 100644 src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff create mode 100644 src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff create mode 100644 src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff 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-borrows-arg.rs create mode 100644 src/test/mir-opt/inline/inline-closure-captures.rs create mode 100644 src/test/mir-opt/inline/inline-closure.rs create mode 100644 src/test/mir-opt/inline/inline-compatibility.rs create mode 100644 src/test/mir-opt/inline/inline-cycle-generic.rs create mode 100644 src/test/mir-opt/inline/inline-cycle.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 create mode 100644 src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir create mode 100644 src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir create mode 100644 src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir create mode 100644 src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir create mode 100644 src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_cycle.one.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_cycle.two.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_diverging.f.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_diverging.g.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_diverging.h.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_generator.main.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff create mode 100644 src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff create mode 100644 src/test/mir-opt/inline/inline_options.main.Inline.after.mir create mode 100644 src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir create mode 100644 src/test/mir-opt/inline/inline_shims.clone.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_shims.drop.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_specialization.main.Inline.diff create mode 100644 src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir create mode 100644 src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir 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 create mode 100644 src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir create mode 100644 src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir create mode 100644 src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir create mode 100644 src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir create mode 100644 src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir create mode 100644 src/test/mir-opt/inline/issue_78442.bar.Inline.diff create mode 100644 src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff (limited to 'src/test/mir-opt/inline') 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/caller_with_trivial_bound.foo.Inline.diff b/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff new file mode 100644 index 000000000..d7deb9c66 --- /dev/null +++ b/src/test/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff @@ -0,0 +1,33 @@ +- // MIR for `foo` before Inline ++ // 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 + scope 1 { + 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 + // mir::Constant + // + 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 + } + + 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 + } + + bb3 (cleanup): { + resume; // scope 0 at $DIR/caller-with-trivial-bound.rs:+0:1: +5:2 + } + } + diff --git a/src/test/mir-opt/inline/cycle.f.Inline.diff b/src/test/mir-opt/inline/cycle.f.Inline.diff new file mode 100644 index 000000000..40fdd1cdb --- /dev/null +++ b/src/test/mir-opt/inline/cycle.f.Inline.diff @@ -0,0 +1,43 @@ +- // MIR for `f` before Inline ++ // MIR for `f` after Inline + + fn f(_1: impl Fn()) -> () { + debug g => _1; // in scope 0 at $DIR/cycle.rs:+0:6: +0:7 + let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:20: +0:20 + let _2: (); // in scope 0 at $DIR/cycle.rs:+1:5: +1:8 + let mut _3: &impl Fn(); // in scope 0 at $DIR/cycle.rs:+1:5: +1:6 + let mut _4: (); // in scope 0 at $DIR/cycle.rs:+1:5: +1:8 + + bb0: { + StorageLive(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:8 + StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:6 + _3 = &_1; // scope 0 at $DIR/cycle.rs:+1:5: +1:6 + StorageLive(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:8 + Deinit(_4); // scope 0 at $DIR/cycle.rs:+1:5: +1:8 + _2 = >::call(move _3, move _4) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/cycle.rs:+1:5: +1:8 + // mir::Constant + // + span: $DIR/cycle.rs:6:5: 6:6 + // + literal: Const { ty: for<'r> extern "rust-call" fn(&'r impl Fn(), ()) -> >::Output {>::call}, val: Value() } + } + + bb1: { + StorageDead(_4); // scope 0 at $DIR/cycle.rs:+1:7: +1:8 + StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:7: +1:8 + StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:8: +1:9 + _0 = const (); // scope 0 at $DIR/cycle.rs:+0:20: +2:2 + drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/cycle.rs:+2:1: +2:2 + } + + bb2: { + return; // scope 0 at $DIR/cycle.rs:+2:2: +2:2 + } + + bb3 (cleanup): { + drop(_1) -> bb4; // scope 0 at $DIR/cycle.rs:+2:1: +2:2 + } + + bb4 (cleanup): { + resume; // scope 0 at $DIR/cycle.rs:+0:1: +2:2 + } + } + diff --git a/src/test/mir-opt/inline/cycle.g.Inline.diff b/src/test/mir-opt/inline/cycle.g.Inline.diff new file mode 100644 index 000000000..59f34d379 --- /dev/null +++ b/src/test/mir-opt/inline/cycle.g.Inline.diff @@ -0,0 +1,57 @@ +- // MIR for `g` before Inline ++ // MIR for `g` after Inline + + fn g() -> () { + let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:8: +0:8 + let _1: (); // in scope 0 at $DIR/cycle.rs:+1:5: +1:12 ++ let mut _2: fn() {main}; // in scope 0 at $DIR/cycle.rs:+1:5: +1:12 ++ scope 1 (inlined f::) { // at $DIR/cycle.rs:12:5: 12:12 ++ debug g => _2; // in scope 1 at $DIR/cycle.rs:+0:6: +0:7 ++ let _3: (); // in scope 1 at $DIR/cycle.rs:+0:5: +0:8 ++ let mut _4: &fn() {main}; // in scope 1 at $DIR/cycle.rs:+0:5: +0:6 ++ let mut _5: (); // in scope 1 at $DIR/cycle.rs:+0:5: +0:8 ++ scope 2 (inlined >::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8 ++ } ++ } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 +- _1 = f::(main) -> bb1; // scope 0 at $DIR/cycle.rs:+1:5: +1:12 ++ StorageLive(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 ++ _2 = main; // scope 0 at $DIR/cycle.rs:+1:5: +1:12 + // mir::Constant +- // + span: $DIR/cycle.rs:12:5: 12:6 +- // + literal: Const { ty: fn(fn() {main}) {f::}, val: Value() } +- // mir::Constant + // + span: $DIR/cycle.rs:12:7: 12:11 + // + literal: Const { ty: fn() {main}, val: Value() } ++ StorageLive(_3); // scope 1 at $DIR/cycle.rs:+0:5: +0:8 ++ StorageLive(_4); // scope 1 at $DIR/cycle.rs:+0:5: +0:6 ++ _4 = &_2; // scope 1 at $DIR/cycle.rs:+0:5: +0:6 ++ StorageLive(_5); // scope 1 at $DIR/cycle.rs:+0:5: +0:8 ++ _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL + } + + bb1: { ++ StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 + StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:12: +1:13 + _0 = const (); // scope 0 at $DIR/cycle.rs:+0:8: +2:2 + return; // scope 0 at $DIR/cycle.rs:+2:2: +2:2 ++ } ++ ++ bb2 (cleanup): { ++ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:+0:1: +0:2 ++ } ++ ++ bb3 (cleanup): { ++ resume; // scope 1 at $DIR/cycle.rs:+0:1: +0:2 ++ } ++ ++ bb4: { ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:+0:7: +0:8 ++ StorageDead(_4); // scope 1 at $DIR/cycle.rs:+0:7: +0:8 ++ StorageDead(_3); // scope 1 at $DIR/cycle.rs:+0:8: +0:9 ++ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:+0:1: +0:2 + } + } + diff --git a/src/test/mir-opt/inline/cycle.main.Inline.diff b/src/test/mir-opt/inline/cycle.main.Inline.diff new file mode 100644 index 000000000..6def7c3ee --- /dev/null +++ b/src/test/mir-opt/inline/cycle.main.Inline.diff @@ -0,0 +1,74 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/cycle.rs:+0:11: +0:11 + let _1: (); // in scope 0 at $DIR/cycle.rs:+1:5: +1:9 ++ let mut _2: fn() {g}; // in scope 0 at $DIR/cycle.rs:+1:5: +1:9 ++ scope 1 (inlined f::) { // at $DIR/cycle.rs:17:5: 17:9 ++ debug g => _2; // in scope 1 at $DIR/cycle.rs:+0:6: +0:7 ++ let _3: (); // in scope 1 at $DIR/cycle.rs:+0:5: +0:8 ++ let mut _4: &fn() {g}; // in scope 1 at $DIR/cycle.rs:+0:5: +0:6 ++ let mut _5: (); // in scope 1 at $DIR/cycle.rs:+0:5: +0: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:+0:5: +0:12 ++ scope 4 (inlined f::) { // at $DIR/cycle.rs:12:5: 12:12 ++ debug g => _6; // in scope 4 at $DIR/cycle.rs:+0:6: +0:7 ++ let _7: (); // in scope 4 at $DIR/cycle.rs:+0:5: +0:8 ++ let mut _8: &fn() {main}; // in scope 4 at $DIR/cycle.rs:+0:5: +0:6 ++ scope 5 (inlined >::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8 ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 +- _1 = f::(g) -> bb1; // scope 0 at $DIR/cycle.rs:+1:5: +1:9 ++ StorageLive(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 ++ _2 = g; // scope 0 at $DIR/cycle.rs:+1:5: +1:9 + // mir::Constant +- // + span: $DIR/cycle.rs:17:5: 17:6 +- // + literal: Const { ty: fn(fn() {g}) {f::}, val: Value() } +- // mir::Constant + // + span: $DIR/cycle.rs:17:7: 17:8 + // + literal: Const { ty: fn() {g}, val: Value() } ++ StorageLive(_3); // scope 1 at $DIR/cycle.rs:+0:5: +0:8 ++ StorageLive(_4); // scope 1 at $DIR/cycle.rs:+0:5: +0:6 ++ _4 = &_2; // scope 1 at $DIR/cycle.rs:+0:5: +0:6 ++ StorageLive(_5); // scope 1 at $DIR/cycle.rs:+0:5: +0:8 ++ StorageLive(_6); // scope 3 at $DIR/cycle.rs:+0:5: +0:12 ++ StorageLive(_7); // scope 4 at $DIR/cycle.rs:+0:5: +0:8 ++ StorageLive(_8); // scope 4 at $DIR/cycle.rs:+0:5: +0:6 ++ _8 = &_6; // scope 4 at $DIR/cycle.rs:+0:5: +0:6 ++ _7 = move (*_8)() -> [return: bb4, unwind: bb2]; // scope 5 at $SRC_DIR/core/src/ops/function.rs:LL:COL + } + + bb1: { ++ StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 + StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:10 + _0 = const (); // scope 0 at $DIR/cycle.rs:+0:11: +2:2 + return; // scope 0 at $DIR/cycle.rs:+2:2: +2:2 ++ } ++ ++ bb2 (cleanup): { ++ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:+0:1: +0:2 ++ } ++ ++ bb3 (cleanup): { ++ resume; // scope 1 at $DIR/cycle.rs:+0:1: +0:2 ++ } ++ ++ bb4: { ++ StorageDead(_8); // scope 4 at $DIR/cycle.rs:+0:7: +0:8 ++ StorageDead(_7); // scope 4 at $DIR/cycle.rs:+0:8: +0:9 ++ StorageDead(_6); // scope 3 at $DIR/cycle.rs:+0:5: +0:12 ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:+0:7: +0:8 ++ StorageDead(_4); // scope 1 at $DIR/cycle.rs:+0:7: +0:8 ++ StorageDead(_3); // scope 1 at $DIR/cycle.rs:+0:8: +0:9 ++ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:+0:1: +0:2 + } + } + diff --git a/src/test/mir-opt/inline/cycle.rs b/src/test/mir-opt/inline/cycle.rs new file mode 100644 index 000000000..9e8950d8a --- /dev/null +++ b/src/test/mir-opt/inline/cycle.rs @@ -0,0 +1,18 @@ +// ignore-wasm32-bare compiled with panic=abort by default + +// EMIT_MIR cycle.f.Inline.diff +#[inline(always)] +fn f(g: impl Fn()) { + g(); +} + +// EMIT_MIR cycle.g.Inline.diff +#[inline(always)] +fn g() { + f(main); +} + +// EMIT_MIR cycle.main.Inline.diff +fn main() { + f(g); +} 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.get_query.Inline.diff b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff new file mode 100644 index 000000000..8eae04c4d --- /dev/null +++ b/src/test/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -0,0 +1,62 @@ +- // MIR for `get_query` before Inline ++ // 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 + 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:+0:36: +0:37 ++ let mut _5: &dyn Cache::V>; // in scope 2 at $DIR/dyn-trait.rs:+0:14: +0:15 ++ let mut _6: &::C; // in scope 2 at $DIR/dyn-trait.rs:+0:14: +0: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:+0:27: +0:28 ++ let mut _7: &dyn Cache::V>; // in scope 3 at $DIR/dyn-trait.rs:+0:5: +0:22 ++ } ++ } + } + + 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 + // mir::Constant + // + span: $DIR/dyn-trait.rs:33:13: 33:21 + // + user_ty: UserType(0) + // + literal: Const { ty: for<'r> fn(&'r T) -> &'r ::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:+0:14: +0:15 ++ StorageLive(_6); // scope 2 at $DIR/dyn-trait.rs:+0:14: +0:15 ++ _6 = _4; // scope 2 at $DIR/dyn-trait.rs:+0:14: +0:15 ++ _5 = move _6 as &dyn Cache::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn-trait.rs:+0:14: +0:15 ++ StorageDead(_6); // scope 2 at $DIR/dyn-trait.rs:+0:14: +0:15 ++ StorageLive(_7); // scope 3 at $DIR/dyn-trait.rs:+0:5: +0:22 ++ _7 = _5; // scope 3 at $DIR/dyn-trait.rs:+0:5: +0:22 ++ _0 = ::V> as Cache>::store_nocache(move _7) -> bb2; // scope 3 at $DIR/dyn-trait.rs:+0:5: +0:22 + // mir::Constant +- // + span: $DIR/dyn-trait.rs:34:5: 34:22 +- // + literal: Const { ty: for<'r> fn(&'r ::C) {try_execute_query::<::C>}, val: Value() } ++ // + span: $DIR/dyn-trait.rs:21:7: 21:20 ++ // + literal: Const { ty: for<'r> fn(&'r dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } + } + + bb2: { ++ StorageDead(_7); // scope 3 at $DIR/dyn-trait.rs:+0:21: +0:22 ++ StorageDead(_5); // scope 2 at $DIR/dyn-trait.rs:+0:15: +0: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 new file mode 100644 index 000000000..994930ef4 --- /dev/null +++ b/src/test/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff @@ -0,0 +1,23 @@ +- // MIR for `mk_cycle` before Inline ++ // 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 + + 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 + // mir::Constant + // + span: $DIR/dyn-trait.rs:21:7: 21:20 + // + literal: Const { ty: for<'r> fn(&'r 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 + } + } + 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 new file mode 100644 index 000000000..e7c5972f4 --- /dev/null +++ b/src/test/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -0,0 +1,37 @@ +- // MIR for `try_execute_query` before Inline ++ // 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:+0:27: +0:28 ++ let mut _4: &dyn Cache::V>; // in scope 1 at $DIR/dyn-trait.rs:+0:5: +0:22 ++ } + + 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:+0:5: +0:22 ++ _4 = _2; // scope 1 at $DIR/dyn-trait.rs:+0:5: +0:22 ++ _0 = ::V> as Cache>::store_nocache(move _4) -> bb1; // scope 1 at $DIR/dyn-trait.rs:+0:5: +0:22 + // mir::Constant +- // + span: $DIR/dyn-trait.rs:27:5: 27:13 +- // + literal: Const { ty: for<'r> fn(&'r (dyn Cache::V> + 'r)) {mk_cycle::<::V>}, val: Value() } ++ // + span: $DIR/dyn-trait.rs:21:7: 21:20 ++ // + literal: Const { ty: for<'r> fn(&'r dyn Cache::V>) {::V> as Cache>::store_nocache}, val: Value() } + } + + bb1: { ++ StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:+0:21: +0: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 + } + } + 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-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.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-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-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-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-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-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.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.rs b/src/test/mir-opt/inline/inline-instruction-set.rs new file mode 100644 index 000000000..be36ff50c --- /dev/null +++ b/src/test/mir-opt/inline/inline-instruction-set.rs @@ -0,0 +1,54 @@ +// 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 new file mode 100644 index 000000000..049a97816 --- /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 +// EMIT_MIR_FOR_EACH_BIT_WIDTH +#![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 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.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.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.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_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_any_operand.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir new file mode 100644 index 000000000..630225258 --- /dev/null +++ b/src/test/mir-opt/inline/inline_any_operand.bar.Inline.after.mir @@ -0,0 +1,44 @@ +// 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 + 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:+6:8: +6:9 + debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:+6:16: +6:17 + let mut _5: i32; // in scope 2 at $DIR/inline-any-operand.rs:+7:5: +7:6 + let mut _6: i32; // in scope 2 at $DIR/inline-any-operand.rs:+7:10: +7:11 + } + } + + 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 + // mir::Constant + // + 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:+7:5: +7:6 + _5 = _3; // scope 2 at $DIR/inline-any-operand.rs:+7:5: +7:6 + StorageLive(_6); // scope 2 at $DIR/inline-any-operand.rs:+7:10: +7:11 + _6 = _4; // scope 2 at $DIR/inline-any-operand.rs:+7:10: +7:11 + _0 = Eq(move _5, move _6); // scope 2 at $DIR/inline-any-operand.rs:+7:5: +7:11 + StorageDead(_6); // scope 2 at $DIR/inline-any-operand.rs:+7:10: +7:11 + StorageDead(_5); // scope 2 at $DIR/inline-any-operand.rs:+7:10: +7: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_closure.foo.Inline.after.mir b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir new file mode 100644 index 000000000..1fadd2464 --- /dev/null +++ b/src/test/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -0,0 +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 + 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 + } + } + + 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 + } +} 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 new file mode 100644 index 000000000..4069e9f89 --- /dev/null +++ b/src/test/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -0,0 +1,56 @@ +// 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 + 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 + scope 3 { + debug variable => _10; // 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 + } +} 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 new file mode 100644 index 000000000..d60b06460 --- /dev/null +++ b/src/test/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -0,0 +1,69 @@ +// 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 + 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:17 + let mut _13: &T; // in scope 2 at $DIR/inline-closure-captures.rs:+1:13: +1:17 + } + } + + 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 + StorageLive(_12); // 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 + StorageDead(_12); // scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23 + StorageLive(_11); // scope 2 at $DIR/inline-closure-captures.rs:+1:22: +1:23 + StorageLive(_13); // 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 + StorageDead(_13); // scope 2 at $DIR/inline-closure-captures.rs:+1:18: +1:24 + 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_compatibility.inlined_no_sanitize.Inline.diff b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff new file mode 100644 index 000000000..cf800ba11 --- /dev/null +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff @@ -0,0 +1,24 @@ +- // MIR for `inlined_no_sanitize` before Inline ++ // 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 ++ } + + 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 +- // mir::Constant +- // + 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 + } + } + 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 new file mode 100644 index 000000000..a45f95902 --- /dev/null +++ b/src/test/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff @@ -0,0 +1,24 @@ +- // MIR for `inlined_target_feature` before Inline ++ // 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 ++ } + + 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 +- // mir::Constant +- // + 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 + } + } + 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 new file mode 100644 index 000000000..49aea431e --- /dev/null +++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff @@ -0,0 +1,25 @@ +- // MIR for `not_inlined_c_variadic` before Inline ++ // 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 + scope 1 { + 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 + // mir::Constant + // + 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 + } + } + 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 new file mode 100644 index 000000000..94ce574a9 --- /dev/null +++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff @@ -0,0 +1,22 @@ +- // MIR for `not_inlined_no_sanitize` before Inline ++ // 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 + + 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 + // mir::Constant + // + 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 + } + } + 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 new file mode 100644 index 000000000..8506e257b --- /dev/null +++ b/src/test/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff @@ -0,0 +1,22 @@ +- // MIR for `not_inlined_target_feature` before Inline ++ // 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 + + 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 + // mir::Constant + // + 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 + } + } + diff --git a/src/test/mir-opt/inline/inline_cycle.one.Inline.diff b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff new file mode 100644 index 000000000..b1c476362 --- /dev/null +++ b/src/test/mir-opt/inline/inline_cycle.one.Inline.diff @@ -0,0 +1,30 @@ +- // MIR for `one` before Inline ++ // 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 ++ } ++ } ++ } + + 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:+23:9: +23:28 + // 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() } + } + + 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 + } + } + diff --git a/src/test/mir-opt/inline/inline_cycle.two.Inline.diff b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff new file mode 100644 index 000000000..dc890a365 --- /dev/null +++ b/src/test/mir-opt/inline/inline_cycle.two.Inline.diff @@ -0,0 +1,55 @@ +- // MIR for `two` before Inline ++ // 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:+5:22: +5:23 ++ let _3: (); // in scope 1 at $DIR/inline-cycle.rs:+6:5: +6:8 ++ let mut _4: fn() {f}; // in scope 1 at $DIR/inline-cycle.rs:+6:5: +6:6 ++ let mut _5: (); // in scope 1 at $DIR/inline-cycle.rs:+6:5: +6: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:+11:5: +11:12 ++ } ++ } ++ } + + 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 + // 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:+6:5: +6:8 ++ StorageLive(_4); // scope 1 at $DIR/inline-cycle.rs:+6:5: +6:6 ++ _4 = move _2; // scope 1 at $DIR/inline-cycle.rs:+6:5: +6:6 ++ StorageLive(_5); // scope 1 at $DIR/inline-cycle.rs:+6:5: +6:8 ++ StorageLive(_6); // scope 3 at $DIR/inline-cycle.rs:+11:5: +11:12 ++ _6 = call::(f) -> bb1; // scope 3 at $DIR/inline-cycle.rs:+11:5: +11: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 + // + literal: Const { ty: fn() {f}, val: Value() } + } + + bb1: { ++ StorageDead(_6); // scope 3 at $DIR/inline-cycle.rs:+11:12: +11:13 ++ StorageDead(_5); // scope 1 at $DIR/inline-cycle.rs:+6:7: +6:8 ++ StorageDead(_4); // scope 1 at $DIR/inline-cycle.rs:+6:7: +6:8 ++ StorageDead(_3); // scope 1 at $DIR/inline-cycle.rs:+6:8: +6: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 new file mode 100644 index 000000000..082f57e59 --- /dev/null +++ b/src/test/mir-opt/inline/inline_cycle_generic.main.Inline.diff @@ -0,0 +1,32 @@ +- // MIR for `main` before Inline ++ // 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 ++ } ++ } ++ } ++ } + + 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:+23:9: +23: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() } + } + + 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 + } + } + diff --git a/src/test/mir-opt/inline/inline_diverging.f.Inline.diff b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff new file mode 100644 index 000000000..6b24b3e16 --- /dev/null +++ b/src/test/mir-opt/inline/inline_diverging.f.Inline.diff @@ -0,0 +1,24 @@ +- // MIR for `f` before Inline ++ // 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 ++ } + + 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 +- // mir::Constant +- // + 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 ++ } ++ ++ bb1: { ++ goto -> bb1; // scope 1 at $DIR/inline-diverging.rs:+32:5: +32: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 new file mode 100644 index 000000000..a25f1454f --- /dev/null +++ b/src/test/mir-opt/inline/inline_diverging.g.Inline.diff @@ -0,0 +1,49 @@ +- // MIR for `g` before Inline ++ // 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 ++ 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 + } + + 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 (Misc); // 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(_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 +- // + 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() } ++ // mir::Constant ++ // + span: $SRC_DIR/std/src/panic.rs:LL:COL ++ // + literal: Const { ty: &str, val: Value(Slice(..)) } + } + } + diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff new file mode 100644 index 000000000..8759f3d02 --- /dev/null +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -0,0 +1,56 @@ +- // MIR for `h` before Inline ++ // 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:+5:36: +5:37 ++ let _3: !; // in scope 1 at $DIR/inline-diverging.rs:+6:9: +6:10 ++ let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:+6:13: +6:14 ++ let mut _5: (); // in scope 1 at $DIR/inline-diverging.rs:+6:13: +6:16 ++ let mut _7: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:+7:13: +7:14 ++ let mut _8: (); // in scope 1 at $DIR/inline-diverging.rs:+7:13: +7:16 ++ let mut _9: !; // in scope 1 at $DIR/inline-diverging.rs:+8:6: +8:7 ++ let mut _10: !; // in scope 1 at $DIR/inline-diverging.rs:+8:9: +8:10 ++ scope 2 { ++ debug a => _3; // in scope 2 at $DIR/inline-diverging.rs:+6:9: +6:10 ++ let _6: !; // in scope 2 at $DIR/inline-diverging.rs:+7:9: +7:10 ++ scope 3 { ++ debug b => _6; // in scope 3 at $DIR/inline-diverging.rs:+7:9: +7: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 ++ } ++ } ++ } + + 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 + // mir::Constant +- // + 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 + // + literal: Const { ty: fn() -> ! {sleep}, val: Value() } ++ StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:+6:9: +6:10 ++ StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:+6:13: +6:14 ++ _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:+6:13: +6:14 ++ StorageLive(_5); // scope 1 at $DIR/inline-diverging.rs:+6:13: +6:16 ++ goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:+18:5: +18:12 ++ } ++ ++ bb1: { ++ goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:+18:5: +18:12 + } + } + diff --git a/src/test/mir-opt/inline/inline_generator.main.Inline.diff b/src/test/mir-opt/inline/inline_generator.main.Inline.diff new file mode 100644 index 000000000..c7c2759cc --- /dev/null +++ b/src/test/mir-opt/inline/inline_generator.main.Inline.diff @@ -0,0 +1,156 @@ +- // MIR for `main` before Inline ++ // 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 + scope 1 { + 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 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32 ++ debug pointer => _3; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL ++ let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 3 at $SRC_DIR/core/src/pin.rs:LL:COL ++ scope 4 { ++ scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:8]>::new_unchecked) { // at $SRC_DIR/core/src/pin.rs:LL:COL ++ debug pointer => _5; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ } ++ } ++ } ++ 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:+7:6: +7:7 ++ let mut _8: i32; // in scope 6 at $DIR/inline-generator.rs:+7:17: +7:39 ++ let mut _9: bool; // in scope 6 at $DIR/inline-generator.rs:+7:20: +7:21 ++ let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:+7:9: +7:9 ++ let _11: bool; // in scope 6 at $DIR/inline-generator.rs:+7:6: +7:7 ++ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ let mut _13: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ let mut _14: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ let mut _15: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ } + + 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 +- // mir::Constant +- // + 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:+7:5: +7:41 ++ discriminant(_4) = 0; // scope 2 at $DIR/inline-generator.rs:+7:5: +7: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 +- // + 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() } +- } +- +- bb2: { ++ StorageLive(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ _5 = move _3; // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL ++ StorageLive(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ _6 = move _5; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ Deinit(_2); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]) = move _6; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ StorageDead(_6); // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL ++ StorageDead(_5); // scope 4 at $SRC_DIR/core/src/pin.rs:LL:COL + 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<'r> fn(Pin<&'r 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 ++ StorageLive(_12); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 ++ StorageLive(_13); // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ _13 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ _12 = discriminant((*_13)); // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ StorageDead(_13); // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 + } + +- bb3: { ++ bb1: { ++ StorageDead(_12); // scope 0 at $DIR/inline-generator.rs:+1:14: +1:46 ++ 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 + } + +- bb4 (cleanup): { ++ bb2 (cleanup): { + resume; // scope 0 at $DIR/inline-generator.rs:+0:1: +2:2 ++ } ++ ++ bb3: { ++ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:+7:17: +7:39 ++ StorageLive(_9); // scope 6 at $DIR/inline-generator.rs:+7:20: +7:21 ++ _9 = _11; // scope 6 at $DIR/inline-generator.rs:+7:20: +7:21 ++ switchInt(move _9) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:+7:20: +7:21 ++ } ++ ++ bb4: { ++ _8 = const 7_i32; // scope 6 at $DIR/inline-generator.rs:+7:24: +7:25 ++ goto -> bb6; // scope 6 at $DIR/inline-generator.rs:+7:17: +7:39 ++ } ++ ++ bb5: { ++ _8 = const 13_i32; // scope 6 at $DIR/inline-generator.rs:+7:35: +7:37 ++ goto -> bb6; // scope 6 at $DIR/inline-generator.rs:+7:17: +7:39 ++ } ++ ++ bb6: { ++ StorageDead(_9); // scope 6 at $DIR/inline-generator.rs:+7:38: +7:39 ++ Deinit(_1); // scope 6 at $DIR/inline-generator.rs:+7:11: +7:39 ++ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:+7:11: +7:39 ++ discriminant(_1) = 0; // scope 6 at $DIR/inline-generator.rs:+7:11: +7:39 ++ StorageLive(_14); // scope 6 at $DIR/inline-generator.rs:+7:11: +7:39 ++ _14 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:+7:11: +7:39 ++ discriminant((*_14)) = 3; // scope 6 at $DIR/inline-generator.rs:+7:11: +7:39 ++ StorageDead(_14); // scope 6 at $DIR/inline-generator.rs:+7:11: +7:39 ++ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:+7:11: +7:39 ++ } ++ ++ bb7: { ++ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ StorageDead(_8); // scope 6 at $DIR/inline-generator.rs:+7:38: +7:39 ++ Deinit(_1); // scope 6 at $DIR/inline-generator.rs:+7:8: +7:8 ++ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:+7:8: +7:8 ++ discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:+7:8: +7:8 ++ StorageLive(_15); // scope 6 at $DIR/inline-generator.rs:+7:8: +7:8 ++ _15 = deref_copy (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline-generator.rs:+7:8: +7:8 ++ discriminant((*_15)) = 1; // scope 6 at $DIR/inline-generator.rs:+7:8: +7:8 ++ StorageDead(_15); // scope 6 at $DIR/inline-generator.rs:+7:8: +7:8 ++ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:+7:8: +7:8 ++ } ++ ++ bb8: { ++ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 ++ } ++ ++ bb9: { ++ unreachable; // scope 6 at $DIR/inline-generator.rs:+7:5: +7:8 + } + } + 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 new file mode 100644 index 000000000..076509df3 --- /dev/null +++ b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -0,0 +1,44 @@ +- // MIR for `default` before Inline ++ // 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 ++ } + + 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 + // mir::Constant + // + span: $DIR/inline-instruction-set.rs:51:5: 51: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 + // mir::Constant + // + span: $DIR/inline-instruction-set.rs:52:5: 52: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 +- // mir::Constant +- // + span: $DIR/inline-instruction-set.rs:53:5: 53: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 + } + } + 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 new file mode 100644 index 000000000..b275d08e0 --- /dev/null +++ b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -0,0 +1,46 @@ +- // MIR for `t32` before Inline ++ // 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 ++ } + + 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 + // mir::Constant + // + span: $DIR/inline-instruction-set.rs:42:5: 42: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 +- // mir::Constant +- // + span: $DIR/inline-instruction-set.rs:43:5: 43: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 + // mir::Constant + // + span: $DIR/inline-instruction-set.rs:46:5: 46:28 + // + literal: Const { ty: fn() {instruction_set_default}, val: Value() } + } + +- bb3: { ++ 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 + } + } + diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff new file mode 100644 index 000000000..deaba70e0 --- /dev/null +++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.32bit.diff @@ -0,0 +1,86 @@ +- // MIR for `main` before Inline ++ // 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: *const std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 ++ let mut _9: &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 + } + scope 2 { + } ++ scope 3 (inlined Vec::::new) { // at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ let mut _10: 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 + // mir::Constant + // + 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 + StorageLive(_7); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +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: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 ++ StorageLive(_9); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 ++ _9 = &mut (*_7); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 ++ StorageLive(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ _10 = const alloc::raw_vec::RawVec::::NEW; // 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 +- // + user_ty: UserType(1) +- // + literal: Const { ty: fn() -> Vec {Vec::::new}, val: Value() } +- } +- +- bb2: { ++ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ // + user_ty: UserType(0) ++ // + literal: Const { ty: alloc::raw_vec::RawVec, val: Unevaluated(alloc::raw_vec::RawVec::::NEW, [u32], None) } ++ Deinit((*_9)); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ ((*_9).0: alloc::raw_vec::RawVec) = move _10; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ ((*_9).1: usize) = const 0_usize; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ StorageDead(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ StorageDead(_9); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 + StorageDead(_7); // 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: bb5]; // 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 + } + +- bb4 (cleanup): { +- StorageDead(_7); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 +- _6 = alloc::alloc::box_free::, std::alloc::Global>(move (_5.0: std::ptr::Unique>), move (_5.1: std::alloc::Global)) -> bb5; // 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 +- // + literal: Const { ty: unsafe fn(Unique>, std::alloc::Global) {alloc::alloc::box_free::, std::alloc::Global>}, val: Value() } +- } +- +- bb5 (cleanup): { ++ bb3 (cleanup): { + resume; // scope 0 at $DIR/inline-into-box-place.rs:+0:1: +2:2 + } + } + diff --git a/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff new file mode 100644 index 000000000..deaba70e0 --- /dev/null +++ b/src/test/mir-opt/inline/inline_into_box_place.main.Inline.64bit.diff @@ -0,0 +1,86 @@ +- // MIR for `main` before Inline ++ // 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: *const std::vec::Vec; // in scope 0 at $DIR/inline-into-box-place.rs:+1:29: +1:43 ++ let mut _9: &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 + } + scope 2 { + } ++ scope 3 (inlined Vec::::new) { // at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ let mut _10: 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 + // mir::Constant + // + 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 + StorageLive(_7); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +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: bb4]; // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 ++ StorageLive(_9); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 ++ _9 = &mut (*_7); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 ++ StorageLive(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ _10 = const alloc::raw_vec::RawVec::::NEW; // 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 +- // + user_ty: UserType(1) +- // + literal: Const { ty: fn() -> Vec {Vec::::new}, val: Value() } +- } +- +- bb2: { ++ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ // + user_ty: UserType(0) ++ // + literal: Const { ty: alloc::raw_vec::RawVec, val: Unevaluated(alloc::raw_vec::RawVec::::NEW, [u32], None) } ++ Deinit((*_9)); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ ((*_9).0: alloc::raw_vec::RawVec) = move _10; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ ((*_9).1: usize) = const 0_usize; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ StorageDead(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ StorageDead(_9); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 + StorageDead(_7); // 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: bb5]; // 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 + } + +- bb4 (cleanup): { +- StorageDead(_7); // scope 0 at $DIR/inline-into-box-place.rs:+1:33: +1:43 +- _6 = alloc::alloc::box_free::, std::alloc::Global>(move (_5.0: std::ptr::Unique>), move (_5.1: std::alloc::Global)) -> bb5; // 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 +- // + literal: Const { ty: unsafe fn(Unique>, std::alloc::Global) {alloc::alloc::box_free::, std::alloc::Global>}, val: Value() } +- } +- +- bb5 (cleanup): { ++ bb3 (cleanup): { + resume; // scope 0 at $DIR/inline-into-box-place.rs:+0:1: +2:2 + } + } + 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 new file mode 100644 index 000000000..275493066 --- /dev/null +++ b/src/test/mir-opt/inline/inline_options.main.Inline.after.mir @@ -0,0 +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:+8:23: +8:26 + let _4: (); // in scope 1 at $DIR/inline-options.rs:+8:28: +8:31 + let _5: (); // in scope 1 at $DIR/inline-options.rs:+8:33: +8: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 + // mir::Constant + // + 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:+8:23: +8:26 + _3 = g() -> bb2; // scope 1 at $DIR/inline-options.rs:+8:23: +8:26 + // mir::Constant + // + 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:+8:26: +8:27 + StorageLive(_4); // scope 1 at $DIR/inline-options.rs:+8:28: +8:31 + _4 = g() -> bb3; // scope 1 at $DIR/inline-options.rs:+8:28: +8:31 + // mir::Constant + // + 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:+8:31: +8:32 + StorageLive(_5); // scope 1 at $DIR/inline-options.rs:+8:33: +8:36 + _5 = g() -> bb4; // scope 1 at $DIR/inline-options.rs:+8:33: +8:36 + // mir::Constant + // + 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:+8:36: +8: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_retag.bar.Inline.after.mir b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir new file mode 100644 index 000000000..768608564 --- /dev/null +++ b/src/test/mir-opt/inline/inline_retag.bar.Inline.after.mir @@ -0,0 +1,72 @@ +// 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<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:+1:9: +1:10 + let mut _2: for<'r, 's> fn(&'r i32, &'s 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:+6:8: +6:9 + debug y => _6; // in scope 2 at $DIR/inline-retag.rs:+6:17: +6:18 + let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:+7:5: +7:7 + let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:+7:11: +7: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 + // mir::Constant + // + span: $DIR/inline-retag.rs:11:13: 11:16 + // + literal: Const { ty: for<'r, 's> fn(&'r i32, &'s 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 bar::promoted[1]; // scope 1 at $DIR/inline-retag.rs:+2:7: +2:9 + // mir::Constant + // + 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 bar::promoted[0]; // scope 1 at $DIR/inline-retag.rs:+2:11: +2:14 + // mir::Constant + // + 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:+6:1: +8:2 + Retag(_6); // scope 2 at $DIR/inline-retag.rs:+6:1: +8:2 + StorageLive(_11); // scope 2 at $DIR/inline-retag.rs:+7:5: +7:7 + _11 = (*_3); // scope 2 at $DIR/inline-retag.rs:+7:5: +7:7 + StorageLive(_12); // scope 2 at $DIR/inline-retag.rs:+7:11: +7:13 + _12 = (*_6); // scope 2 at $DIR/inline-retag.rs:+7:11: +7:13 + _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline-retag.rs:+7:5: +7:13 + StorageDead(_12); // scope 2 at $DIR/inline-retag.rs:+7:12: +7:13 + StorageDead(_11); // scope 2 at $DIR/inline-retag.rs:+7:12: +7: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_shims.clone.Inline.diff b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff new file mode 100644 index 000000000..25ca05893 --- /dev/null +++ b/src/test/mir-opt/inline/inline_shims.clone.Inline.diff @@ -0,0 +1,26 @@ +- // MIR for `clone` before Inline ++ // 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 ++ } + + 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 +- // mir::Constant +- // + span: $DIR/inline-shims.rs:6:7: 6:12 +- // + literal: Const { ty: for<'r> fn(&'r 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 + } + } + diff --git a/src/test/mir-opt/inline/inline_shims.drop.Inline.diff b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff new file mode 100644 index 000000000..f7b1cde80 --- /dev/null +++ b/src/test/mir-opt/inline/inline_shims.drop.Inline.diff @@ -0,0 +1,56 @@ +- // MIR for `drop` before Inline ++ // 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 + scope 1 { + } + scope 2 { ++ 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 + // mir::Constant + // + 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 +- // mir::Constant +- // + 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 ++ _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 ++ } ++ ++ bb3: { ++ drop((((*_5) as Some).0: B)) -> bb2; // scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + } + } + diff --git a/src/test/mir-opt/inline/inline_specialization.main.Inline.diff b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff new file mode 100644 index 000000000..106291b36 --- /dev/null +++ b/src/test/mir-opt/inline/inline_specialization.main.Inline.diff @@ -0,0 +1,28 @@ +- // MIR for `main` before Inline ++ // 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 + scope 1 { + 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 ++ } + + 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 +- // mir::Constant +- // + 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:+10:31: +10: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_trait_method.test.Inline.after.mir b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir new file mode 100644 index 000000000..ed95edd16 --- /dev/null +++ b/src/test/mir-opt/inline/inline_trait_method.test.Inline.after.mir @@ -0,0 +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 + + 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 + // mir::Constant + // + span: $DIR/inline-trait-method.rs:9:7: 9:8 + // + literal: Const { ty: for<'r> fn(&'r 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 + } +} 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 new file mode 100644 index 000000000..116ae4e36 --- /dev/null +++ b/src/test/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -0,0 +1,32 @@ +// 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:+5:9: +5:10 + let mut _4: &dyn X; // in scope 1 at $DIR/inline-trait-method_2.rs:+6:5: +6: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:+6:5: +6:10 + _4 = _2; // scope 1 at $DIR/inline-trait-method_2.rs:+6:5: +6:10 + _0 = ::y(move _4) -> bb1; // scope 1 at $DIR/inline-trait-method_2.rs:+6:5: +6:10 + // mir::Constant + // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 + // + literal: Const { ty: for<'r> fn(&'r dyn X) -> bool {::y}, val: Value() } + } + + bb1: { + StorageDead(_4); // scope 1 at $DIR/inline-trait-method_2.rs:+6:9: +6: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 + } +} 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.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.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/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 new file mode 100644 index 000000000..5168ae031 --- /dev/null +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir @@ -0,0 +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 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(_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 + } +} 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 new file mode 100644 index 000000000..4006dd15a --- /dev/null +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -0,0 +1,42 @@ +// 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 self => _4; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + let mut _5: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + let mut _6: &mut T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + let mut _7: std::boxed::Box; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + let mut _8: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + } + + 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(_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 + StorageLive(_7); // 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 + StorageLive(_8); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _8 = (((_7.0: std::ptr::Unique).0: std::ptr::NonNull).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _6 = &mut (*_8); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + StorageDead(_8); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + StorageDead(_7); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _5 = &mut (*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _3 = &mut (*_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + StorageDead(_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + StorageDead(_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _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 new file mode 100644 index 000000000..c7f20ff98 --- /dev/null +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir @@ -0,0 +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 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 + _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 + } +} 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 new file mode 100644 index 000000000..e516269c1 --- /dev/null +++ b/src/test/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -0,0 +1,30 @@ +// 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 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(_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + _4 = deref_copy (*_3); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + StorageLive(_5); // 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 + StorageDead(_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + StorageDead(_4); // 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 + } +} 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 new file mode 100644 index 000000000..fca53a72f --- /dev/null +++ b/src/test/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -0,0 +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 + 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 + scope 3 { + 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 + } +} diff --git a/src/test/mir-opt/inline/issue_78442.bar.Inline.diff b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff new file mode 100644 index 000000000..c16dfdf39 --- /dev/null +++ b/src/test/mir-opt/inline/issue_78442.bar.Inline.diff @@ -0,0 +1,68 @@ +- // MIR for `bar` before Inline ++ // 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 ++ } + + 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 + // mir::Constant + // + 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 +- // mir::Constant +- // + span: $DIR/issue-78442.rs:11:5: 11:15 +- // + literal: Const { ty: for<'r> extern "rust-call" fn(&'r 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 + } + +- bb3: { +- 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 + } + + 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 + } + +- bb5 (cleanup): { +- 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 + } + } + diff --git a/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff new file mode 100644 index 000000000..0faa522cb --- /dev/null +++ b/src/test/mir-opt/inline/issue_78442.bar.RevealAll.diff @@ -0,0 +1,57 @@ +- // MIR for `bar` before RevealAll ++ // 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 + + 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 + // mir::Constant + // + 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 + // mir::Constant + // + span: $DIR/issue-78442.rs:11:5: 11:15 +- // + literal: Const { ty: for<'r> extern "rust-call" fn(&'r impl Fn(), ()) -> >::Output {>::call}, val: Value() } ++ // + literal: Const { ty: for<'r> extern "rust-call" fn(&'r 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 + } + + bb3: { + 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 + } + + bb5 (cleanup): { + resume; // scope 0 at $DIR/issue-78442.rs:+0:1: +5:2 + } + } + -- cgit v1.2.3