Skip to content

Commit 54bb4fe

Browse files
committed
Auto merge of #89666 - rusticstuff:disable_new_llvm_pass_manager_on_s390x_take_two, r=nagisa
Default to disabling the new pass manager for the s390x arch targets. This hack disables the new LLVM pass manager by default for s390x arch targets until the performance issues are fixed (see #89609). The command line option `-Z new-llvm-pass-manager=(yes|no)` continues to take precedence over this default.
2 parents 87df4dd + 4593d78 commit 54bb4fe

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ pub(crate) fn run_pass_manager(
596596
// tools/lto/LTOCodeGenerator.cpp
597597
debug!("running the pass manager");
598598
unsafe {
599-
if write::should_use_new_llvm_pass_manager(config) {
599+
if write::should_use_new_llvm_pass_manager(cgcx, config) {
600600
let opt_stage = if thin { llvm::OptStage::ThinLTO } else { llvm::OptStage::FatLTO };
601601
let opt_level = config.opt_level.unwrap_or(config::OptLevel::No);
602602
write::optimize_with_new_llvm_pass_manager(

compiler/rustc_codegen_llvm/src/back/write.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,19 @@ fn get_pgo_sample_use_path(config: &ModuleConfig) -> Option<CString> {
377377
.map(|path_buf| CString::new(path_buf.to_string_lossy().as_bytes()).unwrap())
378378
}
379379

380-
pub(crate) fn should_use_new_llvm_pass_manager(config: &ModuleConfig) -> bool {
380+
pub(crate) fn should_use_new_llvm_pass_manager(
381+
cgcx: &CodegenContext<LlvmCodegenBackend>,
382+
config: &ModuleConfig,
383+
) -> bool {
381384
// The new pass manager is enabled by default for LLVM >= 13.
382385
// This matches Clang, which also enables it since Clang 13.
383-
config.new_llvm_pass_manager.unwrap_or_else(|| llvm_util::get_version() >= (13, 0, 0))
386+
387+
// FIXME: There are some perf issues with the new pass manager
388+
// when targeting s390x, so it is temporarily disabled for that
389+
// arch, see https://github.com/rust-lang/rust/issues/89609
390+
config
391+
.new_llvm_pass_manager
392+
.unwrap_or_else(|| cgcx.target_arch != "s390x" && llvm_util::get_version() >= (13, 0, 0))
384393
}
385394

386395
pub(crate) unsafe fn optimize_with_new_llvm_pass_manager(
@@ -482,7 +491,7 @@ pub(crate) unsafe fn optimize(
482491
}
483492

484493
if let Some(opt_level) = config.opt_level {
485-
if should_use_new_llvm_pass_manager(config) {
494+
if should_use_new_llvm_pass_manager(cgcx, config) {
486495
let opt_stage = match cgcx.lto {
487496
Lto::Fat => llvm::OptStage::PreLinkFatLTO,
488497
Lto::Thin | Lto::ThinLocal => llvm::OptStage::PreLinkThinLTO,

0 commit comments

Comments
 (0)