diff options
| author | Ana-Maria Mihalache <mihalacheana.maria@yahoo.com> | 2020-04-04 17:15:01 +0000 |
|---|---|---|
| committer | Ana-Maria Mihalache <mihalacheana.maria@yahoo.com> | 2020-04-07 17:49:14 +0000 |
| commit | 688a4ddd20742f94155ec47fa2c1a96e1e3d78d3 (patch) | |
| tree | 448f4434be52f28469efcdefd9bec5aa54243233 /src/test/mir-opt/inline | |
| parent | ef88769e4fd74cea5cc4f0c03259d6ee8a119e0f (diff) | |
| download | rust-688a4ddd20742f94155ec47fa2c1a96e1e3d78d3.tar.gz rust-688a4ddd20742f94155ec47fa2c1a96e1e3d78d3.zip | |
--bless more mir-opt tests.
Diffstat (limited to 'src/test/mir-opt/inline')
18 files changed, 474 insertions, 280 deletions
diff --git a/src/test/mir-opt/inline/inline-any-operand.rs b/src/test/mir-opt/inline/inline-any-operand.rs index b5455003719..2edde12d72e 100644 --- a/src/test/mir-opt/inline/inline-any-operand.rs +++ b/src/test/mir-opt/inline/inline-any-operand.rs @@ -6,6 +6,7 @@ fn main() { println!("{}", bar()); } +// EMIT_MIR rustc.bar.Inline.after.mir fn bar() -> bool { let f = foo; f(1, -1) @@ -15,15 +16,3 @@ fn bar() -> bool { fn foo(x: i32, y: i32) -> bool { x == y } - -// END RUST SOURCE -// START rustc.bar.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = Eq(move _3, move _4); -// ... -// return; -// } -// ... -// END rustc.bar.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir new file mode 100644 index 00000000000..058d9e70d26 --- /dev/null +++ b/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir @@ -0,0 +1,47 @@ +// MIR for `bar` after Inline + +fn bar() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/inline-any-operand.rs:10:13: 10:17 + let _1: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10 + let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:6 + let mut _3: i32; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13 + let mut _4: i32; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13 + scope 1 { + debug f => _1; // in scope 1 at $DIR/inline-any-operand.rs:11:9: 11:10 + scope 2 { + debug x => _3; // in scope 2 at $DIR/inline-any-operand.rs:16:8: 16:9 + debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:16:16: 16:17 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10 + _1 = const foo; // bb0[1]: scope 0 at $DIR/inline-any-operand.rs:11:13: 11:16 + // ty::Const + // + ty: fn(i32, i32) -> bool {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:11:13: 11:16 + // + literal: Const { ty: fn(i32, i32) -> bool {foo}, val: Value(Scalar(<ZST>)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6 + _2 = _1; // bb0[3]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6 + _3 = const 1i32; // bb0[4]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:12:7: 12:8 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + _4 = const -1i32; // bb0[5]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0xffffffff)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:12:10: 12:12 + // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) } + _0 = Eq(move _3, move _4); // bb0[6]: scope 2 at $DIR/inline-any-operand.rs:17:5: 17:11 + StorageDead(_2); // bb0[7]: scope 1 at $DIR/inline-any-operand.rs:12:12: 12:13 + StorageDead(_1); // bb0[8]: scope 0 at $DIR/inline-any-operand.rs:13:1: 13:2 + return; // bb0[9]: scope 0 at $DIR/inline-any-operand.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs b/src/test/mir-opt/inline/inline-closure-borrows-arg.rs index 768f4953228..a82a91945d8 100644 --- a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs +++ b/src/test/mir-opt/inline/inline-closure-borrows-arg.rs @@ -7,6 +7,7 @@ fn main() { println!("{}", foo(0, &14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(_t: T, q: &i32) -> i32 { let x = |r: &i32, _s: &i32| { let variable = &*r; @@ -14,46 +15,3 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 { }; x(q, q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: &i32) -> i32{ -// debug _t => _1; -// debug q => _2; -// let mut _0: i32; -// let _3: [closure@foo<T>::{{closure}}#0]; -// let mut _4: &[closure@foo<T>::{{closure}}#0]; -// let mut _5: (&i32, &i32); -// let mut _6: &i32; -// let mut _7: &i32; -// let mut _8: &i32; -// let mut _9: &i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug r => _8; -// debug _s => _9; -// } -// } -// scope 3 { -// debug variable => _8; -// } -// bb0: { -// ... -// _3 = [closure@foo::<T>::{{closure}}#0]; -// ... -// _4 = &_3; -// ... -// _6 = &(*_2); -// ... -// _7 = &(*_2); -// _5 = (move _6, move _7); -// _8 = move (_5.0: &i32); -// _9 = move (_5.1: &i32); -// ... -// _0 = (*_8); -// ... -// return; -// } -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..a8e846d1181 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir @@ -0,0 +1,54 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: &i32) -> i32 { + debug _t => _1; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:17: 11:19 + debug q => _2; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:24: 11:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:36: 11:39 + let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + let mut _5: (&i32, &i32); // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let mut _6: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + let mut _7: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + let mut _8: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let mut _9: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + scope 2 { + debug r => _8; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:14: 12:15 + debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:23: 12:25 + } + } + scope 3 { + debug variable => _8; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: scope 0 at $DIR/inline-closure-borrows-arg.rs:12:13: 15:6 + // closure + // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[317d]::foo[0]::{{closure}}[0]) + // + substs: [ + // T, + // i8, + // for<'r, 's> extern "rust-call" fn((&'r i32, &'s i32)) -> i32, + // (), + // ] + StorageLive(_4); // bb0[2]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + _4 = &_3; // bb0[3]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + StorageLive(_5); // bb0[4]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + StorageLive(_6); // bb0[5]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + _6 = &(*_2); // bb0[6]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + StorageLive(_7); // bb0[7]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + _7 = &(*_2); // bb0[8]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + _5 = (move _6, move _7); // bb0[9]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _8 = move (_5.0: &i32); // bb0[10]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _9 = move (_5.1: &i32); // bb0[11]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _0 = (*_8); // bb0[12]: scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18 + StorageDead(_7); // bb0[13]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_6); // bb0[14]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_5); // bb0[15]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_4); // bb0[16]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_3); // bb0[17]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:1: 17:2 + return; // bb0[18]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:2: 17:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure-captures.rs b/src/test/mir-opt/inline/inline-closure-captures.rs index e000a418d90..4a0aad9b0e6 100644 --- a/src/test/mir-opt/inline/inline-closure-captures.rs +++ b/src/test/mir-opt/inline/inline-closure-captures.rs @@ -6,55 +6,8 @@ fn main() { println!("{:?}", foo(0, 14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(t: T, q: i32) -> (i32, T) { let x = |_q| (q, t); x(q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: i32) -> (i32, T){ -// debug t => _1; -// debug q => _2; -// let mut _0: (i32, T); -// let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; -// let mut _4: &i32; -// let mut _5: &T; -// let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; -// let mut _7: (i32,); -// let mut _8: i32; -// let mut _11: i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug _q => _11; -// debug q => (*((*_6).0: &i32)); -// debug t => (*((*_6).1: &T)); -// let mut _9: i32; -// let mut _10: T; -// } -// } -// bb0: { -// ... -// _4 = &_2; -// ... -// _5 = &_1; -// _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; -// ... -// _6 = &_3; -// ... -// ... -// _8 = _2; -// _7 = (move _8,); -// _11 = move (_7.0: i32); -// ... -// _9 = (*((*_6).0: &i32)); -// ... -// _10 = (*((*_6).1: &T)); -// (_0.0: i32) = move _9; -// (_0.1: T) = move _10; -// ... -// return; -// } -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..8f7c5615662 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir @@ -0,0 +1,63 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: i32) -> (i32, T) { + debug t => _1; // in scope 0 at $DIR/inline-closure-captures.rs:10:17: 10:18 + debug q => _2; // in scope 0 at $DIR/inline-closure-captures.rs:10:23: 10:24 + let mut _0: (i32, T); // return place in scope 0 at $DIR/inline-closure-captures.rs:10:34: 10:42 + let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10 + let mut _4: &i32; // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + let mut _5: &T; // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:6 + let mut _7: (i32,); // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _8: i32; // in scope 0 at $DIR/inline-closure-captures.rs:12:7: 12:8 + let mut _11: i32; // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure-captures.rs:11:9: 11:10 + scope 2 { + debug _q => _11; // in scope 2 at $DIR/inline-closure-captures.rs:11:14: 11:16 + debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:10:23: 10:24 + debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18 + let mut _9: i32; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + } + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10 + StorageLive(_4); // bb0[1]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _4 = &_2; // bb0[2]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + StorageLive(_5); // bb0[3]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _5 = &_1; // bb0[4]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; // bb0[5]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + // closure + // + def_id: DefId(0:6 ~ inline_closure_captures[317d]::foo[0]::{{closure}}[0]) + // + substs: [ + // T, + // i8, + // extern "rust-call" fn((i32,)) -> (i32, T), + // (&i32, &T), + // ] + StorageDead(_5); // bb0[6]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_4); // bb0[7]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageLive(_6); // bb0[8]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6 + _6 = &_3; // bb0[9]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6 + StorageLive(_7); // bb0[10]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_8); // bb0[11]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 + _8 = _2; // bb0[12]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 + _7 = (move _8,); // bb0[13]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + _11 = move (_7.0: i32); // bb0[14]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_9); // bb0[15]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 + _9 = (*((*_6).0: &i32)); // bb0[16]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 + StorageLive(_10); // bb0[17]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + _10 = (*((*_6).1: &T)); // bb0[18]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + (_0.0: i32) = move _9; // bb0[19]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 + (_0.1: T) = move _10; // bb0[20]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 + StorageDead(_10); // bb0[21]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_9); // bb0[22]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_8); // bb0[23]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_7); // bb0[24]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_6); // bb0[25]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_3); // bb0[26]: scope 0 at $DIR/inline-closure-captures.rs:13:1: 13:2 + return; // bb0[27]: scope 0 at $DIR/inline-closure-captures.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure.rs b/src/test/mir-opt/inline/inline-closure.rs index bd36e77818e..77e424a2bb3 100644 --- a/src/test/mir-opt/inline/inline-closure.rs +++ b/src/test/mir-opt/inline/inline-closure.rs @@ -6,45 +6,8 @@ fn main() { println!("{}", foo(0, 14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(_t: T, q: i32) -> i32 { let x = |_t, _q| _t; x(q, q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: i32) -> i32{ -// debug _t => _1; -// debug q => _2; -// let mut _0: i32; -// let _3: [closure@foo<T>::{{closure}}#0]; -// let mut _4: &[closure@foo<T>::{{closure}}#0]; -// let mut _5: (i32, i32); -// let mut _6: i32; -// let mut _7: i32; -// let mut _8: i32; -// let mut _9: i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug _t => _8; -// debug _q => _9; -// } -// } -// bb0: { -// ... -// _3 = [closure@foo::<T>::{{closure}}#0]; -// ... -// _4 = &_3; -// ... -// _6 = _2; -// ... -// _7 = _2; -// _5 = (move _6, move _7); -// _8 = move (_5.0: i32); -// _9 = move (_5.1: i32); -// _0 = _8; -// ... -// return; -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..e31032e8c69 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir @@ -0,0 +1,51 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: i32) -> i32 { + debug _t => _1; // in scope 0 at $DIR/inline-closure.rs:10:17: 10:19 + debug q => _2; // in scope 0 at $DIR/inline-closure.rs:10:24: 10:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline-closure.rs:10:35: 10:38 + let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:11:9: 11:10 + let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:6 + let mut _5: (i32, i32); // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + let mut _6: i32; // in scope 0 at $DIR/inline-closure.rs:12:7: 12:8 + let mut _7: i32; // in scope 0 at $DIR/inline-closure.rs:12:10: 12:11 + let mut _8: i32; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + let mut _9: i32; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure.rs:11:9: 11:10 + scope 2 { + debug _t => _8; // in scope 2 at $DIR/inline-closure.rs:11:14: 11:16 + debug _q => _9; // in scope 2 at $DIR/inline-closure.rs:11:18: 11:20 + } + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure.rs:11:9: 11:10 + _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: scope 0 at $DIR/inline-closure.rs:11:13: 11:24 + // closure + // + def_id: DefId(0:6 ~ inline_closure[317d]::foo[0]::{{closure}}[0]) + // + substs: [ + // T, + // i8, + // extern "rust-call" fn((i32, i32)) -> i32, + // (), + // ] + StorageLive(_4); // bb0[2]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6 + _4 = &_3; // bb0[3]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6 + StorageLive(_5); // bb0[4]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + StorageLive(_6); // bb0[5]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8 + _6 = _2; // bb0[6]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8 + StorageLive(_7); // bb0[7]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11 + _7 = _2; // bb0[8]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11 + _5 = (move _6, move _7); // bb0[9]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _8 = move (_5.0: i32); // bb0[10]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _9 = move (_5.1: i32); // bb0[11]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _0 = _8; // bb0[12]: scope 2 at $DIR/inline-closure.rs:11:22: 11:24 + StorageDead(_7); // bb0[13]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_6); // bb0[14]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_5); // bb0[15]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_4); // bb0[16]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_3); // bb0[17]: scope 0 at $DIR/inline-closure.rs:13:1: 13:2 + return; // bb0[18]: scope 0 at $DIR/inline-closure.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-into-box-place.rs b/src/test/mir-opt/inline/inline-into-box-place.rs index fcb7b4c4fe6..d36d93cd01c 100644 --- a/src/test/mir-opt/inline/inline-into-box-place.rs +++ b/src/test/mir-opt/inline/inline-into-box-place.rs @@ -1,73 +1,9 @@ -// ignore-tidy-linelength // ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -Z mir-opt-level=3 // only-64bit FIXME: the mir representation of RawVec depends on ptr size #![feature(box_syntax)] +// EMIT_MIR rustc.main.Inline.diff fn main() { let _x: Box<Vec<u32>> = box Vec::new(); } - -// END RUST SOURCE -// START rustc.main.Inline.before.mir -// let mut _0: (); -// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; -// let mut _2: std::boxed::Box<std::vec::Vec<u32>>; -// let mut _3: (); -// scope 1 { -// debug _x => _1; -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(std::vec::Vec<u32>); -// (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// _1 = move _2; -// StorageDead(_2); -// _0 = (); -// drop(_1) -> [return: bb3, unwind: bb1]; -// } -// bb3: { -// StorageDead(_1); -// return; -// } -// bb4 (cleanup): { -// _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1; -// } -// END rustc.main.Inline.before.mir -// START rustc.main.Inline.after.mir -// let mut _0: (); -// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; -// let mut _2: std::boxed::Box<std::vec::Vec<u32>>; -// let mut _3: (); -// let mut _4: &mut std::vec::Vec<u32>; -// scope 1 { -// debug _x => _1; -// } -// scope 2 { -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(std::vec::Vec<u32>); -// _4 = &mut (*_2); -// ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>; -// ((*_4).1: usize) = const 0usize; -// _1 = move _2; -// StorageDead(_2); -// _0 = (); -// drop(_1) -> [return: bb2, unwind: bb1]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff new file mode 100644 index 00000000000..a0db20cbb74 --- /dev/null +++ b/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff @@ -0,0 +1,76 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/inline-into-box-place.rs:7:11: 7:11 + let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + let mut _2: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 + let mut _3: (); // in scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 ++ let mut _4: &mut std::vec::Vec<u32>; // in scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + scope 1 { + debug _x => _1; // in scope 1 at $DIR/inline-into-box-place.rs:8:9: 8:11 + } ++ scope 2 { ++ } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 + _2 = Box(std::vec::Vec<u32>); // bb0[2]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 +- (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4]; // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ _4 = &mut (*_2); // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL + // ty::Const +- // + ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new} +- // + val: Value(Scalar(<ZST>)) ++ // + ty: alloc::raw_vec::RawVec<u32> ++ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant +- // + span: $DIR/inline-into-box-place.rs:8:33: 8:41 +- // + user_ty: UserType(1) +- // + literal: Const { ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new}, val: Value(Scalar(<ZST>)) } ++ // + span: $SRC_DIR/liballoc/vec.rs:LL:COL ++ // + user_ty: UserType(0) ++ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } ++ ((*_4).1: usize) = const 0usize; // bb0[5]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x0000000000000000)) ++ // mir::Constant ++ // + span: $SRC_DIR/liballoc/vec.rs:LL:COL ++ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } ++ _1 = move _2; // bb0[6]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 ++ StorageDead(_2); // bb0[7]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 ++ _0 = (); // bb0[8]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 ++ drop(_1) -> [return: bb2, unwind: bb1]; // bb0[9]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/inline-into-box-place.rs:7:1: 9:2 + } + + bb2: { +- _1 = move _2; // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 +- StorageDead(_2); // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 +- _0 = (); // bb2[2]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 +- drop(_1) -> [return: bb3, unwind: bb1]; // bb2[3]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 +- } +- +- bb3: { +- StorageDead(_1); // bb3[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 +- return; // bb3[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2 +- } +- +- bb4 (cleanup): { +- _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1; // bb4[0]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 +- // ty::Const +- // + ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>} +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/inline-into-box-place.rs:8:42: 8:43 +- // + literal: Const { ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>}, val: Value(Scalar(<ZST>)) } ++ StorageDead(_1); // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 ++ return; // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2 + } + } + diff --git a/src/test/mir-opt/inline/inline-retag.rs b/src/test/mir-opt/inline/inline-retag.rs index 7b78fc339f2..d7e425ec658 100644 --- a/src/test/mir-opt/inline/inline-retag.rs +++ b/src/test/mir-opt/inline/inline-retag.rs @@ -6,6 +6,7 @@ fn main() { println!("{}", bar()); } +// EMIT_MIR rustc.bar.Inline.after.mir fn bar() -> bool { let f = foo; f(&1, &-1) @@ -15,23 +16,3 @@ fn bar() -> bool { fn foo(x: &i32, y: &i32) -> bool { *x == *y } - -// END RUST SOURCE -// START rustc.bar.Inline.after.mir -// ... -// bb0: { -// ... -// Retag(_3); -// ... -// Retag(_3); -// Retag(_6); -// StorageLive(_11); -// _11 = (*_3); -// StorageLive(_12); -// _12 = (*_6); -// _0 = Eq(move _11, move _12); -// ... -// return; -// } -// ... -// END rustc.bar.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir new file mode 100644 index 00000000000..ae2226bd183 --- /dev/null +++ b/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir @@ -0,0 +1,81 @@ +// MIR for `bar` after Inline + +fn bar() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/inline-retag.rs:10:13: 10:17 + let _1: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:11:9: 11:10 + let mut _2: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:12:5: 12:6 + let mut _3: &i32; // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9 + let _4: &i32; // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9 + let _5: i32; // in scope 0 at $DIR/inline-retag.rs:12:8: 12:9 + let mut _6: &i32; // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14 + let _7: &i32; // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14 + let _8: i32; // in scope 0 at $DIR/inline-retag.rs:12:12: 12:14 + scope 1 { + debug f => _1; // in scope 1 at $DIR/inline-retag.rs:11:9: 11:10 + let mut _9: &i32; // in scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + let mut _10: &i32; // in scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + scope 2 { + debug x => _3; // in scope 2 at $DIR/inline-retag.rs:16:8: 16:9 + debug y => _6; // in scope 2 at $DIR/inline-retag.rs:16:17: 16:18 + let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-retag.rs:11:9: 11:10 + _1 = const foo; // bb0[1]: scope 0 at $DIR/inline-retag.rs:11:13: 11:16 + // ty::Const + // + ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-retag.rs:11:13: 11:16 + // + literal: Const { ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}, val: Value(Scalar(<ZST>)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6 + _2 = _1; // bb0[3]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + StorageLive(_4); // bb0[5]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _10 = const bar::promoted[1]; // bb0[6]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1])) + // mir::Constant + // + span: $DIR/inline-retag.rs:12:7: 12:9 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1])) } + Retag(_10); // bb0[7]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _4 = &(*_10); // bb0[8]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + Retag(_4); // bb0[9]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _3 = &(*_4); // bb0[10]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + Retag(_3); // bb0[11]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + StorageLive(_6); // bb0[12]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + StorageLive(_7); // bb0[13]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _9 = const bar::promoted[0]; // bb0[14]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/inline-retag.rs:12:11: 12:14 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0])) } + Retag(_9); // bb0[15]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _7 = &(*_9); // bb0[16]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_7); // bb0[17]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _6 = &(*_7); // bb0[18]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_6); // bb0[19]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_3); // bb0[20]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2 + Retag(_6); // bb0[21]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2 + StorageLive(_11); // bb0[22]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7 + _11 = (*_3); // bb0[23]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7 + StorageLive(_12); // bb0[24]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + _12 = (*_6); // bb0[25]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + _0 = Eq(move _11, move _12); // bb0[26]: scope 2 at $DIR/inline-retag.rs:17:5: 17:13 + StorageDead(_12); // bb0[27]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13 + StorageDead(_11); // bb0[28]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13 + StorageDead(_6); // bb0[29]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_3); // bb0[30]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_2); // bb0[31]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_1); // bb0[32]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + StorageDead(_7); // bb0[33]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + StorageDead(_4); // bb0[34]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + return; // bb0[35]: scope 0 at $DIR/inline-retag.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-specialization.rs b/src/test/mir-opt/inline/inline-specialization.rs index 9591019bb4f..fcdaca460a9 100644 --- a/src/test/mir-opt/inline/inline-specialization.rs +++ b/src/test/mir-opt/inline/inline-specialization.rs @@ -1,5 +1,6 @@ #![feature(specialization)] +// EMIT_MIR rustc.main.Inline.diff fn main() { let x = <Vec::<()> as Foo>::bar(); } @@ -12,37 +13,3 @@ impl<T> Foo for Vec<T> { #[inline(always)] default fn bar() -> u32 { 123 } } - -// END RUST SOURCE -// START rustc.main.Inline.before.mir -// let mut _0: (); -// let _1: u32; -// scope 1 { -// debug x => _1; -// } -// bb0: { -// StorageLive(_1); -// _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1; -// } -// bb1: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.before.mir -// START rustc.main.Inline.after.mir -// let mut _0: (); -// let _1: u32; -// scope 1 { -// debug x => _1; -// } -// scope 2 { -// } -// bb0: { -// StorageLive(_1); -// _1 = const 123u32; -// _0 = (); -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff new file mode 100644 index 00000000000..98d03b19977 --- /dev/null +++ b/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff @@ -0,0 +1,38 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/inline-specialization.rs:4:11: 4:11 + let _1: u32; // in scope 0 at $DIR/inline-specialization.rs:5:9: 5:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/inline-specialization.rs:5:9: 5:10 + } ++ scope 2 { ++ } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-specialization.rs:5:9: 5:10 +- _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1; // bb0[1]: scope 0 at $DIR/inline-specialization.rs:5:13: 5:38 ++ _1 = const 123u32; // bb0[1]: scope 2 at $DIR/inline-specialization.rs:14:31: 14:34 + // ty::Const +- // + ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar} +- // + val: Value(Scalar(<ZST>)) ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000007b)) + // mir::Constant +- // + span: $DIR/inline-specialization.rs:5:13: 5:36 +- // + literal: Const { ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar}, val: Value(Scalar(<ZST>)) } +- } +- +- bb1: { +- _0 = (); // bb1[0]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 +- StorageDead(_1); // bb1[1]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 +- return; // bb1[2]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 ++ // + span: $DIR/inline-specialization.rs:14:31: 14:34 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000007b)) } ++ _0 = (); // bb0[2]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 ++ StorageDead(_1); // bb0[3]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 ++ return; // bb0[4]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/inline/inline-trait-method.rs b/src/test/mir-opt/inline/inline-trait-method.rs index a2c5fb920cd..cb3db9b5592 100644 --- a/src/test/mir-opt/inline/inline-trait-method.rs +++ b/src/test/mir-opt/inline/inline-trait-method.rs @@ -4,6 +4,7 @@ fn main() { println!("{}", test(&())); } +// EMIT_MIR rustc.test.Inline.after.mir fn test(x: &dyn X) -> u32 { x.y() } @@ -19,13 +20,3 @@ impl X for () { 2 } } - -// END RUST SOURCE -// START rustc.test.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = const <dyn X as X>::y(move _2) -> bb1; -// } -// ... -// END rustc.test.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir new file mode 100644 index 00000000000..488303e09ef --- /dev/null +++ b/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir @@ -0,0 +1,24 @@ +// MIR for `test` after Inline + +fn test(_1: &dyn X) -> u32 { + debug x => _1; // in scope 0 at $DIR/inline-trait-method.rs:8:9: 8:10 + let mut _0: u32; // return place in scope 0 at $DIR/inline-trait-method.rs:8:23: 8:26 + let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + _2 = &(*_1); // bb0[1]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[2]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:10 + // ty::Const + // + ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-trait-method.rs:9:7: 9:8 + // + literal: Const { ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/inline-trait-method.rs:9:9: 9:10 + return; // bb1[1]: scope 0 at $DIR/inline-trait-method.rs:10:2: 10:2 + } +} diff --git a/src/test/mir-opt/inline/inline-trait-method_2.rs b/src/test/mir-opt/inline/inline-trait-method_2.rs index 4ad4311113a..e37f091c5cd 100644 --- a/src/test/mir-opt/inline/inline-trait-method_2.rs +++ b/src/test/mir-opt/inline/inline-trait-method_2.rs @@ -1,5 +1,6 @@ // compile-flags: -Z span_free_formats -Z mir-opt-level=3 +// EMIT_MIR rustc.test2.Inline.after.mir fn test2(x: &dyn X) -> bool { test(x) } @@ -24,13 +25,3 @@ impl X for () { fn main() { println!("Should be true: {}", test2(&())); } - -// END RUST SOURCE -// START rustc.test2.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = const <dyn X as X>::y(move _2) -> bb1; -// } -// ... -// END rustc.test2.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir new file mode 100644 index 00000000000..aca47198aa9 --- /dev/null +++ b/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir @@ -0,0 +1,31 @@ +// MIR for `test2` after Inline + +fn test2(_1: &dyn X) -> bool { + debug x => _1; // in scope 0 at $DIR/inline-trait-method_2.rs:4:10: 4:11 + let mut _0: bool; // return place in scope 0 at $DIR/inline-trait-method_2.rs:4:24: 4:28 + let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + let mut _3: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + scope 1 { + debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10 + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _3 = &(*_1); // bb0[2]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _2 = move _3 as &dyn X (Pointer(Unsize)); // bb0[3]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + StorageDead(_3); // bb0[4]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[5]: scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 + // ty::Const + // + ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 + // + literal: Const { ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:11: 5:12 + return; // bb1[1]: scope 0 at $DIR/inline-trait-method_2.rs:6:2: 6:2 + } +} |
