]> git.lizzy.rs Git - rust.git/commit
std: Improve codegen size of accessing TLS
authorAlex Crichton <alex@alexcrichton.com>
Sun, 28 Oct 2018 15:26:47 +0000 (08:26 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 1 Nov 2018 17:46:31 +0000 (10:46 -0700)
commit0c3d08e9676a7defd16b88307838f7294d28c3e5
treec0989a845de8bc5eaccc4c042cea6a8eda8488ee
parent49ec93586ba46b429b8a51e186b5a3719e6bc7d1
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.
src/libstd/thread/local.rs
src/test/run-make/wasm-panic-small/Makefile
src/test/run-make/wasm-panic-small/foo.rs