-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
std: Improve codegen size of accessing TLS #55518
Conversation
r? @bluss (rust_highfive has picked a reviewer for you, use r? to override) |
r? @sfackler |
@bors r+ |
📌 Commit 62eec9ee4c523ead0f46f1a5e6e85460ef02bc1a has been approved by |
src/libstd/thread/local.rs
Outdated
(*ptr).as_ref().unwrap() | ||
match *ptr { | ||
Some(ref x) => x, | ||
None => intrinsics::unreachable(), |
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 think this really deserves a comment indicating why it was done -- could you add one? That way we can avoid confusion or cleanup removing this without knowing what to check
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.
Sure thing!
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.
Also don't we have unreachable_unchecked so that we do not have to call an intrinsic directly?
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.
Sure!
62eec9e
to
36990de
Compare
@bors: r=sfackler |
📌 Commit 36990de9f160739bc56925d4e7036e13476300be has been approved by |
36990de
to
f64efa5
Compare
@bors: r=sfackler |
📌 Commit f64efa5ea3607047aba695154767030da5abf3d4 has been approved by |
This comment has been minimized.
This comment has been minimized.
f64efa5
to
c24c2c9
Compare
@bors: r=sfackler |
📌 Commit c24c2c95f47f05eec17f3c4afbd981addb795fbf has been approved by |
@bors r- Failed in #55579 (comment) |
No need for this to actually show up in optimized non-LTO executables!
Some code in the TLS implementation in libstd stores `Some(val)` into an `&mut Option<T>` (effectively) and then pulls out `&T`, but it currently uses `.unwrap()` which can codegen into a panic even though it can never panic. With sufficient optimizations enabled (like LTO) the compiler can see through this but this commit helps it along in normal mode (`--release` with Cargo by default) to avoid codegen'ing the panic path. This ends up improving the optimized codegen on wasm by ensuring that a call to panic pulling in more file size doesn't stick around.
💔 Test failed - status-appveyor |
@bors: retry Seems spurious ... |
std: Improve codegen size of accessing TLS Some code in the TLS implementation in libstd stores `Some(val)` into an `&mut Option<T>` (effectively) and then pulls out `&T`, but it currently uses `.unwrap()` which can codegen into a panic even though it can never panic. With sufficient optimizations enabled (like LTO) the compiler can see through this but this commit helps it along in normal mode (`--release` with Cargo by default) to avoid codegen'ing the panic path. This ends up improving the optimized codegen on wasm by ensuring that a call to panic pulling in more file size doesn't stick around.
💔 Test failed - status-travis |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
std: Improve codegen size of accessing TLS Some code in the TLS implementation in libstd stores `Some(val)` into an `&mut Option<T>` (effectively) and then pulls out `&T`, but it currently uses `.unwrap()` which can codegen into a panic even though it can never panic. With sufficient optimizations enabled (like LTO) the compiler can see through this but this commit helps it along in normal mode (`--release` with Cargo by default) to avoid codegen'ing the panic path. This ends up improving the optimized codegen on wasm by ensuring that a call to panic pulling in more file size doesn't stick around.
💔 Test failed - status-appveyor |
@bors: retry 3 hr timeout |
std: Improve codegen size of accessing TLS Some code in the TLS implementation in libstd stores `Some(val)` into an `&mut Option<T>` (effectively) and then pulls out `&T`, but it currently uses `.unwrap()` which can codegen into a panic even though it can never panic. With sufficient optimizations enabled (like LTO) the compiler can see through this but this commit helps it along in normal mode (`--release` with Cargo by default) to avoid codegen'ing the panic path. This ends up improving the optimized codegen on wasm by ensuring that a call to panic pulling in more file size doesn't stick around.
☀️ Test successful - status-appveyor, status-travis |
Some code in the TLS implementation in libstd stores
Some(val)
into an&mut Option<T>
(effectively) and then pulls out&T
, but it currentlyuses
.unwrap()
which can codegen into a panic even though it can neverpanic. With sufficient optimizations enabled (like LTO) the compiler can
see through this but this commit helps it along in normal mode
(
--release
with Cargo by default) to avoid codegen'ing the panic path.This ends up improving the optimized codegen on wasm by ensuring that a
call to panic pulling in more file size doesn't stick around.