Add a mir-opt test for drop shims of arrays

This commit is contained in:
Scott McMurray 2024-12-14 21:19:01 -08:00
parent b57d93d8b9
commit e1a727e466
2 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,55 @@
// MIR for `std::ptr::drop_in_place` before AddMovesForPackedDrops
fn std::ptr::drop_in_place(_1: *mut [String; 42]) -> () {
let mut _0: ();
let mut _2: usize;
let mut _3: usize;
let mut _4: *mut std::string::String;
let mut _5: bool;
let mut _6: *mut std::string::String;
let mut _7: bool;
bb0: {
goto -> bb8;
}
bb1: {
return;
}
bb2 (cleanup): {
resume;
}
bb3 (cleanup): {
_4 = &raw mut (*_1)[_3];
_3 = Add(move _3, const 1_usize);
drop((*_4)) -> [return: bb4, unwind terminate(cleanup)];
}
bb4 (cleanup): {
_5 = Eq(copy _3, copy _2);
switchInt(move _5) -> [0: bb3, otherwise: bb2];
}
bb5: {
_6 = &raw mut (*_1)[_3];
_3 = Add(move _3, const 1_usize);
drop((*_6)) -> [return: bb6, unwind: bb4];
}
bb6: {
_7 = Eq(copy _3, copy _2);
switchInt(move _7) -> [0: bb5, otherwise: bb1];
}
bb7: {
_2 = Len((*_1));
_3 = const 0_usize;
goto -> bb6;
}
bb8: {
goto -> bb7;
}
}

View file

@ -5,6 +5,8 @@
// if we use -Clink-dead-code.
// EMIT_MIR core.ptr-drop_in_place.[String].AddMovesForPackedDrops.before.mir
// EMIT_MIR core.ptr-drop_in_place.[String;42].AddMovesForPackedDrops.before.mir
fn main() {
let _fn = std::ptr::drop_in_place::<[String]> as unsafe fn(_);
let _fn = std::ptr::drop_in_place::<[String; 42]> as unsafe fn(_);
}