Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
2,254 additions
and
1,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,6 @@ | ||
// compile-flags: -O | ||
|
||
// EMIT_MIR rustc.main.ConstProp.diff | ||
fn main() { | ||
let x = (0, 1, 2).1 + 0; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _3 = (const 0i32, const 1i32, const 2i32); | ||
// _2 = (_3.1: i32); | ||
// _1 = Add(move _2, const 0i32); | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _3 = (const 0i32, const 1i32, const 2i32); | ||
// _2 = const 1i32; | ||
// _1 = const 1i32; | ||
// ... | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
62 changes: 62 additions & 0 deletions
62
src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
- // MIR for `main` before ConstProp | ||
+ // MIR for `main` after ConstProp | ||
|
||
fn main() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:4:11: 4:11 | ||
let _1: i32; // in scope 0 at $DIR/aggregate.rs:5:9: 5:10 | ||
let mut _2: i32; // in scope 0 at $DIR/aggregate.rs:5:13: 5:24 | ||
let mut _3: (i32, i32, i32); // in scope 0 at $DIR/aggregate.rs:5:13: 5:22 | ||
scope 1 { | ||
debug x => _1; // in scope 1 at $DIR/aggregate.rs:5:9: 5:10 | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); // bb0[0]: scope 0 at $DIR/aggregate.rs:5:9: 5:10 | ||
StorageLive(_2); // bb0[1]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 | ||
StorageLive(_3); // bb0[2]: scope 0 at $DIR/aggregate.rs:5:13: 5:22 | ||
_3 = (const 0i32, const 1i32, const 2i32); // bb0[3]: scope 0 at $DIR/aggregate.rs:5:13: 5:22 | ||
// ty::Const | ||
// + ty: i32 | ||
// + val: Value(Scalar(0x00000000)) | ||
// mir::Constant | ||
// + span: $DIR/aggregate.rs:5:14: 5:15 | ||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } | ||
// ty::Const | ||
// + ty: i32 | ||
// + val: Value(Scalar(0x00000001)) | ||
// mir::Constant | ||
// + span: $DIR/aggregate.rs:5:17: 5:18 | ||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } | ||
// ty::Const | ||
// + ty: i32 | ||
// + val: Value(Scalar(0x00000002)) | ||
// mir::Constant | ||
// + span: $DIR/aggregate.rs:5:20: 5:21 | ||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } | ||
- _2 = (_3.1: i32); // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 | ||
- _1 = Add(move _2, const 0i32); // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28 | ||
+ _2 = const 1i32; // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 | ||
// ty::Const | ||
// + ty: i32 | ||
- // + val: Value(Scalar(0x00000000)) | ||
+ // + val: Value(Scalar(0x00000001)) | ||
// mir::Constant | ||
- // + span: $DIR/aggregate.rs:5:27: 5:28 | ||
- // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } | ||
+ // + span: $DIR/aggregate.rs:5:13: 5:24 | ||
+ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } | ||
+ _1 = const 1i32; // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28 | ||
+ // ty::Const | ||
+ // + ty: i32 | ||
+ // + val: Value(Scalar(0x00000001)) | ||
+ // mir::Constant | ||
+ // + span: $DIR/aggregate.rs:5:13: 5:28 | ||
+ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } | ||
StorageDead(_2); // bb0[6]: scope 0 at $DIR/aggregate.rs:5:27: 5:28 | ||
StorageDead(_3); // bb0[7]: scope 0 at $DIR/aggregate.rs:5:28: 5:29 | ||
_0 = (); // bb0[8]: scope 0 at $DIR/aggregate.rs:4:11: 6:2 | ||
StorageDead(_1); // bb0[9]: scope 0 at $DIR/aggregate.rs:6:1: 6:2 | ||
return; // bb0[10]: scope 0 at $DIR/aggregate.rs:6:2: 6:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
// EMIT_MIR rustc.main.ConstProp.diff | ||
|
||
fn main() { | ||
let x: u32 = [0, 1, 2, 3][2]; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; | ||
// ... | ||
// _3 = const 2usize; | ||
// _4 = const 4usize; | ||
// _5 = Lt(_3, _4); | ||
// assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; | ||
// } | ||
// bb1: { | ||
// _1 = _2[_3]; | ||
// ... | ||
// return; | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _5 = const true; | ||
// assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; | ||
// } | ||
// bb1: { | ||
// _1 = const 2u32; | ||
// ... | ||
// return; | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
92 changes: 92 additions & 0 deletions
92
src/test/mir-opt/const_prop/array_index/rustc.main.ConstProp.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
- // MIR for `main` before ConstProp | ||
+ // MIR for `main` after ConstProp | ||
|
||
fn main() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:3:11: 3:11 | ||
let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:4:9: 4:10 | ||
let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:4:18: 4:30 | ||
let _3: usize; // in scope 0 at $DIR/array_index.rs:4:31: 4:32 | ||
let mut _4: usize; // in scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
let mut _5: bool; // in scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
scope 1 { | ||
debug x => _1; // in scope 1 at $DIR/array_index.rs:4:9: 4:10 | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); // bb0[0]: scope 0 at $DIR/array_index.rs:4:9: 4:10 | ||
StorageLive(_2); // bb0[1]: scope 0 at $DIR/array_index.rs:4:18: 4:30 | ||
_2 = [const 0u32, const 1u32, const 2u32, const 3u32]; // bb0[2]: scope 0 at $DIR/array_index.rs:4:18: 4:30 | ||
// ty::Const | ||
// + ty: u32 | ||
// + val: Value(Scalar(0x00000000)) | ||
// mir::Constant | ||
// + span: $DIR/array_index.rs:4:19: 4:20 | ||
// + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } | ||
// ty::Const | ||
// + ty: u32 | ||
// + val: Value(Scalar(0x00000001)) | ||
// mir::Constant | ||
// + span: $DIR/array_index.rs:4:22: 4:23 | ||
// + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } | ||
// ty::Const | ||
// + ty: u32 | ||
// + val: Value(Scalar(0x00000002)) | ||
// mir::Constant | ||
// + span: $DIR/array_index.rs:4:25: 4:26 | ||
// + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } | ||
// ty::Const | ||
// + ty: u32 | ||
// + val: Value(Scalar(0x00000003)) | ||
// mir::Constant | ||
// + span: $DIR/array_index.rs:4:28: 4:29 | ||
// + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } | ||
StorageLive(_3); // bb0[3]: scope 0 at $DIR/array_index.rs:4:31: 4:32 | ||
_3 = const 2usize; // bb0[4]: scope 0 at $DIR/array_index.rs:4:31: 4:32 | ||
// ty::Const | ||
// + ty: usize | ||
// + val: Value(Scalar(0x0000000000000002)) | ||
// mir::Constant | ||
// + span: $DIR/array_index.rs:4:31: 4:32 | ||
// + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } | ||
_4 = const 4usize; // bb0[5]: scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
// ty::Const | ||
// + ty: usize | ||
// + val: Value(Scalar(0x0000000000000004)) | ||
// mir::Constant | ||
// + span: $DIR/array_index.rs:4:18: 4:33 | ||
// + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000004)) } | ||
- _5 = Lt(_3, _4); // bb0[6]: scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
- assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
+ _5 = const true; // bb0[6]: scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
+ // ty::Const | ||
+ // + ty: bool | ||
+ // + val: Value(Scalar(0x01)) | ||
+ // mir::Constant | ||
+ // + span: $DIR/array_index.rs:4:18: 4:33 | ||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } | ||
+ assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
+ // ty::Const | ||
+ // + ty: bool | ||
+ // + val: Value(Scalar(0x01)) | ||
+ // mir::Constant | ||
+ // + span: $DIR/array_index.rs:4:18: 4:33 | ||
+ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } | ||
} | ||
|
||
bb1: { | ||
- _1 = _2[_3]; // bb1[0]: scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
+ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/array_index.rs:4:18: 4:33 | ||
+ // ty::Const | ||
+ // + ty: u32 | ||
+ // + val: Value(Scalar(0x00000002)) | ||
+ // mir::Constant | ||
+ // + span: $DIR/array_index.rs:4:18: 4:33 | ||
+ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } | ||
StorageDead(_3); // bb1[1]: scope 0 at $DIR/array_index.rs:4:33: 4:34 | ||
StorageDead(_2); // bb1[2]: scope 0 at $DIR/array_index.rs:4:33: 4:34 | ||
_0 = (); // bb1[3]: scope 0 at $DIR/array_index.rs:3:11: 5:2 | ||
StorageDead(_1); // bb1[4]: scope 0 at $DIR/array_index.rs:5:1: 5:2 | ||
return; // bb1[5]: scope 0 at $DIR/array_index.rs:5:2: 5:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
- // MIR for `main` before ConstProp | ||
+ // MIR for `main` after ConstProp | ||
|
||
fn main() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:11:11: 11:11 | ||
let _1: i32; // in scope 0 at $DIR/boxes.rs:12:9: 12:10 | ||
let mut _2: i32; // in scope 0 at $DIR/boxes.rs:12:13: 12:22 | ||
let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22 | ||
let mut _4: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22 | ||
scope 1 { | ||
debug x => _1; // in scope 1 at $DIR/boxes.rs:12:9: 12:10 | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); // bb0[0]: scope 0 at $DIR/boxes.rs:12:9: 12:10 | ||
StorageLive(_2); // bb0[1]: scope 0 at $DIR/boxes.rs:12:13: 12:22 | ||
StorageLive(_3); // bb0[2]: scope 0 at $DIR/boxes.rs:12:14: 12:22 | ||
StorageLive(_4); // bb0[3]: scope 0 at $DIR/boxes.rs:12:14: 12:22 | ||
_4 = Box(i32); // bb0[4]: scope 0 at $DIR/boxes.rs:12:14: 12:22 | ||
(*_4) = const 42i32; // bb0[5]: scope 0 at $DIR/boxes.rs:12:19: 12:21 | ||
// ty::Const | ||
// + ty: i32 | ||
// + val: Value(Scalar(0x0000002a)) | ||
// mir::Constant | ||
// + span: $DIR/boxes.rs:12:19: 12:21 | ||
// + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } | ||
_3 = move _4; // bb0[6]: scope 0 at $DIR/boxes.rs:12:14: 12:22 | ||
StorageDead(_4); // bb0[7]: scope 0 at $DIR/boxes.rs:12:21: 12:22 | ||
_2 = (*_3); // bb0[8]: scope 0 at $DIR/boxes.rs:12:13: 12:22 | ||
_1 = Add(move _2, const 0i32); // bb0[9]: scope 0 at $DIR/boxes.rs:12:13: 12:26 | ||
// ty::Const | ||
// + ty: i32 | ||
// + val: Value(Scalar(0x00000000)) | ||
// mir::Constant | ||
// + span: $DIR/boxes.rs:12:25: 12:26 | ||
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } | ||
StorageDead(_2); // bb0[10]: scope 0 at $DIR/boxes.rs:12:25: 12:26 | ||
drop(_3) -> [return: bb2, unwind: bb1]; // bb0[11]: scope 0 at $DIR/boxes.rs:12:26: 12:27 | ||
} | ||
|
||
bb1 (cleanup): { | ||
resume; // bb1[0]: scope 0 at $DIR/boxes.rs:11:1: 13:2 | ||
} | ||
|
||
bb2: { | ||
StorageDead(_3); // bb2[0]: scope 0 at $DIR/boxes.rs:12:26: 12:27 | ||
_0 = (); // bb2[1]: scope 0 at $DIR/boxes.rs:11:11: 13:2 | ||
StorageDead(_1); // bb2[2]: scope 0 at $DIR/boxes.rs:13:1: 13:2 | ||
return; // bb2[3]: scope 0 at $DIR/boxes.rs:13:2: 13:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,6 @@ | ||
// compile-flags: -C overflow-checks=on | ||
|
||
// EMIT_MIR rustc.main.ConstProp.diff | ||
fn main() { | ||
let x: u32 = 1 + 1; | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.main.ConstProp.before.mir | ||
// bb0: { | ||
// ... | ||
// _2 = CheckedAdd(const 1u32, const 1u32); | ||
// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; | ||
// } | ||
// END rustc.main.ConstProp.before.mir | ||
// START rustc.main.ConstProp.after.mir | ||
// bb0: { | ||
// ... | ||
// _2 = (const 2u32, const false); | ||
// assert(!const false, "attempt to add with overflow") -> bb1; | ||
// } | ||
// END rustc.main.ConstProp.after.mir |
Oops, something went wrong.