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.
This commit is contained in:
parent
7c4989ab70
commit
5519cbfe33
1 changed files with 0 additions and 22 deletions
|
@ -584,12 +584,6 @@ pub(crate) fn run_pass_manager(
|
||||||
if write::should_use_new_llvm_pass_manager(config) {
|
if write::should_use_new_llvm_pass_manager(config) {
|
||||||
let opt_stage = if thin { llvm::OptStage::ThinLTO } else { llvm::OptStage::FatLTO };
|
let opt_stage = if thin { llvm::OptStage::ThinLTO } else { llvm::OptStage::FatLTO };
|
||||||
let opt_level = config.opt_level.unwrap_or(config::OptLevel::No);
|
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);
|
write::optimize_with_new_llvm_pass_manager(cgcx, module, config, opt_level, opt_stage);
|
||||||
debug!("lto done");
|
debug!("lto done");
|
||||||
return;
|
return;
|
||||||
|
@ -603,26 +597,10 @@ pub(crate) fn run_pass_manager(
|
||||||
llvm::LLVMRustAddPass(pm, pass.unwrap());
|
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
|
let opt_level = config
|
||||||
.opt_level
|
.opt_level
|
||||||
.map(|x| to_llvm_opt_settings(x).0)
|
.map(|x| to_llvm_opt_settings(x).0)
|
||||||
.unwrap_or(llvm::CodeGenOptLevel::None);
|
.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| {
|
with_llvm_pmb(module.module_llvm.llmod(), config, opt_level, false, &mut |b| {
|
||||||
if thin {
|
if thin {
|
||||||
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
|
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue