diff options
| author | bors <bors@rust-lang.org> | 2021-09-18 09:15:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-09-18 09:15:40 +0000 |
| commit | 6cdd42f9f8dd4e5e5ba0aa816bc4c99ab8b102f9 (patch) | |
| tree | fd318ddfe3cf15536f72f42637ea2944916abda4 | |
| parent | 5438ee424c004d7c89f16b9b1b95e899dbc87b25 (diff) | |
| parent | db5ecd539c38a4a096f3bc7550698ec1480a2ec4 (diff) | |
| download | rust-6cdd42f9f8dd4e5e5ba0aa816bc4c99ab8b102f9.tar.gz rust-6cdd42f9f8dd4e5e5ba0aa816bc4c99ab8b102f9.zip | |
Auto merge of #88988 - Mark-Simulacrum:avoid-into-ok, r=nagisa
Avoid codegen for Result::into_ok in lang_start
This extra codegen seems to be the cause for the regressions in max-rss on #86034. While LLVM will certainly optimize the dead code away, avoiding it's generation in the first place seems good, particularly when it is so simple.
#86034 produced this [diff](https://gist.github.com/Mark-Simulacrum/95c7599883093af3b960c35ffadf4dab#file-86034-diff) for a simple `fn main() {}`. With this PR, that diff [becomes limited to just a few extra IR instructions](https://gist.github.com/Mark-Simulacrum/95c7599883093af3b960c35ffadf4dab#file-88988-from-pre-diff) -- no extra functions.
Note that these are pre-optimization; LLVM surely will eliminate this during optimization. However, that optimization can end up generating more work and bump memory usage, and this eliminates that.
| -rw-r--r-- | library/std/src/rt.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/rt.rs b/library/std/src/rt.rs index b4f2adf938b..893167e3730 100644 --- a/library/std/src/rt.rs +++ b/library/std/src/rt.rs @@ -60,10 +60,10 @@ fn lang_start<T: crate::process::Termination + 'static>( argc: isize, argv: *const *const u8, ) -> isize { - lang_start_internal( + let Ok(v) = lang_start_internal( &move || crate::sys_common::backtrace::__rust_begin_short_backtrace(main).report(), argc, argv, - ) - .into_ok() + ); + v } |
