diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /tests/mir-opt/inline | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/inline')
46 files changed, 929 insertions, 255 deletions
diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.diff index f1b62ac38..ba1bfec05 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.diff @@ -7,7 +7,7 @@ + scope 1 (inlined foo) { // at $DIR/asm_unwind.rs:21:5: 21:10 + let _2: D; // in scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 + scope 2 { -+ debug _d => _2; // in scope 2 at $DIR/asm_unwind.rs:15:9: 15:11 ++ debug _d => const D; // in scope 2 at $DIR/asm_unwind.rs:15:9: 15:11 + scope 3 { + } + } @@ -19,23 +19,23 @@ - // mir::Constant - // + span: $DIR/asm_unwind.rs:21:5: 21:8 - // + literal: Const { ty: fn() {foo}, val: Value(<ZST>) } -+ StorageLive(_2); // scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 -+ asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54 ++ StorageLive(_2); // scope 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: { -+ drop(_2) -> bb2; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 -+ } -+ -+ bb2: { -+ StorageDead(_2); // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 ++ StorageDead(_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) -> bb4; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 ++ drop(_2) -> [return: bb4, unwind terminate]; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 + } + + bb4 (cleanup): { diff --git a/tests/mir-opt/inline/cycle.f.Inline.diff b/tests/mir-opt/inline/cycle.f.Inline.diff index 501390c3b..8da597577 100644 --- a/tests/mir-opt/inline/cycle.f.Inline.diff +++ b/tests/mir-opt/inline/cycle.f.Inline.diff @@ -33,7 +33,7 @@ } bb3 (cleanup): { - drop(_1) -> bb4; // scope 0 at $DIR/cycle.rs:+2:1: +2:2 + drop(_1) -> [return: bb4, unwind terminate]; // scope 0 at $DIR/cycle.rs:+2:1: +2:2 } bb4 (cleanup): { diff --git a/tests/mir-opt/inline/cycle.g.Inline.diff b/tests/mir-opt/inline/cycle.g.Inline.diff index 5f3ee467c..1e6e30f9e 100644 --- a/tests/mir-opt/inline/cycle.g.Inline.diff +++ b/tests/mir-opt/inline/cycle.g.Inline.diff @@ -5,11 +5,11 @@ 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 -+ let mut _5: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + scope 2 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8 + } + } @@ -25,14 +25,16 @@ - // mir::Constant // + span: $DIR/cycle.rs:12:7: 12:11 // + literal: Const { ty: fn() {main}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ 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 @@ -40,7 +42,7 @@ + } + + bb2 (cleanup): { -+ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ drop(_2) -> [return: bb3, unwind terminate]; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + + bb3 (cleanup): { @@ -48,9 +50,8 @@ + } + + bb4: { -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 + drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 } } diff --git a/tests/mir-opt/inline/cycle.main.Inline.diff b/tests/mir-opt/inline/cycle.main.Inline.diff index 6b4c63bbd..315634945 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.diff @@ -5,11 +5,11 @@ 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 -+ let mut _5: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + scope 2 (inlined <fn() {g} as Fn<()>>::call - shim(fn() {g})) { // at $DIR/cycle.rs:6:5: 6:8 + } + } @@ -25,14 +25,16 @@ - // mir::Constant // + span: $DIR/cycle.rs:17:7: 17:8 // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ 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 @@ -40,7 +42,7 @@ + } + + bb2 (cleanup): { -+ drop(_2) -> bb3; // scope 1 at $DIR/cycle.rs:7:1: 7:2 ++ drop(_2) -> [return: bb3, unwind terminate]; // scope 1 at $DIR/cycle.rs:7:1: 7:2 + } + + bb3 (cleanup): { @@ -48,9 +50,8 @@ + } + + bb4: { -+ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:7: 6:8 ++ StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 + drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 } } diff --git a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff b/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff index 64c3e47ff..75d9bd54d 100644 --- a/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.get_query.Inline.diff @@ -9,11 +9,11 @@ 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:34:5: 34:25 -+ debug c => _4; // in scope 2 at $DIR/dyn_trait.rs:26:36: 26:37 -+ let mut _5: &dyn Cache<V = <Q as Query>::V>; // in scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 -+ scope 3 (inlined mk_cycle::<<Q as Query>::V>) { // at $DIR/dyn_trait.rs:27:5: 27:16 -+ debug c => _5; // in scope 3 at $DIR/dyn_trait.rs:20:27: 20:28 ++ 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 + } + } } @@ -24,7 +24,7 @@ _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:33:13: 33:21 + // + 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>) } } @@ -34,18 +34,18 @@ 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:27:14: 27:15 -+ _5 = _4 as &dyn Cache<V = <Q as Query>::V> (Pointer(Unsize)); // scope 2 at $DIR/dyn_trait.rs:27:14: 27:15 -+ _0 = <dyn Cache<V = <Q as Query>::V> as Cache>::store_nocache(_5) -> bb2; // scope 3 at $DIR/dyn_trait.rs:21:5: 21:22 ++ 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:34:5: 34:22 +- // + 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:21:7: 21:20 ++ // + 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:27:15: 27:16 ++ 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.mk_cycle.Inline.diff b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff index 7653a5ded..925c95988 100644 --- a/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.mk_cycle.Inline.diff @@ -11,7 +11,7 @@ _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:21:7: 21:20 + // + 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>) } } diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs index 6a46e1e07..2af81f825 100644 --- a/tests/mir-opt/inline/dyn_trait.rs +++ b/tests/mir-opt/inline/dyn_trait.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #![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 index 3fa9c3e88..f4e5272ab 100644 --- a/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff +++ b/tests/mir-opt/inline/dyn_trait.try_execute_query.Inline.diff @@ -6,8 +6,8 @@ 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:27:5: 27:16 -+ debug c => _2; // in scope 1 at $DIR/dyn_trait.rs:20:27: 20:28 ++ 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: { @@ -17,11 +17,11 @@ _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:21:5: 21:22 ++ _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:27:5: 27:13 +- // + 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:21:7: 21:20 ++ // + 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>) } } diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff index 7fd62be7a..30af8661d 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff @@ -4,72 +4,72 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/exponential_runtime.rs:+0:11: +0:11 let _1: (); // in scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ scope 1 (inlined <() as G>::call) { // at $DIR/exponential_runtime.rs:86:5: 86:22 -+ let _2: (); // in scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 -+ let _3: (); // in scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ let _4: (); // in scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ scope 2 (inlined <() as F>::call) { // at $DIR/exponential_runtime.rs:73:9: 73:25 -+ let _5: (); // in scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 -+ let _6: (); // in scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 -+ let _7: (); // in scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 ++ 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 1 at $DIR/exponential_runtime.rs:73:9: 73:25 -+ StorageLive(_5); // scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 -+ _5 = <() as E>::call() -> bb3; // scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 ++ 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:86:5: 86:20 +- // + span: $DIR/exponential_runtime.rs:87:5: 87:20 - // + literal: Const { ty: fn() {<() as G>::call}, val: Value(<ZST>) } -+ // + span: $DIR/exponential_runtime.rs:61:9: 61:23 ++ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 + // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } } bb1: { -+ StorageDead(_3); // scope 1 at $DIR/exponential_runtime.rs:74:25: 74:26 -+ StorageLive(_4); // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ _4 = <() as F>::call() -> bb2; // 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>) } -+ } -+ -+ bb2: { -+ StorageDead(_4); // scope 1 at $DIR/exponential_runtime.rs:75:25: 75:26 ++ 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: { -+ StorageDead(_5); // scope 2 at $DIR/exponential_runtime.rs:61:25: 61:26 -+ StorageLive(_6); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 -+ _6 = <() as E>::call() -> bb4; // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ _4 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:76:9: 76:25 + // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 -+ // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } ++ // + span: $DIR/exponential_runtime.rs:76:9: 76:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } + } + + bb4: { -+ StorageDead(_6); // scope 2 at $DIR/exponential_runtime.rs:62:25: 62:26 -+ StorageLive(_7); // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 -+ _7 = <() as E>::call() -> bb5; // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 ++ _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: { -+ StorageDead(_7); // scope 2 at $DIR/exponential_runtime.rs:63:25: 63:26 -+ StorageDead(_2); // scope 1 at $DIR/exponential_runtime.rs:73:25: 73:26 -+ StorageLive(_3); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ _3 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ _7 = <() as E>::call() -> bb2; // scope 2 at $DIR/exponential_runtime.rs:64:9: 64:25 + // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:74:9: 74:23 -+ // + literal: Const { ty: fn() {<() as F>::call}, val: Value(<ZST>) } ++ // + 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.rs b/tests/mir-opt/inline/exponential_runtime.rs index d9219d76a..39985528f 100644 --- a/tests/mir-opt/inline/exponential_runtime.rs +++ b/tests/mir-opt/inline/exponential_runtime.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Checks that code with exponential runtime does not have exponential behavior in inlining. trait A { 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 fff8d0171..1d2f99cbe 100644 --- a/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure.foo.Inline.after.mir @@ -23,7 +23,7 @@ fn foo(_1: T, _2: i32) -> i32 { 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[92ba]::foo::{closure#0}) + // + def_id: DefId(0:6 ~ inline_closure[8f32]::foo::{closure#0}) // + substs: [ // T, // i8, 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 dab204306..80274bb7e 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 @@ -26,7 +26,7 @@ fn foo(_1: T, _2: &i32) -> i32 { 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[96e9]::foo::{closure#0}) + // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[f89f]::foo::{closure#0}) // + substs: [ // T, // i8, 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 84fd051e0..b36711f82 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 @@ -32,7 +32,7 @@ fn foo(_1: T, _2: i32) -> (i32, T) { _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[8bc0]::foo::{closure#0}) + // + def_id: DefId(0:6 ~ inline_closure_captures[63a5]::foo::{closure#0}) // + substs: [ // T, // i8, diff --git a/tests/mir-opt/inline/inline_cycle.one.Inline.diff b/tests/mir-opt/inline/inline_cycle.one.Inline.diff index 5510cd7bc..f6ba69a1d 100644 --- a/tests/mir-opt/inline/inline_cycle.one.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle.one.Inline.diff @@ -4,9 +4,9 @@ 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:14:5: 14:24 -+ scope 2 (inlined <A<C> as Call>::call) { // at $DIR/inline_cycle.rs:43:9: 43:23 -+ scope 3 (inlined <B<C> as Call>::call) { // at $DIR/inline_cycle.rs:28:9: 28:31 ++ 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 + } + } + } @@ -14,10 +14,10 @@ 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:36:9: 36:28 ++ _1 = <C as Call>::call() -> bb1; // scope 3 at $DIR/inline_cycle.rs:37:9: 37:28 // mir::Constant -- // + span: $DIR/inline_cycle.rs:14:5: 14:22 -+ // + span: $DIR/inline_cycle.rs:36:9: 36:26 +- // + 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>) } } diff --git a/tests/mir-opt/inline/inline_cycle.rs b/tests/mir-opt/inline/inline_cycle.rs index 63ad57de1..2f81696cf 100644 --- a/tests/mir-opt/inline/inline_cycle.rs +++ b/tests/mir-opt/inline/inline_cycle.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index 64c0065b5..c8f58111d 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.diff @@ -5,11 +5,11 @@ let mut _0: (); // return place in scope 0 at $DIR/inline_cycle.rs:+0:10: +0:10 let _1: (); // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + let mut _2: fn() {f}; // in scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 -+ scope 1 (inlined call::<fn() {f}>) { // at $DIR/inline_cycle.rs:49:5: 49:12 -+ debug f => _2; // in scope 1 at $DIR/inline_cycle.rs:53:22: 53:23 -+ let _3: (); // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 -+ let mut _4: (); // in scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 -+ scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { // at $DIR/inline_cycle.rs:54:5: 54:8 ++ 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 + } + } @@ -19,19 +19,20 @@ + StorageLive(_2); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + _2 = f; // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 // mir::Constant -- // + span: $DIR/inline_cycle.rs:49:5: 49:9 +- // + span: $DIR/inline_cycle.rs:50:5: 50:9 - // + literal: Const { ty: fn(fn() {f}) {call::<fn() {f}>}, val: Value(<ZST>) } - // mir::Constant - // + span: $DIR/inline_cycle.rs:49:10: 49:11 + // + span: $DIR/inline_cycle.rs:50:10: 50:11 // + literal: Const { ty: fn() {f}, val: Value(<ZST>) } -+ StorageLive(_3); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 -+ StorageLive(_4); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 ++ 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:54:7: 54:8 -+ StorageDead(_3); // scope 1 at $DIR/inline_cycle.rs:54:8: 54:9 ++ 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 diff --git a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff index 52debab4d..9429ca593 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff @@ -4,23 +4,20 @@ 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:9:5: 9:24 -+ scope 2 (inlined <B<A> as Call>::call) { // at $DIR/inline_cycle_generic.rs:38:9: 38:31 -+ scope 3 (inlined <A as Call>::call) { // at $DIR/inline_cycle_generic.rs:31:9: 31:28 -+ scope 4 (inlined <B<C> as Call>::call) { // at $DIR/inline_cycle_generic.rs:23:9: 23:31 -+ } -+ } ++ 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 = <C as Call>::call() -> bb1; // scope 4 at $DIR/inline_cycle_generic.rs:31:9: 31:28 ++ _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:9:5: 9:22 -+ // + span: $DIR/inline_cycle_generic.rs:31:9: 31:26 - // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(<ZST>) } +- // + 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: { diff --git a/tests/mir-opt/inline/inline_cycle_generic.rs b/tests/mir-opt/inline/inline_cycle_generic.rs index 24b4f3793..84e6e4005 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.rs +++ b/tests/mir-opt/inline/inline_cycle_generic.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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.g.Inline.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.diff index b787a19f4..4f22ad437 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.diff @@ -34,7 +34,7 @@ bb2: { StorageLive(_6); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 - _6 = panic(); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 -+ StorageLive(_7); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL ++ 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 diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.diff index e1b2f7dbf..d501b6ca8 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.diff @@ -5,19 +5,18 @@ 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: (); // in scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 -+ let mut _6: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:14 -+ let mut _7: (); // in scope 1 at $DIR/inline_diverging.rs:28:13: 28:16 -+ let mut _8: !; // in scope 1 at $DIR/inline_diverging.rs:29:6: 29:7 -+ let mut _9: !; // in scope 1 at $DIR/inline_diverging.rs:29:9: 29:10 ++ 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 => _9; // in scope 3 at $DIR/inline_diverging.rs:28:9: 28:10 ++ 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 @@ -35,21 +34,21 @@ - // mir::Constant // + span: $DIR/inline_diverging.rs:22:16: 22:21 // + literal: Const { ty: fn() -> ! {sleep}, val: Value(<ZST>) } -+ StorageLive(_9); // scope 0 at $DIR/inline_diverging.rs:+1:5: +1:22 ++ 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(_5); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 ++ 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(_7); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 -+ StorageDead(_6); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 -+ StorageLive(_8); // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _8 = move _3; // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _1 = (move _8, move _9); // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 -+ StorageDead(_8); // scope 3 at $DIR/inline_diverging.rs:29:10: 29:11 ++ StorageDead(_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 + } @@ -59,11 +58,11 @@ + } + + bb3 (cleanup): { -+ drop(_3) -> bb4; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 ++ drop(_3) -> [return: bb4, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 + } + + bb4 (cleanup): { -+ drop(_2) -> bb5; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 ++ drop(_2) -> [return: bb5, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 + } + + bb5 (cleanup): { @@ -71,12 +70,11 @@ + } + + bb6: { -+ StorageDead(_5); // scope 1 at $DIR/inline_diverging.rs:27:15: 27:16 ++ 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(_6); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ _6 = &_2; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ StorageLive(_7); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 -+ _9 = <fn() -> ! {sleep} as Fn<()>>::call(move _6, move _7) -> [return: bb1, unwind: bb3]; // scope 2 at $DIR/inline_diverging.rs:28:13: 28: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_generator.main.Inline.diff b/tests/mir-opt/inline/inline_generator.main.Inline.diff index 01f5052b6..c3ca2d7d4 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.diff @@ -44,7 +44,7 @@ - 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[ea31]::g::{closure#0}) ++ // + def_id: DefId(0:7 ~ inline_generator[e37e]::g::{closure#0}) + // + substs: [ + // bool, + // i32, 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 f1988ea4b..a1d2423ae 100644 --- a/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.default.Inline.diff @@ -16,7 +16,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + _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>) } @@ -25,7 +25,7 @@ bb1: { StorageDead(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27 StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 - _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 + _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>) } @@ -34,7 +34,7 @@ bb2: { StorageDead(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27 StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- _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>) } @@ -43,11 +43,11 @@ - bb3: { StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _4 = inline_always_and_using_inline_asm() -> [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))) -> bb3; // scope 3 at $DIR/inline_instruction_set.rs:43:14: 43:38 ++ asm!("/* do nothing */", options((empty))) -> [return: bb3, unwind unreachable]; // scope 3 at $DIR/inline_instruction_set.rs:43:14: 43:38 } - bb4: { 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 e777b2cc2..36aec4f47 100644 --- a/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ b/tests/mir-opt/inline/inline_instruction_set.t32.Inline.diff @@ -14,7 +14,7 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline_instruction_set.rs:+1:5: +1:26 + _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>) } @@ -23,7 +23,7 @@ bb1: { StorageDead(_1); // scope 0 at $DIR/inline_instruction_set.rs:+1:26: +1:27 StorageLive(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 -- _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+2:5: +2:26 +- _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>) } @@ -32,7 +32,7 @@ - bb2: { StorageDead(_2); // scope 0 at $DIR/inline_instruction_set.rs:+2:26: +2:27 StorageLive(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline_instruction_set.rs:+3:5: +3:30 +- _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>) } @@ -41,8 +41,8 @@ - bb3: { StorageDead(_3); // scope 0 at $DIR/inline_instruction_set.rs:+3:30: +3:31 StorageLive(_4); // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -- _4 = inline_always_and_using_inline_asm() -> bb4; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 -+ _4 = inline_always_and_using_inline_asm() -> bb2; // scope 0 at $DIR/inline_instruction_set.rs:+4:5: +4:41 +- _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>) } diff --git a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff b/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff index a1cbf0d3e..a5129e0e8 100644 --- a/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff +++ b/tests/mir-opt/inline/inline_into_box_place.main.Inline.diff @@ -4,81 +4,78 @@ 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: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _3: usize; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _4: *mut u8; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _5: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - let mut _6: (); // in scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 - let mut _7: *const std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 -+ let mut _8: &mut std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ let mut _9: std::vec::Vec<u32>; // in scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 + 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 { - } -+ scope 3 (inlined Vec::<u32>::new) { // at $DIR/inline_into_box_place.rs:8:33: 8:43 -+ let mut _10: alloc::raw_vec::RawVec<u32>; // in scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL ++ 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 - _2 = SizeOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _3 = AlignOf(std::vec::Vec<u32>); // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1; // scope 2 at $DIR/inline_into_box_place.rs:+1:29: +1:43 + StorageLive(_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:29: 8:43 - // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) } +- // + 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: { - StorageLive(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _5 = ShallowInitBox(move _4, std::vec::Vec<u32>); // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - _7 = (((_5.0: std::ptr::Unique<std::vec::Vec<u32>>).0: std::ptr::NonNull<std::vec::Vec<u32>>).0: *const std::vec::Vec<u32>); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -- (*_7) = Vec::<u32>::new() -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageLive(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ _8 = &mut (*_7); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageLive(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageLive(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ _10 = const _; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL - // mir::Constant -- // + span: $DIR/inline_into_box_place.rs:8:33: 8:41 +- _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> {Vec::<u32>::new}, val: Value(<ZST>) } -- } -- +- // + 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: { -+ // + 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) } -+ _9 = Vec::<u32> { buf: move _10, len: const 0_usize }; // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ StorageDead(_10); // scope 3 at $SRC_DIR/alloc/src/vec/mod.rs:LL:COL -+ (*_8) = move _9; // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageDead(_9); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 -+ StorageDead(_8); // scope 0 at $DIR/inline_into_box_place.rs:+1:33: +1:43 - _1 = move _5; // scope 0 at $DIR/inline_into_box_place.rs:+1:29: +1:43 - StorageDead(_5); // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 - _0 = const (); // scope 0 at $DIR/inline_into_box_place.rs:+0:11: +2:2 +- 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 -+ drop(_1) -> [return: bb2, unwind: bb3]; // 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: { -+ bb2: { - StorageDead(_1); // scope 0 at $DIR/inline_into_box_place.rs:+2:1: +2:2 - return; // scope 0 at $DIR/inline_into_box_place.rs:+2:2: +2:2 + 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): { -+ bb3 (cleanup): { - resume; // scope 0 at $DIR/inline_into_box_place.rs:+0:1: +2:2 -- } -- -- bb5 (cleanup): { -- _6 = alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>(move (_5.0: std::ptr::Unique<std::vec::Vec<u32>>), move (_5.1: std::alloc::Global)) -> bb4; // scope 0 at $DIR/inline_into_box_place.rs:+1:42: +1:43 -- // mir::Constant -- // + span: $DIR/inline_into_box_place.rs:8:42: 8:43 -- // + literal: Const { ty: unsafe fn(Unique<Vec<u32>>, std::alloc::Global) {alloc::alloc::box_free::<Vec<u32>, std::alloc::Global>}, val: Value(<ZST>) } + 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.rs b/tests/mir-opt/inline/inline_into_box_place.rs index 232bcc7b2..02823e4e1 100644 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ b/tests/mir-opt/inline/inline_into_box_place.rs @@ -1,9 +1,9 @@ // ignore-endian-big // ignore-wasm32-bare compiled with panic=abort by default +// ignore-debug MIR alignment checks in std alter the diff, breaking the test // compile-flags: -Z mir-opt-level=4 -#![feature(box_syntax)] // EMIT_MIR inline_into_box_place.main.Inline.diff fn main() { - let _x: Box<Vec<u32>> = box Vec::new(); + let _x: Box<Vec<u32>> = Box::new(Vec::new()); } diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.mir index 1c590be94..a2938ead0 100644 --- a/tests/mir-opt/inline/inline_options.main.Inline.after.mir +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.mir @@ -4,52 +4,52 @@ 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:10:5: 10:21 - let _3: (); // in scope 1 at $DIR/inline_options.rs:16:23: 16:26 - let _4: (); // in scope 1 at $DIR/inline_options.rs:16:28: 16:31 - let _5: (); // in scope 1 at $DIR/inline_options.rs:16:33: 16:36 + 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:9:5: 9:16 + // + 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 1 at $DIR/inline_options.rs:16:23: 16:26 - _3 = g() -> bb2; // scope 1 at $DIR/inline_options.rs:16:23: 16:26 + 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:16:23: 16:24 + // + span: $DIR/inline_options.rs:17:23: 17:24 // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } } bb2: { - StorageDead(_3); // scope 1 at $DIR/inline_options.rs:16:26: 16:27 - StorageLive(_4); // scope 1 at $DIR/inline_options.rs:16:28: 16:31 - _4 = g() -> bb3; // scope 1 at $DIR/inline_options.rs:16:28: 16:31 - // mir::Constant - // + span: $DIR/inline_options.rs:16:28: 16:29 - // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } + 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: { - StorageDead(_4); // scope 1 at $DIR/inline_options.rs:16:31: 16:32 - StorageLive(_5); // scope 1 at $DIR/inline_options.rs:16:33: 16:36 - _5 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:16:33: 16:36 + _4 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:17:28: 17:31 // mir::Constant - // + span: $DIR/inline_options.rs:16:33: 16:34 + // + span: $DIR/inline_options.rs:17:28: 17:29 // + literal: Const { ty: fn() {g}, val: Value(<ZST>) } } bb4: { - StorageDead(_5); // scope 1 at $DIR/inline_options.rs:16:36: 16:37 - StorageDead(_2); // scope 0 at $DIR/inline_options.rs:+2:21: +2:22 - _0 = const (); // scope 0 at $DIR/inline_options.rs:+0:11: +3:2 - return; // scope 0 at $DIR/inline_options.rs:+3:2: +3:2 + _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.rs b/tests/mir-opt/inline/inline_options.rs index 477f050b6..f0a898832 100644 --- a/tests/mir-opt/inline/inline_options.rs +++ b/tests/mir-opt/inline/inline_options.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // Checks that inlining threshold can be controlled with // inline-mir-threshold and inline-hint-threshold options. // diff --git a/tests/mir-opt/inline/inline_specialization.main.Inline.diff b/tests/mir-opt/inline/inline_specialization.main.Inline.diff index af08296ed..9dde9994d 100644 --- a/tests/mir-opt/inline/inline_specialization.main.Inline.diff +++ b/tests/mir-opt/inline/inline_specialization.main.Inline.diff @@ -7,19 +7,19 @@ 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:5:13: 5:38 ++ 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:5:13: 5:36 +- // + 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:14:31: 14:34 ++ _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.rs b/tests/mir-opt/inline/inline_specialization.rs index 87275b4e5..c24795e05 100644 --- a/tests/mir-opt/inline/inline_specialization.rs +++ b/tests/mir-opt/inline/inline_specialization.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default #![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 74be53f55..6aa957eb5 100644 --- a/tests/mir-opt/inline/inline_trait_method.rs +++ b/tests/mir-opt/inline/inline_trait_method.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index 637bf282a..a9020a5bb 100644 --- a/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir +++ b/tests/mir-opt/inline/inline_trait_method.test.Inline.after.mir @@ -10,7 +10,7 @@ fn test(_1: &dyn X) -> u32 { _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:9:7: 9:8 + // + 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>) } } diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs index 378e71a25..07a601908 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.rs +++ b/tests/mir-opt/inline/inline_trait_method_2.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default // 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 index b7c5bbecb..a4bbecf3b 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir +++ b/tests/mir-opt/inline/inline_trait_method_2.test2.Inline.after.mir @@ -5,8 +5,8 @@ fn test2(_1: &dyn X) -> bool { let mut _0: bool; // return place in scope 0 at $DIR/inline_trait_method_2.rs:+0:24: +0:28 let mut _2: &dyn X; // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 let mut _3: &dyn X; // in scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 - scope 1 (inlined test) { // at $DIR/inline_trait_method_2.rs:5:5: 5:12 - debug x => _2; // in scope 1 at $DIR/inline_trait_method_2.rs:9:9: 9:10 + 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: { @@ -15,9 +15,9 @@ fn test2(_1: &dyn X) -> bool { _3 = &(*_1); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 _2 = move _3 as &dyn X (Pointer(Unsize)); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 StorageDead(_3); // scope 0 at $DIR/inline_trait_method_2.rs:+1:10: +1:11 - _0 = <dyn X as X>::y(_2) -> bb1; // scope 1 at $DIR/inline_trait_method_2.rs:10:5: 10:10 + _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:10:7: 10:8 + // + 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>) } } diff --git a/tests/mir-opt/inline/issue_106141.outer.Inline.diff b/tests/mir-opt/inline/issue_106141.outer.Inline.diff index 97361fa5f..18df6f9af 100644 --- a/tests/mir-opt/inline/issue_106141.outer.Inline.diff +++ b/tests/mir-opt/inline/issue_106141.outer.Inline.diff @@ -3,14 +3,14 @@ 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:2:5: 2:12 -+ let mut _1: bool; // in scope 1 at $DIR/issue_106141.rs:13:8: 13:21 -+ let mut _2: bool; // in scope 1 at $DIR/issue_106141.rs:13:8: 13:21 -+ let mut _3: &[bool; 1]; // in scope 1 at $DIR/issue_106141.rs:11:18: 11:25 ++ 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 => _3; // in scope 2 at $DIR/issue_106141.rs:11:9: 11:15 ++ debug buffer => _3; // 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:12:9: 12:14 ++ debug index => _0; // in scope 3 at $DIR/issue_106141.rs:13:9: 13:14 + } + } + } @@ -18,36 +18,36 @@ 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:11:18: 11:25 ++ _3 = const _; // scope 1 at $DIR/issue_106141.rs:12:18: 12:25 // mir::Constant -- // + span: $DIR/issue_106141.rs:2:5: 2:10 +- // + span: $DIR/issue_106141.rs:3:5: 3:10 - // + literal: Const { ty: fn() -> usize {inner}, val: Value(<ZST>) } -+ // + span: $DIR/issue_106141.rs:11:18: 11:25 ++ // + 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:12:17: 12:24 ++ _0 = index() -> bb1; // scope 2 at $DIR/issue_106141.rs:13:17: 13:24 + // mir::Constant -+ // + span: $DIR/issue_106141.rs:12:17: 12:22 ++ // + 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:13:8: 13:21 -+ _2 = Lt(_0, const 1_usize); // scope 3 at $DIR/issue_106141.rs:13:8: 13: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:13:8: 13:21 ++ 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:13:8: 13:21 -+ switchInt(move _1) -> [0: bb3, otherwise: bb4]; // scope 3 at $DIR/issue_106141.rs:13:8: 13:21 ++ _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:16:9: 16:10 -+ goto -> bb4; // scope 3 at $DIR/issue_106141.rs:13:5: 17:6 ++ _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:17:5: 17:6 ++ 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.rs b/tests/mir-opt/inline/issue_106141.rs index c8288b7f3..b6bd806e6 100644 --- a/tests/mir-opt/inline/issue_106141.rs +++ b/tests/mir-opt/inline/issue_106141.rs @@ -1,3 +1,4 @@ +// ignore-wasm32 compiled with panic=abort by default pub fn outer() -> usize { inner() } 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 4dd1aad48..1da3c8bb7 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 @@ -10,10 +10,9 @@ fn main() -> () { scope 1 { debug f => _1; // in scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:9: +1:10 scope 2 (inlined main::{closure#0}) { // at $DIR/issue_76997_inline_scopes_parenting.rs:6:5: 6:10 - debug x => _5; // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:14: +1:15 - let _6: (); // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 + debug x => const (); // in scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:14: +1:15 scope 3 { - debug y => _6; // in scope 3 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 + debug y => const (); // in scope 3 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 } } } @@ -22,7 +21,7 @@ fn main() -> () { 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[bc59]::main::{closure#0}) + // + def_id: DefId(0:4 ~ issue_76997_inline_scopes_parenting[5cd2]::main::{closure#0}) // + substs: [ // i8, // extern "rust-call" fn(((),)), @@ -36,8 +35,6 @@ fn main() -> () { _3 = (move _4,); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 StorageLive(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 _5 = move (_3.0: ()); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 - StorageLive(_6); // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:23: +1:24 - StorageDead(_6); // scope 2 at $DIR/issue_76997_inline_scopes_parenting.rs:+1:32: +1:33 StorageDead(_5); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:5: +2:10 StorageDead(_4); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 StorageDead(_3); // scope 1 at $DIR/issue_76997_inline_scopes_parenting.rs:+2:9: +2:10 diff --git a/tests/mir-opt/inline/issue_78442.bar.Inline.diff b/tests/mir-opt/inline/issue_78442.bar.Inline.diff index aa62e4a16..dc3fe7555 100644 --- a/tests/mir-opt/inline/issue_78442.bar.Inline.diff +++ b/tests/mir-opt/inline/issue_78442.bar.Inline.diff @@ -46,11 +46,11 @@ - bb3: { - return; // scope 0 at $DIR/issue_78442.rs:+5:2: +5:2 + bb3 (cleanup): { -+ drop(_1) -> bb4; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 ++ drop(_1) -> [return: bb4, unwind terminate]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } bb4 (cleanup): { -- drop(_1) -> bb5; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 +- 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 } diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff index 21055c6bf..8f56ef258 100644 --- a/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.diff @@ -47,7 +47,7 @@ } bb4 (cleanup): { - drop(_1) -> bb5; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 + drop(_1) -> [return: bb5, unwind terminate]; // scope 0 at $DIR/issue_78442.rs:+5:1: +5:2 } bb5 (cleanup): { diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs new file mode 100644 index 000000000..17724530d --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -0,0 +1,18 @@ +// ignore-wasm32 compiled with panic=abort by default +#![crate_type = "lib"] +#![feature(unchecked_math)] + +// ignore-debug: the debug assertions prevent the inlining we are testing for +// compile-flags: -Zmir-opt-level=2 -Zinline-mir + +// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff +// EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir +pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { + a.unchecked_shl(b) +} + +// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff +// EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir +pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 { + a.unchecked_shr(b) +} 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 new file mode 100644 index 000000000..6184a0acd --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff @@ -0,0 +1,144 @@ +- // 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/uint_macros.rs:LL:COL ++ let mut _6: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ scope 2 { ++ scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ } ++ scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 6 { ++ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 7 { ++ scope 8 { ++ debug x => const TryFromIntError(()); // 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/uint_macros.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 => _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 => _13; // 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/uint_macros.rs:LL:COL ++ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { ++ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ ++ bb2: { ++ 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 ++ } ++ ++ bb3: { ++ _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb4: { ++ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb5: { ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb6: { ++ _6 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb7: { ++ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb8: { ++ _12 = move ((_7 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<u16>::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb9: { ++ _5 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL ++ _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb2, 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.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir new file mode 100644 index 000000000..726b6bbf9 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir @@ -0,0 +1,130 @@ +// 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/uint_macros.rs:LL:COL + let mut _4: std::option::Option<u16>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _5: std::result::Result<u16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 2 { + scope 3 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 4 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: u16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 5 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _10: u16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + scope 6 { + debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 7 { + scope 8 { + debug x => const TryFromIntError(()); // 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/uint_macros.rs:LL:COL + debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _11: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: 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 => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } + } + + bb0: { + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = const 65535_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { + StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb2: { + 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 + } + + bb3: { + _5 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = _2 as u16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = Result::<u16, TryFromIntError>::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb5: { + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { + _4 = Option::<u16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { + unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { + _10 = move ((_5 as Ok).0: u16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::<u16>::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb9: { + _3 = move ((_4 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _0 = unchecked_shl::<u16>(_1, move _3) -> [return: bb2, 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_shr_signed_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff new file mode 100644 index 000000000..35d5b6e72 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff @@ -0,0 +1,144 @@ +- // 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/int_macros.rs:LL:COL ++ let mut _6: std::option::Option<i16>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ let mut _7: std::result::Result<i16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ scope 2 { ++ scope 3 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _4; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ scope 4 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug u => _4; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ } ++ scope 5 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ debug self => _7; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ scope 6 { ++ debug x => _12; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ scope 7 { ++ scope 8 { ++ debug x => const TryFromIntError(()); // 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/int_macros.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 => _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 => _13; // 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/int_macros.rs:LL:COL ++ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { ++ StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ } ++ ++ bb2: { ++ 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 ++ } ++ ++ bb3: { ++ _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb4: { ++ StorageLive(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<i16, TryFromIntError>::Ok(move _10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ } ++ ++ bb5: { ++ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _11 = discriminant(_7); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb6: { ++ _6 = Option::<i16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb7: { ++ unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb8: { ++ _12 = move ((_7 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<i16>::Some(move _12); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL ++ goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL ++ } ++ ++ bb9: { ++ _5 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL ++ _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb2, 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.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir new file mode 100644 index 000000000..b006085b5 --- /dev/null +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir @@ -0,0 +1,130 @@ +// 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/int_macros.rs:LL:COL + let mut _4: std::option::Option<i16>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _5: std::result::Result<i16, std::num::TryFromIntError>; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + scope 2 { + scope 3 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _2; // in scope 3 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 4 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug u => _2; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _6: bool; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _7: u32; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _8: i16; // in scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 5 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _10: i16; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + scope 6 { + debug x => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + } + scope 7 { + scope 8 { + debug x => const TryFromIntError(()); // 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/int_macros.rs:LL:COL + debug self => _4; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _11: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: 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 => _11; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } + } + + bb0: { + StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _7 = const 32767_u32; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Gt(_2, move _7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _6) -> [0: bb4, otherwise: bb3]; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb1: { + StorageDead(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _12 = discriminant(_4); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _12) -> [1: bb9, otherwise: bb7]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb2: { + 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 + } + + bb3: { + _5 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _8 = _2 as i16 (IntToInt); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = Result::<i16, TryFromIntError>::Ok(move _8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_8); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb5; // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb5: { + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_10); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _9 = discriminant(_5); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _9) -> [0: bb8, 1: bb6, otherwise: bb7]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb6: { + _4 = Option::<i16>::None; // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb7: { + unreachable; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { + _10 = move ((_5 as Ok).0: i16); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _4 = Option::<i16>::Some(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb9: { + _3 = move ((_4 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _0 = unchecked_shr::<i16>(_1, move _3) -> [return: bb2, 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/unwrap_unchecked.rs b/tests/mir-opt/inline/unwrap_unchecked.rs new file mode 100644 index 000000000..5856f1479 --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.rs @@ -0,0 +1,11 @@ +#![crate_type = "lib"] + +// ignore-wasm32-bare compiled with panic=abort by default +// ignore-debug: the debug assertions prevent the inlining we are testing for +// compile-flags: -Zmir-opt-level=2 -Zinline-mir + +// EMIT_MIR unwrap_unchecked.unwrap_unchecked.Inline.diff +// EMIT_MIR unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir +pub unsafe fn unwrap_unchecked<T>(slf: Option<T>) -> T { + slf.unwrap_unchecked() +} diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff new file mode 100644 index 000000000..543ddcfc4 --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.diff @@ -0,0 +1,55 @@ +- // 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) -> [0: bb1, 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.PreCodegen.after.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir new file mode 100644 index 000000000..c5e2469fc --- /dev/null +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir @@ -0,0 +1,41 @@ +// 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 + } +} |