diff options
| author | bjorn3 <bjorn3@users.noreply.github.com> | 2022-04-30 20:58:42 +0200 |
|---|---|---|
| committer | bjorn3 <bjorn3@users.noreply.github.com> | 2022-04-30 20:58:42 +0200 |
| commit | fab72301d9089761766b389df209986c2bc38e5d (patch) | |
| tree | 31539769a409546a5d822f09cd8183c40be22dda | |
| parent | ee94ff254aceccd27919f26c02541277a3ca7dd7 (diff) | |
| download | rust-fab72301d9089761766b389df209986c2bc38e5d.tar.gz rust-fab72301d9089761766b389df209986c2bc38e5d.zip | |
Remove config parameter of optimize_fat and avoid interior mutability for module
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/lto.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/lib.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/lto.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/traits/write.rs | 3 |
5 files changed, 11 insertions, 17 deletions
diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index 72da59a1bf8..684b845c38a 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -229,7 +229,7 @@ impl WriteBackendMethods for GccCodegenBackend { Ok(()) } - fn optimize_fat(_cgcx: &CodegenContext<Self>, _module: &ModuleCodegen<Self::Module>, _config: &ModuleConfig) -> Result<(), FatalError> { + fn optimize_fat(_cgcx: &CodegenContext<Self>, _module: &mut ModuleCodegen<Self::Module>) -> Result<(), FatalError> { // TODO(antoyo) Ok(()) } diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 570410caaab..b5b2a27d237 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -6,9 +6,7 @@ use crate::llvm::{self, build_string, False, True}; use crate::{llvm_util, LlvmCodegenBackend, ModuleLlvm}; use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared}; use rustc_codegen_ssa::back::symbol_export; -use rustc_codegen_ssa::back::write::{ - CodegenContext, FatLTOInput, ModuleConfig, TargetMachineFactoryConfig, -}; +use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, TargetMachineFactoryConfig}; use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind}; use rustc_data_structures::fx::FxHashMap; @@ -578,11 +576,11 @@ fn thin_lto( pub(crate) fn run_pass_manager( cgcx: &CodegenContext<LlvmCodegenBackend>, diag_handler: &Handler, - module: &ModuleCodegen<ModuleLlvm>, - config: &ModuleConfig, + module: &mut ModuleCodegen<ModuleLlvm>, thin: bool, ) -> Result<(), FatalError> { let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &*module.name); + let config = cgcx.config(module.kind); // Now we have one massive module inside of llmod. Time to run the // LTO-specific optimization passes that LLVM provides. @@ -743,7 +741,7 @@ pub unsafe fn optimize_thin_module( // that LLVM Context and Module. let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names); let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &diag_handler)? as *const _; - let module = ModuleCodegen { + let mut module = ModuleCodegen { module_llvm: ModuleLlvm { llmod_raw, llcx, tm }, name: thin_module.name().to_string(), kind: ModuleKind::Regular, @@ -859,8 +857,7 @@ pub unsafe fn optimize_thin_module( // little differently. { info!("running thin lto passes over {}", module.name); - let config = cgcx.config(module.kind); - run_pass_manager(cgcx, &diag_handler, &module, config, true)?; + run_pass_manager(cgcx, &diag_handler, &mut module, true)?; save_temp_bitcode(cgcx, &module, "thin-lto-after-pm"); } } diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs index c3db6352a53..b48c738124d 100644 --- a/compiler/rustc_codegen_llvm/src/lib.rs +++ b/compiler/rustc_codegen_llvm/src/lib.rs @@ -212,11 +212,10 @@ impl WriteBackendMethods for LlvmCodegenBackend { } fn optimize_fat( cgcx: &CodegenContext<Self>, - module: &ModuleCodegen<Self::Module>, - config: &ModuleConfig, + module: &mut ModuleCodegen<Self::Module>, ) -> Result<(), FatalError> { let diag_handler = cgcx.create_diag_handler(); - back::lto::run_pass_manager(cgcx, &diag_handler, module, config, false) + back::lto::run_pass_manager(cgcx, &diag_handler, module, false) } unsafe fn optimize_thin( cgcx: &CodegenContext<Self>, diff --git a/compiler/rustc_codegen_ssa/src/back/lto.rs b/compiler/rustc_codegen_ssa/src/back/lto.rs index 6dc8cb5038e..3c5b0e5cc43 100644 --- a/compiler/rustc_codegen_ssa/src/back/lto.rs +++ b/compiler/rustc_codegen_ssa/src/back/lto.rs @@ -68,10 +68,9 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> { cgcx: &CodegenContext<B>, ) -> Result<ModuleCodegen<B::Module>, FatalError> { match self { - LtoModuleCodegen::Fat { module, .. } => { + LtoModuleCodegen::Fat { mut module, .. } => { { - let config = cgcx.config(module.kind); - B::optimize_fat(cgcx, &module, config)?; + B::optimize_fat(cgcx, &mut module)?; } Ok(module) } diff --git a/compiler/rustc_codegen_ssa/src/traits/write.rs b/compiler/rustc_codegen_ssa/src/traits/write.rs index ed0f6591809..e54ec34f1ce 100644 --- a/compiler/rustc_codegen_ssa/src/traits/write.rs +++ b/compiler/rustc_codegen_ssa/src/traits/write.rs @@ -43,8 +43,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone { ) -> Result<(), FatalError>; fn optimize_fat( cgcx: &CodegenContext<Self>, - llmod: &ModuleCodegen<Self::Module>, - config: &ModuleConfig, + llmod: &mut ModuleCodegen<Self::Module>, ) -> Result<(), FatalError>; unsafe fn optimize_thin( cgcx: &CodegenContext<Self>, |
