Skip to content

Commit 2860f77

Browse files
committed
Remove support for LLVM's legacy pass manager
1 parent a37499a commit 2860f77

File tree

8 files changed

+23
-653
lines changed

8 files changed

+23
-653
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3263,7 +3263,6 @@ dependencies = [
32633263
"bitflags",
32643264
"cstr",
32653265
"libc",
3266-
"libloading",
32673266
"measureme",
32683267
"object 0.29.0",
32693268
"rustc-demangle",

compiler/rustc_codegen_llvm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ doctest = false
1111
bitflags = "1.0"
1212
cstr = "0.2"
1313
libc = "0.2"
14-
libloading = "0.7.1"
1514
measureme = "10.0.0"
1615
object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "archive", "coff", "elf", "macho", "pe"] }
1716
tracing = "0.1"

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use crate::back::write::{
2-
self, save_temp_bitcode, to_llvm_opt_settings, with_llvm_pmb, DiagnosticHandlers,
3-
};
4-
use crate::llvm::{self, build_string, False, True};
5-
use crate::{llvm_util, LlvmCodegenBackend, ModuleLlvm};
1+
use crate::back::write::{self, save_temp_bitcode, DiagnosticHandlers};
2+
use crate::llvm::{self, build_string};
3+
use crate::{LlvmCodegenBackend, ModuleLlvm};
64
use object::read::archive::ArchiveFile;
75
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
86
use rustc_codegen_ssa::back::symbol_export;
@@ -597,61 +595,9 @@ pub(crate) fn run_pass_manager(
597595
1,
598596
);
599597
}
600-
if llvm_util::should_use_new_llvm_pass_manager(
601-
&config.new_llvm_pass_manager,
602-
&cgcx.target_arch,
603-
) {
604-
let opt_stage = if thin { llvm::OptStage::ThinLTO } else { llvm::OptStage::FatLTO };
605-
let opt_level = config.opt_level.unwrap_or(config::OptLevel::No);
606-
write::optimize_with_new_llvm_pass_manager(
607-
cgcx,
608-
diag_handler,
609-
module,
610-
config,
611-
opt_level,
612-
opt_stage,
613-
)?;
614-
debug!("lto done");
615-
return Ok(());
616-
}
617-
618-
let pm = llvm::LLVMCreatePassManager();
619-
llvm::LLVMAddAnalysisPasses(module.module_llvm.tm, pm);
620-
621-
if config.verify_llvm_ir {
622-
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr().cast());
623-
llvm::LLVMRustAddPass(pm, pass.unwrap());
624-
}
625-
626-
let opt_level = config
627-
.opt_level
628-
.map(|x| to_llvm_opt_settings(x).0)
629-
.unwrap_or(llvm::CodeGenOptLevel::None);
630-
with_llvm_pmb(module.module_llvm.llmod(), config, opt_level, false, &mut |b| {
631-
if thin {
632-
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
633-
} else {
634-
llvm::LLVMRustPassManagerBuilderPopulateLTOPassManager(
635-
b, pm, /* Internalize = */ False, /* RunInliner = */ True,
636-
);
637-
}
638-
});
639-
640-
// We always generate bitcode through ThinLTOBuffers,
641-
// which do not support anonymous globals
642-
if config.bitcode_needed() {
643-
let pass = llvm::LLVMRustFindAndCreatePass("name-anon-globals\0".as_ptr().cast());
644-
llvm::LLVMRustAddPass(pm, pass.unwrap());
645-
}
646-
647-
if config.verify_llvm_ir {
648-
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr().cast());
649-
llvm::LLVMRustAddPass(pm, pass.unwrap());
650-
}
651-
652-
llvm::LLVMRunPassManager(pm, module.module_llvm.llmod());
653-
654-
llvm::LLVMDisposePassManager(pm);
598+
let opt_stage = if thin { llvm::OptStage::ThinLTO } else { llvm::OptStage::FatLTO };
599+
let opt_level = config.opt_level.unwrap_or(config::OptLevel::No);
600+
write::optimize(cgcx, diag_handler, module, config, opt_level, opt_stage)?;
655601
}
656602
debug!("lto done");
657603
Ok(())

0 commit comments

Comments
 (0)