Skip to content

Commit d1bd1be

Browse files
committed
Use EMIT_MIR_FOR_EACH_BIT_WIDTH in transmute mir-opt test
1 parent 4adb8fb commit d1bd1be

21 files changed

+217
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- // MIR for `from_char` before ConstProp
2+
+ // MIR for `from_char` after ConstProp
3+
4+
fn from_char() -> i32 {
5+
let mut _0: i32; // return place in scope 0 at $DIR/transmute.rs:+0:23: +0:26
6+
scope 1 {
7+
}
8+
9+
bb0: {
10+
- _0 = const 'R' as i32 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:28
11+
+ _0 = const 82_i32; // scope 1 at $DIR/transmute.rs:+1:14: +1:28
12+
return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2
13+
}
14+
}
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- // MIR for `invalid_bool` before ConstProp
2+
+ // MIR for `invalid_bool` after ConstProp
3+
4+
fn invalid_bool() -> bool {
5+
let mut _0: bool; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37
6+
scope 1 {
7+
}
8+
9+
bb0: {
10+
- _0 = const -1_i8 as bool (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:30
11+
+ _0 = const {transmute(0xff): bool}; // scope 1 at $DIR/transmute.rs:+1:14: +1:30
12+
return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2
13+
}
14+
}
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- // MIR for `invalid_char` before ConstProp
2+
+ // MIR for `invalid_char` after ConstProp
3+
4+
fn invalid_char() -> char {
5+
let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:33: +0:37
6+
scope 1 {
7+
}
8+
9+
bb0: {
10+
- _0 = const _ as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33
11+
+ _0 = const {transmute(0x7fffffff): char}; // scope 1 at $DIR/transmute.rs:+1:14: +1:33
12+
return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2
13+
}
14+
}
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
- // MIR for `less_as_i8` before ConstProp
2+
+ // MIR for `less_as_i8` after ConstProp
3+
4+
fn less_as_i8() -> i8 {
5+
let mut _0: i8; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:26
6+
let mut _1: std::cmp::Ordering; // in scope 0 at $DIR/transmute.rs:+1:24: +1:48
7+
scope 1 {
8+
}
9+
10+
bb0: {
11+
StorageLive(_1); // scope 1 at $DIR/transmute.rs:+1:24: +1:48
12+
- _1 = Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48
13+
- _0 = move _1 as i8 (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:49
14+
+ _1 = const Less; // scope 1 at $DIR/transmute.rs:+1:24: +1:48
15+
+ // mir::Constant
16+
+ // + span: no-location
17+
+ // + literal: Const { ty: std::cmp::Ordering, val: Value(Scalar(0xff)) }
18+
+ _0 = const -1_i8; // scope 1 at $DIR/transmute.rs:+1:14: +1:49
19+
StorageDead(_1); // scope 1 at $DIR/transmute.rs:+1:48: +1:49
20+
return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2
21+
}
22+
}
23+

tests/mir-opt/const_prop/transmute.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// unit-test: ConstProp
22
// compile-flags: -O --crate-type=lib
3+
// ignore-endian-big
4+
// EMIT_MIR_FOR_EACH_BIT_WIDTH
35

46
use std::mem::transmute;
57

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
- // MIR for `undef_union_as_integer` before ConstProp
2+
+ // MIR for `undef_union_as_integer` after ConstProp
3+
4+
fn undef_union_as_integer() -> u32 {
5+
let mut _0: u32; // return place in scope 0 at $DIR/transmute.rs:+0:43: +0:46
6+
let mut _1: undef_union_as_integer::Union32; // in scope 0 at $DIR/transmute.rs:+2:24: +2:44
7+
let mut _2: (); // in scope 0 at $DIR/transmute.rs:+2:40: +2:42
8+
scope 1 {
9+
}
10+
11+
bb0: {
12+
StorageLive(_1); // scope 1 at $DIR/transmute.rs:+2:24: +2:44
13+
StorageLive(_2); // scope 1 at $DIR/transmute.rs:+2:40: +2:42
14+
_2 = (); // scope 1 at $DIR/transmute.rs:+2:40: +2:42
15+
_1 = Union32 { value: move _2 }; // scope 1 at $DIR/transmute.rs:+2:24: +2:44
16+
StorageDead(_2); // scope 1 at $DIR/transmute.rs:+2:43: +2:44
17+
_0 = move _1 as u32 (Transmute); // scope 1 at $DIR/transmute.rs:+2:14: +2:45
18+
StorageDead(_1); // scope 1 at $DIR/transmute.rs:+2:44: +2:45
19+
return; // scope 0 at $DIR/transmute.rs:+3:2: +3:2
20+
}
21+
}
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
- // MIR for `unreachable_box` before ConstProp
2+
+ // MIR for `unreachable_box` after ConstProp
3+
4+
fn unreachable_box() -> ! {
5+
let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37
6+
let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2
7+
let _2: std::boxed::Box<Never>; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10
8+
let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16
9+
scope 1 {
10+
debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10
11+
}
12+
scope 2 {
13+
}
14+
15+
bb0: {
16+
StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2
17+
StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10
18+
- _2 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
19+
+ _2 = const Box::<Never>(Unique::<Never> {{ pointer: NonNull::<Never> {{ pointer: {0x1 as *const Never} }}, _marker: PhantomData::<Never> }}, std::alloc::Global); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
20+
+ // mir::Constant
21+
+ // + span: no-location
22+
+ // + literal: Const { ty: Box<Never>, val: Value(Scalar(0x00000001)) }
23+
StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16
24+
unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13
25+
}
26+
}
27+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
- // MIR for `unreachable_direct` before ConstProp
2+
+ // MIR for `unreachable_direct` after ConstProp
3+
4+
fn unreachable_direct() -> ! {
5+
let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:39: +0:40
6+
let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:41: +3:2
7+
let _2: Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10
8+
let mut _3: (); // in scope 0 at $DIR/transmute.rs:+1:39: +1:41
9+
let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:15
10+
scope 1 {
11+
debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10
12+
}
13+
scope 2 {
14+
}
15+
16+
bb0: {
17+
StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:41: +3:2
18+
StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10
19+
StorageLive(_3); // scope 2 at $DIR/transmute.rs:+1:39: +1:41
20+
_3 = (); // scope 2 at $DIR/transmute.rs:+1:39: +1:41
21+
_2 = move _3 as Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:29: +1:42
22+
unreachable; // scope 2 at $DIR/transmute.rs:+1:29: +1:42
23+
}
24+
}
25+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- // MIR for `unreachable_mut` before ConstProp
2+
+ // MIR for `unreachable_mut` after ConstProp
3+
4+
fn unreachable_mut() -> ! {
5+
let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37
6+
let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2
7+
let _2: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10
8+
let mut _3: &mut Never; // in scope 0 at $DIR/transmute.rs:+1:34: +1:52
9+
let mut _4: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16
10+
scope 1 {
11+
debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10
12+
}
13+
scope 2 {
14+
}
15+
16+
bb0: {
17+
StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2
18+
StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10
19+
StorageLive(_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52
20+
- _3 = const 1_usize as &mut Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:34: +1:52
21+
+ _3 = const {0x1 as &mut Never}; // scope 2 at $DIR/transmute.rs:+1:34: +1:52
22+
+ // mir::Constant
23+
+ // + span: no-location
24+
+ // + literal: Const { ty: &mut Never, val: Value(Scalar(0x00000001)) }
25+
_2 = &mut (*_3); // scope 0 at $DIR/transmute.rs:+1:34: +1:52
26+
StorageDead(_3); // scope 0 at $DIR/transmute.rs:+1:54: +1:55
27+
StorageLive(_4); // scope 1 at $DIR/transmute.rs:+2:5: +2:16
28+
unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13
29+
}
30+
}
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
- // MIR for `unreachable_ref` before ConstProp
2+
+ // MIR for `unreachable_ref` after ConstProp
3+
4+
fn unreachable_ref() -> ! {
5+
let mut _0: !; // return place in scope 0 at $DIR/transmute.rs:+0:36: +0:37
6+
let mut _1: !; // in scope 0 at $DIR/transmute.rs:+0:38: +3:2
7+
let _2: &Never; // in scope 0 at $DIR/transmute.rs:+1:9: +1:10
8+
let mut _3: !; // in scope 0 at $DIR/transmute.rs:+2:5: +2:16
9+
scope 1 {
10+
debug x => _2; // in scope 1 at $DIR/transmute.rs:+1:9: +1:10
11+
}
12+
scope 2 {
13+
}
14+
15+
bb0: {
16+
StorageLive(_1); // scope 0 at $DIR/transmute.rs:+0:38: +3:2
17+
StorageLive(_2); // scope 0 at $DIR/transmute.rs:+1:9: +1:10
18+
- _2 = const 1_usize as &Never (Transmute); // scope 2 at $DIR/transmute.rs:+1:30: +1:48
19+
+ _2 = const {0x1 as &Never}; // scope 2 at $DIR/transmute.rs:+1:30: +1:48
20+
+ // mir::Constant
21+
+ // + span: no-location
22+
+ // + literal: Const { ty: &Never, val: Value(Scalar(0x00000001)) }
23+
StorageLive(_3); // scope 1 at $DIR/transmute.rs:+2:5: +2:16
24+
unreachable; // scope 1 at $DIR/transmute.rs:+2:11: +2:13
25+
}
26+
}
27+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- // MIR for `valid_char` before ConstProp
2+
+ // MIR for `valid_char` after ConstProp
3+
4+
fn valid_char() -> char {
5+
let mut _0: char; // return place in scope 0 at $DIR/transmute.rs:+0:24: +0:28
6+
scope 1 {
7+
}
8+
9+
bb0: {
10+
- _0 = const 82_u32 as char (Transmute); // scope 1 at $DIR/transmute.rs:+1:14: +1:33
11+
+ _0 = const 'R'; // scope 1 at $DIR/transmute.rs:+1:14: +1:33
12+
return; // scope 0 at $DIR/transmute.rs:+2:2: +2:2
13+
}
14+
}
15+

0 commit comments

Comments
 (0)