Remove config parameter of optimize_fat and avoid interior mutability for module
This commit is contained in:
parent
ee94ff254a
commit
fab72301d9
@ -229,7 +229,7 @@ unsafe fn optimize(_cgcx: &CodegenContext<Self>, _diag_handler: &Handler, module
|
||||
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(())
|
||||
}
|
||||
|
@ -6,9 +6,7 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -212,11 +212,10 @@ unsafe fn optimize(
|
||||
}
|
||||
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>,
|
||||
|
@ -68,10 +68,9 @@ pub unsafe fn optimize(
|
||||
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)
|
||||
}
|
||||
|
@ -43,8 +43,7 @@ unsafe fn optimize(
|
||||
) -> 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>,
|
||||
|
Loading…
Reference in New Issue
Block a user