Skip to content

Commit 804aa6a

Browse files
committed
FileCheck transmute.
1 parent eaabda7 commit 804aa6a

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

tests/mir-opt/const_prop/transmute.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// unit-test: ConstProp
32
// compile-flags: -O --crate-type=lib
43
// ignore-endian-big
@@ -8,55 +7,77 @@ use std::mem::transmute;
87

98
// EMIT_MIR transmute.less_as_i8.ConstProp.diff
109
pub fn less_as_i8() -> i8 {
10+
// CHECK-LABEL: fn less_as_i8(
11+
// CHECK: _0 = const -1_i8;
1112
unsafe { transmute(std::cmp::Ordering::Less) }
1213
}
1314

1415
// EMIT_MIR transmute.from_char.ConstProp.diff
1516
pub fn from_char() -> i32 {
17+
// CHECK-LABEL: fn from_char(
18+
// CHECK: _0 = const 82_i32;
1619
unsafe { transmute('R') }
1720
}
1821

1922
// EMIT_MIR transmute.valid_char.ConstProp.diff
2023
pub fn valid_char() -> char {
24+
// CHECK-LABEL: fn valid_char(
25+
// CHECK: _0 = const 'R';
2126
unsafe { transmute(0x52_u32) }
2227
}
2328

2429
// EMIT_MIR transmute.invalid_char.ConstProp.diff
2530
pub unsafe fn invalid_char() -> char {
31+
// CHECK-LABEL: fn invalid_char(
32+
// CHECK: _0 = const {transmute(0x7fffffff): char};
2633
unsafe { transmute(i32::MAX) }
2734
}
2835

2936
// EMIT_MIR transmute.invalid_bool.ConstProp.diff
3037
pub unsafe fn invalid_bool() -> bool {
38+
// CHECK-LABEL: fn invalid_bool(
39+
// CHECK: _0 = const {transmute(0xff): bool};
3140
unsafe { transmute(-1_i8) }
3241
}
3342

3443
// EMIT_MIR transmute.undef_union_as_integer.ConstProp.diff
3544
pub unsafe fn undef_union_as_integer() -> u32 {
45+
// CHECK-LABEL: fn undef_union_as_integer(
46+
// CHECK: _1 = Union32 {
47+
// CHECK: _0 = move _1 as u32 (Transmute);
3648
union Union32 { value: u32, unit: () }
3749
unsafe { transmute(Union32 { unit: () }) }
3850
}
3951

4052
// EMIT_MIR transmute.unreachable_direct.ConstProp.diff
4153
pub unsafe fn unreachable_direct() -> ! {
54+
// CHECK-LABEL: fn unreachable_direct(
55+
// CHECK: [[unit:_.*]] = ();
56+
// CHECK: move [[unit]] as Never (Transmute);
4257
let x: Never = unsafe { transmute(()) };
4358
match x {}
4459
}
4560

4661
// EMIT_MIR transmute.unreachable_ref.ConstProp.diff
4762
pub unsafe fn unreachable_ref() -> ! {
63+
// CHECK-LABEL: fn unreachable_ref(
64+
// CHECK: = const {0x1 as &Never};
4865
let x: &Never = unsafe { transmute(1_usize) };
4966
match *x {}
5067
}
5168

5269
// EMIT_MIR transmute.unreachable_mut.ConstProp.diff
5370
pub unsafe fn unreachable_mut() -> ! {
71+
// CHECK-LABEL: fn unreachable_mut(
72+
// CHECK: = const {0x1 as &mut Never};
5473
let x: &mut Never = unsafe { transmute(1_usize) };
5574
match *x {}
5675
}
5776

5877
// EMIT_MIR transmute.unreachable_box.ConstProp.diff
5978
pub unsafe fn unreachable_box() -> ! {
79+
// CHECK-LABEL: fn unreachable_box(
80+
// CHECK: = const Box::<Never>(
6081
let x: Box<Never> = unsafe { transmute(1_usize) };
6182
match *x {}
6283
}

