rust/tests/mir-opt/gvn.manual_slice_mut_len.GVN.panic-unwind.diff
Scott McMurray 4a7b6c0e6c More GVN for PtrMetadata
`PtrMetadata` doesn't care about `*const`/`*mut`/`&`/`&mut`, so GVN away those casts in its argument.

This includes updating MIR to allow calling PtrMetadata on references too, not just raw pointers.  That means that `[T]::len` can be just `_0 = PtrMetadata(_1)`, for example.

# Conflicts:
#	tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir
#	tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir
2024-06-20 22:16:59 -07:00

42 lines
985 B
Diff

- // MIR for `manual_slice_mut_len` before GVN
+ // MIR for `manual_slice_mut_len` after GVN
fn manual_slice_mut_len(_1: &mut [i32]) -> usize {
debug x => _1;
let mut _0: usize;
let _2: *mut [i32];
let mut _4: *mut [i32];
let mut _5: *const [i32];
scope 1 {
debug x => _2;
let _3: *const [i32];
scope 2 {
debug x => _3;
}
}
bb0: {
- StorageLive(_2);
+ nop;
_2 = &raw mut (*_1);
- StorageLive(_3);
+ nop;
StorageLive(_4);
_4 = _2;
- _3 = move _4 as *const [i32] (PtrToPtr);
+ _3 = _2 as *const [i32] (PtrToPtr);
StorageDead(_4);
StorageLive(_5);
_5 = _3;
- _0 = PtrMetadata(move _5);
+ _0 = PtrMetadata(_1);
StorageDead(_5);
- StorageDead(_3);
- StorageDead(_2);
+ nop;
+ nop;
return;
}
}