Skip to content

Commit fab7230

Browse files
committed
Remove config parameter of optimize_fat and avoid interior mutability for module
1 parent ee94ff2 commit fab7230

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

compiler/rustc_codegen_gcc/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl WriteBackendMethods for GccCodegenBackend {
229229
Ok(())
230230
}
231231

232-
fn optimize_fat(_cgcx: &CodegenContext<Self>, _module: &ModuleCodegen<Self::Module>, _config: &ModuleConfig) -> Result<(), FatalError> {
232+
fn optimize_fat(_cgcx: &CodegenContext<Self>, _module: &mut ModuleCodegen<Self::Module>) -> Result<(), FatalError> {
233233
// TODO(antoyo)
234234
Ok(())
235235
}

compiler/rustc_codegen_llvm/src/back/lto.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use crate::llvm::{self, build_string, False, True};
66
use crate::{llvm_util, LlvmCodegenBackend, ModuleLlvm};
77
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
88
use rustc_codegen_ssa::back::symbol_export;
9-
use rustc_codegen_ssa::back::write::{
10-
CodegenContext, FatLTOInput, ModuleConfig, TargetMachineFactoryConfig,
11-
};
9+
use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, TargetMachineFactoryConfig};
1210
use rustc_codegen_ssa::traits::*;
1311
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
1412
use rustc_data_structures::fx::FxHashMap;
@@ -578,11 +576,11 @@ fn thin_lto(
578576
pub(crate) fn run_pass_manager(
579577
cgcx: &CodegenContext<LlvmCodegenBackend>,
580578
diag_handler: &Handler,
581-
module: &ModuleCodegen<ModuleLlvm>,
582-
config: &ModuleConfig,
579+
module: &mut ModuleCodegen<ModuleLlvm>,
583580
thin: bool,
584581
) -> Result<(), FatalError> {
585582
let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &*module.name);
583+
let config = cgcx.config(module.kind);
586584

587585
// Now we have one massive module inside of llmod. Time to run the
588586
// LTO-specific optimization passes that LLVM provides.
@@ -743,7 +741,7 @@ pub unsafe fn optimize_thin_module(
743741
// that LLVM Context and Module.
744742
let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
745743
let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &diag_handler)? as *const _;
746-
let module = ModuleCodegen {
744+
let mut module = ModuleCodegen {
747745
module_llvm: ModuleLlvm { llmod_raw, llcx, tm },
748746
name: thin_module.name().to_string(),
749747
kind: ModuleKind::Regular,
@@ -859,8 +857,7 @@ pub unsafe fn optimize_thin_module(
859857
// little differently.
860858
{
861859
info!("running thin lto passes over {}", module.name);
862-
let config = cgcx.config(module.kind);
863-
run_pass_manager(cgcx, &diag_handler, &module, config, true)?;
860+
run_pass_manager(cgcx, &diag_handler, &mut module, true)?;
864861
save_temp_bitcode(cgcx, &module, "thin-lto-after-pm");
865862
}
866863
}

compiler/rustc_codegen_llvm/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,10 @@ impl WriteBackendMethods for LlvmCodegenBackend {
212212
}
213213
fn optimize_fat(
214214
cgcx: &CodegenContext<Self>,
215-
module: &ModuleCodegen<Self::Module>,
216-
config: &ModuleConfig,
215+
module: &mut ModuleCodegen<Self::Module>,
217216
) -> Result<(), FatalError> {
218217
let diag_handler = cgcx.create_diag_handler();
219-
back::lto::run_pass_manager(cgcx, &diag_handler, module, config, false)
218+
back::lto::run_pass_manager(cgcx, &diag_handler, module, false)
220219
}
221220
unsafe fn optimize_thin(
222221
cgcx: &CodegenContext<Self>,

compiler/rustc_codegen_ssa/src/back/lto.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
6868
cgcx: &CodegenContext<B>,
6969
) -> Result<ModuleCodegen<B::Module>, FatalError> {
7070
match self {
71-
LtoModuleCodegen::Fat { module, .. } => {
71+
LtoModuleCodegen::Fat { mut module, .. } => {
7272
{
73-
let config = cgcx.config(module.kind);
74-
B::optimize_fat(cgcx, &module, config)?;
73+
B::optimize_fat(cgcx, &mut module)?;
7574
}
7675
Ok(module)
7776
}

compiler/rustc_codegen_ssa/src/traits/write.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
4343
) -> Result<(), FatalError>;
4444
fn optimize_fat(
4545
cgcx: &CodegenContext<Self>,
46-
llmod: &ModuleCodegen<Self::Module>,
47-
config: &ModuleConfig,
46+
llmod: &mut ModuleCodegen<Self::Module>,
4847
) -> Result<(), FatalError>;
4948
unsafe fn optimize_thin(
5049
cgcx: &CodegenContext<Self>,

0 commit comments

Comments
 (0)