diff options
Diffstat (limited to 'tests/mir-opt/inline')
151 files changed, 3900 insertions, 2539 deletions
diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.diff deleted file mode 100644 index ba1bfec05..000000000 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.diff +++ /dev/null @@ -1,45 +0,0 @@ -- // MIR for `main` before Inline -+ // MIR for `main` after Inline - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/asm_unwind.rs:+0:15: +0:15 - let _1: (); // in scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 -+ scope 1 (inlined foo) { // at $DIR/asm_unwind.rs:21:5: 21:10 -+ let _2: D; // in scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 -+ scope 2 { -+ debug _d => const D; // in scope 2 at $DIR/asm_unwind.rs:15:9: 15:11 -+ scope 3 { -+ } -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 -- _1 = foo() -> bb1; // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 -- // mir::Constant -- // + span: $DIR/asm_unwind.rs:21:5: 21:8 -- // + literal: Const { ty: fn() {foo}, val: Value(<ZST>) } -+ StorageLive(_2); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 -+ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54 - } - - bb1: { -+ StorageDead(_2); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 - StorageDead(_1); // scope 0 at $DIR/asm_unwind.rs:+1:10: +1:11 - _0 = const (); // scope 0 at $DIR/asm_unwind.rs:+0:15: +2:2 - return; // scope 0 at $DIR/asm_unwind.rs:+2:2: +2:2 -+ } -+ -+ bb2: { -+ drop(_2) -> bb1; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 -+ } -+ -+ bb3 (cleanup): { -+ drop(_2) -> [return: bb4, unwind terminate]; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 -+ } -+ -+ bb4 (cleanup): { -+ resume; // scope 1 at $DIR/asm_unwind.rs:14:1: 17:2 - } - } - diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff new file mode 100644 index 000000000..503dc5beb --- /dev/null +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-abort.diff @@ -0,0 +1,34 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined foo) { ++ let _2: D; ++ scope 2 { ++ debug _d => const D; ++ scope 3 { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = foo() -> [return: bb1, unwind unreachable]; ++ StorageLive(_2); ++ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind terminate]; + } + + bb1: { ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2: { ++ drop(_2) -> [return: bb1, unwind unreachable]; + } + } + diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..684211b53 --- /dev/null +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.panic-unwind.diff @@ -0,0 +1,42 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined foo) { ++ let _2: D; ++ scope 2 { ++ debug _d => const D; ++ scope 3 { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = foo() -> [return: bb1, unwind continue]; ++ StorageLive(_2); ++ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind: bb3]; + } + + bb1: { ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2: { ++ drop(_2) -> [return: bb1, unwind continue]; ++ } ++ ++ bb3 (cleanup): { ++ drop(_2) -> [return: bb4, unwind terminate]; ++ } ++ ++ bb4 (cleanup): { ++ resume; + } + } + diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs index c03feb433..573ae1ba6 100644 --- a/tests/mir-opt/inline/asm_unwind.rs +++ b/tests/mir-opt/inline/asm_unwind.rs @@ -1,7 +1,8 @@ // Tests inlining of `may_unwind` inline assembly. // -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // needs-asm-support +// compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(asm_unwind)] struct D; @@ -10,7 +11,7 @@ impl Drop for D { fn drop(&mut self) {} } -#[inline(always)] +#[inline] fn foo() { let _d = D; unsafe { std::arch::asm!("", options(may_unwind)) }; diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff b/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff deleted file mode 100644 index 8b0300678..000000000 --- a/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.diff +++ /dev/null @@ -1,33 +0,0 @@ -- // 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: <IntFactory as Factory<T>>::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::<T>() -> 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() -> <IntFactory as Factory<T>>::Item {bar::<T>}, val: Value(<ZST>) } - } - - 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/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff b/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff new file mode 100644 index 000000000..d4427b2a8 --- /dev/null +++ b/tests/mir-opt/inline/caller_with_trivial_bound.foo.Inline.panic-unwind.diff @@ -0,0 +1,30 @@ +- // MIR for `foo` before Inline ++ // MIR for `foo` after Inline + + fn foo() -> () { + let mut _0: (); + let mut _1: <IntFactory as Factory<T>>::Item; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + _1 = bar::<T>() -> [return: bb1, unwind continue]; + } + + bb1: { + _0 = const (); + drop(_1) -> [return: bb2, unwind: bb3]; + } + + bb2: { + StorageDead(_1); + return; + } + + bb3 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.rs b/tests/mir-opt/inline/caller_with_trivial_bound.rs index 8545db894..a8f101d48 100644 --- a/tests/mir-opt/inline/caller_with_trivial_bound.rs +++ b/tests/mir-opt/inline/caller_with_trivial_bound.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // needs-unwind #![crate_type = "lib"] diff --git a/tests/mir-opt/inline/cycle.f.Inline.diff b/tests/mir-opt/inline/cycle.f.Inline.diff deleted file mode 100644 index 8da597577..000000000 --- a/tests/mir-opt/inline/cycle.f.Inline.diff +++ /dev/null @@ -1,43 +0,0 @@ -- // 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 - _4 = (); // scope 0 at $DIR/cycle.rs:+1:5: +1:8 - _2 = <impl Fn() as Fn<()>>::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<'a> extern "rust-call" fn(&'a impl Fn(), ()) -> <impl Fn() as FnOnce<()>>::Output {<impl Fn() as Fn<()>>::call}, val: Value(<ZST>) } - } - - 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) -> [return: bb4, unwind terminate]; // 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/tests/mir-opt/inline/cycle.f.Inline.panic-abort.diff b/tests/mir-opt/inline/cycle.f.Inline.panic-abort.diff new file mode 100644 index 000000000..861b2fc9f --- /dev/null +++ b/tests/mir-opt/inline/cycle.f.Inline.panic-abort.diff @@ -0,0 +1,32 @@ +- // MIR for `f` before Inline ++ // MIR for `f` after Inline + + fn f(_1: impl Fn()) -> () { + debug g => _1; + let mut _0: (); + let _2: (); + let mut _3: &impl Fn(); + let mut _4: (); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &_1; + StorageLive(_4); + _4 = (); + _2 = <impl Fn() as Fn<()>>::call(move _3, move _4) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb2, unwind unreachable]; + } + + bb2: { + return; + } + } + diff --git a/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff new file mode 100644 index 000000000..f3a6ee22c --- /dev/null +++ b/tests/mir-opt/inline/cycle.f.Inline.panic-unwind.diff @@ -0,0 +1,40 @@ +- // MIR for `f` before Inline ++ // MIR for `f` after Inline + + fn f(_1: impl Fn()) -> () { + debug g => _1; + let mut _0: (); + let _2: (); + let mut _3: &impl Fn(); + let mut _4: (); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &_1; + StorageLive(_4); + _4 = (); + _2 = <impl Fn() as Fn<()>>::call(move _3, move _4) -> [return: bb1, unwind: bb3]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb2, unwind: bb4]; + } + + bb2: { + return; + } + + bb3 (cleanup): { + drop(_1) -> [return: bb4, unwind terminate]; + } + + bb4 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/inline/cycle.g.Inline.diff b/tests/mir-opt/inline/cycle.g.Inline.diff deleted file mode 100644 index 1e6e30f9e..000000000 --- a/tests/mir-opt/inline/cycle.g.Inline.diff +++ /dev/null @@ -1,58 +0,0 @@ -- // 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 -+ let mut _5: (); // in scope 0 at $DIR/cycle.rs:6:5: 6:8 -+ scope 1 (inlined f::<fn() {main}>) { // at $DIR/cycle.rs:12:5: 12:12 -+ debug g => _2; // in scope 1 at $DIR/cycle.rs:5:6: 5:7 -+ let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ let mut _4: &fn() {main}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ scope 2 (inlined <fn() {main} as Fn<()>>::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::<fn() {main}>(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::<fn() {main}>}, val: Value(<ZST>) } -- // mir::Constant - // + span: $DIR/cycle.rs:12:7: 12:11 - // + literal: Const { ty: fn() {main}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 -+ StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ _5 = const (); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL - } - - bb1: { -+ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 -+ 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) -> [return: bb3, unwind terminate]; // scope 1 at $DIR/cycle.rs:7:1: 7:2 -+ } -+ -+ bb3 (cleanup): { -+ resume; // scope 1 at $DIR/cycle.rs:5:1: 7:2 -+ } -+ -+ bb4: { -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 - } - } - diff --git a/tests/mir-opt/inline/cycle.g.Inline.panic-abort.diff b/tests/mir-opt/inline/cycle.g.Inline.panic-abort.diff new file mode 100644 index 000000000..f3f4d895a --- /dev/null +++ b/tests/mir-opt/inline/cycle.g.Inline.panic-abort.diff @@ -0,0 +1,44 @@ +- // MIR for `g` before Inline ++ // MIR for `g` after Inline + + fn g() -> () { + let mut _0: (); + let _1: (); ++ let mut _2: fn() {main}; ++ let mut _5: (); ++ scope 1 (inlined f::<fn() {main}>) { ++ debug g => _2; ++ let mut _3: &fn() {main}; ++ let _4: (); ++ scope 2 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = f::<fn() {main}>(main) -> [return: bb1, unwind unreachable]; ++ StorageLive(_2); ++ _2 = main; ++ StorageLive(_4); ++ StorageLive(_3); ++ _3 = &_2; ++ StorageLive(_5); ++ _5 = const (); ++ _4 = move (*_3)() -> [return: bb2, unwind unreachable]; + } + + bb1: { ++ StorageDead(_4); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2: { ++ StorageDead(_5); ++ StorageDead(_3); ++ drop(_2) -> [return: bb1, unwind unreachable]; + } + } + diff --git a/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff new file mode 100644 index 000000000..3ce8d9acf --- /dev/null +++ b/tests/mir-opt/inline/cycle.g.Inline.panic-unwind.diff @@ -0,0 +1,52 @@ +- // MIR for `g` before Inline ++ // MIR for `g` after Inline + + fn g() -> () { + let mut _0: (); + let _1: (); ++ let mut _2: fn() {main}; ++ let mut _5: (); ++ scope 1 (inlined f::<fn() {main}>) { ++ debug g => _2; ++ let mut _3: &fn() {main}; ++ let _4: (); ++ scope 2 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = f::<fn() {main}>(main) -> [return: bb1, unwind continue]; ++ StorageLive(_2); ++ _2 = main; ++ StorageLive(_4); ++ StorageLive(_3); ++ _3 = &_2; ++ StorageLive(_5); ++ _5 = const (); ++ _4 = move (*_3)() -> [return: bb4, unwind: bb2]; + } + + bb1: { ++ StorageDead(_4); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2 (cleanup): { ++ drop(_2) -> [return: bb3, unwind terminate]; ++ } ++ ++ bb3 (cleanup): { ++ resume; ++ } ++ ++ bb4: { ++ StorageDead(_5); ++ StorageDead(_3); ++ drop(_2) -> [return: bb1, unwind continue]; + } + } + diff --git a/tests/mir-opt/inline/cycle.main.Inline.diff b/tests/mir-opt/inline/cycle.main.Inline.diff deleted file mode 100644 index 315634945..000000000 --- a/tests/mir-opt/inline/cycle.main.Inline.diff +++ /dev/null @@ -1,58 +0,0 @@ -- // 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 -+ let mut _5: (); // in scope 0 at $DIR/cycle.rs:6:5: 6:8 -+ scope 1 (inlined f::<fn() {g}>) { // at $DIR/cycle.rs:17:5: 17:9 -+ debug g => _2; // in scope 1 at $DIR/cycle.rs:5:6: 5:7 -+ let _3: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ let mut _4: &fn() {g}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ scope 2 (inlined <fn() {g} as Fn<()>>::call - shim(fn() {g})) { // at $DIR/cycle.rs:6:5: 6:8 -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 -- _1 = f::<fn() {g}>(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::<fn() {g}>}, val: Value(<ZST>) } -- // mir::Constant - // + span: $DIR/cycle.rs:17:7: 17:8 - // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 -+ StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 -+ StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ _5 = const (); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ _3 = move (*_4)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL - } - - bb1: { -+ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 -+ 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) -> [return: bb3, unwind terminate]; // scope 1 at $DIR/cycle.rs:7:1: 7:2 -+ } -+ -+ bb3 (cleanup): { -+ resume; // scope 1 at $DIR/cycle.rs:5:1: 7:2 -+ } -+ -+ bb4: { -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 - } - } - diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff new file mode 100644 index 000000000..eb0076354 --- /dev/null +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-abort.diff @@ -0,0 +1,54 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ let mut _2: fn() {g}; ++ let mut _5: (); ++ scope 1 (inlined f::<fn() {g}>) { ++ debug g => _2; ++ let mut _3: &fn() {g}; ++ let _4: (); ++ scope 2 (inlined <fn() {g} as Fn<()>>::call - shim(fn() {g})) { ++ scope 3 (inlined g) { ++ scope 4 (inlined f::<fn() {main}>) { ++ debug g => main; ++ let _6: (); ++ scope 5 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = f::<fn() {g}>(g) -> [return: bb1, unwind unreachable]; ++ StorageLive(_2); ++ _2 = g; ++ StorageLive(_4); ++ StorageLive(_3); ++ _3 = &_2; ++ StorageLive(_5); ++ _5 = const (); ++ StorageLive(_6); ++ _6 = main() -> [return: bb2, unwind unreachable]; + } + + bb1: { ++ StorageDead(_4); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2: { ++ StorageDead(_6); ++ StorageDead(_5); ++ StorageDead(_3); ++ drop(_2) -> [return: bb1, unwind unreachable]; + } + } + diff --git a/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..198a23226 --- /dev/null +++ b/tests/mir-opt/inline/cycle.main.Inline.panic-unwind.diff @@ -0,0 +1,62 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ let mut _2: fn() {g}; ++ let mut _5: (); ++ scope 1 (inlined f::<fn() {g}>) { ++ debug g => _2; ++ let mut _3: &fn() {g}; ++ let _4: (); ++ scope 2 (inlined <fn() {g} as Fn<()>>::call - shim(fn() {g})) { ++ scope 3 (inlined g) { ++ scope 4 (inlined f::<fn() {main}>) { ++ debug g => main; ++ let _6: (); ++ scope 5 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = f::<fn() {g}>(g) -> [return: bb1, unwind continue]; ++ StorageLive(_2); ++ _2 = g; ++ StorageLive(_4); ++ StorageLive(_3); ++ _3 = &_2; ++ StorageLive(_5); ++ _5 = const (); ++ StorageLive(_6); ++ _6 = main() -> [return: bb4, unwind: bb2]; + } + + bb1: { ++ StorageDead(_4); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2 (cleanup): { ++ drop(_2) -> [return: bb3, unwind terminate]; ++ } ++ ++ bb3 (cleanup): { ++ resume; ++ } ++ ++ bb4: { ++ StorageDead(_6); ++ StorageDead(_5); ++ StorageDead(_3); ++ drop(_2) -> [return: bb1, unwind continue]; + } + } + diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs index 9e8950d8a..1b74d8184 100644 --- a/tests/mir-opt/inline/cycle.rs +++ b/tests/mir-opt/inline/cycle.rs @@ -1,4 +1,5 @@ -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zinline-mir-hint-threshold=1000 // EMIT_MIR cycle.f.Inline.diff #[inline(always)] diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff deleted file mode 100644 index 75d9bd54d..000000000 --- a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff +++ /dev/null @@ -1,54 +0,0 @@ -- // 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: &<Q as Query>::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: &<Q as Query>::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::<<Q as Query>::C>) { // at $DIR/dyn_trait.rs:35:5: 35:25 -+ debug c => _4; // in scope 2 at $DIR/dyn_trait.rs:27:36: 27:37 -+ let mut _5: &dyn Cache<V = <Q as Query>::V>; // in scope 2 at $DIR/dyn_trait.rs:28:14: 28:15 -+ scope 3 (inlined mk_cycle::<<Q as Query>::V>) { // at $DIR/dyn_trait.rs:28:5: 28:16 -+ debug c => _5; // in scope 3 at $DIR/dyn_trait.rs:21:27: 21:28 -+ } -+ } - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/dyn_trait.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23 - _3 = &(*_1); // scope 0 at $DIR/dyn_trait.rs:+1:22: +1:23 - _2 = <Q as Query>::cache::<T>(move _3) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:13: +1:24 - // mir::Constant - // + span: $DIR/dyn_trait.rs:34:13: 34:21 - // + user_ty: UserType(0) - // + literal: Const { ty: for<'a> fn(&'a T) -> &'a <Q as Query>::C {<Q as Query>::cache::<T>}, val: Value(<ZST>) } - } - - 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::<<Q as 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:28:14: 28:15 -+ _5 = _4 as &dyn Cache<V = <Q as Query>::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn_trait.rs:28:14: 28:15 -+ _0 = <dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache(_5) -> bb2; // scope 3 at $DIR/dyn_trait.rs:22:5: 22:22 - // mir::Constant -- // + span: $DIR/dyn_trait.rs:35:5: 35:22 -- // + literal: Const { ty: for<'a> fn(&'a <Q as Query>::C) {try_execute_query::<<Q as Query>::C>}, val: Value(<ZST>) } -+ // + span: $DIR/dyn_trait.rs:22:7: 22:20 -+ // + literal: Const { ty: for<'a> fn(&'a dyn Cache<V = <Q as Query>::V>) {<dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache}, val: Value(<ZST>) } - } - - bb2: { -+ StorageDead(_5); // scope 2 at $DIR/dyn_trait.rs:28:15: 28: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/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-abort.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-abort.diff new file mode 100644 index 000000000..57b0849e1 --- /dev/null +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-abort.diff @@ -0,0 +1,45 @@ +- // MIR for `get_query` before Inline ++ // MIR for `get_query` after Inline + + fn get_query(_1: &T) -> () { + debug t => _1; + let mut _0: (); + let _2: &<Q as Query>::C; + let mut _3: &T; + let mut _4: &<Q as Query>::C; + scope 1 { + debug c => _2; ++ scope 2 (inlined try_execute_query::<<Q as Query>::C>) { ++ debug c => _4; ++ let mut _5: &dyn Cache<V = <Q as Query>::V>; ++ scope 3 (inlined mk_cycle::<<Q as Query>::V>) { ++ debug c => _5; ++ } ++ } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _2 = <Q as Query>::cache::<T>(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageLive(_4); + _4 = &(*_2); +- _0 = try_execute_query::<<Q as Query>::C>(move _4) -> [return: bb2, unwind unreachable]; ++ StorageLive(_5); ++ _5 = _4 as &dyn Cache<V = <Q as Query>::V> (PointerCoercion(Unsize)); ++ _0 = <dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache(_5) -> [return: bb2, unwind unreachable]; + } + + bb2: { ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff new file mode 100644 index 000000000..706c1d481 --- /dev/null +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.panic-unwind.diff @@ -0,0 +1,45 @@ +- // MIR for `get_query` before Inline ++ // MIR for `get_query` after Inline + + fn get_query(_1: &T) -> () { + debug t => _1; + let mut _0: (); + let _2: &<Q as Query>::C; + let mut _3: &T; + let mut _4: &<Q as Query>::C; + scope 1 { + debug c => _2; ++ scope 2 (inlined try_execute_query::<<Q as Query>::C>) { ++ debug c => _4; ++ let mut _5: &dyn Cache<V = <Q as Query>::V>; ++ scope 3 (inlined mk_cycle::<<Q as Query>::V>) { ++ debug c => _5; ++ } ++ } + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _2 = <Q as Query>::cache::<T>(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageLive(_4); + _4 = &(*_2); +- _0 = try_execute_query::<<Q as Query>::C>(move _4) -> [return: bb2, unwind continue]; ++ StorageLive(_5); ++ _5 = _4 as &dyn Cache<V = <Q as Query>::V> (PointerCoercion(Unsize)); ++ _0 = <dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache(_5) -> [return: bb2, unwind continue]; + } + + bb2: { ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff deleted file mode 100644 index 925c95988..000000000 --- a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff +++ /dev/null @@ -1,23 +0,0 @@ -- // MIR for `mk_cycle` before Inline -+ // MIR for `mk_cycle` after Inline - - fn mk_cycle(_1: &dyn Cache<V = V>) -> () { - 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<V = V>; // 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 = <dyn Cache<V = V> 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:22:7: 22:20 - // + literal: Const { ty: for<'a> fn(&'a dyn Cache<V = V>) {<dyn Cache<V = V> as Cache>::store_nocache}, val: Value(<ZST>) } - } - - 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/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-abort.diff b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-abort.diff new file mode 100644 index 000000000..d7801b7a0 --- /dev/null +++ b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-abort.diff @@ -0,0 +1,20 @@ +- // MIR for `mk_cycle` before Inline ++ // MIR for `mk_cycle` after Inline + + fn mk_cycle(_1: &dyn Cache<V = V>) -> () { + debug c => _1; + let mut _0: (); + let mut _2: &dyn Cache<V = V>; + + bb0: { + StorageLive(_2); + _2 = &(*_1); + _0 = <dyn Cache<V = V> as Cache>::store_nocache(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-unwind.diff new file mode 100644 index 000000000..7b1cf895a --- /dev/null +++ b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.panic-unwind.diff @@ -0,0 +1,20 @@ +- // MIR for `mk_cycle` before Inline ++ // MIR for `mk_cycle` after Inline + + fn mk_cycle(_1: &dyn Cache<V = V>) -> () { + debug c => _1; + let mut _0: (); + let mut _2: &dyn Cache<V = V>; + + bb0: { + StorageLive(_2); + _2 = &(*_1); + _0 = <dyn Cache<V = V> as Cache>::store_nocache(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs index 2af81f825..0faeec0bb 100644 --- a/tests/mir-opt/inline/dyn_trait.rs +++ b/tests/mir-opt/inline/dyn_trait.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] use std::fmt::Debug; diff --git a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff deleted file mode 100644 index f4e5272ab..000000000 --- a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff +++ /dev/null @@ -1,33 +0,0 @@ -- // 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 = <C as 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::<<C as Cache>::V>) { // at $DIR/dyn_trait.rs:28:5: 28:16 -+ debug c => _2; // in scope 1 at $DIR/dyn_trait.rs:21:27: 21:28 -+ } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 - StorageLive(_3); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 - _3 = &(*_1); // scope 0 at $DIR/dyn_trait.rs:+1:14: +1:15 - _2 = move _3 as &dyn Cache<V = <C as 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::<<C as Cache>::V>(move _2) -> bb1; // scope 0 at $DIR/dyn_trait.rs:+1:5: +1:16 -+ _0 = <dyn Cache<V = <C as Cache>::V> as Cache>::store_nocache(_2) -> bb1; // scope 1 at $DIR/dyn_trait.rs:22:5: 22:22 - // mir::Constant -- // + span: $DIR/dyn_trait.rs:28:5: 28:13 -- // + literal: Const { ty: for<'a> fn(&'a (dyn Cache<V = <C as Cache>::V> + 'a)) {mk_cycle::<<C as Cache>::V>}, val: Value(<ZST>) } -+ // + span: $DIR/dyn_trait.rs:22:7: 22:20 -+ // + literal: Const { ty: for<'a> fn(&'a dyn Cache<V = <C as Cache>::V>) {<dyn Cache<V = <C as Cache>::V> as Cache>::store_nocache}, val: Value(<ZST>) } - } - - bb1: { - 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/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-abort.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-abort.diff new file mode 100644 index 000000000..9a6d3596f --- /dev/null +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-abort.diff @@ -0,0 +1,28 @@ +- // MIR for `try_execute_query` before Inline ++ // MIR for `try_execute_query` after Inline + + fn try_execute_query(_1: &C) -> () { + debug c => _1; + let mut _0: (); + let mut _2: &dyn Cache<V = <C as Cache>::V>; + let mut _3: &C; ++ scope 1 (inlined mk_cycle::<<C as Cache>::V>) { ++ debug c => _2; ++ } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _2 = move _3 as &dyn Cache<V = <C as Cache>::V> (PointerCoercion(Unsize)); + StorageDead(_3); +- _0 = mk_cycle::<<C as Cache>::V>(move _2) -> [return: bb1, unwind unreachable]; ++ _0 = <dyn Cache<V = <C as Cache>::V> as Cache>::store_nocache(_2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff new file mode 100644 index 000000000..1a08df2b0 --- /dev/null +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.panic-unwind.diff @@ -0,0 +1,28 @@ +- // MIR for `try_execute_query` before Inline ++ // MIR for `try_execute_query` after Inline + + fn try_execute_query(_1: &C) -> () { + debug c => _1; + let mut _0: (); + let mut _2: &dyn Cache<V = <C as Cache>::V>; + let mut _3: &C; ++ scope 1 (inlined mk_cycle::<<C as Cache>::V>) { ++ debug c => _2; ++ } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _2 = move _3 as &dyn Cache<V = <C as Cache>::V> (PointerCoercion(Unsize)); + StorageDead(_3); +- _0 = mk_cycle::<<C as Cache>::V>(move _2) -> [return: bb1, unwind continue]; ++ _0 = <dyn Cache<V = <C as Cache>::V> as Cache>::store_nocache(_2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff deleted file mode 100644 index 30af8661d..000000000 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff +++ /dev/null @@ -1,75 +0,0 @@ -- // MIR for `main` before Inline -+ // MIR for `main` after Inline - - fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/exponential_runtime.rs:+0:11: +0:11 - let _1: (); // in scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ scope 1 (inlined <() as G>::call) { // at $DIR/exponential_runtime.rs:87:5: 87:22 -+ let _2: (); // in scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ let _3: (); // in scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ let _4: (); // in scope 1 at $DIR/exponential_runtime.rs:76:9: 76:25 -+ scope 2 (inlined <() as F>::call) { // at $DIR/exponential_runtime.rs:74:9: 74:25 -+ let _5: (); // in scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 -+ let _6: (); // in scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 -+ let _7: (); // in scope 2 at $DIR/exponential_runtime.rs:64:9: 64:25 -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -- _1 = <() as G>::call() -> bb1; // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageLive(_2); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageLive(_3); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageLive(_4); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageLive(_5); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ StorageLive(_6); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ StorageLive(_7); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ _5 = <() as E>::call() -> bb4; // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 - // mir::Constant -- // + span: $DIR/exponential_runtime.rs:87:5: 87:20 -- // + literal: Const { ty: fn() {<() as G>::call}, val: Value(<ZST>) } -+ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 -+ // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } - } - - bb1: { -+ StorageDead(_4); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageDead(_3); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageDead(_2); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 - StorageDead(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:22: +1:23 - _0 = const (); // scope 0 at $DIR/exponential_runtime.rs:+0:11: +2:2 - return; // scope 0 at $DIR/exponential_runtime.rs:+2:2: +2:2 -+ } -+ -+ bb2: { -+ StorageDead(_7); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ StorageDead(_6); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ StorageDead(_5); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ _3 = <() as F>::call() -> bb3; // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:75:9: 75:23 -+ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } -+ } -+ -+ bb3: { -+ _4 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:76:9: 76:25 -+ // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:76:9: 76:23 -+ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } -+ } -+ -+ bb4: { -+ _6 = <() as E>::call() -> bb5; // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 -+ // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:63:9: 63:23 -+ // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } -+ } -+ -+ bb5: { -+ _7 = <() as E>::call() -> bb2; // scope 2 at $DIR/exponential_runtime.rs:64:9: 64:25 -+ // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:64:9: 64:23 -+ // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } - } - } - diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff new file mode 100644 index 000000000..217c8b802 --- /dev/null +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-abort.diff @@ -0,0 +1,134 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined <() as G>::call) { ++ let _2: (); ++ let _3: (); ++ let _4: (); ++ scope 2 (inlined <() as F>::call) { ++ let _5: (); ++ let _6: (); ++ let _7: (); ++ scope 3 (inlined <() as E>::call) { ++ let _8: (); ++ let _9: (); ++ let _10: (); ++ scope 4 (inlined <() as D>::call) { ++ let _11: (); ++ let _12: (); ++ let _13: (); ++ scope 5 (inlined <() as C>::call) { ++ let _14: (); ++ let _15: (); ++ let _16: (); ++ scope 6 (inlined <() as B>::call) { ++ let _17: (); ++ let _18: (); ++ let _19: (); ++ } ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = <() as G>::call() -> [return: bb1, unwind unreachable]; ++ StorageLive(_2); ++ StorageLive(_3); ++ StorageLive(_4); ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); ++ StorageLive(_8); ++ StorageLive(_9); ++ StorageLive(_10); ++ StorageLive(_11); ++ StorageLive(_12); ++ StorageLive(_13); ++ StorageLive(_14); ++ StorageLive(_15); ++ StorageLive(_16); ++ StorageLive(_17); ++ StorageLive(_18); ++ StorageLive(_19); ++ _17 = <() as A>::call() -> [return: bb12, unwind unreachable]; + } + + bb1: { ++ StorageDead(_4); ++ StorageDead(_3); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2: { ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); ++ _3 = <() as F>::call() -> [return: bb3, unwind unreachable]; ++ } ++ ++ bb3: { ++ _4 = <() as F>::call() -> [return: bb1, unwind unreachable]; ++ } ++ ++ bb4: { ++ StorageDead(_10); ++ StorageDead(_9); ++ StorageDead(_8); ++ _6 = <() as E>::call() -> [return: bb5, unwind unreachable]; ++ } ++ ++ bb5: { ++ _7 = <() as E>::call() -> [return: bb2, unwind unreachable]; ++ } ++ ++ bb6: { ++ StorageDead(_13); ++ StorageDead(_12); ++ StorageDead(_11); ++ _9 = <() as D>::call() -> [return: bb7, unwind unreachable]; ++ } ++ ++ bb7: { ++ _10 = <() as D>::call() -> [return: bb4, unwind unreachable]; ++ } ++ ++ bb8: { ++ StorageDead(_16); ++ StorageDead(_15); ++ StorageDead(_14); ++ _12 = <() as C>::call() -> [return: bb9, unwind unreachable]; ++ } ++ ++ bb9: { ++ _13 = <() as C>::call() -> [return: bb6, unwind unreachable]; ++ } ++ ++ bb10: { ++ StorageDead(_19); ++ StorageDead(_18); ++ StorageDead(_17); ++ _15 = <() as B>::call() -> [return: bb11, unwind unreachable]; ++ } ++ ++ bb11: { ++ _16 = <() as B>::call() -> [return: bb8, unwind unreachable]; ++ } ++ ++ bb12: { ++ _18 = <() as A>::call() -> [return: bb13, unwind unreachable]; ++ } ++ ++ bb13: { ++ _19 = <() as A>::call() -> [return: bb10, unwind unreachable]; + } + } + diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..0a4ce40c5 --- /dev/null +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff @@ -0,0 +1,134 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined <() as G>::call) { ++ let _2: (); ++ let _3: (); ++ let _4: (); ++ scope 2 (inlined <() as F>::call) { ++ let _5: (); ++ let _6: (); ++ let _7: (); ++ scope 3 (inlined <() as E>::call) { ++ let _8: (); ++ let _9: (); ++ let _10: (); ++ scope 4 (inlined <() as D>::call) { ++ let _11: (); ++ let _12: (); ++ let _13: (); ++ scope 5 (inlined <() as C>::call) { ++ let _14: (); ++ let _15: (); ++ let _16: (); ++ scope 6 (inlined <() as B>::call) { ++ let _17: (); ++ let _18: (); ++ let _19: (); ++ } ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = <() as G>::call() -> [return: bb1, unwind continue]; ++ StorageLive(_2); ++ StorageLive(_3); ++ StorageLive(_4); ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); ++ StorageLive(_8); ++ StorageLive(_9); ++ StorageLive(_10); ++ StorageLive(_11); ++ StorageLive(_12); ++ StorageLive(_13); ++ StorageLive(_14); ++ StorageLive(_15); ++ StorageLive(_16); ++ StorageLive(_17); ++ StorageLive(_18); ++ StorageLive(_19); ++ _17 = <() as A>::call() -> [return: bb12, unwind continue]; + } + + bb1: { ++ StorageDead(_4); ++ StorageDead(_3); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb2: { ++ StorageDead(_7); ++ StorageDead(_6); ++ StorageDead(_5); ++ _3 = <() as F>::call() -> [return: bb3, unwind continue]; ++ } ++ ++ bb3: { ++ _4 = <() as F>::call() -> [return: bb1, unwind continue]; ++ } ++ ++ bb4: { ++ StorageDead(_10); ++ StorageDead(_9); ++ StorageDead(_8); ++ _6 = <() as E>::call() -> [return: bb5, unwind continue]; ++ } ++ ++ bb5: { ++ _7 = <() as E>::call() -> [return: bb2, unwind continue]; ++ } ++ ++ bb6: { ++ StorageDead(_13); ++ StorageDead(_12); ++ StorageDead(_11); ++ _9 = <() as D>::call() -> [return: bb7, unwind continue]; ++ } ++ ++ bb7: { ++ _10 = <() as D>::call() -> [return: bb4, unwind continue]; ++ } ++ ++ bb8: { ++ StorageDead(_16); ++ StorageDead(_15); ++ StorageDead(_14); ++ _12 = <() as C>::call() -> [return: bb9, unwind continue]; ++ } ++ ++ bb9: { ++ _13 = <() as C>::call() -> [return: bb6, unwind continue]; ++ } ++ ++ bb10: { ++ StorageDead(_19); ++ StorageDead(_18); ++ StorageDead(_17); ++ _15 = <() as B>::call() -> [return: bb11, unwind continue]; ++ } ++ ++ bb11: { ++ _16 = <() as B>::call() -> [return: bb8, unwind continue]; ++ } ++ ++ bb12: { ++ _18 = <() as A>::call() -> [return: bb13, unwind continue]; ++ } ++ ++ bb13: { ++ _19 = <() as A>::call() -> [return: bb10, unwind continue]; + } + } + diff --git a/tests/mir-opt/inline/exponential_runtime.rs b/tests/mir-opt/inline/exponential_runtime.rs index 39985528f..cfa9ff210 100644 --- a/tests/mir-opt/inline/exponential_runtime.rs +++ b/tests/mir-opt/inline/exponential_runtime.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Checks that code with exponential runtime does not have exponential behavior in inlining. trait A { diff --git a/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir b/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir index 20f737cc2..2d0b71e0a 100644 --- a/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir +++ b/tests/mir-opt/inline/inline_any_operand.bar.Inline.after.mir @@ -1,36 +1,33 @@ // MIR for `bar` after Inline fn bar() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/inline_any_operand.rs:+0:13: +0:17 - let _1: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline_any_operand.rs:+1:9: +1:10 - let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:6 - let mut _3: i32; // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:13 - let mut _4: i32; // in scope 0 at $DIR/inline_any_operand.rs:+2:5: +2:13 + let mut _0: bool; + let _1: fn(i32, i32) -> bool {foo}; + let mut _2: fn(i32, i32) -> bool {foo}; + let mut _3: i32; + let mut _4: i32; scope 1 { - debug f => _1; // in scope 1 at $DIR/inline_any_operand.rs:+1:9: +1:10 - scope 2 (inlined foo) { // at $DIR/inline_any_operand.rs:12:5: 12:13 - debug x => _3; // in scope 2 at $DIR/inline_any_operand.rs:16:8: 16:9 - debug y => _4; // in scope 2 at $DIR/inline_any_operand.rs:16:16: 16:17 + debug f => _1; + scope 2 (inlined foo) { + debug x => _3; + debug y => _4; } } 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(<ZST>) } - StorageLive(_2); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:6 - _2 = _1; // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:6 - StorageLive(_3); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 - _3 = const 1_i32; // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 - StorageLive(_4); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 - _4 = const -1_i32; // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 - _0 = Eq(_3, _4); // scope 2 at $DIR/inline_any_operand.rs:17:5: 17:11 - StorageDead(_4); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 - StorageDead(_3); // scope 1 at $DIR/inline_any_operand.rs:+2:5: +2:13 - StorageDead(_2); // scope 1 at $DIR/inline_any_operand.rs:+2:12: +2:13 - StorageDead(_1); // scope 0 at $DIR/inline_any_operand.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline_any_operand.rs:+3:2: +3:2 + StorageLive(_1); + _1 = foo; + StorageLive(_2); + _2 = _1; + StorageLive(_3); + _3 = const 1_i32; + StorageLive(_4); + _4 = const -1_i32; + _0 = Eq(_3, _4); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir index 1d2f99cbe..9384064c5 100644 --- a/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -1,55 +1,47 @@ // 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<T>::{closure#0}]; // in scope 0 at $DIR/inline_closure.rs:+1:9: +1:10 - let mut _4: &[closure@foo<T>::{closure#0}]; // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:6 - let mut _5: (i32, i32); // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12 - let mut _6: i32; // in scope 0 at $DIR/inline_closure.rs:+2:7: +2:8 - let mut _7: i32; // in scope 0 at $DIR/inline_closure.rs:+2:10: +2:11 - let mut _8: i32; // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12 - let mut _9: i32; // in scope 0 at $DIR/inline_closure.rs:+2:5: +2:12 + debug _t => _1; + debug q => _2; + let mut _0: i32; + let _3: [closure@foo<T>::{closure#0}]; + let mut _4: &[closure@foo<T>::{closure#0}]; + let mut _5: (i32, i32); + let mut _6: i32; + let mut _7: i32; + let mut _8: i32; + let mut _9: i32; scope 1 { - debug x => _3; // in scope 1 at $DIR/inline_closure.rs:+1:9: +1:10 - scope 2 (inlined foo::<T>::{closure#0}) { // at $DIR/inline_closure.rs:12:5: 12:12 - debug _t => _8; // in scope 2 at $DIR/inline_closure.rs:+1:14: +1:16 - debug _q => _9; // in scope 2 at $DIR/inline_closure.rs:+1:18: +1:20 + debug x => _3; + scope 2 (inlined foo::<T>::{closure#0}) { + debug _t => _8; + debug _q => _9; } } bb0: { - StorageLive(_3); // scope 0 at $DIR/inline_closure.rs:+1:9: +1:10 - _3 = [closure@foo::<T>::{closure#0}]; // scope 0 at $DIR/inline_closure.rs:+1:13: +1:24 - // closure - // + def_id: DefId(0:6 ~ inline_closure[8f32]::foo::{closure#0}) - // + substs: [ - // T, - // i8, - // extern "rust-call" fn((i32, i32)) -> i32, - // (), - // ] - StorageLive(_4); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:6 - _4 = &_3; // scope 1 at $DIR/inline_closure.rs:+2:5: +2:6 - StorageLive(_5); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - 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 - _5 = (move _6, move _7); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - StorageLive(_8); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - _8 = move (_5.0: i32); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - StorageLive(_9); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - _9 = move (_5.1: i32); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - _0 = _8; // scope 2 at $DIR/inline_closure.rs:+1:22: +1:24 - StorageDead(_9); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - StorageDead(_8); // scope 1 at $DIR/inline_closure.rs:+2:5: +2:12 - StorageDead(_7); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 - StorageDead(_6); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 - StorageDead(_5); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 - StorageDead(_4); // scope 1 at $DIR/inline_closure.rs:+2:11: +2:12 - StorageDead(_3); // scope 0 at $DIR/inline_closure.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline_closure.rs:+3:2: +3:2 + StorageLive(_3); + _3 = [closure@foo::<T>::{closure#0}]; + StorageLive(_4); + _4 = &_3; + StorageLive(_5); + StorageLive(_6); + _6 = _2; + StorageLive(_7); + _7 = _2; + _5 = (move _6, move _7); + StorageLive(_8); + _8 = move (_5.0: i32); + StorageLive(_9); + _9 = move (_5.1: i32); + _0 = _8; + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; } } diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir index 80274bb7e..17676638a 100644 --- a/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir @@ -1,58 +1,50 @@ // 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<T>::{closure#0}]; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10 - let mut _4: &[closure@foo<T>::{closure#0}]; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6 - let mut _5: (&i32, &i32); // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - let mut _6: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:7: +5:8 - let mut _7: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:10: +5:11 - let mut _8: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - let mut _9: &i32; // in scope 0 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 + debug _t => _1; + debug q => _2; + let mut _0: i32; + let _3: [closure@foo<T>::{closure#0}]; + let mut _4: &[closure@foo<T>::{closure#0}]; + let mut _5: (&i32, &i32); + let mut _6: &i32; + let mut _7: &i32; + let mut _8: &i32; + let mut _9: &i32; scope 1 { - debug x => _3; // in scope 1 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10 - scope 2 (inlined foo::<T>::{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 + debug x => _3; + scope 2 (inlined foo::<T>::{closure#0}) { + debug r => _8; + debug _s => _9; scope 3 { - debug variable => _8; // in scope 3 at $DIR/inline_closure_borrows_arg.rs:+2:13: +2:21 + debug variable => _8; } } } bb0: { - StorageLive(_3); // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:9: +1:10 - _3 = [closure@foo::<T>::{closure#0}]; // scope 0 at $DIR/inline_closure_borrows_arg.rs:+1:13: +4:6 - // closure - // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[f89f]::foo::{closure#0}) - // + substs: [ - // T, - // i8, - // for<'a, 'b> extern "rust-call" fn((&'a i32, &'b i32)) -> i32, - // (), - // ] - StorageLive(_4); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6 - _4 = &_3; // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:6 - StorageLive(_5); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - 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 - _5 = (move _6, move _7); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - StorageLive(_8); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - _8 = move (_5.0: &i32); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - StorageLive(_9); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - _9 = move (_5.1: &i32); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - _0 = (*_8); // scope 3 at $DIR/inline_closure_borrows_arg.rs:+3:9: +3:18 - StorageDead(_9); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - StorageDead(_8); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:5: +5:12 - StorageDead(_7); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 - StorageDead(_6); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 - StorageDead(_5); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 - StorageDead(_4); // scope 1 at $DIR/inline_closure_borrows_arg.rs:+5:11: +5:12 - StorageDead(_3); // scope 0 at $DIR/inline_closure_borrows_arg.rs:+6:1: +6:2 - return; // scope 0 at $DIR/inline_closure_borrows_arg.rs:+6:2: +6:2 + StorageLive(_3); + _3 = [closure@foo::<T>::{closure#0}]; + StorageLive(_4); + _4 = &_3; + StorageLive(_5); + StorageLive(_6); + _6 = &(*_2); + StorageLive(_7); + _7 = &(*_2); + _5 = (move _6, move _7); + StorageLive(_8); + _8 = move (_5.0: &i32); + StorageLive(_9); + _9 = move (_5.1: &i32); + _0 = (*_8); + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; } } diff --git a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index b36711f82..b8178d201 100644 --- a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -1,68 +1,60 @@ // 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<T>::{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<T>::{closure#0}]; // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:6 - let mut _7: (i32,); // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:9 - let mut _8: i32; // in scope 0 at $DIR/inline_closure_captures.rs:+2:7: +2:8 - let mut _9: i32; // in scope 0 at $DIR/inline_closure_captures.rs:+2:5: +2:9 + debug t => _1; + debug q => _2; + let mut _0: (i32, T); + let _3: [closure@foo<T>::{closure#0}]; + let mut _4: &i32; + let mut _5: &T; + let mut _6: &[closure@foo<T>::{closure#0}]; + let mut _7: (i32,); + let mut _8: i32; + let mut _9: i32; scope 1 { - debug x => _3; // in scope 1 at $DIR/inline_closure_captures.rs:+1:9: +1:10 - scope 2 (inlined foo::<T>::{closure#0}) { // at $DIR/inline_closure_captures.rs:12:5: 12:9 - debug _q => _9; // in scope 2 at $DIR/inline_closure_captures.rs:+1:14: +1:16 - debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:23: +0:24 - debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline_closure_captures.rs:+0:17: +0:18 - let mut _10: i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 - let mut _11: T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 - let mut _12: &i32; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24 - let mut _13: &T; // in scope 2 at $DIR/inline_closure_captures.rs:+1:13: +1:24 + debug x => _3; + scope 2 (inlined foo::<T>::{closure#0}) { + debug _q => _9; + debug q => (*((*_6).0: &i32)); + debug t => (*((*_6).1: &T)); + let mut _10: &i32; + let mut _11: i32; + let mut _12: &T; + let mut _13: T; } } 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 - _3 = [closure@foo::<T>::{closure#0}] { q: move _4, t: move _5 }; // scope 0 at $DIR/inline_closure_captures.rs:+1:13: +1:24 - // closure - // + def_id: DefId(0:6 ~ inline_closure_captures[63a5]::foo::{closure#0}) - // + substs: [ - // T, - // i8, - // extern "rust-call" fn((i32,)) -> (i32, T), - // (&i32, &T), - // ] - StorageDead(_5); // scope 0 at $DIR/inline_closure_captures.rs:+1:16: +1:17 - StorageDead(_4); // scope 0 at $DIR/inline_closure_captures.rs:+1:16: +1:17 - StorageLive(_6); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:6 - _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 - _7 = (move _8,); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 - StorageLive(_9); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 - _9 = move (_7.0: i32); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 - StorageLive(_10); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 - _12 = deref_copy ((*_6).0: &i32); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 - _10 = (*_12); // scope 2 at $DIR/inline_closure_captures.rs:+1:19: +1:20 - StorageLive(_11); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 - _13 = deref_copy ((*_6).1: &T); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 - _11 = (*_13); // scope 2 at $DIR/inline_closure_captures.rs:+1:22: +1:23 - _0 = (move _10, move _11); // scope 2 at $DIR/inline_closure_captures.rs:+1:18: +1:24 - StorageDead(_11); // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24 - StorageDead(_10); // scope 2 at $DIR/inline_closure_captures.rs:+1:23: +1:24 - StorageDead(_9); // scope 1 at $DIR/inline_closure_captures.rs:+2:5: +2:9 - StorageDead(_8); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9 - StorageDead(_7); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9 - StorageDead(_6); // scope 1 at $DIR/inline_closure_captures.rs:+2:8: +2:9 - StorageDead(_3); // scope 0 at $DIR/inline_closure_captures.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline_closure_captures.rs:+3:2: +3:2 + StorageLive(_3); + StorageLive(_4); + _4 = &_2; + StorageLive(_5); + _5 = &_1; + _3 = [closure@foo::<T>::{closure#0}] { q: move _4, t: move _5 }; + StorageDead(_5); + StorageDead(_4); + StorageLive(_6); + _6 = &_3; + StorageLive(_7); + StorageLive(_8); + _8 = _2; + _7 = (move _8,); + StorageLive(_9); + _9 = move (_7.0: i32); + StorageLive(_11); + _10 = deref_copy ((*_6).0: &i32); + _11 = (*_10); + StorageLive(_13); + _12 = deref_copy ((*_6).1: &T); + _13 = (*_12); + _0 = (move _11, move _13); + StorageDead(_13); + StorageDead(_11); + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); + StorageDead(_6); + StorageDead(_3); + return; } } diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff deleted file mode 100644 index e30a5e116..000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.diff +++ /dev/null @@ -1,24 +0,0 @@ -- // 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(<ZST>) } -- } -- -- 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/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff new file mode 100644 index 000000000..eac51000c --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-abort.diff @@ -0,0 +1,21 @@ +- // MIR for `inlined_no_sanitize` before Inline ++ // MIR for `inlined_no_sanitize` after Inline + + fn inlined_no_sanitize() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined no_sanitize) { ++ } + + bb0: { + StorageLive(_1); +- _1 = no_sanitize() -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff new file mode 100644 index 000000000..eba5ad9cf --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.inlined_no_sanitize.Inline.panic-unwind.diff @@ -0,0 +1,21 @@ +- // MIR for `inlined_no_sanitize` before Inline ++ // MIR for `inlined_no_sanitize` after Inline + + fn inlined_no_sanitize() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined no_sanitize) { ++ } + + bb0: { + StorageLive(_1); +- _1 = no_sanitize() -> [return: bb1, unwind continue]; +- } +- +- bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff deleted file mode 100644 index c2b3c46a3..000000000 --- a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.diff +++ /dev/null @@ -1,24 +0,0 @@ -- // 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(<ZST>) } -- } -- -- 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/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff new file mode 100644 index 000000000..c2a81b980 --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-abort.diff @@ -0,0 +1,21 @@ +- // MIR for `inlined_target_feature` before Inline ++ // MIR for `inlined_target_feature` after Inline + + fn inlined_target_feature() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined target_feature) { ++ } + + bb0: { + StorageLive(_1); +- _1 = target_feature() -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff new file mode 100644 index 000000000..24457819b --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.inlined_target_feature.Inline.panic-unwind.diff @@ -0,0 +1,21 @@ +- // MIR for `inlined_target_feature` before Inline ++ // MIR for `inlined_target_feature` after Inline + + fn inlined_target_feature() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined target_feature) { ++ } + + bb0: { + StorageLive(_1); +- _1 = target_feature() -> [return: bb1, unwind continue]; +- } +- +- bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff deleted file mode 100644 index 0ca5a5f70..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.diff +++ /dev/null @@ -1,25 +0,0 @@ -- // 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(<ZST>) } - } - - 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/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff new file mode 100644 index 000000000..791c5a0f2 --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-abort.diff @@ -0,0 +1,22 @@ +- // MIR for `not_inlined_c_variadic` before Inline ++ // MIR for `not_inlined_c_variadic` after Inline + + fn not_inlined_c_variadic() -> () { + let mut _0: (); + let _1: u32; + scope 1 { + debug s => _1; + } + + bb0: { + StorageLive(_1); + _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> [return: bb1, unwind unreachable]; + } + + bb1: { + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff new file mode 100644 index 000000000..364acab6d --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_c_variadic.Inline.panic-unwind.diff @@ -0,0 +1,22 @@ +- // MIR for `not_inlined_c_variadic` before Inline ++ // MIR for `not_inlined_c_variadic` after Inline + + fn not_inlined_c_variadic() -> () { + let mut _0: (); + let _1: u32; + scope 1 { + debug s => _1; + } + + bb0: { + StorageLive(_1); + _1 = sum(const 4_u32, const 4_u32, const 30_u32, const 200_u32, const 1000_u32) -> [return: bb1, unwind continue]; + } + + bb1: { + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff deleted file mode 100644 index 00d405c77..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.diff +++ /dev/null @@ -1,22 +0,0 @@ -- // 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(<ZST>) } - } - - 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/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff new file mode 100644 index 000000000..b9d0946b7 --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-abort.diff @@ -0,0 +1,19 @@ +- // MIR for `not_inlined_no_sanitize` before Inline ++ // MIR for `not_inlined_no_sanitize` after Inline + + fn not_inlined_no_sanitize() -> () { + let mut _0: (); + let _1: (); + + bb0: { + StorageLive(_1); + _1 = no_sanitize() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff new file mode 100644 index 000000000..965b7ddca --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_no_sanitize.Inline.panic-unwind.diff @@ -0,0 +1,19 @@ +- // MIR for `not_inlined_no_sanitize` before Inline ++ // MIR for `not_inlined_no_sanitize` after Inline + + fn not_inlined_no_sanitize() -> () { + let mut _0: (); + let _1: (); + + bb0: { + StorageLive(_1); + _1 = no_sanitize() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff deleted file mode 100644 index 8b9c86f55..000000000 --- a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.diff +++ /dev/null @@ -1,22 +0,0 @@ -- // 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(<ZST>) } - } - - 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/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff new file mode 100644 index 000000000..7c689a734 --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-abort.diff @@ -0,0 +1,19 @@ +- // MIR for `not_inlined_target_feature` before Inline ++ // MIR for `not_inlined_target_feature` after Inline + + fn not_inlined_target_feature() -> () { + let mut _0: (); + let _1: (); + + bb0: { + StorageLive(_1); + _1 = target_feature() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff new file mode 100644 index 000000000..bcdbd6e33 --- /dev/null +++ b/tests/mir-opt/inline/inline_compatibility.not_inlined_target_feature.Inline.panic-unwind.diff @@ -0,0 +1,19 @@ +- // MIR for `not_inlined_target_feature` before Inline ++ // MIR for `not_inlined_target_feature` after Inline + + fn not_inlined_target_feature() -> () { + let mut _0: (); + let _1: (); + + bb0: { + StorageLive(_1); + _1 = target_feature() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_compatibility.rs b/tests/mir-opt/inline/inline_compatibility.rs index 30aff0a64..1527fea1c 100644 --- a/tests/mir-opt/inline/inline_compatibility.rs +++ b/tests/mir-opt/inline/inline_compatibility.rs @@ -1,6 +1,7 @@ // Checks that only functions with compatible attributes are inlined. // // only-x86_64 +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] #![feature(no_sanitize)] diff --git a/tests/mir-opt/inline/inline_cycle.one.Inline.diff b/tests/mir-opt/inline/inline_cycle.one.Inline.diff deleted file mode 100644 index f6ba69a1d..000000000 --- a/tests/mir-opt/inline/inline_cycle.one.Inline.diff +++ /dev/null @@ -1,30 +0,0 @@ -- // 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 <C as Call>::call) { // at $DIR/inline_cycle.rs:15:5: 15:24 -+ scope 2 (inlined <A<C> as Call>::call) { // at $DIR/inline_cycle.rs:44:9: 44:23 -+ scope 3 (inlined <B<C> as Call>::call) { // at $DIR/inline_cycle.rs:29:9: 29:31 -+ } -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 -- _1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:24 -+ _1 = <C as Call>::call() -> bb1; // scope 3 at $DIR/inline_cycle.rs:37:9: 37:28 - // mir::Constant -- // + span: $DIR/inline_cycle.rs:15:5: 15:22 -+ // + span: $DIR/inline_cycle.rs:37:9: 37:26 - // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(<ZST>) } - } - - 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/tests/mir-opt/inline/inline_cycle.one.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_cycle.one.Inline.panic-abort.diff new file mode 100644 index 000000000..c8805a446 --- /dev/null +++ b/tests/mir-opt/inline/inline_cycle.one.Inline.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `one` before Inline ++ // MIR for `one` after Inline + + fn one() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined <C as Call>::call) { ++ scope 2 (inlined <A<C> as Call>::call) { ++ scope 3 (inlined <B<C> as Call>::call) { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); + _1 = <C as Call>::call() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_cycle.one.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle.one.Inline.panic-unwind.diff new file mode 100644 index 000000000..75ac40bea --- /dev/null +++ b/tests/mir-opt/inline/inline_cycle.one.Inline.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `one` before Inline ++ // MIR for `one` after Inline + + fn one() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined <C as Call>::call) { ++ scope 2 (inlined <A<C> as Call>::call) { ++ scope 3 (inlined <B<C> as Call>::call) { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); + _1 = <C as Call>::call() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_cycle.rs b/tests/mir-opt/inline/inline_cycle.rs index 2f81696cf..42a6914c9 100644 --- a/tests/mir-opt/inline/inline_cycle.rs +++ b/tests/mir-opt/inline/inline_cycle.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // 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. diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.diff deleted file mode 100644 index c8f58111d..000000000 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.diff +++ /dev/null @@ -1,42 +0,0 @@ -- // 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 -+ let mut _4: (); // in scope 0 at $DIR/inline_cycle.rs:55:5: 55:8 -+ scope 1 (inlined call::<fn() {f}>) { // at $DIR/inline_cycle.rs:50:5: 50:12 -+ debug f => _2; // in scope 1 at $DIR/inline_cycle.rs:54:22: 54:23 -+ let _3: (); // in scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 -+ scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { // at $DIR/inline_cycle.rs:55:5: 55:8 -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 -- _1 = call::<fn() {f}>(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:50:5: 50:9 -- // + literal: Const { ty: fn(fn() {f}) {call::<fn() {f}>}, val: Value(<ZST>) } -- // mir::Constant - // + span: $DIR/inline_cycle.rs:50:10: 50:11 - // + literal: Const { ty: fn() {f}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 -+ StorageLive(_4); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 -+ _4 = const (); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 -+ _3 = move _2() -> bb1; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL - } - - bb1: { -+ StorageDead(_4); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 -+ StorageDead(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 -+ 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/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff new file mode 100644 index 000000000..d83c8d585 --- /dev/null +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-abort.diff @@ -0,0 +1,46 @@ +- // MIR for `two` before Inline ++ // MIR for `two` after Inline + + fn two() -> () { + let mut _0: (); + let _1: (); ++ let mut _2: fn() {f}; ++ let mut _4: (); ++ scope 1 (inlined call::<fn() {f}>) { ++ debug f => _2; ++ let _3: (); ++ scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { ++ scope 3 (inlined f) { ++ scope 4 (inlined call::<fn() {f}>) { ++ debug f => f; ++ let _5: (); ++ scope 5 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = call::<fn() {f}>(f) -> [return: bb1, unwind unreachable]; ++ StorageLive(_2); ++ _2 = f; ++ StorageLive(_3); ++ StorageLive(_4); ++ _4 = const (); ++ StorageLive(_5); ++ _5 = f() -> [return: bb1, unwind unreachable]; + } + + bb1: { ++ StorageDead(_5); ++ StorageDead(_4); ++ StorageDead(_3); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff new file mode 100644 index 000000000..a08662959 --- /dev/null +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.panic-unwind.diff @@ -0,0 +1,46 @@ +- // MIR for `two` before Inline ++ // MIR for `two` after Inline + + fn two() -> () { + let mut _0: (); + let _1: (); ++ let mut _2: fn() {f}; ++ let mut _4: (); ++ scope 1 (inlined call::<fn() {f}>) { ++ debug f => _2; ++ let _3: (); ++ scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { ++ scope 3 (inlined f) { ++ scope 4 (inlined call::<fn() {f}>) { ++ debug f => f; ++ let _5: (); ++ scope 5 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = call::<fn() {f}>(f) -> [return: bb1, unwind continue]; ++ StorageLive(_2); ++ _2 = f; ++ StorageLive(_3); ++ StorageLive(_4); ++ _4 = const (); ++ StorageLive(_5); ++ _5 = f() -> [return: bb1, unwind continue]; + } + + bb1: { ++ StorageDead(_5); ++ StorageDead(_4); ++ StorageDead(_3); ++ StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff deleted file mode 100644 index 9429ca593..000000000 --- a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff +++ /dev/null @@ -1,29 +0,0 @@ -- // 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 <C as Call>::call) { // at $DIR/inline_cycle_generic.rs:10:5: 10:24 -+ scope 2 (inlined <B<A> as Call>::call) { // at $DIR/inline_cycle_generic.rs:39:9: 39:31 -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 -- _1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 -+ _1 = <A as Call>::call() -> bb1; // scope 2 at $DIR/inline_cycle_generic.rs:32:9: 32:28 - // mir::Constant -- // + span: $DIR/inline_cycle_generic.rs:10:5: 10:22 -- // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(<ZST>) } -+ // + span: $DIR/inline_cycle_generic.rs:32:9: 32:26 -+ // + literal: Const { ty: fn() {<A as Call>::call}, val: Value(<ZST>) } - } - - 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/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-abort.diff new file mode 100644 index 000000000..d437dbf57 --- /dev/null +++ b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-abort.diff @@ -0,0 +1,26 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined <C as Call>::call) { ++ scope 2 (inlined <B<A> as Call>::call) { ++ scope 3 (inlined <A as Call>::call) { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = <C as Call>::call() -> [return: bb1, unwind unreachable]; ++ _1 = <B<C> as Call>::call() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..8314526ee --- /dev/null +++ b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.panic-unwind.diff @@ -0,0 +1,26 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: (); ++ scope 1 (inlined <C as Call>::call) { ++ scope 2 (inlined <B<A> as Call>::call) { ++ scope 3 (inlined <A as Call>::call) { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = <C as Call>::call() -> [return: bb1, unwind continue]; ++ _1 = <B<C> as Call>::call() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_1); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_cycle_generic.rs b/tests/mir-opt/inline/inline_cycle_generic.rs index 84e6e4005..ef261b04c 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.rs +++ b/tests/mir-opt/inline/inline_cycle_generic.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // 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. diff --git a/tests/mir-opt/inline/inline_diverging.f.Inline.diff b/tests/mir-opt/inline/inline_diverging.f.Inline.diff deleted file mode 100644 index b49191f49..000000000 --- a/tests/mir-opt/inline/inline_diverging.f.Inline.diff +++ /dev/null @@ -1,24 +0,0 @@ -- // 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(<ZST>) } -+ goto -> bb1; // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:12 -+ } -+ -+ bb1: { -+ goto -> bb1; // scope 1 at $DIR/inline_diverging.rs:39:5: 39:12 - } - } - diff --git a/tests/mir-opt/inline/inline_diverging.f.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.f.Inline.panic-abort.diff new file mode 100644 index 000000000..3de72d03c --- /dev/null +++ b/tests/mir-opt/inline/inline_diverging.f.Inline.panic-abort.diff @@ -0,0 +1,21 @@ +- // MIR for `f` before Inline ++ // MIR for `f` after Inline + + fn f() -> () { + let mut _0: (); + let mut _1: !; + let _2: !; ++ scope 1 (inlined sleep) { ++ } + + bb0: { + StorageLive(_2); +- _2 = sleep() -> unwind unreachable; ++ goto -> bb1; ++ } ++ ++ bb1: { ++ goto -> bb1; + } + } + diff --git a/tests/mir-opt/inline/inline_diverging.f.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.f.Inline.panic-unwind.diff new file mode 100644 index 000000000..b79918992 --- /dev/null +++ b/tests/mir-opt/inline/inline_diverging.f.Inline.panic-unwind.diff @@ -0,0 +1,21 @@ +- // MIR for `f` before Inline ++ // MIR for `f` after Inline + + fn f() -> () { + let mut _0: (); + let mut _1: !; + let _2: !; ++ scope 1 (inlined sleep) { ++ } + + bb0: { + StorageLive(_2); +- _2 = sleep() -> unwind continue; ++ goto -> bb1; ++ } ++ ++ bb1: { ++ goto -> bb1; + } + } + diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.diff deleted file mode 100644 index 4f22ad437..000000000 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.diff +++ /dev/null @@ -1,49 +0,0 @@ -- // 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) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/inline_diverging.rs:+1:8: +1:13 - } - - bb1: { - StorageLive(_4); // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10 - _4 = _1; // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:10 - _0 = move _4 as u32 (IntToInt); // scope 0 at $DIR/inline_diverging.rs:+2:9: +2:17 - StorageDead(_4); // scope 0 at $DIR/inline_diverging.rs:+2:16: +2:17 - StorageDead(_2); // scope 0 at $DIR/inline_diverging.rs:+5:5: +5:6 - return; // scope 0 at $DIR/inline_diverging.rs:+6:2: +6:2 - } - - 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 0 at $DIR/inline_diverging.rs:+4:9: +4:16 -+ _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(<ZST>) } -+ // + span: $SRC_DIR/std/src/panic.rs:LL:COL -+ // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(<ZST>) } -+ // mir::Constant -+ // + span: $SRC_DIR/std/src/panic.rs:LL:COL -+ // + literal: Const { ty: &str, val: Value(Slice(..)) } - } - } - diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff new file mode 100644 index 000000000..9db0d385d --- /dev/null +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff @@ -0,0 +1,41 @@ +- // MIR for `g` before Inline ++ // MIR for `g` after Inline + + fn g(_1: i32) -> u32 { + debug i => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: i32; + let mut _4: i32; + let mut _5: !; + let _6: !; ++ scope 1 (inlined panic) { ++ let mut _7: !; ++ } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = Gt(move _3, const 0_i32); + StorageDead(_3); + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageLive(_4); + _4 = _1; + _0 = move _4 as u32 (IntToInt); + StorageDead(_4); + StorageDead(_2); + return; + } + + bb2: { + StorageLive(_6); +- _6 = panic() -> unwind unreachable; ++ StorageLive(_7); ++ _7 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + } + } + diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff new file mode 100644 index 000000000..5663b4624 --- /dev/null +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff @@ -0,0 +1,41 @@ +- // MIR for `g` before Inline ++ // MIR for `g` after Inline + + fn g(_1: i32) -> u32 { + debug i => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: i32; + let mut _4: i32; + let mut _5: !; + let _6: !; ++ scope 1 (inlined panic) { ++ let mut _7: !; ++ } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = Gt(move _3, const 0_i32); + StorageDead(_3); + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageLive(_4); + _4 = _1; + _0 = move _4 as u32 (IntToInt); + StorageDead(_4); + StorageDead(_2); + return; + } + + bb2: { + StorageLive(_6); +- _6 = panic() -> unwind continue; ++ StorageLive(_7); ++ _7 = begin_panic::<&str>(const "explicit panic") -> unwind continue; + } + } + diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.diff deleted file mode 100644 index d501b6ca8..000000000 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.diff +++ /dev/null @@ -1,83 +0,0 @@ -- // 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 -+ let mut _8: (); // in scope 0 at $DIR/inline_diverging.rs:27:13: 27:16 -+ scope 1 (inlined call_twice::<!, fn() -> ! {sleep}>) { // at $DIR/inline_diverging.rs:22:5: 22:22 -+ debug f => _2; // in scope 1 at $DIR/inline_diverging.rs:26:36: 26:37 -+ let _3: !; // in scope 1 at $DIR/inline_diverging.rs:27:9: 27:10 -+ let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 -+ let mut _5: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:14 -+ let mut _6: !; // in scope 1 at $DIR/inline_diverging.rs:29:6: 29:7 -+ let mut _7: !; // in scope 1 at $DIR/inline_diverging.rs:29:9: 29:10 -+ scope 2 { -+ debug a => _3; // in scope 2 at $DIR/inline_diverging.rs:27:9: 27:10 -+ scope 3 { -+ debug b => _7; // in scope 3 at $DIR/inline_diverging.rs:28:9: 28:10 -+ } -+ } -+ scope 4 (inlined <fn() -> ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline_diverging.rs:27:13: 27:16 -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 -- _1 = call_twice::<!, fn() -> ! {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::<!, fn() -> ! {sleep}>}, val: Value(<ZST>) } -- // mir::Constant - // + span: $DIR/inline_diverging.rs:22:16: 22:21 - // + literal: Const { ty: fn() -> ! {sleep}, val: Value(<ZST>) } -+ StorageLive(_7); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 -+ StorageLive(_3); // scope 1 at $DIR/inline_diverging.rs:27:9: 27:10 -+ StorageLive(_4); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 -+ _4 = &_2; // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 -+ StorageLive(_8); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 -+ _8 = const (); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 -+ _3 = move (*_4)() -> [return: bb6, unwind: bb4]; // scope 4 at $SRC_DIR/core/src/ops/function.rs:LL:COL -+ } -+ -+ bb1: { -+ StorageDead(_5); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 -+ StorageLive(_6); // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _6 = move _3; // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _1 = (move _6, move _7); // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 -+ StorageDead(_6); // scope 3 at $DIR/inline_diverging.rs:29:10: 29:11 -+ StorageDead(_3); // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ drop(_2) -> bb2; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ } -+ -+ bb2: { -+ unreachable; // scope 0 at $DIR/inline_diverging.rs:30:2: 30:2 -+ } -+ -+ bb3 (cleanup): { -+ drop(_3) -> [return: bb4, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ } -+ -+ bb4 (cleanup): { -+ drop(_2) -> [return: bb5, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ } -+ -+ bb5 (cleanup): { -+ resume; // scope 1 at $DIR/inline_diverging.rs:26:1: 30:2 -+ } -+ -+ bb6: { -+ StorageDead(_8); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 -+ StorageDead(_4); // scope 1 at $DIR/inline_diverging.rs:27:15: 27:16 -+ StorageLive(_5); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ _5 = &_2; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ _7 = <fn() -> ! {sleep} as Fn<()>>::call(move _5, const ()) -> [return: bb1, unwind: bb3]; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 -+ // mir::Constant -+ // + span: $DIR/inline_diverging.rs:28:13: 28:14 -+ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() -> ! {sleep}, ()) -> <fn() -> ! {sleep} as FnOnce<()>>::Output {<fn() -> ! {sleep} as Fn<()>>::call}, val: Value(<ZST>) } - } - } - diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff new file mode 100644 index 000000000..0dcd5fae8 --- /dev/null +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff @@ -0,0 +1,45 @@ +- // MIR for `h` before Inline ++ // MIR for `h` after Inline + + fn h() -> () { + let mut _0: (); + let _1: (!, !); ++ let mut _2: fn() -> ! {sleep}; ++ let mut _7: (); ++ scope 1 (inlined call_twice::<!, fn() -> ! {sleep}>) { ++ debug f => _2; ++ let mut _3: &fn() -> ! {sleep}; ++ let mut _4: !; ++ let mut _5: &fn() -> ! {sleep}; ++ let mut _6: !; ++ scope 2 { ++ debug a => _4; ++ scope 3 { ++ debug b => _6; ++ } ++ } ++ scope 4 (inlined <fn() -> ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { ++ scope 5 (inlined sleep) { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = call_twice::<!, fn() -> ! {sleep}>(sleep) -> unwind unreachable; ++ StorageLive(_2); ++ _2 = sleep; ++ StorageLive(_4); ++ StorageLive(_6); ++ StorageLive(_3); ++ _3 = &_2; ++ StorageLive(_7); ++ _7 = const (); ++ goto -> bb1; ++ } ++ ++ bb1: { ++ goto -> bb1; + } + } + diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff new file mode 100644 index 000000000..dfc12db12 --- /dev/null +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff @@ -0,0 +1,46 @@ +- // MIR for `h` before Inline ++ // MIR for `h` after Inline + + fn h() -> () { + let mut _0: (); + let _1: (!, !); ++ let mut _2: fn() -> ! {sleep}; ++ let mut _8: (); ++ scope 1 (inlined call_twice::<!, fn() -> ! {sleep}>) { ++ debug f => _2; ++ let mut _3: &fn() -> ! {sleep}; ++ let _4: !; ++ let mut _5: &fn() -> ! {sleep}; ++ let mut _6: !; ++ let mut _7: !; ++ scope 2 { ++ debug a => _4; ++ scope 3 { ++ debug b => _6; ++ } ++ } ++ scope 4 (inlined <fn() -> ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { ++ scope 5 (inlined sleep) { ++ } ++ } ++ } + + bb0: { + StorageLive(_1); +- _1 = call_twice::<!, fn() -> ! {sleep}>(sleep) -> unwind continue; ++ StorageLive(_2); ++ _2 = sleep; ++ StorageLive(_6); ++ StorageLive(_4); ++ StorageLive(_3); ++ _3 = &_2; ++ StorageLive(_8); ++ _8 = const (); ++ goto -> bb1; ++ } ++ ++ bb1: { ++ goto -> bb1; + } + } + diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs index ae6f814c2..e01c4c1dd 100644 --- a/tests/mir-opt/inline/inline_diverging.rs +++ b/tests/mir-opt/inline/inline_diverging.rs @@ -1,6 +1,7 @@ // Tests inlining of diverging calls. // -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zinline-mir-hint-threshold=1000 #![crate_type = "lib"] // EMIT_MIR inline_diverging.f.Inline.diff diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.diff b/tests/mir-opt/inline/inline_generator.main.Inline.diff deleted file mode 100644 index c3ca2d7d4..000000000 --- a/tests/mir-opt/inline/inline_generator.main.Inline.diff +++ /dev/null @@ -1,132 +0,0 @@ -- // 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<i32, bool>; // 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 _5: bool; // in scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 - scope 1 { - debug _r => _1; // in scope 1 at $DIR/inline_generator.rs:+1:9: +1:11 - } -+ 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 -+ 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 => _3; // in scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL -+ } -+ } -+ } -+ scope 6 (inlined g::{closure#0}) { // at $DIR/inline_generator.rs:9:33: 9:46 -+ debug a => _5; // in scope 6 at $DIR/inline_generator.rs:15:6: 15:7 -+ let mut _6: i32; // in scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ let mut _7: u32; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _8: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _9: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ let mut _10: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]; // in scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ } - - 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<bool> {g}, val: Value(<ZST>) } -- } -- -- bb1: { -+ _4 = [generator@$DIR/inline_generator.rs:15:5: 15:8 (#0)]; // scope 2 at $DIR/inline_generator.rs:15:5: 15:41 -+ // generator -+ // + def_id: DefId(0:7 ~ inline_generator[e37e]::g::{closure#0}) -+ // + substs: [ -+ // bool, -+ // i32, -+ // bool, -+ // {bool, i32}, -+ // (), -+ // ] -+ // + movability: Movable - _3 = &mut _4; // scope 0 at $DIR/inline_generator.rs:+1:23: +1:31 -- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>::new(move _3) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:32 -- // mir::Constant -- // + 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(<ZST>) } -- } -- -- bb2: { -+ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:15:5: 15:8]> { pointer: move _3 }; // scope 5 at $SRC_DIR/core/src/pin.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/inline_generator.rs:+1:31: +1:32 -- _1 = <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_generator.rs:+1:14: +1:46 -- // mir::Constant -- // + span: $DIR/inline_generator.rs:9:33: 9:39 -- // + literal: Const { ty: for<'a> fn(Pin<&'a mut [generator@$DIR/inline_generator.rs:15:5: 15:8]>, bool) -> GeneratorState<<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::Yield, <[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::Return> {<[generator@$DIR/inline_generator.rs:15:5: 15:8] as Generator<bool>>::resume}, val: Value(<ZST>) } -+ StorageLive(_5); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _5 = const false; // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 -+ _8 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ _7 = discriminant((*_8)); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ switchInt(move _7) -> [0: bb3, 1: bb8, 3: bb7, otherwise: bb9]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 - } - -- bb3: { -+ bb1: { -+ StorageDead(_5); // scope 0 at $DIR/inline_generator.rs:+1:33: +1:46 - StorageDead(_2); // scope 0 at $DIR/inline_generator.rs:+1:45: +1:46 - StorageDead(_4); // scope 0 at $DIR/inline_generator.rs:+1:46: +1:47 - _0 = const (); // scope 0 at $DIR/inline_generator.rs:+0:11: +2:2 - 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: { -+ StorageLive(_6); // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ switchInt(_5) -> [0: bb5, otherwise: bb4]; // scope 6 at $DIR/inline_generator.rs:15:20: 15:21 -+ } -+ -+ bb4: { -+ _6 = const 7_i32; // scope 6 at $DIR/inline_generator.rs:15:24: 15:25 -+ goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ } -+ -+ bb5: { -+ _6 = const 13_i32; // scope 6 at $DIR/inline_generator.rs:15:35: 15:37 -+ goto -> bb6; // scope 6 at $DIR/inline_generator.rs:15:17: 15:39 -+ } -+ -+ bb6: { -+ _1 = GeneratorState::<i32, bool>::Yielded(move _6); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ discriminant((*_9)) = 3; // scope 6 at $DIR/inline_generator.rs:15:11: 15:39 -+ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:11: 15:39 -+ } -+ -+ bb7: { -+ StorageLive(_6); // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ StorageDead(_6); // scope 6 at $DIR/inline_generator.rs:15:38: 15:39 -+ _1 = GeneratorState::<i32, bool>::Complete(_5); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:15:5: 15:8]); // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ discriminant((*_10)) = 1; // scope 6 at $DIR/inline_generator.rs:15:41: 15:41 -+ goto -> bb1; // scope 0 at $DIR/inline_generator.rs:15:41: 15:41 -+ } -+ -+ bb8: { -+ assert(const false, "generator resumed after completion") -> [success: bb8, unwind: bb2]; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 -+ } -+ -+ bb9: { -+ unreachable; // scope 6 at $DIR/inline_generator.rs:15:5: 15:41 - } - } - diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff new file mode 100644 index 000000000..e05c605a4 --- /dev/null +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff @@ -0,0 +1,107 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: std::ops::GeneratorState<i32, bool>; + let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>; + let mut _3: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _4: [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _5: bool; + scope 1 { + debug _r => _1; + } ++ scope 2 (inlined g) { ++ } ++ scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new) { ++ debug pointer => _3; ++ scope 4 { ++ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new_unchecked) { ++ debug pointer => _3; ++ } ++ } ++ } ++ scope 6 (inlined g::{closure#0}) { ++ debug a => _5; ++ let mut _6: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _7: u32; ++ let mut _8: i32; ++ let mut _9: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _10: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); +- _4 = g() -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { ++ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)]; + _3 = &mut _4; +- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind unreachable]; +- } +- +- bb2: { ++ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]> { pointer: move _3 }; + StorageDead(_3); +- _1 = <[generator@$DIR/inline_generator.rs:16:5: 16:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; ++ StorageLive(_5); ++ _5 = const false; ++ _6 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); ++ _7 = discriminant((*_6)); ++ switchInt(move _7) -> [0: bb2, 1: bb6, 3: bb7, otherwise: bb8]; + } + +- bb3: { ++ bb1: { ++ StorageDead(_5); + StorageDead(_2); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; ++ } ++ ++ bb2: { ++ StorageLive(_8); ++ switchInt(_5) -> [0: bb3, otherwise: bb4]; ++ } ++ ++ bb3: { ++ _8 = const 13_i32; ++ goto -> bb5; ++ } ++ ++ bb4: { ++ _8 = const 7_i32; ++ goto -> bb5; ++ } ++ ++ bb5: { ++ _1 = GeneratorState::<i32, bool>::Yielded(move _8); ++ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); ++ discriminant((*_9)) = 3; ++ goto -> bb1; ++ } ++ ++ bb6: { ++ assert(const false, "generator resumed after completion") -> [success: bb6, unwind unreachable]; ++ } ++ ++ bb7: { ++ StorageLive(_8); ++ StorageDead(_8); ++ _1 = GeneratorState::<i32, bool>::Complete(_5); ++ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); ++ discriminant((*_10)) = 1; ++ goto -> bb1; ++ } ++ ++ bb8: { ++ unreachable; + } + } + diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..fedcf0423 --- /dev/null +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff @@ -0,0 +1,112 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: std::ops::GeneratorState<i32, bool>; + let mut _2: std::pin::Pin<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>; + let mut _3: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; + let mut _4: [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _5: bool; + scope 1 { + debug _r => _1; + } ++ scope 2 (inlined g) { ++ } ++ scope 3 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new) { ++ debug pointer => _3; ++ scope 4 { ++ scope 5 (inlined Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new_unchecked) { ++ debug pointer => _3; ++ } ++ } ++ } ++ scope 6 (inlined g::{closure#0}) { ++ debug a => _5; ++ let mut _6: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _7: u32; ++ let mut _8: i32; ++ let mut _9: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ let mut _10: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]; ++ } + + bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); +- _4 = g() -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)]; + _3 = &mut _4; +- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind: bb4]; +- } +- +- bb2: { ++ _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]> { pointer: move _3 }; + StorageDead(_3); +- _1 = <[generator@$DIR/inline_generator.rs:16:5: 16:8] as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4]; ++ StorageLive(_5); ++ _5 = const false; ++ _6 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); ++ _7 = discriminant((*_6)); ++ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; + } + +- bb3: { ++ bb1: { ++ StorageDead(_5); + StorageDead(_2); + StorageDead(_4); + _0 = const (); + StorageDead(_1); + return; + } + +- bb4 (cleanup): { ++ bb2 (cleanup): { + resume; ++ } ++ ++ bb3: { ++ StorageLive(_8); ++ switchInt(_5) -> [0: bb4, otherwise: bb5]; ++ } ++ ++ bb4: { ++ _8 = const 13_i32; ++ goto -> bb6; ++ } ++ ++ bb5: { ++ _8 = const 7_i32; ++ goto -> bb6; ++ } ++ ++ bb6: { ++ _1 = GeneratorState::<i32, bool>::Yielded(move _8); ++ _9 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); ++ discriminant((*_9)) = 3; ++ goto -> bb1; ++ } ++ ++ bb7: { ++ assert(const false, "generator resumed after completion") -> [success: bb7, unwind: bb2]; ++ } ++ ++ bb8: { ++ StorageLive(_8); ++ StorageDead(_8); ++ _1 = GeneratorState::<i32, bool>::Complete(_5); ++ _10 = deref_copy (_2.0: &mut [generator@$DIR/inline_generator.rs:16:5: 16:8]); ++ discriminant((*_10)) = 1; ++ goto -> bb1; ++ } ++ ++ bb9: { ++ unreachable; + } + } + diff --git a/tests/mir-opt/inline/inline_generator.rs b/tests/mir-opt/inline/inline_generator.rs index d11b3e548..2d71458c1 100644 --- a/tests/mir-opt/inline/inline_generator.rs +++ b/tests/mir-opt/inline/inline_generator.rs @@ -1,4 +1,5 @@ -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(generators, generator_trait)] use std::ops::Generator; @@ -9,8 +10,8 @@ fn main() { let _r = Pin::new(&mut g()).resume(false); } -#[inline(always)] +#[inline] pub fn g() -> impl Generator<bool> { - #[inline(always)] + #[inline] |a| { yield if a { 7 } else { 13 } } } diff --git a/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff b/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff index a1d2423ae..6f8b730b4 100644 --- a/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -2,59 +2,47 @@ + // 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 - let _4: (); // in scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -+ scope 1 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:59:5: 59:30 + let mut _0: (); + let _1: (); + let _2: (); + let _3: (); + let _4: (); ++ scope 1 (inlined instruction_set_default) { + } -+ scope 2 (inlined inline_always_and_using_inline_asm) { // at $DIR/inline_instruction_set.rs:60:5: 60:41 ++ scope 2 (inlined inline_always_and_using_inline_asm) { + scope 3 { + } + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:57:5: 57:24 - // + literal: Const { ty: fn() {instruction_set_a32}, val: Value(<ZST>) } + StorageLive(_1); + _1 = instruction_set_a32() -> [return: bb1, unwind unreachable]; } 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() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:58:5: 58:24 - // + literal: Const { ty: fn() {instruction_set_t32}, val: Value(<ZST>) } + StorageDead(_1); + StorageLive(_2); + _2 = instruction_set_t32() -> [return: bb2, unwind unreachable]; } 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() -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 -- // mir::Constant -- // + span: $DIR/inline_instruction_set.rs:59:5: 59:28 -- // + literal: Const { ty: fn() {instruction_set_default}, val: Value(<ZST>) } + StorageDead(_2); + StorageLive(_3); +- _3 = instruction_set_default() -> [return: bb3, unwind unreachable]; - } - - bb3: { - StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 - StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -- _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -- // mir::Constant -- // + span: $DIR/inline_instruction_set.rs:60:5: 60:39 -- // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value(<ZST>) } -+ asm!("/* do nothing */", options((empty))) -> [return: bb3, unwind unreachable]; // scope 3 at $DIR/inline_instruction_set.rs:43:14: 43:38 + StorageDead(_3); + StorageLive(_4); +- _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; ++ asm!("/* do nothing */", options((empty))) -> [return: bb3, unwind unreachable]; } - bb4: { + bb3: { - StorageDead(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:41: +4:42 - _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:18: +5:2 - return; // scope 0 at $DIR/inline_instruction_set.rs:+5:2: +5:2 + StorageDead(_4); + _0 = const (); + return; } } diff --git a/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff index 36aec4f47..33dc116f6 100644 --- a/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -2,57 +2,45 @@ + // 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:+3:5: +3:30 - let _4: (); // in scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -+ scope 1 (inlined instruction_set_t32) { // at $DIR/inline_instruction_set.rs:50:5: 50:26 + let mut _0: (); + let _1: (); + let _2: (); + let _3: (); + let _4: (); ++ scope 1 (inlined instruction_set_t32) { + } -+ scope 2 (inlined instruction_set_default) { // at $DIR/inline_instruction_set.rs:51:5: 51:30 ++ scope 2 (inlined instruction_set_default) { + } bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:49:5: 49:24 - // + literal: Const { ty: fn() {instruction_set_a32}, val: Value(<ZST>) } + StorageLive(_1); + _1 = instruction_set_a32() -> [return: bb1, unwind unreachable]; } 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() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 -- // mir::Constant -- // + span: $DIR/inline_instruction_set.rs:50:5: 50:24 -- // + literal: Const { ty: fn() {instruction_set_t32}, val: Value(<ZST>) } + StorageDead(_1); + StorageLive(_2); +- _2 = instruction_set_t32() -> [return: bb2, unwind unreachable]; - } - - 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() -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 -- // mir::Constant -- // + span: $DIR/inline_instruction_set.rs:51:5: 51:28 -- // + literal: Const { ty: fn() {instruction_set_default}, val: Value(<ZST>) } + StorageDead(_2); + StorageLive(_3); +- _3 = instruction_set_default() -> [return: bb3, unwind unreachable]; - } - - bb3: { - StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 - StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -- _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -+ _4 = inline_always_and_using_inline_asm() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 - // mir::Constant - // + span: $DIR/inline_instruction_set.rs:52:5: 52:39 - // + literal: Const { ty: fn() {inline_always_and_using_inline_asm}, val: Value(<ZST>) } + StorageDead(_3); + StorageLive(_4); +- _4 = inline_always_and_using_inline_asm() -> [return: bb4, unwind unreachable]; ++ _4 = inline_always_and_using_inline_asm() -> [return: bb2, unwind unreachable]; } - bb4: { + bb2: { - StorageDead(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:41: +4:42 - _0 = const (); // scope 0 at $DIR/inline_instruction_set.rs:+0:14: +5:2 - return; // scope 0 at $DIR/inline_instruction_set.rs:+5:2: +5:2 + StorageDead(_4); + _0 = const (); + return; } } diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff deleted file mode 100644 index a5129e0e8..000000000 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff +++ /dev/null @@ -1,81 +0,0 @@ -- // 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<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11 - let mut _2: std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48 - scope 1 { - debug _x => _1; // in scope 1 at $DIR/inline_into_box_place.rs:+1:9: +1:11 - } -+ scope 2 (inlined Vec::<u32>::new) { // at $DIR/inline_into_box_place.rs:8:38: 8:48 -+ let mut _3: alloc::raw_vec::RawVec<u32>; // in scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ } -+ scope 3 (inlined Box::<Vec<u32>>::new) { // at $DIR/inline_into_box_place.rs:8:29: 8:49 -+ debug x => _2; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ let mut _4: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ let mut _5: usize; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ let mut _6: *mut u8; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ let mut _7: *const std::vec::Vec<u32>; // in scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ scope 4 { -+ } -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_into_box_place.rs:+1:9: +1:11 - StorageLive(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48 -- _2 = Vec::<u32>::new() -> bb1; // scope 0 at $DIR/inline_into_box_place.rs:+1:38: +1:48 -+ StorageLive(_3); // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ _3 = const _; // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - // mir::Constant -- // + span: $DIR/inline_into_box_place.rs:8:38: 8:46 -- // + user_ty: UserType(2) -- // + literal: Const { ty: fn() -> Vec<u32> {Vec::<u32>::new}, val: Value(<ZST>) } -+ // + span: $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ // + user_ty: UserType(0) -+ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Unevaluated(alloc::raw_vec::RawVec::<T>::NEW, [u32], None) } -+ _2 = Vec::<u32> { buf: move _3, len: const 0_usize }; // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ StorageDead(_3); // scope 2 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ _4 = SizeOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ _5 = AlignOf(std::vec::Vec<u32>); // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ _6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb3, unwind: bb4]; // scope 4 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ // mir::Constant -+ // + span: $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } - } - - bb1: { -- _1 = Box::<Vec<u32>>::new(move _2) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:49 -- // mir::Constant -- // + span: $DIR/inline_into_box_place.rs:8:29: 8:37 -- // + user_ty: UserType(1) -- // + literal: Const { ty: fn(Vec<u32>) -> Box<Vec<u32>> {Box::<Vec<u32>>::new}, val: Value(<ZST>) } -+ 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 - } - -- bb2: { -- StorageDead(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:48: +1:49 -- _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 -- drop(_1) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 -+ bb2 (cleanup): { -+ resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2 - } - - bb3: { -- 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 -+ _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ (*_7) = move _2; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL -+ StorageDead(_2); // scope 0 at $DIR/inline_into_box_place.rs:+1:48: +1:49 -+ _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 -+ drop(_1) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 - } - - bb4 (cleanup): { -- resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2 -+ drop(_2) -> [return: bb2, unwind terminate]; // scope 3 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - } - } - diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff new file mode 100644 index 000000000..3848196ec --- /dev/null +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-abort.diff @@ -0,0 +1,205 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: std::boxed::Box<std::vec::Vec<u32>>; + let mut _2: std::vec::Vec<u32>; + scope 1 { + debug _x => _1; + } ++ scope 2 (inlined Vec::<u32>::new) { ++ let mut _3: alloc::raw_vec::RawVec<u32>; ++ } ++ scope 3 (inlined Box::<Vec<u32>>::new) { ++ debug x => _2; ++ let mut _4: usize; ++ let mut _5: usize; ++ let mut _6: *mut u8; ++ let mut _7: *const std::vec::Vec<u32>; ++ scope 4 { ++ scope 5 (inlined alloc::alloc::exchange_malloc) { ++ debug size => _4; ++ debug align => _5; ++ let _8: std::alloc::Layout; ++ let mut _9: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>; ++ let mut _10: isize; ++ let mut _12: !; ++ scope 6 { ++ debug layout => _8; ++ let _11: std::ptr::NonNull<[u8]>; ++ let mut _13: &std::alloc::Global; ++ scope 8 { ++ debug ptr => _11; ++ scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { ++ debug self => _11; ++ let mut _16: std::ptr::NonNull<u8>; ++ scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { ++ debug self => _11; ++ let mut _17: *mut u8; ++ let mut _18: *mut [u8]; ++ scope 20 { ++ scope 21 (inlined NonNull::<[u8]>::as_ptr) { ++ debug self => _11; ++ let mut _19: *const [u8]; ++ } ++ scope 22 (inlined ptr::mut_ptr::<impl *mut [u8]>::as_mut_ptr) { ++ debug self => _18; ++ } ++ scope 23 (inlined NonNull::<u8>::new_unchecked) { ++ debug ptr => _17; ++ let mut _20: *const u8; ++ let mut _21: *mut u8; ++ scope 24 { ++ scope 25 (inlined NonNull::<T>::new_unchecked::runtime::<u8>) { ++ debug ptr => _21; ++ scope 26 (inlined ptr::mut_ptr::<impl *mut u8>::is_null) { ++ debug self => _21; ++ let mut _22: *mut u8; ++ scope 27 { ++ scope 28 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { ++ debug ptr => _22; ++ scope 29 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { ++ debug self => _22; ++ scope 30 { ++ scope 31 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { ++ debug self => _22; ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ scope 32 (inlined NonNull::<u8>::as_ptr) { ++ debug self => _16; ++ let mut _23: *const u8; ++ } ++ } ++ } ++ scope 17 (inlined <std::alloc::Global as Allocator>::allocate) { ++ debug self => const _; ++ debug layout => _8; ++ } ++ } ++ scope 7 { ++ scope 9 (inlined Layout::from_size_align_unchecked) { ++ debug size => _4; ++ debug align => _5; ++ let mut _14: std::ptr::Alignment; ++ scope 10 { ++ scope 11 (inlined std::ptr::Alignment::new_unchecked) { ++ debug align => _5; ++ let mut _15: usize; ++ scope 12 { ++ scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { ++ debug align => _15; ++ scope 15 (inlined core::num::<impl usize>::is_power_of_two) { ++ debug self => _15; ++ scope 16 (inlined core::num::<impl usize>::count_ones) { ++ debug self => _15; ++ } ++ } ++ } ++ } ++ scope 13 { ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = Vec::<u32>::new() -> [return: bb1, unwind unreachable]; ++ StorageLive(_3); ++ _3 = const _; ++ _2 = Vec::<u32> { buf: move _3, len: const 0_usize }; ++ StorageDead(_3); ++ _4 = SizeOf(std::vec::Vec<u32>); ++ _5 = AlignOf(std::vec::Vec<u32>); ++ StorageLive(_8); ++ StorageLive(_11); ++ StorageLive(_12); ++ StorageLive(_13); ++ StorageLive(_14); ++ StorageLive(_15); ++ _14 = _5 as std::ptr::Alignment (Transmute); ++ StorageDead(_15); ++ _8 = Layout { size: _4, align: move _14 }; ++ StorageDead(_14); ++ StorageLive(_9); ++ _13 = const _; ++ _9 = std::alloc::Global::alloc_impl(_13, _8, const false) -> [return: bb5, unwind unreachable]; + } + + bb1: { +- _1 = Box::<Vec<u32>>::new(move _2) -> [return: bb2, unwind unreachable]; ++ StorageDead(_1); ++ return; + } + + bb2: { ++ _12 = handle_alloc_error(_8) -> unwind unreachable; ++ } ++ ++ bb3: { ++ unreachable; ++ } ++ ++ bb4: { ++ _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); ++ StorageLive(_16); ++ StorageLive(_17); ++ StorageLive(_18); ++ StorageLive(_19); ++ _19 = (_11.0: *const [u8]); ++ _18 = move _19 as *mut [u8] (PtrToPtr); ++ StorageDead(_19); ++ _17 = _18 as *mut u8 (PtrToPtr); ++ StorageDead(_18); ++ StorageLive(_20); ++ StorageLive(_21); ++ StorageLive(_22); ++ _20 = _17 as *const u8 (PointerCoercion(MutToConstPointer)); ++ _16 = NonNull::<u8> { pointer: _20 }; ++ StorageDead(_22); ++ StorageDead(_21); ++ StorageDead(_20); ++ StorageDead(_17); ++ StorageLive(_23); ++ _23 = (_16.0: *const u8); ++ _6 = move _23 as *mut u8 (PtrToPtr); ++ StorageDead(_23); ++ StorageDead(_16); ++ StorageDead(_9); ++ StorageDead(_13); ++ StorageDead(_12); ++ StorageDead(_11); ++ StorageDead(_8); ++ _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); ++ _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); ++ (*_7) = move _2; + StorageDead(_2); + _0 = const (); +- drop(_1) -> [return: bb3, unwind unreachable]; ++ drop(_1) -> [return: bb1, unwind unreachable]; + } + +- bb3: { +- StorageDead(_1); +- return; ++ bb5: { ++ _10 = discriminant(_9); ++ switchInt(move _10) -> [0: bb4, 1: bb2, otherwise: bb3]; + } + } + diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..80b5810aa --- /dev/null +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.panic-unwind.diff @@ -0,0 +1,218 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: std::boxed::Box<std::vec::Vec<u32>>; + let mut _2: std::vec::Vec<u32>; + scope 1 { + debug _x => _1; + } ++ scope 2 (inlined Vec::<u32>::new) { ++ let mut _3: alloc::raw_vec::RawVec<u32>; ++ } ++ scope 3 (inlined Box::<Vec<u32>>::new) { ++ debug x => _2; ++ let mut _4: usize; ++ let mut _5: usize; ++ let mut _6: *mut u8; ++ let mut _7: *const std::vec::Vec<u32>; ++ scope 4 { ++ scope 5 (inlined alloc::alloc::exchange_malloc) { ++ debug size => _4; ++ debug align => _5; ++ let _8: std::alloc::Layout; ++ let mut _9: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>; ++ let mut _10: isize; ++ let mut _12: !; ++ scope 6 { ++ debug layout => _8; ++ let _11: std::ptr::NonNull<[u8]>; ++ let mut _13: &std::alloc::Global; ++ scope 8 { ++ debug ptr => _11; ++ scope 18 (inlined NonNull::<[u8]>::as_mut_ptr) { ++ debug self => _11; ++ let mut _16: std::ptr::NonNull<u8>; ++ scope 19 (inlined NonNull::<[u8]>::as_non_null_ptr) { ++ debug self => _11; ++ let mut _17: *mut u8; ++ let mut _18: *mut [u8]; ++ scope 20 { ++ scope 21 (inlined NonNull::<[u8]>::as_ptr) { ++ debug self => _11; ++ let mut _19: *const [u8]; ++ } ++ scope 22 (inlined ptr::mut_ptr::<impl *mut [u8]>::as_mut_ptr) { ++ debug self => _18; ++ } ++ scope 23 (inlined NonNull::<u8>::new_unchecked) { ++ debug ptr => _17; ++ let mut _20: *const u8; ++ let mut _21: *mut u8; ++ scope 24 { ++ scope 25 (inlined NonNull::<T>::new_unchecked::runtime::<u8>) { ++ debug ptr => _21; ++ scope 26 (inlined ptr::mut_ptr::<impl *mut u8>::is_null) { ++ debug self => _21; ++ let mut _22: *mut u8; ++ scope 27 { ++ scope 28 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { ++ debug ptr => _22; ++ scope 29 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { ++ debug self => _22; ++ scope 30 { ++ scope 31 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { ++ debug self => _22; ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ scope 32 (inlined NonNull::<u8>::as_ptr) { ++ debug self => _16; ++ let mut _23: *const u8; ++ } ++ } ++ } ++ scope 17 (inlined <std::alloc::Global as Allocator>::allocate) { ++ debug self => const _; ++ debug layout => _8; ++ } ++ } ++ scope 7 { ++ scope 9 (inlined Layout::from_size_align_unchecked) { ++ debug size => _4; ++ debug align => _5; ++ let mut _14: std::ptr::Alignment; ++ scope 10 { ++ scope 11 (inlined std::ptr::Alignment::new_unchecked) { ++ debug align => _5; ++ let mut _15: usize; ++ scope 12 { ++ scope 14 (inlined std::ptr::Alignment::new_unchecked::runtime) { ++ debug align => _15; ++ scope 15 (inlined core::num::<impl usize>::is_power_of_two) { ++ debug self => _15; ++ scope 16 (inlined core::num::<impl usize>::count_ones) { ++ debug self => _15; ++ } ++ } ++ } ++ } ++ scope 13 { ++ } ++ } ++ } ++ } ++ } ++ } ++ } ++ } + + bb0: { + StorageLive(_1); + StorageLive(_2); +- _2 = Vec::<u32>::new() -> [return: bb1, unwind continue]; ++ StorageLive(_3); ++ _3 = const _; ++ _2 = Vec::<u32> { buf: move _3, len: const 0_usize }; ++ StorageDead(_3); ++ _4 = SizeOf(std::vec::Vec<u32>); ++ _5 = AlignOf(std::vec::Vec<u32>); ++ StorageLive(_8); ++ StorageLive(_11); ++ StorageLive(_12); ++ StorageLive(_13); ++ StorageLive(_14); ++ StorageLive(_15); ++ _14 = _5 as std::ptr::Alignment (Transmute); ++ StorageDead(_15); ++ _8 = Layout { size: _4, align: move _14 }; ++ StorageDead(_14); ++ StorageLive(_9); ++ _13 = const _; ++ _9 = std::alloc::Global::alloc_impl(_13, _8, const false) -> [return: bb7, unwind: bb3]; + } + + bb1: { +- _1 = Box::<Vec<u32>>::new(move _2) -> [return: bb2, unwind: bb4]; ++ StorageDead(_1); ++ return; + } + +- bb2: { +- StorageDead(_2); +- _0 = const (); +- drop(_1) -> [return: bb3, unwind: bb4]; ++ bb2 (cleanup): { ++ resume; + } + +- bb3: { +- StorageDead(_1); +- return; ++ bb3 (cleanup): { ++ drop(_2) -> [return: bb2, unwind terminate]; + } + +- bb4 (cleanup): { +- resume; ++ bb4: { ++ _12 = handle_alloc_error(_8) -> bb3; ++ } ++ ++ bb5: { ++ unreachable; ++ } ++ ++ bb6: { ++ _11 = ((_9 as Ok).0: std::ptr::NonNull<[u8]>); ++ StorageLive(_16); ++ StorageLive(_17); ++ StorageLive(_18); ++ StorageLive(_19); ++ _19 = (_11.0: *const [u8]); ++ _18 = move _19 as *mut [u8] (PtrToPtr); ++ StorageDead(_19); ++ _17 = _18 as *mut u8 (PtrToPtr); ++ StorageDead(_18); ++ StorageLive(_20); ++ StorageLive(_21); ++ StorageLive(_22); ++ _20 = _17 as *const u8 (PointerCoercion(MutToConstPointer)); ++ _16 = NonNull::<u8> { pointer: _20 }; ++ StorageDead(_22); ++ StorageDead(_21); ++ StorageDead(_20); ++ StorageDead(_17); ++ StorageLive(_23); ++ _23 = (_16.0: *const u8); ++ _6 = move _23 as *mut u8 (PtrToPtr); ++ StorageDead(_23); ++ StorageDead(_16); ++ StorageDead(_9); ++ StorageDead(_13); ++ StorageDead(_12); ++ StorageDead(_11); ++ StorageDead(_8); ++ _1 = ShallowInitBox(move _6, std::vec::Vec<u32>); ++ _7 = (((_1.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); ++ (*_7) = move _2; ++ StorageDead(_2); ++ _0 = const (); ++ drop(_1) -> [return: bb1, unwind: bb2]; ++ } ++ ++ bb7: { ++ _10 = discriminant(_9); ++ switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + } + } + diff --git a/tests/mir-opt/inline/inline_into_box_place.rs b/tests/mir-opt/inline/inline_into_box_place.rs index 02823e4e1..56f174e51 100644 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ b/tests/mir-opt/inline/inline_into_box_place.rs @@ -1,7 +1,7 @@ // ignore-endian-big -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // ignore-debug MIR alignment checks in std alter the diff, breaking the test -// compile-flags: -Z mir-opt-level=4 +// compile-flags: -Zmir-opt-level=4 -Zinline-mir-hint-threshold=200 // EMIT_MIR inline_into_box_place.main.Inline.diff fn main() { diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.mir deleted file mode 100644 index a2938ead0..000000000 --- a/tests/mir-opt/inline/inline_options.main.Inline.after.mir +++ /dev/null @@ -1,55 +0,0 @@ -// 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::<u32>) { // at $DIR/inline_options.rs:11:5: 11:21 - let _3: (); // in scope 1 at $DIR/inline_options.rs:17:23: 17:26 - let _4: (); // in scope 1 at $DIR/inline_options.rs:17:28: 17:31 - let _5: (); // in scope 1 at $DIR/inline_options.rs:17:33: 17: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:10:5: 10:16 - // + literal: Const { ty: fn() {not_inlined}, val: Value(<ZST>) } - } - - 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 0 at $DIR/inline_options.rs:+2:5: +2:21 - StorageLive(_4); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - StorageLive(_5); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - _3 = g() -> bb3; // scope 1 at $DIR/inline_options.rs:17:23: 17:26 - // mir::Constant - // + span: $DIR/inline_options.rs:17:23: 17:24 - // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } - } - - bb2: { - StorageDead(_5); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - StorageDead(_4); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - StorageDead(_3); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - 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 - } - - bb3: { - _4 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:17:28: 17:31 - // mir::Constant - // + span: $DIR/inline_options.rs:17:28: 17:29 - // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } - } - - bb4: { - _5 = g() -> bb2; // scope 1 at $DIR/inline_options.rs:17:33: 17:36 - // mir::Constant - // + span: $DIR/inline_options.rs:17:33: 17:34 - // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } - } -} diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-abort.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-abort.mir new file mode 100644 index 000000000..3218c4e56 --- /dev/null +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-abort.mir @@ -0,0 +1,43 @@ +// MIR for `main` after Inline + +fn main() -> () { + let mut _0: (); + let _1: (); + let _2: (); + scope 1 (inlined inlined::<u32>) { + let _3: (); + let _4: (); + let _5: (); + } + + bb0: { + StorageLive(_1); + _1 = not_inlined() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _3 = g() -> [return: bb3, unwind unreachable]; + } + + bb2: { + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; + } + + bb3: { + _4 = g() -> [return: bb4, unwind unreachable]; + } + + bb4: { + _5 = g() -> [return: bb2, unwind unreachable]; + } +} diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir new file mode 100644 index 000000000..df0cab513 --- /dev/null +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.panic-unwind.mir @@ -0,0 +1,43 @@ +// MIR for `main` after Inline + +fn main() -> () { + let mut _0: (); + let _1: (); + let _2: (); + scope 1 (inlined inlined::<u32>) { + let _3: (); + let _4: (); + let _5: (); + } + + bb0: { + StorageLive(_1); + _1 = not_inlined() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_1); + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _3 = g() -> [return: bb3, unwind continue]; + } + + bb2: { + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; + } + + bb3: { + _4 = g() -> [return: bb4, unwind continue]; + } + + bb4: { + _5 = g() -> [return: bb2, unwind continue]; + } +} diff --git a/tests/mir-opt/inline/inline_options.rs b/tests/mir-opt/inline/inline_options.rs index f0a898832..b247ecd0b 100644 --- a/tests/mir-opt/inline/inline_options.rs +++ b/tests/mir-opt/inline/inline_options.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Checks that inlining threshold can be controlled with // inline-mir-threshold and inline-hint-threshold options. // diff --git a/tests/mir-opt/inline/inline_retag.bar.Inline.after.mir b/tests/mir-opt/inline/inline_retag.bar.Inline.after.mir index 60149ff36..8c3f3a458 100644 --- a/tests/mir-opt/inline/inline_retag.bar.Inline.after.mir +++ b/tests/mir-opt/inline/inline_retag.bar.Inline.after.mir @@ -1,68 +1,59 @@ // MIR for `bar` after Inline fn bar() -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/inline_retag.rs:+0:13: +0:17 - let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline_retag.rs:+1:9: +1:10 - let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; // in scope 0 at $DIR/inline_retag.rs:+2:5: +2:6 - let mut _3: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:7: +2:9 - let _4: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:7: +2:9 - let _5: i32; // in scope 0 at $DIR/inline_retag.rs:+2:8: +2:9 - let mut _6: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:11: +2:14 - let _7: &i32; // in scope 0 at $DIR/inline_retag.rs:+2:11: +2:14 - let _8: i32; // in scope 0 at $DIR/inline_retag.rs:+2:12: +2:14 + let mut _0: bool; + let _1: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; + let mut _2: for<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}; + let mut _3: &i32; + let _4: &i32; + let _5: i32; + let mut _6: &i32; + let _7: &i32; + let _8: i32; scope 1 { - debug f => _1; // in scope 1 at $DIR/inline_retag.rs:+1:9: +1:10 - let mut _9: &i32; // in scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 - let mut _10: &i32; // in scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 - scope 2 (inlined foo) { // at $DIR/inline_retag.rs:12:5: 12:15 - debug x => _3; // in scope 2 at $DIR/inline_retag.rs:16:8: 16:9 - debug y => _6; // in scope 2 at $DIR/inline_retag.rs:16:17: 16:18 - let mut _11: i32; // in scope 2 at $DIR/inline_retag.rs:17:5: 17:7 - let mut _12: i32; // in scope 2 at $DIR/inline_retag.rs:17:11: 17:13 + debug f => _1; + let mut _9: &i32; + let mut _10: &i32; + scope 2 (inlined foo) { + debug x => _3; + debug y => _6; + let mut _11: i32; + let mut _12: i32; } } 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<'a, 'b> fn(&'a i32, &'b i32) -> bool {foo}, val: Value(<ZST>) } - StorageLive(_2); // scope 1 at $DIR/inline_retag.rs:+2:5: +2:6 - _2 = _1; // scope 1 at $DIR/inline_retag.rs:+2:5: +2:6 - StorageLive(_3); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 - StorageLive(_4); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 - _10 = const _; // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 - // mir::Constant - // + span: $DIR/inline_retag.rs:12:7: 12:9 - // + 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 - _3 = &(*_4); // scope 1 at $DIR/inline_retag.rs:+2:7: +2:9 - StorageLive(_6); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 - StorageLive(_7); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 - _9 = const _; // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 - // mir::Constant - // + span: $DIR/inline_retag.rs:12:11: 12:14 - // + 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 - _6 = &(*_7); // scope 1 at $DIR/inline_retag.rs:+2:11: +2:14 - Retag(_3); // scope 2 at $DIR/inline_retag.rs:16:8: 16:9 - Retag(_6); // scope 2 at $DIR/inline_retag.rs:16:17: 16:18 - StorageLive(_11); // scope 2 at $DIR/inline_retag.rs:17:5: 17:7 - _11 = (*_3); // scope 2 at $DIR/inline_retag.rs:17:5: 17:7 - StorageLive(_12); // scope 2 at $DIR/inline_retag.rs:17:11: 17:13 - _12 = (*_6); // scope 2 at $DIR/inline_retag.rs:17:11: 17:13 - _0 = Eq(move _11, move _12); // scope 2 at $DIR/inline_retag.rs:17:5: 17:13 - StorageDead(_12); // scope 2 at $DIR/inline_retag.rs:17:12: 17:13 - StorageDead(_11); // scope 2 at $DIR/inline_retag.rs:17:12: 17:13 - StorageDead(_6); // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15 - StorageDead(_3); // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15 - StorageDead(_2); // scope 1 at $DIR/inline_retag.rs:+2:14: +2:15 - StorageDead(_1); // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2 - StorageDead(_7); // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2 - StorageDead(_4); // scope 0 at $DIR/inline_retag.rs:+3:1: +3:2 - return; // scope 0 at $DIR/inline_retag.rs:+3:2: +3:2 + StorageLive(_1); + _1 = foo; + StorageLive(_2); + _2 = _1; + StorageLive(_3); + StorageLive(_4); + _10 = const _; + Retag(_10); + _4 = &(*_10); + _3 = &(*_4); + StorageLive(_6); + StorageLive(_7); + _9 = const _; + Retag(_9); + _7 = &(*_9); + _6 = &(*_7); + Retag(_3); + Retag(_6); + StorageLive(_11); + _11 = (*_3); + StorageLive(_12); + _12 = (*_6); + _0 = Eq(move _11, move _12); + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + StorageDead(_7); + StorageDead(_4); + return; } } diff --git a/tests/mir-opt/inline/inline_shims.clone.Inline.diff b/tests/mir-opt/inline/inline_shims.clone.Inline.diff deleted file mode 100644 index 09dd35c4c..000000000 --- a/tests/mir-opt/inline/inline_shims.clone.Inline.diff +++ /dev/null @@ -1,26 +0,0 @@ -- // 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 <fn(A, B) as Clone>::clone - shim(fn(A, B))) { // at $DIR/inline_shims.rs:6:7: 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 = <fn(A, B) as Clone>::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<'a> fn(&'a fn(A, B)) -> fn(A, B) {<fn(A, B) as Clone>::clone}, val: Value(<ZST>) } -- } -- -- 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/tests/mir-opt/inline/inline_shims.clone.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_shims.clone.Inline.panic-abort.diff new file mode 100644 index 000000000..8117e58fa --- /dev/null +++ b/tests/mir-opt/inline/inline_shims.clone.Inline.panic-abort.diff @@ -0,0 +1,23 @@ +- // MIR for `clone` before Inline ++ // MIR for `clone` after Inline + + fn clone(_1: fn(A, B)) -> fn(A, B) { + debug f => _1; + let mut _0: fn(A, B); + let mut _2: &fn(A, B); ++ scope 1 (inlined <fn(A, B) as Clone>::clone - shim(fn(A, B))) { ++ } + + bb0: { + StorageLive(_2); + _2 = &_1; +- _0 = <fn(A, B) as Clone>::clone(move _2) -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { ++ _0 = (*_2); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_shims.clone.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_shims.clone.Inline.panic-unwind.diff new file mode 100644 index 000000000..00e92a0f5 --- /dev/null +++ b/tests/mir-opt/inline/inline_shims.clone.Inline.panic-unwind.diff @@ -0,0 +1,23 @@ +- // MIR for `clone` before Inline ++ // MIR for `clone` after Inline + + fn clone(_1: fn(A, B)) -> fn(A, B) { + debug f => _1; + let mut _0: fn(A, B); + let mut _2: &fn(A, B); ++ scope 1 (inlined <fn(A, B) as Clone>::clone - shim(fn(A, B))) { ++ } + + bb0: { + StorageLive(_2); + _2 = &_1; +- _0 = <fn(A, B) as Clone>::clone(move _2) -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ _0 = (*_2); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.diff deleted file mode 100644 index 36ddb189e..000000000 --- a/tests/mir-opt/inline/inline_shims.drop.Inline.diff +++ /dev/null @@ -1,56 +0,0 @@ -- // MIR for `drop` before Inline -+ // MIR for `drop` after Inline - - fn drop(_1: *mut Vec<A>, _2: *mut Option<B>) -> () { - 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<A>; // in scope 0 at $DIR/inline_shims.rs:+1:38: +1:39 - let mut _5: *mut std::option::Option<B>; // in scope 0 at $DIR/inline_shims.rs:+2:38: +2:39 - scope 1 { - } - scope 2 { -+ scope 3 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) { // 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::<Vec<A>>(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<A>) {std::ptr::drop_in_place::<Vec<A>>}, val: Value(<ZST>) } - } - - 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::<Option<B>>(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<B>) {std::ptr::drop_in_place::<Option<B>>}, val: Value(<ZST>) } -+ 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: 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/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff new file mode 100644 index 000000000..4fcd49994 --- /dev/null +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-abort.diff @@ -0,0 +1,64 @@ +- // MIR for `drop` before Inline ++ // MIR for `drop` after Inline + + fn drop(_1: *mut Vec<A>, _2: *mut Option<B>) -> () { + debug a => _1; + debug b => _2; + let mut _0: (); + let _3: (); + let mut _4: *mut std::vec::Vec<A>; + let mut _5: *mut std::option::Option<B>; + scope 1 { ++ scope 3 (inlined std::ptr::drop_in_place::<Vec<A>> - shim(Some(Vec<A>))) { ++ let mut _6: &mut std::vec::Vec<A>; ++ let mut _7: (); ++ } + } + scope 2 { ++ scope 4 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) { ++ let mut _8: isize; ++ let mut _9: isize; ++ } + } + + bb0: { + StorageLive(_3); + StorageLive(_4); + _4 = _1; +- _3 = std::ptr::drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind unreachable]; ++ StorageLive(_6); ++ StorageLive(_7); ++ _6 = &mut (*_4); ++ _7 = <Vec<A> as Drop>::drop(move _6) -> [return: bb2, unwind unreachable]; + } + + bb1: { ++ StorageDead(_7); ++ StorageDead(_6); + StorageDead(_4); + StorageDead(_3); + StorageLive(_5); + _5 = _2; +- _0 = std::ptr::drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind unreachable]; ++ StorageLive(_8); ++ StorageLive(_9); ++ _8 = discriminant((*_5)); ++ switchInt(move _8) -> [0: bb3, otherwise: bb4]; + } + + bb2: { ++ drop(((*_4).0: alloc::raw_vec::RawVec<A>)) -> [return: bb1, unwind unreachable]; ++ } ++ ++ bb3: { ++ StorageDead(_9); ++ StorageDead(_8); + StorageDead(_5); + return; ++ } ++ ++ bb4: { ++ drop((((*_5) as Some).0: B)) -> [return: bb3, unwind unreachable]; + } + } + diff --git a/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff new file mode 100644 index 000000000..4270ae00b --- /dev/null +++ b/tests/mir-opt/inline/inline_shims.drop.Inline.panic-unwind.diff @@ -0,0 +1,50 @@ +- // MIR for `drop` before Inline ++ // MIR for `drop` after Inline + + fn drop(_1: *mut Vec<A>, _2: *mut Option<B>) -> () { + debug a => _1; + debug b => _2; + let mut _0: (); + let _3: (); + let mut _4: *mut std::vec::Vec<A>; + let mut _5: *mut std::option::Option<B>; + scope 1 { + } + scope 2 { ++ scope 3 (inlined std::ptr::drop_in_place::<Option<B>> - shim(Some(Option<B>))) { ++ let mut _6: isize; ++ let mut _7: isize; ++ } + } + + bb0: { + StorageLive(_3); + StorageLive(_4); + _4 = _1; + _3 = std::ptr::drop_in_place::<Vec<A>>(move _4) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + StorageLive(_5); + _5 = _2; +- _0 = std::ptr::drop_in_place::<Option<B>>(move _5) -> [return: bb2, unwind continue]; ++ StorageLive(_6); ++ StorageLive(_7); ++ _6 = discriminant((*_5)); ++ switchInt(move _6) -> [0: bb2, otherwise: bb3]; + } + + bb2: { ++ StorageDead(_7); ++ StorageDead(_6); + StorageDead(_5); + return; ++ } ++ ++ bb3: { ++ drop((((*_5) as Some).0: B)) -> [return: bb2, unwind continue]; + } + } + diff --git a/tests/mir-opt/inline/inline_shims.rs b/tests/mir-opt/inline/inline_shims.rs index 7c8618f71..eafbb962e 100644 --- a/tests/mir-opt/inline/inline_shims.rs +++ b/tests/mir-opt/inline/inline_shims.rs @@ -1,4 +1,4 @@ -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] // EMIT_MIR inline_shims.clone.Inline.diff diff --git a/tests/mir-opt/inline/inline_specialization.main.Inline.diff b/tests/mir-opt/inline/inline_specialization.main.Inline.diff deleted file mode 100644 index 9dde9994d..000000000 --- a/tests/mir-opt/inline/inline_specialization.main.Inline.diff +++ /dev/null @@ -1,28 +0,0 @@ -- // 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 <Vec<()> as Foo>::bar) { // at $DIR/inline_specialization.rs:6:13: 6:38 -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline_specialization.rs:+1:9: +1:10 -- _1 = <Vec<()> as Foo>::bar() -> bb1; // scope 0 at $DIR/inline_specialization.rs:+1:13: +1:38 -- // mir::Constant -- // + span: $DIR/inline_specialization.rs:6:13: 6:36 -- // + literal: Const { ty: fn() -> u32 {<Vec<()> as Foo>::bar}, val: Value(<ZST>) } -- } -- -- bb1: { -+ _1 = const 123_u32; // scope 2 at $DIR/inline_specialization.rs:15:31: 15: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/tests/mir-opt/inline/inline_specialization.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_specialization.main.Inline.panic-abort.diff new file mode 100644 index 000000000..22afcd2ee --- /dev/null +++ b/tests/mir-opt/inline/inline_specialization.main.Inline.panic-abort.diff @@ -0,0 +1,25 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: u32; + scope 1 { + debug x => _1; + } ++ scope 2 (inlined <Vec<()> as Foo>::bar) { ++ } + + bb0: { + StorageLive(_1); +- _1 = <Vec<()> as Foo>::bar() -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { ++ _1 = const 123_u32; + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_specialization.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_specialization.main.Inline.panic-unwind.diff new file mode 100644 index 000000000..bc841101d --- /dev/null +++ b/tests/mir-opt/inline/inline_specialization.main.Inline.panic-unwind.diff @@ -0,0 +1,25 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); + let _1: u32; + scope 1 { + debug x => _1; + } ++ scope 2 (inlined <Vec<()> as Foo>::bar) { ++ } + + bb0: { + StorageLive(_1); +- _1 = <Vec<()> as Foo>::bar() -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ _1 = const 123_u32; + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_specialization.rs b/tests/mir-opt/inline/inline_specialization.rs index c24795e05..0311531dc 100644 --- a/tests/mir-opt/inline/inline_specialization.rs +++ b/tests/mir-opt/inline/inline_specialization.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![feature(specialization)] // EMIT_MIR inline_specialization.main.Inline.diff diff --git a/tests/mir-opt/inline/inline_trait_method.rs b/tests/mir-opt/inline/inline_trait_method.rs index 6aa957eb5..a9d2168c2 100644 --- a/tests/mir-opt/inline/inline_trait_method.rs +++ b/tests/mir-opt/inline/inline_trait_method.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Z span_free_formats fn main() { diff --git a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir deleted file mode 100644 index a9020a5bb..000000000 --- a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir +++ /dev/null @@ -1,21 +0,0 @@ -// 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 = <dyn X as X>::y(move _2) -> bb1; // scope 0 at $DIR/inline_trait_method.rs:+1:5: +1:10 - // mir::Constant - // + span: $DIR/inline_trait_method.rs:10:7: 10:8 - // + literal: Const { ty: for<'a> fn(&'a dyn X) -> u32 {<dyn X as X>::y}, val: Value(<ZST>) } - } - - 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/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-abort.mir b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-abort.mir new file mode 100644 index 000000000..2441e3f1c --- /dev/null +++ b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-abort.mir @@ -0,0 +1,18 @@ +// MIR for `test` after Inline + +fn test(_1: &dyn X) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: &dyn X; + + bb0: { + StorageLive(_2); + _2 = &(*_1); + _0 = <dyn X as X>::y(move _2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-unwind.mir new file mode 100644 index 000000000..da18a5adc --- /dev/null +++ b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.panic-unwind.mir @@ -0,0 +1,18 @@ +// MIR for `test` after Inline + +fn test(_1: &dyn X) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: &dyn X; + + bb0: { + StorageLive(_2); + _2 = &(*_1); + _0 = <dyn X as X>::y(move _2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs index 07a601908..62ec7ebde 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.rs +++ b/tests/mir-opt/inline/inline_trait_method_2.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Z span_free_formats -Z mir-opt-level=4 // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir diff --git a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir deleted file mode 100644 index a4bbecf3b..000000000 --- a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ /dev/null @@ -1,28 +0,0 @@ -// 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:6:5: 6:12 - debug x => _2; // in scope 1 at $DIR/inline_trait_method_2.rs:10:9: 10: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 - _0 = <dyn X as X>::y(_2) -> bb1; // scope 1 at $DIR/inline_trait_method_2.rs:11:5: 11:10 - // mir::Constant - // + span: $DIR/inline_trait_method_2.rs:11:7: 11:8 - // + literal: Const { ty: for<'a> fn(&'a dyn X) -> bool {<dyn X as X>::y}, val: Value(<ZST>) } - } - - bb1: { - 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/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-abort.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-abort.mir new file mode 100644 index 000000000..503f15308 --- /dev/null +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-abort.mir @@ -0,0 +1,25 @@ +// MIR for `test2` after Inline + +fn test2(_1: &dyn X) -> bool { + debug x => _1; + let mut _0: bool; + let mut _2: &dyn X; + let mut _3: &dyn X; + scope 1 (inlined test) { + debug x => _2; + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _2 = move _3 as &dyn X (PointerCoercion(Unsize)); + StorageDead(_3); + _0 = <dyn X as X>::y(_2) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir new file mode 100644 index 000000000..37bb53e79 --- /dev/null +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.panic-unwind.mir @@ -0,0 +1,25 @@ +// MIR for `test2` after Inline + +fn test2(_1: &dyn X) -> bool { + debug x => _1; + let mut _0: bool; + let mut _2: &dyn X; + let mut _3: &dyn X; + scope 1 (inlined test) { + debug x => _2; + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _2 = move _3 as &dyn X (PointerCoercion(Unsize)); + StorageDead(_3); + _0 = <dyn X as X>::y(_2) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.diff deleted file mode 100644 index 3aebfb69e..000000000 --- a/tests/mir-opt/inline/issue_106141.outer.Inline.diff +++ /dev/null @@ -1,55 +0,0 @@ -- // MIR for `outer` before Inline -+ // MIR for `outer` after Inline - - fn outer() -> usize { - let mut _0: usize; // return place in scope 0 at $DIR/issue_106141.rs:+0:19: +0:24 -+ scope 1 (inlined inner) { // at $DIR/issue_106141.rs:3:5: 3:12 -+ let mut _1: bool; // in scope 1 at $DIR/issue_106141.rs:14:8: 14:21 -+ let mut _2: bool; // in scope 1 at $DIR/issue_106141.rs:14:8: 14:21 -+ let mut _3: &[bool; 1]; // in scope 1 at $DIR/issue_106141.rs:12:18: 12:25 -+ scope 2 { -+ debug buffer => const _; // in scope 2 at $DIR/issue_106141.rs:12:9: 12:15 -+ scope 3 { -+ debug index => _0; // in scope 3 at $DIR/issue_106141.rs:13:9: 13:14 -+ } -+ } -+ } - - bb0: { -- _0 = inner() -> bb1; // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 -+ StorageLive(_3); // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 -+ _3 = const _; // scope 1 at $DIR/issue_106141.rs:12:18: 12:25 - // mir::Constant -- // + span: $DIR/issue_106141.rs:3:5: 3:10 -- // + literal: Const { ty: fn() -> usize {inner}, val: Value(<ZST>) } -+ // + span: $DIR/issue_106141.rs:12:18: 12:25 -+ // + literal: Const { ty: &[bool; 1], val: Unevaluated(inner, [], Some(promoted[0])) } -+ _0 = index() -> bb1; // scope 2 at $DIR/issue_106141.rs:13:17: 13:24 -+ // mir::Constant -+ // + span: $DIR/issue_106141.rs:13:17: 13:22 -+ // + literal: Const { ty: fn() -> usize {index}, val: Value(<ZST>) } - } - - bb1: { -+ StorageLive(_1); // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 -+ _2 = Lt(_0, const 1_usize); // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 -+ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> bb2; // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 -+ } -+ -+ bb2: { -+ _1 = (*_3)[_0]; // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 -+ switchInt(move _1) -> [0: bb3, otherwise: bb4]; // scope 3 at $DIR/issue_106141.rs:14:8: 14:21 -+ } -+ -+ bb3: { -+ _0 = const 0_usize; // scope 3 at $DIR/issue_106141.rs:17:9: 17:10 -+ goto -> bb4; // scope 3 at $DIR/issue_106141.rs:14:5: 18:6 -+ } -+ -+ bb4: { -+ StorageDead(_1); // scope 3 at $DIR/issue_106141.rs:18:5: 18:6 -+ StorageDead(_3); // scope 0 at $DIR/issue_106141.rs:+1:5: +1:12 - return; // scope 0 at $DIR/issue_106141.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff new file mode 100644 index 000000000..3d0c10725 --- /dev/null +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-abort.diff @@ -0,0 +1,47 @@ +- // MIR for `outer` before Inline ++ // MIR for `outer` after Inline + + fn outer() -> usize { + let mut _0: usize; ++ scope 1 (inlined inner) { ++ let mut _1: &[bool; 1]; ++ let mut _2: bool; ++ let mut _3: bool; ++ scope 2 { ++ debug buffer => const _; ++ scope 3 { ++ debug index => _0; ++ } ++ } ++ } + + bb0: { +- _0 = inner() -> [return: bb1, unwind unreachable]; ++ StorageLive(_1); ++ _1 = const _; ++ _0 = index() -> [return: bb1, unwind unreachable]; + } + + bb1: { ++ StorageLive(_3); ++ _2 = Lt(_0, const 1_usize); ++ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> [success: bb2, unwind unreachable]; ++ } ++ ++ bb2: { ++ _3 = (*_1)[_0]; ++ switchInt(move _3) -> [0: bb3, otherwise: bb4]; ++ } ++ ++ bb3: { ++ _0 = const 0_usize; ++ goto -> bb4; ++ } ++ ++ bb4: { ++ StorageDead(_3); ++ StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff new file mode 100644 index 000000000..16a19f4a3 --- /dev/null +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.panic-unwind.diff @@ -0,0 +1,47 @@ +- // MIR for `outer` before Inline ++ // MIR for `outer` after Inline + + fn outer() -> usize { + let mut _0: usize; ++ scope 1 (inlined inner) { ++ let mut _1: &[bool; 1]; ++ let mut _2: bool; ++ let mut _3: bool; ++ scope 2 { ++ debug buffer => const _; ++ scope 3 { ++ debug index => _0; ++ } ++ } ++ } + + bb0: { +- _0 = inner() -> [return: bb1, unwind continue]; ++ StorageLive(_1); ++ _1 = const _; ++ _0 = index() -> [return: bb1, unwind continue]; + } + + bb1: { ++ StorageLive(_3); ++ _2 = Lt(_0, const 1_usize); ++ assert(move _2, "index out of bounds: the length is {} but the index is {}", const 1_usize, _0) -> [success: bb2, unwind continue]; ++ } ++ ++ bb2: { ++ _3 = (*_1)[_0]; ++ switchInt(move _3) -> [0: bb3, otherwise: bb4]; ++ } ++ ++ bb3: { ++ _0 = const 0_usize; ++ goto -> bb4; ++ } ++ ++ bb4: { ++ StorageDead(_3); ++ StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/inline/issue_106141.rs b/tests/mir-opt/inline/issue_106141.rs index b6bd806e6..eed1d8917 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY pub fn outer() -> usize { inner() } diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir index 6441a9668..7cc65efe0 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.a.Inline.after.mir @@ -1,26 +1,26 @@ // 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:7: 3:15 - debug self => _4; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug x => _1; + let mut _0: &mut [T]; + let mut _2: &mut [T]; + let mut _3: &mut [T]; + let mut _4: &mut [T]; + scope 1 (inlined <[T] as AsMut<[T]>>::as_mut) { + debug self => _4; } 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 - _3 = _4; // scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - _2 = &mut (*_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageDead(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15 - _0 = &mut (*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - 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 + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = &mut (*_1); + _3 = _4; + _2 = &mut (*_3); + StorageDead(_4); + _0 = &mut (*_2); + StorageDead(_3); + StorageDead(_2); + return; } } diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir index 21570a88a..6837da27a 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.b.Inline.after.mir @@ -1,30 +1,30 @@ // MIR for `b` after Inline fn b(_1: &mut Box<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: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<T>; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - scope 1 (inlined <Box<T> as AsMut<T>>::as_mut) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:8:7: 8:15 - debug self => _4; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _5: std::boxed::Box<T>; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _6: *const T; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL + debug x => _1; + let mut _0: &mut T; + let mut _2: &mut T; + let mut _3: &mut T; + let mut _4: &mut std::boxed::Box<T>; + scope 1 (inlined <Box<T> as AsMut<T>>::as_mut) { + debug self => _4; + let mut _5: std::boxed::Box<T>; + let mut _6: *const T; } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageLive(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - _4 = &mut (*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - _5 = deref_copy (*_4); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _6 = (((_5.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _3 = &mut (*_6); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _2 = &mut (*_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageDead(_4); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15 - _0 = &mut (*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - 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 + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = &mut (*_1); + _5 = deref_copy (*_4); + _6 = (((_5.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); + _3 = &mut (*_6); + _2 = &mut (*_3); + StorageDead(_4); + _0 = &mut (*_2); + StorageDead(_3); + StorageDead(_2); + return; } } diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir index af830d249..bad7f31ae 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.c.Inline.after.mir @@ -1,22 +1,22 @@ // MIR for `c` after Inline fn c(_1: &[T]) -> &[T] { - debug x => _1; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:13: +0:14 - let mut _0: &[T]; // return place in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+0:25: +0:29 - let _2: &[T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - let mut _3: &[T]; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:13:7: 13:15 - debug self => _3; // in scope 1 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug x => _1; + let mut _0: &[T]; + let _2: &[T]; + let mut _3: &[T]; + scope 1 (inlined <[T] as AsRef<[T]>>::as_ref) { + debug self => _3; } 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 + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _2 = _3; + _0 = &(*_2); + StorageDead(_3); + StorageDead(_2); + return; } } diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir index 4f9342247..d09bfc33f 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.d.Inline.after.mir @@ -1,26 +1,26 @@ // MIR for `d` after Inline fn d(_1: &Box<T>) -> &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<T>; // in scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - scope 1 (inlined <Box<T> as AsRef<T>>::as_ref) { // at $DIR/issue_58867_inline_as_ref_as_mut.rs:18:7: 18:15 - debug self => _3; // in scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - let mut _4: std::boxed::Box<T>; // 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 + debug x => _1; + let mut _0: &T; + let _2: &T; + let mut _3: &std::boxed::Box<T>; + scope 1 (inlined <Box<T> as AsRef<T>>::as_ref) { + debug self => _3; + let mut _4: std::boxed::Box<T>; + let mut _5: *const T; } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageLive(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - _3 = &(*_1); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - _4 = deref_copy (*_3); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _5 = (((_4.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _2 = &(*_5); // scope 1 at $SRC_DIR/alloc/src/boxed.rs:LL:COL - _0 = &(*_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:5: +1:15 - StorageDead(_3); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+1:14: +1:15 - StorageDead(_2); // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:1: +2:2 - return; // scope 0 at $DIR/issue_58867_inline_as_ref_as_mut.rs:+2:2: +2:2 + StorageLive(_2); + StorageLive(_3); + _3 = &(*_1); + _4 = deref_copy (*_3); + _5 = (((_4.0: std::ptr::Unique<T>).0: std::ptr::NonNull<T>).0: *const T); + _2 = &(*_5); + _0 = &(*_2); + StorageDead(_3); + StorageDead(_2); + return; } } diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index 1da3c8bb7..ef91f5040 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -1,45 +1,38 @@ // MIR for `main` after Inline fn main() -> () { - let mut _0: (); // return place in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+0:11: +0:11 - let _1: [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 - let mut _2: &[closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6 - let mut _3: ((),); // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - let mut _4: (); // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9 - let mut _5: (); // in scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 + let mut _0: (); + let _1: [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; + let mut _2: &[closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; + let mut _3: ((),); + let mut _4: (); + let mut _5: (); 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 => const (); // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:14: +1:15 + debug f => _1; + scope 2 (inlined main::{closure#0}) { + debug x => const (); scope 3 { - debug y => const (); // in scope 3 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 + debug y => const (); } } } bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 - _1 = [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:13: +1:33 - // closure - // + def_id: DefId(0:4 ~ issue_76997_inline_scopes_parenting[5cd2]::main::{closure#0}) - // + substs: [ - // i8, - // extern "rust-call" fn(((),)), - // (), - // ] - StorageLive(_2); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6 - _2 = &_1; // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:6 - StorageLive(_3); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - StorageLive(_4); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9 - _4 = (); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:7: +2:9 - _3 = (move _4,); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - StorageLive(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - _5 = move (_3.0: ()); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - StorageDead(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - StorageDead(_4); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 - StorageDead(_3); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 - StorageDead(_2); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 - StorageDead(_1); // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+3:1: +3:2 - return; // scope 0 at $DIR/issue_76997_inline_scopes_parenting.rs:+3:2: +3:2 + StorageLive(_1); + _1 = [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16]; + StorageLive(_2); + _2 = &_1; + StorageLive(_3); + StorageLive(_4); + _4 = (); + _3 = (move _4,); + StorageLive(_5); + _5 = move (_3.0: ()); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); + return; } } diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.diff deleted file mode 100644 index dc3fe7555..000000000 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.diff +++ /dev/null @@ -1,68 +0,0 @@ -- // 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 <fn() {foo} as Fn<()>>::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(<ZST>) } - } - - 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 - _5 = (); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 -- _2 = <fn() {foo} as Fn<()>>::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<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> <fn() {foo} as FnOnce<()>>::Output {<fn() {foo} as Fn<()>>::call}, val: Value(<ZST>) } -+ _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) -> [return: bb4, unwind terminate]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 - } - - bb4 (cleanup): { -- drop(_1) -> [return: bb5, unwind terminate]; // 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/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff new file mode 100644 index 000000000..b86eb5f35 --- /dev/null +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-abort.diff @@ -0,0 +1,47 @@ +- // MIR for `bar` before Inline ++ // MIR for `bar` after Inline + + fn bar(_1: P) -> () { + debug _baz => _1; + let mut _0: (); + let _2: (); + let mut _3: &fn() {foo}; + let _4: fn() {foo}; + let mut _5: (); ++ scope 1 (inlined <fn() {foo} as Fn<()>>::call - shim(fn() {foo})) { ++ } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = hide_foo() -> [return: bb1, unwind unreachable]; + } + + bb1: { + _3 = &_4; + StorageLive(_5); + _5 = (); +- _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable]; ++ _2 = move (*_3)() -> [return: bb3, unwind unreachable]; + } + + bb2: { ++ return; ++ } ++ ++ bb3: { + StorageDead(_5); + StorageDead(_3); + StorageDead(_4); + StorageDead(_2); + _0 = const (); +- drop(_1) -> [return: bb3, unwind unreachable]; +- } +- +- bb3: { +- return; ++ drop(_1) -> [return: bb2, unwind unreachable]; + } + } + diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff new file mode 100644 index 000000000..c67babba2 --- /dev/null +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.panic-unwind.diff @@ -0,0 +1,62 @@ +- // MIR for `bar` before Inline ++ // MIR for `bar` after Inline + + fn bar(_1: P) -> () { + debug _baz => _1; + let mut _0: (); + let _2: (); + let mut _3: &fn() {foo}; + let _4: fn() {foo}; + let mut _5: (); ++ scope 1 (inlined <fn() {foo} as Fn<()>>::call - shim(fn() {foo})) { ++ } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); +- _4 = hide_foo() -> [return: bb1, unwind: bb4]; ++ _4 = hide_foo() -> [return: bb1, unwind: bb3]; + } + + bb1: { + _3 = &_4; + StorageLive(_5); + _5 = (); +- _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; ++ _2 = move (*_3)() -> [return: bb5, unwind: bb3]; + } + + bb2: { +- StorageDead(_5); +- StorageDead(_3); +- StorageDead(_4); +- StorageDead(_2); +- _0 = const (); +- drop(_1) -> [return: bb3, unwind: bb5]; ++ return; + } + +- bb3: { +- return; ++ bb3 (cleanup): { ++ drop(_1) -> [return: bb4, unwind terminate]; + } + + bb4 (cleanup): { +- drop(_1) -> [return: bb5, unwind terminate]; ++ resume; + } + +- bb5 (cleanup): { +- resume; ++ bb5: { ++ StorageDead(_5); ++ StorageDead(_3); ++ StorageDead(_4); ++ StorageDead(_2); ++ _0 = const (); ++ drop(_1) -> [return: bb2, unwind: bb4]; + } + } + diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff deleted file mode 100644 index 8f56ef258..000000000 --- a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff +++ /dev/null @@ -1,57 +0,0 @@ -- // 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(<ZST>) } - } - - 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 - _5 = (); // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 -- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/issue_78442.rs:+4:5: +4:17 -+ _2 = <fn() {foo} as Fn<()>>::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<'a> extern "rust-call" fn(&'a impl Fn(), ()) -> <impl Fn() as FnOnce<()>>::Output {<impl Fn() as Fn<()>>::call}, val: Value(<ZST>) } -+ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() {foo}, ()) -> <fn() {foo} as FnOnce<()>>::Output {<fn() {foo} as Fn<()>>::call}, val: Value(<ZST>) } - } - - 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) -> [return: bb5, unwind terminate]; // 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 - } - } - diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-abort.diff new file mode 100644 index 000000000..c94dd2556 --- /dev/null +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-abort.diff @@ -0,0 +1,42 @@ +- // MIR for `bar` before RevealAll ++ // MIR for `bar` after RevealAll + + fn bar(_1: P) -> () { + debug _baz => _1; + let mut _0: (); + let _2: (); +- let mut _3: &impl Fn(); +- let _4: impl Fn(); ++ let mut _3: &fn() {foo}; ++ let _4: fn() {foo}; + let mut _5: (); + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = hide_foo() -> [return: bb1, unwind unreachable]; + } + + bb1: { + _3 = &_4; + StorageLive(_5); + _5 = (); +- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable]; ++ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_5); + StorageDead(_3); + StorageDead(_4); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb3, unwind unreachable]; + } + + bb3: { + return; + } + } + diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff new file mode 100644 index 000000000..7765e491d --- /dev/null +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff @@ -0,0 +1,50 @@ +- // MIR for `bar` before RevealAll ++ // MIR for `bar` after RevealAll + + fn bar(_1: P) -> () { + debug _baz => _1; + let mut _0: (); + let _2: (); +- let mut _3: &impl Fn(); +- let _4: impl Fn(); ++ let mut _3: &fn() {foo}; ++ let _4: fn() {foo}; + let mut _5: (); + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = hide_foo() -> [return: bb1, unwind: bb4]; + } + + bb1: { + _3 = &_4; + StorageLive(_5); + _5 = (); +- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; ++ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; + } + + bb2: { + StorageDead(_5); + StorageDead(_3); + StorageDead(_4); + StorageDead(_2); + _0 = const (); + drop(_1) -> [return: bb3, unwind: bb5]; + } + + bb3: { + return; + } + + bb4 (cleanup): { + drop(_1) -> [return: bb5, unwind terminate]; + } + + bb5 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/inline/issue_78442.rs b/tests/mir-opt/inline/issue_78442.rs index aa8ede2df..d956e6241 100644 --- a/tests/mir-opt/inline/issue_78442.rs +++ b/tests/mir-opt/inline/issue_78442.rs @@ -1,5 +1,5 @@ // compile-flags: -Z mir-opt-level=3 -Z inline-mir -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] // EMIT_MIR issue_78442.bar.RevealAll.diff diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs index 17724530d..22f84e44a 100644 --- a/tests/mir-opt/inline/unchecked_shifts.rs +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -1,4 +1,4 @@ -// ignore-wasm32 compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] #![feature(unchecked_math)] @@ -16,3 +16,15 @@ pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 { a.unchecked_shr(b) } + +// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.diff +// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.mir +pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 { + a.unchecked_shl(b) +} + +// EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.Inline.diff +// EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir +pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 { + a.unchecked_shr(b) +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-abort.diff new file mode 100644 index 000000000..1ab1d01e5 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-abort.diff @@ -0,0 +1,36 @@ +- // MIR for `unchecked_shl_unsigned_bigger` before Inline ++ // MIR for `unchecked_shl_unsigned_bigger` after Inline + + fn unchecked_shl_unsigned_bigger(_1: u64, _2: u32) -> u64 { + debug a => _1; + debug b => _2; + let mut _0: u64; + let mut _3: u64; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl u64>::unchecked_shl) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: u64; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl u64>::unchecked_shl(move _3, move _4) -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { ++ StorageLive(_5); ++ _5 = _4 as u64 (IntToInt); ++ _0 = ShlUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-unwind.diff new file mode 100644 index 000000000..d71b5c4a6 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.panic-unwind.diff @@ -0,0 +1,36 @@ +- // MIR for `unchecked_shl_unsigned_bigger` before Inline ++ // MIR for `unchecked_shl_unsigned_bigger` after Inline + + fn unchecked_shl_unsigned_bigger(_1: u64, _2: u32) -> u64 { + debug a => _1; + debug b => _2; + let mut _0: u64; + let mut _3: u64; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl u64>::unchecked_shl) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: u64; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl u64>::unchecked_shl(move _3, move _4) -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ StorageLive(_5); ++ _5 = _4 as u64 (IntToInt); ++ _0 = ShlUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.panic-abort.mir new file mode 100644 index 000000000..65b832497 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.panic-abort.mir @@ -0,0 +1,22 @@ +// MIR for `unchecked_shl_unsigned_bigger` after PreCodegen + +fn unchecked_shl_unsigned_bigger(_1: u64, _2: u32) -> u64 { + debug a => _1; + debug b => _2; + let mut _0: u64; + scope 1 (inlined core::num::<impl u64>::unchecked_shl) { + debug self => _1; + debug rhs => _2; + let mut _3: u64; + scope 2 { + } + } + + bb0: { + StorageLive(_3); + _3 = _2 as u64 (IntToInt); + _0 = ShlUnchecked(_1, move _3); + StorageDead(_3); + return; + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.panic-unwind.mir new file mode 100644 index 000000000..65b832497 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,22 @@ +// MIR for `unchecked_shl_unsigned_bigger` after PreCodegen + +fn unchecked_shl_unsigned_bigger(_1: u64, _2: u32) -> u64 { + debug a => _1; + debug b => _2; + let mut _0: u64; + scope 1 (inlined core::num::<impl u64>::unchecked_shl) { + debug self => _1; + debug rhs => _2; + let mut _3: u64; + scope 2 { + } + } + + bb0: { + StorageLive(_3); + _3 = _2 as u64 (IntToInt); + _0 = ShlUnchecked(_1, move _3); + StorageDead(_3); + return; + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff deleted file mode 100644 index d76cd0e2b..000000000 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff +++ /dev/null @@ -1,152 +0,0 @@ -- // MIR for `unchecked_shl_unsigned_smaller` before Inline -+ // MIR for `unchecked_shl_unsigned_smaller` after Inline - - fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { - debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:46: +0:47 - debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:54: +0:55 - let mut _0: u16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:65: +0:68 - let mut _3: u16; // in scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 - let mut _4: u32; // in scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 -+ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 -+ debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ scope 2 { -+ scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _8: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _9: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ scope 4 { -+ scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _12: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ } -+ scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _14: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ scope 8 { -+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _15: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 10 { -+ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL -+ } -+ } -+ } -+ } -+ scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ } -+ } -+ } -+ } -+ } - - bb0: { - StorageLive(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 - _3 = _1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 - StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 - _4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 -- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23 -- // mir::Constant -- // + span: $DIR/unchecked_shifts.rs:11:7: 11:20 -- // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::<impl u16>::unchecked_shl}, val: Value(<ZST>) } -+ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _11 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb1: { -+ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 - StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 - return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 -+ } -+ -+ bb2: { -+ _9 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } -+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ -+ bb3: { -+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _12 = _7 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = Result::<u16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ -+ bb4: { -+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb5: { -+ _8 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb6: { -+ unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb7: { -+ _14 = move ((_9 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ _8 = Option::<u16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb8: { -+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ -+ bb9: { -+ _5 = move ((_8 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ // mir::Constant -+ // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL -+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) } - } - } - diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff new file mode 100644 index 000000000..90b32247c --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff @@ -0,0 +1,45 @@ +- // MIR for `unchecked_shl_unsigned_smaller` before Inline ++ // MIR for `unchecked_shl_unsigned_smaller` after Inline + + fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { + debug a => _1; + debug b => _2; + let mut _0: u16; + let mut _3: u16; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: u16; ++ let mut _6: bool; ++ let mut _7: u32; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); ++ _7 = const 65535_u32; ++ _6 = Le(_4, move _7); ++ StorageDead(_7); ++ assume(move _6); ++ StorageDead(_6); ++ _5 = _4 as u16 (IntToInt); ++ _0 = ShlUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff new file mode 100644 index 000000000..cae25759c --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff @@ -0,0 +1,45 @@ +- // MIR for `unchecked_shl_unsigned_smaller` before Inline ++ // MIR for `unchecked_shl_unsigned_smaller` after Inline + + fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { + debug a => _1; + debug b => _2; + let mut _0: u16; + let mut _3: u16; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl u16>::unchecked_shl) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: u16; ++ let mut _6: bool; ++ let mut _7: u32; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl u16>::unchecked_shl(move _3, move _4) -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); ++ _7 = const 65535_u32; ++ _6 = Le(_4, move _7); ++ StorageDead(_7); ++ assume(move _6); ++ StorageDead(_6); ++ _5 = _4 as u16 (IntToInt); ++ _0 = ShlUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir deleted file mode 100644 index 3c175ed15..000000000 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir +++ /dev/null @@ -1,138 +0,0 @@ -// MIR for `unchecked_shl_unsigned_smaller` after PreCodegen - -fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { - debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:46: +0:47 - debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:54: +0:55 - let mut _0: u16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:65: +0:68 - scope 1 (inlined core::num::<impl u16>::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 - debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _3: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _4: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _5: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - scope 2 { - scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug x => _5; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _6: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - scope 4 { - scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _5; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _5; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _10: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - } - scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let _12: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - scope 8 { - debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - } - } - scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _13: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - scope 10 { - debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - } - } - } - } - scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL - } - } - } - } - } - } - - bb0: { - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _4 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _5 = move (_4.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _9 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = Gt(_5, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb1: { - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 - } - - bb2: { - _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - // mir::Constant - // + span: no-location - // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } - goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb3: { - StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _10 = _5 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb4: { - StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb5: { - _6 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb6: { - unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb7: { - _12 = move ((_7 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _6 = Option::<u16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb8: { - StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - } - - bb9: { - _3 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) } - } -} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir new file mode 100644 index 000000000..3f388a69d --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-abort.mir @@ -0,0 +1,31 @@ +// MIR for `unchecked_shl_unsigned_smaller` after PreCodegen + +fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { + debug a => _1; + debug b => _2; + let mut _0: u16; + scope 1 (inlined core::num::<impl u16>::unchecked_shl) { + debug self => _1; + debug rhs => _2; + let mut _3: u32; + let mut _4: bool; + let mut _5: u16; + scope 2 { + } + } + + bb0: { + StorageLive(_5); + StorageLive(_4); + StorageLive(_3); + _3 = const 65535_u32; + _4 = Le(_2, move _3); + StorageDead(_3); + assume(move _4); + StorageDead(_4); + _5 = _2 as u16 (IntToInt); + _0 = ShlUnchecked(_1, move _5); + StorageDead(_5); + return; + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir new file mode 100644 index 000000000..3f388a69d --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,31 @@ +// MIR for `unchecked_shl_unsigned_smaller` after PreCodegen + +fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { + debug a => _1; + debug b => _2; + let mut _0: u16; + scope 1 (inlined core::num::<impl u16>::unchecked_shl) { + debug self => _1; + debug rhs => _2; + let mut _3: u32; + let mut _4: bool; + let mut _5: u16; + scope 2 { + } + } + + bb0: { + StorageLive(_5); + StorageLive(_4); + StorageLive(_3); + _3 = const 65535_u32; + _4 = Le(_2, move _3); + StorageDead(_3); + assume(move _4); + StorageDead(_4); + _5 = _2 as u16 (IntToInt); + _0 = ShlUnchecked(_1, move _5); + StorageDead(_5); + return; + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff new file mode 100644 index 000000000..1e83fec4f --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff @@ -0,0 +1,36 @@ +- // MIR for `unchecked_shr_signed_bigger` before Inline ++ // MIR for `unchecked_shr_signed_bigger` after Inline + + fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { + debug a => _1; + debug b => _2; + let mut _0: i64; + let mut _3: i64; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl i64>::unchecked_shr) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: i64; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl i64>::unchecked_shr(move _3, move _4) -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { ++ StorageLive(_5); ++ _5 = _4 as i64 (IntToInt); ++ _0 = ShrUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff new file mode 100644 index 000000000..6aafb61dc --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff @@ -0,0 +1,36 @@ +- // MIR for `unchecked_shr_signed_bigger` before Inline ++ // MIR for `unchecked_shr_signed_bigger` after Inline + + fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { + debug a => _1; + debug b => _2; + let mut _0: i64; + let mut _3: i64; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl i64>::unchecked_shr) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: i64; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl i64>::unchecked_shr(move _3, move _4) -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ StorageLive(_5); ++ _5 = _4 as i64 (IntToInt); ++ _0 = ShrUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir new file mode 100644 index 000000000..7524ec497 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-abort.mir @@ -0,0 +1,22 @@ +// MIR for `unchecked_shr_signed_bigger` after PreCodegen + +fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { + debug a => _1; + debug b => _2; + let mut _0: i64; + scope 1 (inlined core::num::<impl i64>::unchecked_shr) { + debug self => _1; + debug rhs => _2; + let mut _3: i64; + scope 2 { + } + } + + bb0: { + StorageLive(_3); + _3 = _2 as i64 (IntToInt); + _0 = ShrUnchecked(_1, move _3); + StorageDead(_3); + return; + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir new file mode 100644 index 000000000..7524ec497 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,22 @@ +// MIR for `unchecked_shr_signed_bigger` after PreCodegen + +fn unchecked_shr_signed_bigger(_1: i64, _2: u32) -> i64 { + debug a => _1; + debug b => _2; + let mut _0: i64; + scope 1 (inlined core::num::<impl i64>::unchecked_shr) { + debug self => _1; + debug rhs => _2; + let mut _3: i64; + scope 2 { + } + } + + bb0: { + StorageLive(_3); + _3 = _2 as i64 (IntToInt); + _0 = ShrUnchecked(_1, move _3); + StorageDead(_3); + return; + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff deleted file mode 100644 index f3d3e6090..000000000 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff +++ /dev/null @@ -1,152 +0,0 @@ -- // MIR for `unchecked_shr_signed_smaller` before Inline -+ // MIR for `unchecked_shr_signed_smaller` after Inline - - fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { - debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:44: +0:45 - debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:52: +0:53 - let mut _0: i16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:63: +0:66 - let mut _3: i16; // in scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 - let mut _4: u32; // in scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 -+ scope 1 (inlined core::num::<impl i16>::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 -+ debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ let mut _5: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ scope 2 { -+ scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _8: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _9: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ scope 4 { -+ scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _12: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ } -+ scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _14: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ scope 8 { -+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ } -+ scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _15: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 10 { -+ debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ scope 11 { -+ scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 14 { -+ scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL -+ } -+ } -+ } -+ } -+ scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ } -+ } -+ } -+ } -+ } - - bb0: { - StorageLive(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 - _3 = _1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:6 - StorageLive(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 - _4 = _2; // scope 0 at $DIR/unchecked_shifts.rs:+1:21: +1:22 -- _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> bb1; // scope 0 at $DIR/unchecked_shifts.rs:+1:5: +1:23 -- // mir::Constant -- // + span: $DIR/unchecked_shifts.rs:17:7: 17:20 -- // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::<impl i16>::unchecked_shr}, val: Value(<ZST>) } -+ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _11 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb1: { -+ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - StorageDead(_4); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 - StorageDead(_3); // scope 0 at $DIR/unchecked_shifts.rs:+1:22: +1:23 - return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 -+ } -+ -+ bb2: { -+ _9 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ // mir::Constant -+ // + span: no-location -+ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } -+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ -+ bb3: { -+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _12 = _7 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = Result::<i16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ } -+ -+ bb4: { -+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb5: { -+ _8 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb6: { -+ unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb7: { -+ _14 = move ((_9 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ _8 = Option::<i16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL -+ goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ } -+ -+ bb8: { -+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ -+ bb9: { -+ _5 = move ((_8 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ // mir::Constant -+ // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL -+ // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) } - } - } - diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff new file mode 100644 index 000000000..fa7e5d16e --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-abort.diff @@ -0,0 +1,45 @@ +- // MIR for `unchecked_shr_signed_smaller` before Inline ++ // MIR for `unchecked_shr_signed_smaller` after Inline + + fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { + debug a => _1; + debug b => _2; + let mut _0: i16; + let mut _3: i16; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl i16>::unchecked_shr) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: i16; ++ let mut _6: bool; ++ let mut _7: u32; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); ++ _7 = const 32767_u32; ++ _6 = Le(_4, move _7); ++ StorageDead(_7); ++ assume(move _6); ++ StorageDead(_6); ++ _5 = _4 as i16 (IntToInt); ++ _0 = ShrUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff new file mode 100644 index 000000000..fe5331214 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.panic-unwind.diff @@ -0,0 +1,45 @@ +- // MIR for `unchecked_shr_signed_smaller` before Inline ++ // MIR for `unchecked_shr_signed_smaller` after Inline + + fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { + debug a => _1; + debug b => _2; + let mut _0: i16; + let mut _3: i16; + let mut _4: u32; ++ scope 1 (inlined core::num::<impl i16>::unchecked_shr) { ++ debug self => _3; ++ debug rhs => _4; ++ let mut _5: i16; ++ let mut _6: bool; ++ let mut _7: u32; ++ scope 2 { ++ } ++ } + + bb0: { + StorageLive(_3); + _3 = _1; + StorageLive(_4); + _4 = _2; +- _0 = core::num::<impl i16>::unchecked_shr(move _3, move _4) -> [return: bb1, unwind continue]; +- } +- +- bb1: { ++ StorageLive(_5); ++ StorageLive(_6); ++ StorageLive(_7); ++ _7 = const 32767_u32; ++ _6 = Le(_4, move _7); ++ StorageDead(_7); ++ assume(move _6); ++ StorageDead(_6); ++ _5 = _4 as i16 (IntToInt); ++ _0 = ShrUnchecked(_3, move _5); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir deleted file mode 100644 index 724b3c567..000000000 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir +++ /dev/null @@ -1,138 +0,0 @@ -// MIR for `unchecked_shr_signed_smaller` after PreCodegen - -fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { - debug a => _1; // in scope 0 at $DIR/unchecked_shifts.rs:+0:44: +0:45 - debug b => _2; // in scope 0 at $DIR/unchecked_shifts.rs:+0:52: +0:53 - let mut _0: i16; // return place in scope 0 at $DIR/unchecked_shifts.rs:+0:63: +0:66 - scope 1 (inlined core::num::<impl i16>::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 - debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - let mut _3: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _4: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _5: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - scope 2 { - scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug x => _5; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _6: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _7: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - scope 4 { - scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _5; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _5; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _10: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - } - scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let _12: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - scope 8 { - debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - } - } - scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _13: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - scope 10 { - debug val => _3; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL - } - scope 11 { - scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL - scope 14 { - scope 15 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - } - } - } - } - scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL - } - } - } - } - } - } - - bb0: { - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _4 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _5 = move (_4.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _9 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = Gt(_5, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb1: { - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 - } - - bb2: { - _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - // mir::Constant - // + span: no-location - // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } - goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb3: { - StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _10 = _5 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = Result::<i16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - } - - bb4: { - StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb5: { - _6 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb6: { - unreachable; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb7: { - _12 = move ((_7 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _6 = Option::<i16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - } - - bb8: { - StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - } - - bb9: { - _3 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _0 = unchecked_shr::<i16>(_1, move _3) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) } - } -} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir new file mode 100644 index 000000000..64ea25349 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-abort.mir @@ -0,0 +1,31 @@ +// MIR for `unchecked_shr_signed_smaller` after PreCodegen + +fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { + debug a => _1; + debug b => _2; + let mut _0: i16; + scope 1 (inlined core::num::<impl i16>::unchecked_shr) { + debug self => _1; + debug rhs => _2; + let mut _3: u32; + let mut _4: bool; + let mut _5: i16; + scope 2 { + } + } + + bb0: { + StorageLive(_5); + StorageLive(_4); + StorageLive(_3); + _3 = const 32767_u32; + _4 = Le(_2, move _3); + StorageDead(_3); + assume(move _4); + StorageDead(_4); + _5 = _2 as i16 (IntToInt); + _0 = ShrUnchecked(_1, move _5); + StorageDead(_5); + return; + } +} diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir new file mode 100644 index 000000000..64ea25349 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,31 @@ +// MIR for `unchecked_shr_signed_smaller` after PreCodegen + +fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { + debug a => _1; + debug b => _2; + let mut _0: i16; + scope 1 (inlined core::num::<impl i16>::unchecked_shr) { + debug self => _1; + debug rhs => _2; + let mut _3: u32; + let mut _4: bool; + let mut _5: i16; + scope 2 { + } + } + + bb0: { + StorageLive(_5); + StorageLive(_4); + StorageLive(_3); + _3 = const 32767_u32; + _4 = Le(_2, move _3); + StorageDead(_3); + assume(move _4); + StorageDead(_4); + _5 = _2 as i16 (IntToInt); + _0 = ShrUnchecked(_1, move _5); + StorageDead(_5); + return; + } +} diff --git a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff index 745f2bb19..6ee6a0ffe 100644 --- a/tests/mir-opt/inline/unsized_argument.caller.Inline.diff +++ b/tests/mir-opt/inline/unsized_argument.caller.Inline.diff @@ -2,49 +2,45 @@ + // MIR for `caller` after Inline fn caller(_1: Box<[i32]>) -> () { - debug x => _1; // in scope 0 at $DIR/unsized_argument.rs:+0:11: +0:12 - let mut _0: (); // return place in scope 0 at $DIR/unsized_argument.rs:+0:26: +0:26 - let _2: (); // in scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 - let mut _3: std::boxed::Box<[i32]>; // in scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 - let mut _4: (); // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 - let mut _5: (); // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 - let mut _6: (); // in scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 - let mut _7: *const [i32]; // in scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: std::boxed::Box<[i32]>; + let mut _4: &mut std::boxed::Box<[i32]>; + let mut _5: (); + let mut _6: &mut std::boxed::Box<[i32]>; + let mut _7: (); + let mut _8: &mut std::boxed::Box<[i32]>; + let mut _9: (); + let mut _10: *const [i32]; bb0: { - StorageLive(_2); // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 - StorageLive(_3); // scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 - _3 = move _1; // scope 0 at $DIR/unsized_argument.rs:+1:13: +1:14 - _7 = (((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>).0: *const [i32]); // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 - _2 = callee(move (*_7)) -> [return: bb3, unwind: bb4]; // scope 0 at $DIR/unsized_argument.rs:+1:5: +1:15 - // mir::Constant - // + span: $DIR/unsized_argument.rs:9:5: 9:11 - // + literal: Const { ty: fn([i32]) {callee}, val: Value(<ZST>) } + StorageLive(_2); + StorageLive(_3); + _3 = move _1; + _10 = (((_3.0: std::ptr::Unique<[i32]>).0: std::ptr::NonNull<[i32]>).0: *const [i32]); + _2 = callee(move (*_10)) -> [return: bb3, unwind: bb4]; } - bb1: { - StorageDead(_3); // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 - StorageDead(_2); // scope 0 at $DIR/unsized_argument.rs:+1:15: +1:16 - _0 = const (); // scope 0 at $DIR/unsized_argument.rs:+0:26: +2:2 - return; // scope 0 at $DIR/unsized_argument.rs:+2:2: +2:2 + bb1 (cleanup): { + resume; } - bb2 (cleanup): { - resume; // scope 0 at $DIR/unsized_argument.rs:+0:1: +2:2 + bb2: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; } bb3: { - _4 = alloc::alloc::box_free::<[i32], std::alloc::Global>(move (_3.0: std::ptr::Unique<[i32]>), move (_3.1: std::alloc::Global)) -> bb1; // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 - // mir::Constant - // + span: $DIR/unsized_argument.rs:9:14: 9:15 - // + literal: Const { ty: unsafe fn(Unique<[i32]>, std::alloc::Global) {alloc::alloc::box_free::<[i32], std::alloc::Global>}, val: Value(<ZST>) } + _4 = &mut _3; + _5 = <Box<[i32]> as Drop>::drop(move _4) -> [return: bb2, unwind: bb1]; } bb4 (cleanup): { - _6 = alloc::alloc::box_free::<[i32], std::alloc::Global>(move (_3.0: std::ptr::Unique<[i32]>), move (_3.1: std::alloc::Global)) -> [return: bb2, unwind terminate]; // scope 0 at $DIR/unsized_argument.rs:+1:14: +1:15 - // mir::Constant - // + span: $DIR/unsized_argument.rs:9:14: 9:15 - // + literal: Const { ty: unsafe fn(Unique<[i32]>, std::alloc::Global) {alloc::alloc::box_free::<[i32], std::alloc::Global>}, val: Value(<ZST>) } + _8 = &mut _3; + _9 = <Box<[i32]> as Drop>::drop(move _8) -> [return: bb1, unwind terminate]; } } diff --git a/tests/mir-opt/inline/unwrap_unchecked.rs b/tests/mir-opt/inline/unwrap_unchecked.rs index 5856f1479..f28aef7a8 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.rs +++ b/tests/mir-opt/inline/unwrap_unchecked.rs @@ -1,6 +1,6 @@ #![crate_type = "lib"] -// ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY // ignore-debug: the debug assertions prevent the inlining we are testing for // compile-flags: -Zmir-opt-level=2 -Zinline-mir diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff deleted file mode 100644 index 8a8cd896e..000000000 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff +++ /dev/null @@ -1,55 +0,0 @@ -- // MIR for `unwrap_unchecked` before Inline -+ // MIR for `unwrap_unchecked` after Inline - - fn unwrap_unchecked(_1: Option<T>) -> T { - debug slf => _1; // in scope 0 at $DIR/unwrap_unchecked.rs:+0:35: +0:38 - let mut _0: T; // return place in scope 0 at $DIR/unwrap_unchecked.rs:+0:54: +0:55 - let mut _2: std::option::Option<T>; // in scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:8 -+ scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { // at $DIR/unwrap_unchecked.rs:10:9: 10:27 -+ debug self => _2; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _3: &std::option::Option<T>; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _4: isize; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 2 { -+ debug val => _0; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ scope 3 { -+ scope 5 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ scope 6 { -+ scope 7 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL -+ } -+ } -+ } -+ } -+ scope 4 (inlined Option::<T>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _3; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL -+ } -+ } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:8 - _2 = move _1; // scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:8 -- _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind: bb2]; // scope 0 at $DIR/unwrap_unchecked.rs:+1:5: +1:27 -- // mir::Constant -- // + span: $DIR/unwrap_unchecked.rs:10:9: 10:25 -- // + literal: Const { ty: unsafe fn(Option<T>) -> T {Option::<T>::unwrap_unchecked}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 -+ _4 = discriminant(_2); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _4) -> [1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL - } - - bb1: { -- StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:26: +1:27 -- return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2 -+ unreachable; // scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - } - -- bb2 (cleanup): { -- resume; // scope 0 at $DIR/unwrap_unchecked.rs:+0:1: +2:2 -+ bb2: { -+ _0 = move ((_2 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_3); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 -+ StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:26: +1:27 -+ return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2 - } - } - diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff new file mode 100644 index 000000000..e3c573473 --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -0,0 +1,48 @@ +- // MIR for `unwrap_unchecked` before Inline ++ // MIR for `unwrap_unchecked` after Inline + + fn unwrap_unchecked(_1: Option<T>) -> T { + debug slf => _1; + let mut _0: T; + let mut _2: std::option::Option<T>; ++ scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { ++ debug self => _2; ++ let mut _3: &std::option::Option<T>; ++ let mut _4: isize; ++ scope 2 { ++ debug val => _0; ++ } ++ scope 3 { ++ scope 5 (inlined unreachable_unchecked) { ++ scope 6 { ++ scope 7 (inlined unreachable_unchecked::runtime) { ++ } ++ } ++ } ++ } ++ scope 4 (inlined Option::<T>::is_some) { ++ debug self => _3; ++ } ++ } + + bb0: { + StorageLive(_2); + _2 = move _1; +- _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind unreachable]; ++ StorageLive(_3); ++ _4 = discriminant(_2); ++ switchInt(move _4) -> [1: bb2, otherwise: bb1]; + } + + bb1: { ++ unreachable; ++ } ++ ++ bb2: { ++ _0 = move ((_2 as Some).0: T); ++ StorageDead(_3); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff new file mode 100644 index 000000000..fc638cb3a --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -0,0 +1,52 @@ +- // MIR for `unwrap_unchecked` before Inline ++ // MIR for `unwrap_unchecked` after Inline + + fn unwrap_unchecked(_1: Option<T>) -> T { + debug slf => _1; + let mut _0: T; + let mut _2: std::option::Option<T>; ++ scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { ++ debug self => _2; ++ let mut _3: &std::option::Option<T>; ++ let mut _4: isize; ++ scope 2 { ++ debug val => _0; ++ } ++ scope 3 { ++ scope 5 (inlined unreachable_unchecked) { ++ scope 6 { ++ scope 7 (inlined unreachable_unchecked::runtime) { ++ } ++ } ++ } ++ } ++ scope 4 (inlined Option::<T>::is_some) { ++ debug self => _3; ++ } ++ } + + bb0: { + StorageLive(_2); + _2 = move _1; +- _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind: bb2]; ++ StorageLive(_3); ++ _4 = discriminant(_2); ++ switchInt(move _4) -> [1: bb2, otherwise: bb1]; + } + + bb1: { +- StorageDead(_2); +- return; ++ unreachable; + } + +- bb2 (cleanup): { +- resume; ++ bb2: { ++ _0 = move ((_2 as Some).0: T); ++ StorageDead(_3); ++ StorageDead(_2); ++ return; + } + } + diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir deleted file mode 100644 index c5e2469fc..000000000 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir +++ /dev/null @@ -1,41 +0,0 @@ -// MIR for `unwrap_unchecked` after PreCodegen - -fn unwrap_unchecked(_1: Option<T>) -> T { - debug slf => _1; // in scope 0 at $DIR/unwrap_unchecked.rs:+0:35: +0:38 - let mut _0: T; // return place in scope 0 at $DIR/unwrap_unchecked.rs:+0:54: +0:55 - scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { // at $DIR/unwrap_unchecked.rs:10:9: 10:27 - debug self => _1; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _2: &std::option::Option<T>; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _3: isize; // in scope 1 at $SRC_DIR/core/src/option.rs:LL:COL - scope 2 { - debug val => _0; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - } - scope 3 { - scope 5 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL - scope 6 { - scope 7 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - } - } - } - } - scope 4 (inlined Option::<T>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _2; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL - } - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 - _3 = discriminant(_1); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _3) -> [1: bb2, otherwise: bb1]; // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL - } - - bb1: { - unreachable; // scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - } - - bb2: { - _0 = move ((_1 as Some).0: T); // scope 1 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_2); // scope 0 at $DIR/unwrap_unchecked.rs:+1:9: +1:27 - return; // scope 0 at $DIR/unwrap_unchecked.rs:+2:2: +2:2 - } -} diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir new file mode 100644 index 000000000..fcc4d43ce --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir @@ -0,0 +1,41 @@ +// MIR for `unwrap_unchecked` after PreCodegen + +fn unwrap_unchecked(_1: Option<T>) -> T { + debug slf => _1; + let mut _0: T; + scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { + debug self => _1; + let mut _2: isize; + let mut _3: &std::option::Option<T>; + scope 2 { + debug val => _0; + } + scope 3 { + scope 5 (inlined unreachable_unchecked) { + scope 6 { + scope 7 (inlined unreachable_unchecked::runtime) { + } + } + } + } + scope 4 (inlined Option::<T>::is_some) { + debug self => _3; + } + } + + bb0: { + StorageLive(_3); + _2 = discriminant(_1); + switchInt(move _2) -> [1: bb1, otherwise: bb2]; + } + + bb1: { + _0 = move ((_1 as Some).0: T); + StorageDead(_3); + return; + } + + bb2: { + unreachable; + } +} diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir new file mode 100644 index 000000000..fcc4d43ce --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,41 @@ +// MIR for `unwrap_unchecked` after PreCodegen + +fn unwrap_unchecked(_1: Option<T>) -> T { + debug slf => _1; + let mut _0: T; + scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { + debug self => _1; + let mut _2: isize; + let mut _3: &std::option::Option<T>; + scope 2 { + debug val => _0; + } + scope 3 { + scope 5 (inlined unreachable_unchecked) { + scope 6 { + scope 7 (inlined unreachable_unchecked::runtime) { + } + } + } + } + scope 4 (inlined Option::<T>::is_some) { + debug self => _3; + } + } + + bb0: { + StorageLive(_3); + _2 = discriminant(_1); + switchInt(move _2) -> [1: bb1, otherwise: bb2]; + } + + bb1: { + _0 = move ((_1 as Some).0: T); + StorageDead(_3); + return; + } + + bb2: { + unreachable; + } +} |