mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Let LtoModuleCodegen::optimize take self by value
This commit is contained in:
parent
336bb0afea
commit
ee94ff254a
@ -213,7 +213,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||
unimplemented!();
|
||||
}
|
||||
};
|
||||
Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: vec![] })
|
||||
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: vec![] })
|
||||
}
|
||||
|
||||
fn run_thin_lto(_cgcx: &CodegenContext<Self>, _modules: Vec<(String, Self::ThinBuffer)>, _cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError> {
|
||||
@ -234,7 +234,7 @@ impl WriteBackendMethods for GccCodegenBackend {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
unsafe fn optimize_thin(_cgcx: &CodegenContext<Self>, _thin: &mut ThinModule<Self>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
||||
unsafe fn optimize_thin(_cgcx: &CodegenContext<Self>, _thin: ThinModule<Self>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ fn fat_lto(
|
||||
}
|
||||
}
|
||||
|
||||
Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: serialized_bitcode })
|
||||
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode })
|
||||
}
|
||||
|
||||
crate struct Linker<'a>(&'a mut llvm::Linker<'a>);
|
||||
@ -726,7 +726,7 @@ impl Drop for ThinBuffer {
|
||||
}
|
||||
|
||||
pub unsafe fn optimize_thin_module(
|
||||
thin_module: &mut ThinModule<LlvmCodegenBackend>,
|
||||
thin_module: ThinModule<LlvmCodegenBackend>,
|
||||
cgcx: &CodegenContext<LlvmCodegenBackend>,
|
||||
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
|
||||
let diag_handler = cgcx.create_diag_handler();
|
||||
|
@ -220,7 +220,7 @@ impl WriteBackendMethods for LlvmCodegenBackend {
|
||||
}
|
||||
unsafe fn optimize_thin(
|
||||
cgcx: &CodegenContext<Self>,
|
||||
thin: &mut ThinModule<Self>,
|
||||
thin: ThinModule<Self>,
|
||||
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
|
||||
back::lto::optimize_thin_module(thin, cgcx)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ pub struct ThinShared<B: WriteBackendMethods> {
|
||||
|
||||
pub enum LtoModuleCodegen<B: WriteBackendMethods> {
|
||||
Fat {
|
||||
module: Option<ModuleCodegen<B::Module>>,
|
||||
module: ModuleCodegen<B::Module>,
|
||||
_serialized_bitcode: Vec<SerializedModule<B::ModuleBuffer>>,
|
||||
},
|
||||
|
||||
@ -64,19 +64,18 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
|
||||
/// It's intended that the module returned is immediately code generated and
|
||||
/// dropped, and then this LTO module is dropped.
|
||||
pub unsafe fn optimize(
|
||||
&mut self,
|
||||
self,
|
||||
cgcx: &CodegenContext<B>,
|
||||
) -> Result<ModuleCodegen<B::Module>, FatalError> {
|
||||
match *self {
|
||||
LtoModuleCodegen::Fat { ref mut module, .. } => {
|
||||
let module = module.take().unwrap();
|
||||
match self {
|
||||
LtoModuleCodegen::Fat { module, .. } => {
|
||||
{
|
||||
let config = cgcx.config(module.kind);
|
||||
B::run_lto_pass_manager(cgcx, &module, config, false)?;
|
||||
B::optimize_fat(cgcx, &module, config)?;
|
||||
}
|
||||
Ok(module)
|
||||
}
|
||||
LtoModuleCodegen::Thin(ref mut thin) => B::optimize_thin(cgcx, thin),
|
||||
LtoModuleCodegen::Thin(thin) => B::optimize_thin(cgcx, thin),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,7 +889,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
|
||||
|
||||
fn execute_lto_work_item<B: ExtraBackendMethods>(
|
||||
cgcx: &CodegenContext<B>,
|
||||
mut module: lto::LtoModuleCodegen<B>,
|
||||
module: lto::LtoModuleCodegen<B>,
|
||||
module_config: &ModuleConfig,
|
||||
) -> Result<WorkItemResult<B>, FatalError> {
|
||||
let module = unsafe { module.optimize(cgcx)? };
|
||||
|
@ -48,7 +48,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
|
||||
) -> Result<(), FatalError>;
|
||||
unsafe fn optimize_thin(
|
||||
cgcx: &CodegenContext<Self>,
|
||||
thin: &mut ThinModule<Self>,
|
||||
thin: ThinModule<Self>,
|
||||
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
|
||||
unsafe fn codegen(
|
||||
cgcx: &CodegenContext<Self>,
|
||||
|
Loading…
Reference in New Issue
Block a user