Update __rust_[rd]ealloc to take NonNull<u8> instead of *mut u8#153251
Update __rust_[rd]ealloc to take NonNull<u8> instead of *mut u8#153251scottmcm wants to merge 1 commit intorust-lang:mainfrom
__rust_[rd]ealloc to take NonNull<u8> instead of *mut u8#153251Conversation
Passing null to it is [already UB](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=8dcd25a549c11de72adc94a668277779) anyway.
|
r? @joboet rustbot has assigned @joboet. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| StorageLive(_9); | ||
| _9 = copy _8 as *mut u8 (Transmute); | ||
| _10 = alloc::alloc::__rust_dealloc(move _9, move _5, move _6) -> [return: bb3, unwind unreachable]; | ||
| _9 = alloc::alloc::__rust_dealloc(move _8, move _5, move _6) -> [return: bb3, unwind unreachable]; |
There was a problem hiding this comment.
Notably, this lets us avoid the transmute back from NonNull to *mut.
All the alloc code is doing the NonNull conversion in practice anyway, as it's using https://doc.rust-lang.org/std/alloc/struct.Global.html#method.deallocate not the alloc::dealloc function directly.
|
Makes sense to me. Let's see if this has any effect on performance... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Update `__rust_[rd]ealloc` to take `NonNull<u8>` instead of `*mut u8`
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (0fd2a86): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.1%, secondary 2.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary -6.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 477.793s -> 479.944s (0.45%) |
|
Yeah, that looks acceptable. |

Passing null to it is already UB per Miri anyway, and this is ABI-compatible as
NonNullisrepr(transparent).Inspired by #152702 (comment) ; Similar to #152605 which changed
align: usizetoalign: ptr::Alignment.