Skip to content

Commit f431df0

Browse files
committed
Load new pass manager plugins only if the new pm is actually used
1 parent 052961b commit f431df0

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

Diff for: compiler/rustc_codegen_llvm/src/llvm_util.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ unsafe fn configure_llvm(sess: &Session) {
119119

120120
llvm::LLVMInitializePasses();
121121

122-
let use_new_llvm_pm_plugin_register =
123-
sess.opts.debugging_opts.new_llvm_pass_manager.unwrap_or(false);
124-
125-
// Use the legacy pm registration if the new_llvm_pass_manager option isn't explicitly enabled
126-
if !use_new_llvm_pm_plugin_register {
122+
// Use the legacy plugin registration if we don't use the new pass manager
123+
if !should_use_new_llvm_pass_manager(
124+
&sess.opts.debugging_opts.new_llvm_pass_manager,
125+
&sess.target.arch,
126+
) {
127127
// Register LLVM plugins by loading them into the compiler process.
128128
for plugin in &sess.opts.debugging_opts.llvm_plugins {
129129
let lib = Library::new(plugin).unwrap_or_else(|e| bug!("couldn't load plugin: {}", e));

Diff for: compiler/rustc_codegen_ssa/src/back/write.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,7 @@ impl ModuleConfig {
261261
inline_threshold: sess.opts.cg.inline_threshold,
262262
new_llvm_pass_manager: sess.opts.debugging_opts.new_llvm_pass_manager,
263263
emit_lifetime_markers: sess.emit_lifetime_markers(),
264-
llvm_plugins: if sess.opts.debugging_opts.new_llvm_pass_manager.unwrap_or(false) {
265-
if_regular!(sess.opts.debugging_opts.llvm_plugins.clone(), vec![])
266-
} else {
267-
vec![]
268-
},
264+
llvm_plugins: if_regular!(sess.opts.debugging_opts.llvm_plugins.clone(), vec![]),
269265
}
270266
}
271267

0 commit comments

Comments
 (0)