tests/mir-opt/dataflow-const-prop/transmute.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// skip-filecheck
21
// unit-test: DataflowConstProp
32
// compile-flags: -O --crate-type=lib
43
// ignore-endian-big
@@ -8,55 +7,77 @@ use std::mem::transmute;
87

98
// EMIT_MIR transmute.less_as_i8.DataflowConstProp.diff
109
pub fn less_as_i8() -> i8 {
10+
// CHECK-LABEL: fn less_as_i8(
11+
// FIXME-CHECK: _0 = const -1_i8;
1112
unsafe { transmute(std::cmp::Ordering::Less) }
1213
}
1314

1415
// EMIT_MIR transmute.from_char.DataflowConstProp.diff
1516
pub fn from_char() -> i32 {
17+
// CHECK-LABEL: fn from_char(
18+
// CHECK: _0 = const 82_i32;
1619
unsafe { transmute('R') }
1720
}
1821

1922
// EMIT_MIR transmute.valid_char.DataflowConstProp.diff
2023
pub fn valid_char() -> char {
24+
// CHECK-LABEL: fn valid_char(
25+
// CHECK: _0 = const 'R';
2126
unsafe { transmute(0x52_u32) }
2227
}
2328

2429
// EMIT_MIR transmute.invalid_char.DataflowConstProp.diff
2530
pub unsafe fn invalid_char() -> char {
31+
// CHECK-LABEL: fn invalid_char(
32+
// CHECK: _0 = const {transmute(0x7fffffff): char};
2633
unsafe { transmute(i32::MAX) }
2734
}
2835

2936
// EMIT_MIR transmute.invalid_bool.DataflowConstProp.diff
3037
pub unsafe fn invalid_bool() -> bool {
38+
// CHECK-LABEL: fn invalid_bool(
39+
// CHECK: _0 = const {transmute(0xff): bool};
3140
unsafe { transmute(-1_i8) }
3241
}
3342

3443
// EMIT_MIR transmute.undef_union_as_integer.DataflowConstProp.diff
3544
pub unsafe fn undef_union_as_integer() -> u32 {
45+
// CHECK-LABEL: fn undef_union_as_integer(
46+
// CHECK: _1 = Union32 {
47+
// CHECK: _0 = move _1 as u32 (Transmute);
3648
union Union32 { value: u32, unit: () }
3749
unsafe { transmute(Union32 { unit: () }) }
3850
}
3951

4052
// EMIT_MIR transmute.unreachable_direct.DataflowConstProp.diff
4153
pub unsafe fn unreachable_direct() -> ! {
54+
// CHECK-LABEL: fn unreachable_direct(
55+
// CHECK: [[unit:_.*]] = ();
56+
// CHECK: move [[unit]] as Never (Transmute);
4257
let x: Never = unsafe { transmute(()) };
4358
match x {}
4459
}
4560

4661
// EMIT_MIR transmute.unreachable_ref.DataflowConstProp.diff
4762
pub unsafe fn unreachable_ref() -> ! {
63+
// CHECK-LABEL: fn unreachable_ref(
64+
// CHECK: = const {0x1 as &Never};
4865
let x: &Never = unsafe { transmute(1_usize) };
4966
match *x {}
5067
}
5168

5269
// EMIT_MIR transmute.unreachable_mut.DataflowConstProp.diff
5370
pub unsafe fn unreachable_mut() -> ! {
71+
// CHECK-LABEL: fn unreachable_mut(
72+
// CHECK: = const {0x1 as &mut Never};
5473
let x: &mut Never = unsafe { transmute(1_usize) };
5574
match *x {}
5675
}
5776

5877
// EMIT_MIR transmute.unreachable_box.DataflowConstProp.diff
5978
pub unsafe fn unreachable_box() -> ! {
79+
// CHECK-LABEL: fn unreachable_box(
80+
// CHECK: = const Box::<Never>(
6081
let x: Box<Never> = unsafe { transmute(1_usize) };
6182
match *x {}
6283
}

0 commit comments

Comments
 (0)