diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2021-04-05 11:12:45 +0200 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-05-08 10:58:08 +0200 |
| commit | 5519cbfe334182f57047ea00368f3fd0b9ca0d1c (patch) | |
| tree | cacb3abc042ab79535ac178553e9bf6b2b79db96 /compiler/rustc_codegen_llvm/src | |
| parent | 7c4989ab707e246b507caf0f554741a7518bc868 (diff) | |
| download | rust-5519cbfe334182f57047ea00368f3fd0b9ca0d1c.tar.gz rust-5519cbfe334182f57047ea00368f3fd0b9ca0d1c.zip | |
Don't force -O1 with ThinLTO
This doesn't seem to be necessary anymore, although I don't know at which point or why that changed. Forcing -O1 makes some tests fail under NewPM, because NewPM also performs inlining at -O1, so it ends up performing much more optimization in practice than before.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/lto.rs | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 4226ed7d99b..48ca7c0060a 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -584,12 +584,6 @@ pub(crate) fn run_pass_manager( if write::should_use_new_llvm_pass_manager(config) { let opt_stage = if thin { llvm::OptStage::ThinLTO } else { llvm::OptStage::FatLTO }; let opt_level = config.opt_level.unwrap_or(config::OptLevel::No); - // See comment below for why this is necessary. - let opt_level = if let config::OptLevel::No = opt_level { - config::OptLevel::Less - } else { - opt_level - }; write::optimize_with_new_llvm_pass_manager(cgcx, module, config, opt_level, opt_stage); debug!("lto done"); return; @@ -603,26 +597,10 @@ pub(crate) fn run_pass_manager( llvm::LLVMRustAddPass(pm, pass.unwrap()); } - // When optimizing for LTO we don't actually pass in `-O0`, but we force - // it to always happen at least with `-O1`. - // - // With ThinLTO we mess around a lot with symbol visibility in a way - // that will actually cause linking failures if we optimize at O0 which - // notable is lacking in dead code elimination. To ensure we at least - // get some optimizations and correctly link we forcibly switch to `-O1` - // to get dead code elimination. - // - // Note that in general this shouldn't matter too much as you typically - // only turn on ThinLTO when you're compiling with optimizations - // otherwise. let opt_level = config .opt_level .map(|x| to_llvm_opt_settings(x).0) .unwrap_or(llvm::CodeGenOptLevel::None); - let opt_level = match opt_level { - llvm::CodeGenOptLevel::None => llvm::CodeGenOptLevel::Less, - level => level, - }; with_llvm_pmb(module.module_llvm.llmod(), config, opt_level, false, &mut |b| { if thin { llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm); |
