-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make certain panicky stdlib functions behave better under panic_immediate_abort #91737
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1653,13 +1653,26 @@ impl<T> Result<T, T> { | |
} | ||
|
||
// This is a separate function to reduce the code size of the methods | ||
#[cfg(not(feature = "panic_immediate_abort"))] | ||
#[inline(never)] | ||
#[cold] | ||
#[track_caller] | ||
fn unwrap_failed(msg: &str, error: &dyn fmt::Debug) -> ! { | ||
panic!("{}: {:?}", msg, error) | ||
} | ||
|
||
// This is a separate function to avoid constructing a `dyn Debug` | ||
// that gets immediately thrown away, since vtables don't get cleaned up | ||
// by dead code elimination if a trait object is constructed even if it goes | ||
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. Is this a limitation of LLVM, or is it something that could be addressed on our end? 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. I don't think this can be addressed on our end because it's something that has to be run after the rest of the optimizations 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. Isn't I am pretty sure LLVM can handle removing unused 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. @eddyb In my experience LLVM is eager to keep around vtable specs that are never used. I think it treats the construction of a dyn and its use differently and if one goes away it doesn't necessarily figure out the other should too. |
||
// unused | ||
#[cfg(feature = "panic_immediate_abort")] | ||
#[inline] | ||
#[cold] | ||
#[track_caller] | ||
fn unwrap_failed<T>(_msg: &str, _error: &T) -> ! { | ||
panic!() | ||
} | ||
|
||
///////////////////////////////////////////////////////////////////////////// | ||
// Trait implementations | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
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.
Does
#[inline]
have any effect when it's also#[cold]
?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.
No idea! We could gate that attribute too, I guess