Skip to content

Commit

Permalink
Bless mir opt tests and remove some broken custom MIR
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Feb 5, 2024
1 parent 74cde5f commit 7a9159b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/mir-opt/dataflow-const-prop/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn statics() {

static RC: &E = &E::V2(4);

// CHECK: [[t:_.*]] = const {alloc2: &&E};
// CHECK: [[t:_.*]] = const {alloc4: &&E};
// CHECK: [[e2]] = (*[[t]]);
let e2 = RC;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
let mut _0: ();
let mut _1: u32;
let mut _2: i64;
let mut _3: i64;
let mut _4: u32;
let mut _5: usize;
let mut _3: usize;

bb0: {
- _1 = const 1_i32 as u32 (Transmute);
- _2 = const 1_u64 as i64 (Transmute);
- _3 = const 1_isize as usize (Transmute);
+ _1 = const 1_i32 as u32 (IntToInt);
_2 = const 1_i32 as i64 (Transmute);
- _3 = const 1_u64 as i64 (Transmute);
+ _3 = const 1_u64 as i64 (IntToInt);
_4 = const 1_u64 as u32 (Transmute);
- _5 = const 1_isize as usize (Transmute);
+ _5 = const 1_isize as usize (IntToInt);
+ _2 = const 1_u64 as i64 (IntToInt);
+ _3 = const 1_isize as usize (IntToInt);
return;
}
}
Expand Down
11 changes: 5 additions & 6 deletions tests/mir-opt/instsimplify/combine_transmutes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![feature(custom_mir)]

use std::intrinsics::mir::*;
use std::mem::{MaybeUninit, ManuallyDrop, transmute};
use std::mem::{transmute, ManuallyDrop, MaybeUninit};

// EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff
pub unsafe fn identity_transmutes() {
Expand All @@ -25,19 +25,15 @@ pub unsafe fn integer_transmutes() {
// CHECK-LABEL: fn integer_transmutes(
// CHECK-NOT: _i32 as u32 (Transmute);
// CHECK: _i32 as u32 (IntToInt);
// CHECK: _i32 as i64 (Transmute);
// CHECK-NOT: _u64 as i64 (Transmute);
// CHECK: _u64 as i64 (IntToInt);
// CHECK: _u64 as u32 (Transmute);
// CHECK-NOT: _isize as usize (Transmute);
// CHECK: _isize as usize (IntToInt);

mir! {
{
let A = CastTransmute::<i32, u32>(1); // Can be a cast
let B = CastTransmute::<i32, i64>(1); // UB
let C = CastTransmute::<u64, i64>(1); // Can be a cast
let D = CastTransmute::<u64, u32>(1); // UB
let E = CastTransmute::<isize, usize>(1); // Can be a cast
Return()
}
Expand All @@ -62,4 +58,7 @@ pub unsafe fn adt_transmutes() {
let _a: ManuallyDrop<String> = transmute(MaybeUninit::<String>::uninit());
}

pub union Union32 { u32: u32, i32: i32 }
pub union Union32 {
u32: u32,
i32: i32,
}

0 comments on commit 7a9159b

Please sign in to comment.