Skip to content

Instantly share code, notes, and snippets.

@Mark-Simulacrum
Created May 11, 2020 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mark-Simulacrum/93386e15a03cd562bdaf9c95dff900b0 to your computer and use it in GitHub Desktop.
Save Mark-Simulacrum/93386e15a03cd562bdaf9c95dff900b0 to your computer and use it in GitHub Desktop.
--- mir_dump/rustc.bar.002-001.SimplifyCfg-qualify-consts.after.mir 2020-05-11 11:57:05.791568852 -0400
+++ mir_dump/rustc.main.002-001.SimplifyCfg-qualify-consts.after.mir 2020-05-11 11:57:05.787568846 -0400
@@ -1,50 +1,59 @@
-// MIR for `bar` after SimplifyCfg-qualify-consts
+// MIR for `main` after SimplifyCfg-qualify-consts
| User Type Annotations
| 0: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }, CanonicalVarInfo { kind: Ty(General(U0)) }], value: TypeOf(DefId(5:3336 ~ alloc[9d4d]::slice[0]::{{impl}}[0]::into_vec[0]), UserSubsts { substs: [^0], user_self_ty: Some(UserSelfTy { impl_def_id: DefId(5:3320 ~ alloc[9d4d]::slice[0]::{{impl}}[0]), self_ty: [^1] }) }) } at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:9: 46:24
|
-fn bar() -> () {
- let mut _0: (); // return place in scope 0 at ./t.rs:17:14: 17:14
- let mut _1: std::vec::Vec<i32>; // in scope 0 at ./t.rs:18:9: 18:14
- let mut _2: std::boxed::Box<[i32]>; // in scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
- let mut _3: std::boxed::Box<[i32; 2]>; // in scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
- let mut _4: std::boxed::Box<[i32; 2]>; // in scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
- let mut _5: i32; // in scope 0 at ./t.rs:19:13: 19:17
- let mut _6: &i32; // in scope 0 at ./t.rs:19:13: 19:17
- let mut _7: &std::vec::Vec<i32>; // in scope 0 at ./t.rs:19:13: 19:14
- let mut _8: &mut i32; // in scope 0 at ./t.rs:19:5: 19:9
- let mut _9: &mut std::vec::Vec<i32>; // in scope 0 at ./t.rs:19:5: 19:6
- let mut _10: (i32, bool); // in scope 0 at ./t.rs:19:5: 19:17
+fn main() -> () {
+ let mut _0: (); // return place in scope 0 at ./t.rs:12:11: 12:11
+ let mut _1: std::vec::Vec<MyNum>; // in scope 0 at ./t.rs:13:9: 13:14
+ let mut _2: std::boxed::Box<[MyNum]>; // in scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
+ let mut _3: std::boxed::Box<[MyNum; 2]>; // in scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
+ let mut _4: std::boxed::Box<[MyNum; 2]>; // in scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
+ let mut _5: MyNum; // in scope 0 at ./t.rs:13:22: 13:30
+ let mut _6: MyNum; // in scope 0 at ./t.rs:13:32: 13:40
+ let _7: (); // in scope 0 at ./t.rs:14:5: 14:17
+ let mut _8: &mut MyNum; // in scope 0 at ./t.rs:14:5: 14:9
+ let mut _9: &mut MyNum; // in scope 0 at ./t.rs:14:5: 14:9
+ let mut _10: &mut std::vec::Vec<MyNum>; // in scope 0 at ./t.rs:14:5: 14:6
+ let mut _11: MyNum; // in scope 0 at ./t.rs:14:13: 14:17
+ let mut _12: &MyNum; // in scope 0 at ./t.rs:14:13: 14:17
+ let mut _13: &std::vec::Vec<MyNum>; // in scope 0 at ./t.rs:14:13: 14:14
scope 1 {
- debug a => _1; // in scope 1 at ./t.rs:18:9: 18:14
+ debug b => _1; // in scope 1 at ./t.rs:13:9: 13:14
}
bb0: {
- StorageLive(_1); // scope 0 at ./t.rs:18:9: 18:14
+ StorageLive(_1); // scope 0 at ./t.rs:13:9: 13:14
StorageLive(_2); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
StorageLive(_3); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
StorageLive(_4); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
- _4 = Box([i32; 2]); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
- (*_4) = [const 0i32, const 1i32]; // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:29: 46:38
+ _4 = Box([MyNum; 2]); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
+ StorageLive(_5); // scope 0 at ./t.rs:13:22: 13:30
+ _5 = MyNum(const 0i32); // scope 0 at ./t.rs:13:22: 13:30
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000000))
// mir::Constant
- // + span: ./t.rs:18:22: 18:23
+ // + span: ./t.rs:13:28: 13:29
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
+ StorageLive(_6); // scope 0 at ./t.rs:13:32: 13:40
+ _6 = MyNum(const 1i32); // scope 0 at ./t.rs:13:32: 13:40
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
- // + span: ./t.rs:18:25: 18:26
+ // + span: ./t.rs:13:38: 13:39
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
+ (*_4) = [move _5, move _6]; // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:29: 46:38
+ StorageDead(_6); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:37: 46:38
+ StorageDead(_5); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:37: 46:38
_3 = move _4; // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
- _2 = move _3 as std::boxed::Box<[i32]> (Pointer(Unsize)); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
+ _2 = move _3 as std::boxed::Box<[MyNum]> (Pointer(Unsize)); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:25: 46:38
drop(_3) -> [return: bb4, unwind: bb3]; // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:37: 46:38
}
bb1 (cleanup): {
- resume; // scope 0 at ./t.rs:17:1: 20:2
+ resume; // scope 0 at ./t.rs:12:1: 15:2
}
bb2 (cleanup): {
@@ -62,86 +71,95 @@
bb5: {
StorageDead(_4); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:37: 46:38
StorageDead(_3); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:37: 46:38
- _1 = const std::slice::<impl [i32]>::into_vec(move _2) -> [return: bb6, unwind: bb2]; // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:9: 46:39
+ _1 = const std::slice::<impl [MyNum]>::into_vec(move _2) -> [return: bb6, unwind: bb2]; // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:9: 46:39
// ty::Const
- // + ty: fn(std::boxed::Box<[i32]>) -> std::vec::Vec<i32> {std::slice::<impl [i32]>::into_vec}
+ // + ty: fn(std::boxed::Box<[MyNum]>) -> std::vec::Vec<MyNum> {std::slice::<impl [MyNum]>::into_vec}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:9: 46:24
// + user_ty: UserType(0)
- // + literal: Const { ty: fn(std::boxed::Box<[i32]>) -> std::vec::Vec<i32> {std::slice::<impl [i32]>::into_vec}, val: Value(Scalar(<ZST>)) }
+ // + literal: Const { ty: fn(std::boxed::Box<[MyNum]>) -> std::vec::Vec<MyNum> {std::slice::<impl [MyNum]>::into_vec}, val: Value(Scalar(<ZST>)) }
}
bb6: {
StorageDead(_2); // scope 0 at /rustc/fa51f810e5b9254904b92660e7280b7d6a46f112/src/liballoc/macros.rs:46:38: 46:39
- FakeRead(ForLet, _1); // scope 0 at ./t.rs:18:9: 18:14
- StorageLive(_5); // scope 1 at ./t.rs:19:13: 19:17
- StorageLive(_6); // scope 1 at ./t.rs:19:13: 19:17
- StorageLive(_7); // scope 1 at ./t.rs:19:13: 19:14
- _7 = &_1; // scope 1 at ./t.rs:19:13: 19:14
- _6 = const <std::vec::Vec<i32> as std::ops::Index<usize>>::index(move _7, const 1usize) -> [return: bb7, unwind: bb8]; // scope 1 at ./t.rs:19:13: 19:17
+ FakeRead(ForLet, _1); // scope 0 at ./t.rs:13:9: 13:14
+ StorageLive(_7); // scope 1 at ./t.rs:14:5: 14:17
+ StorageLive(_8); // scope 1 at ./t.rs:14:5: 14:9
+ StorageLive(_9); // scope 1 at ./t.rs:14:5: 14:9
+ StorageLive(_10); // scope 1 at ./t.rs:14:5: 14:6
+ _10 = &mut _1; // scope 1 at ./t.rs:14:5: 14:6
+ _9 = const <std::vec::Vec<MyNum> as std::ops::IndexMut<usize>>::index_mut(move _10, const 0usize) -> [return: bb7, unwind: bb8]; // scope 1 at ./t.rs:14:5: 14:9
// ty::Const
- // + ty: for<'r> fn(&'r std::vec::Vec<i32>, usize) -> &'r <std::vec::Vec<i32> as std::ops::Index<usize>>::Output {<std::vec::Vec<i32> as std::ops::Index<usize>>::index}
+ // + ty: for<'r> fn(&'r mut std::vec::Vec<MyNum>, usize) -> &'r mut <std::vec::Vec<MyNum> as std::ops::Index<usize>>::Output {<std::vec::Vec<MyNum> as std::ops::IndexMut<usize>>::index_mut}
// + val: Value(Scalar(<ZST>))
// mir::Constant
- // + span: ./t.rs:19:13: 19:17
- // + literal: Const { ty: for<'r> fn(&'r std::vec::Vec<i32>, usize) -> &'r <std::vec::Vec<i32> as std::ops::Index<usize>>::Output {<std::vec::Vec<i32> as std::ops::Index<usize>>::index}, val: Value(Scalar(<ZST>)) }
+ // + span: ./t.rs:14:5: 14:9
+ // + literal: Const { ty: for<'r> fn(&'r mut std::vec::Vec<MyNum>, usize) -> &'r mut <std::vec::Vec<MyNum> as std::ops::Index<usize>>::Output {<std::vec::Vec<MyNum> as std::ops::IndexMut<usize>>::index_mut}, val: Value(Scalar(<ZST>)) }
// ty::Const
// + ty: usize
- // + val: Value(Scalar(0x0000000000000001))
+ // + val: Value(Scalar(0x0000000000000000))
// mir::Constant
- // + span: ./t.rs:19:15: 19:16
- // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
+ // + span: ./t.rs:14:7: 14:8
+ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
}
bb7: {
- _5 = (*_6); // scope 1 at ./t.rs:19:13: 19:17
- StorageDead(_7); // scope 1 at ./t.rs:19:16: 19:17
- StorageLive(_8); // scope 1 at ./t.rs:19:5: 19:9
- StorageLive(_9); // scope 1 at ./t.rs:19:5: 19:6
- _9 = &mut _1; // scope 1 at ./t.rs:19:5: 19:6
- _8 = const <std::vec::Vec<i32> as std::ops::IndexMut<usize>>::index_mut(move _9, const 0usize) -> [return: bb9, unwind: bb8]; // scope 1 at ./t.rs:19:5: 19:9
+ _8 = &mut (*_9); // scope 1 at ./t.rs:14:5: 14:9
+ StorageDead(_10); // scope 1 at ./t.rs:14:8: 14:9
+ StorageLive(_11); // scope 1 at ./t.rs:14:13: 14:17
+ StorageLive(_12); // scope 1 at ./t.rs:14:13: 14:17
+ StorageLive(_13); // scope 1 at ./t.rs:14:13: 14:14
+ _13 = &_1; // scope 1 at ./t.rs:14:13: 14:14
+ _12 = const <std::vec::Vec<MyNum> as std::ops::Index<usize>>::index(move _13, const 1usize) -> [return: bb9, unwind: bb8]; // scope 1 at ./t.rs:14:13: 14:17
// ty::Const
- // + ty: for<'r> fn(&'r mut std::vec::Vec<i32>, usize) -> &'r mut <std::vec::Vec<i32> as std::ops::Index<usize>>::Output {<std::vec::Vec<i32> as std::ops::IndexMut<usize>>::index_mut}
+ // + ty: for<'r> fn(&'r std::vec::Vec<MyNum>, usize) -> &'r <std::vec::Vec<MyNum> as std::ops::Index<usize>>::Output {<std::vec::Vec<MyNum> as std::ops::Index<usize>>::index}
// + val: Value(Scalar(<ZST>))
// mir::Constant
- // + span: ./t.rs:19:5: 19:9
- // + literal: Const { ty: for<'r> fn(&'r mut std::vec::Vec<i32>, usize) -> &'r mut <std::vec::Vec<i32> as std::ops::Index<usize>>::Output {<std::vec::Vec<i32> as std::ops::IndexMut<usize>>::index_mut}, val: Value(Scalar(<ZST>)) }
+ // + span: ./t.rs:14:13: 14:17
+ // + literal: Const { ty: for<'r> fn(&'r std::vec::Vec<MyNum>, usize) -> &'r <std::vec::Vec<MyNum> as std::ops::Index<usize>>::Output {<std::vec::Vec<MyNum> as std::ops::Index<usize>>::index}, val: Value(Scalar(<ZST>)) }
// ty::Const
// + ty: usize
- // + val: Value(Scalar(0x0000000000000000))
+ // + val: Value(Scalar(0x0000000000000001))
// mir::Constant
- // + span: ./t.rs:19:7: 19:8
- // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) }
+ // + span: ./t.rs:14:15: 14:16
+ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) }
}
bb8 (cleanup): {
- drop(_1) -> bb1; // scope 0 at ./t.rs:20:1: 20:2
+ drop(_1) -> bb1; // scope 0 at ./t.rs:15:1: 15:2
}
bb9: {
- StorageDead(_9); // scope 1 at ./t.rs:19:8: 19:9
- _10 = CheckedAdd((*_8), move _5); // scope 1 at ./t.rs:19:5: 19:17
- assert(!move (_10.1: bool), "attempt to add with overflow") -> [success: bb10, unwind: bb8]; // scope 1 at ./t.rs:19:5: 19:17
+ _11 = (*_12); // scope 1 at ./t.rs:14:13: 14:17
+ StorageDead(_13); // scope 1 at ./t.rs:14:16: 14:17
+ _7 = const <MyNum as std::ops::AddAssign>::add_assign(move _8, move _11) -> [return: bb10, unwind: bb8]; // scope 1 at ./t.rs:14:5: 14:17
+ // ty::Const
+ // + ty: for<'r> fn(&'r mut MyNum, MyNum) {<MyNum as std::ops::AddAssign>::add_assign}
+ // + val: Value(Scalar(<ZST>))
+ // mir::Constant
+ // + span: ./t.rs:14:5: 14:17
+ // + literal: Const { ty: for<'r> fn(&'r mut MyNum, MyNum) {<MyNum as std::ops::AddAssign>::add_assign}, val: Value(Scalar(<ZST>)) }
}
bb10: {
- (*_8) = move (_10.0: i32); // scope 1 at ./t.rs:19:5: 19:17
- StorageDead(_5); // scope 1 at ./t.rs:19:16: 19:17
- StorageDead(_8); // scope 1 at ./t.rs:19:17: 19:18
- StorageDead(_6); // scope 1 at ./t.rs:19:17: 19:18
- _0 = const (); // scope 0 at ./t.rs:17:14: 20:2
+ StorageDead(_11); // scope 1 at ./t.rs:14:16: 14:17
+ StorageDead(_8); // scope 1 at ./t.rs:14:16: 14:17
+ StorageDead(_12); // scope 1 at ./t.rs:14:17: 14:18
+ StorageDead(_9); // scope 1 at ./t.rs:14:17: 14:18
+ StorageDead(_7); // scope 1 at ./t.rs:14:17: 14:18
+ _0 = const (); // scope 0 at ./t.rs:12:11: 15:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
- // + span: ./t.rs:17:14: 20:2
+ // + span: ./t.rs:12:11: 15:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
- drop(_1) -> [return: bb11, unwind: bb1]; // scope 0 at ./t.rs:20:1: 20:2
+ drop(_1) -> [return: bb11, unwind: bb1]; // scope 0 at ./t.rs:15:1: 15:2
}
bb11: {
- StorageDead(_1); // scope 0 at ./t.rs:20:1: 20:2
- return; // scope 0 at ./t.rs:20:2: 20:2
+ StorageDead(_1); // scope 0 at ./t.rs:15:1: 15:2
+ return; // scope 0 at ./t.rs:15:2: 15:2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment