-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Update __rust_[rd]ealloc to take NonNull<u8> instead of *mut u8
#153251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+76
−97
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { | |
| let _2: std::ptr::NonNull<[T]>; | ||
| let mut _3: *mut [T]; | ||
| let mut _4: *const [T]; | ||
| let _10: (); | ||
| let _9: (); | ||
| scope 3 { | ||
| scope 4 { | ||
| scope 17 (inlined Layout::size) { | ||
|
|
@@ -28,15 +28,12 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { | |
| scope 23 (inlined <std::alloc::Global as Allocator>::deallocate) { | ||
| scope 24 (inlined std::alloc::Global::deallocate_impl) { | ||
| scope 25 (inlined std::alloc::Global::deallocate_impl_runtime) { | ||
| let mut _9: *mut u8; | ||
| scope 26 (inlined Layout::size) { | ||
| } | ||
| scope 27 (inlined NonNull::<u8>::as_ptr) { | ||
| } | ||
| scope 28 (inlined std::alloc::dealloc) { | ||
| scope 29 (inlined Layout::size) { | ||
| scope 27 (inlined alloc::alloc::dealloc_nonnull) { | ||
| scope 28 (inlined Layout::size) { | ||
| } | ||
| scope 30 (inlined Layout::alignment) { | ||
| scope 29 (inlined Layout::alignment) { | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -87,25 +84,18 @@ fn generic_in_place(_1: *mut Box<[T]>) -> () { | |
| bb1: { | ||
| _6 = const <T as std::mem::SizedTypeProperties>::ALIGN as std::ptr::Alignment (Transmute); | ||
| StorageDead(_4); | ||
| switchInt(copy _5) -> [0: bb4, otherwise: bb2]; | ||
| switchInt(copy _5) -> [0: bb3, otherwise: bb2]; | ||
| } | ||
|
|
||
| bb2: { | ||
| StorageLive(_7); | ||
| _7 = copy _3 as *mut u8 (PtrToPtr); | ||
| _8 = copy _7 as std::ptr::NonNull<u8> (Transmute); | ||
| StorageDead(_7); | ||
| 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]; | ||
|
Comment on lines
-98
to
+95
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notably, this lets us avoid the transmute back from All the alloc code is doing the |
||
| } | ||
|
|
||
| bb3: { | ||
| StorageDead(_9); | ||
| goto -> bb4; | ||
| } | ||
|
|
||
| bb4: { | ||
| StorageDead(_2); | ||
| StorageDead(_8); | ||
| StorageDead(_3); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth it to manually inline these functions. They are tiny and not even encapsulating any unsafeness or tricky logic. Would make optimizations slightly faster and backtraces slightly shorter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect that it's already disappeared in the shipped liballoc rlib since the mir inliner should have done that for us already. So it would remove a
inlinedentry in the mir scopes, but that's it, afaict.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MIR inlined calls do still show in backtraces.