Skip to content

Commit 5519cbf

Browse files
committed
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.
1 parent 7c4989a commit 5519cbf

File tree

1 file changed

+0
-22
lines changed
  • compiler/rustc_codegen_llvm/src/back

1 file changed

+0
-22
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -584,12 +584,6 @@ pub(crate) fn run_pass_manager(
584584
if write::should_use_new_llvm_pass_manager(config) {
585585
let opt_stage = if thin { llvm::OptStage::ThinLTO } else { llvm::OptStage::FatLTO };
586586
let opt_level = config.opt_level.unwrap_or(config::OptLevel::No);
587-
// See comment below for why this is necessary.
588-
let opt_level = if let config::OptLevel::No = opt_level {
589-
config::OptLevel::Less
590-
} else {
591-
opt_level
592-
};
593587
write::optimize_with_new_llvm_pass_manager(cgcx, module, config, opt_level, opt_stage);
594588
debug!("lto done");
595589
return;
@@ -603,26 +597,10 @@ pub(crate) fn run_pass_manager(
603597
llvm::LLVMRustAddPass(pm, pass.unwrap());
604598
}
605599

606-
// When optimizing for LTO we don't actually pass in `-O0`, but we force
607-
// it to always happen at least with `-O1`.
608-
//
609-
// With ThinLTO we mess around a lot with symbol visibility in a way
610-
// that will actually cause linking failures if we optimize at O0 which
611-
// notable is lacking in dead code elimination. To ensure we at least
612-
// get some optimizations and correctly link we forcibly switch to `-O1`
613-
// to get dead code elimination.
614-
//
615-
// Note that in general this shouldn't matter too much as you typically
616-
// only turn on ThinLTO when you're compiling with optimizations
617-
// otherwise.
618600
let opt_level = config
619601
.opt_level
620602
.map(|x| to_llvm_opt_settings(x).0)
621603
.unwrap_or(llvm::CodeGenOptLevel::None);
622-
let opt_level = match opt_level {
623-
llvm::CodeGenOptLevel::None => llvm::CodeGenOptLevel::Less,
624-
level => level,
625-
};
626604
with_llvm_pmb(module.module_llvm.llmod(), config, opt_level, false, &mut |b| {
627605
if thin {
628606
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);

0 commit comments

Comments
 (0)