From ee94ff254aceccd27919f26c02541277a3ca7dd7 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 30 Apr 2022 20:51:17 +0200 Subject: Let LtoModuleCodegen::optimize take self by value --- compiler/rustc_codegen_ssa/src/back/lto.rs | 13 ++++++------- compiler/rustc_codegen_ssa/src/back/write.rs | 2 +- compiler/rustc_codegen_ssa/src/traits/write.rs | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src') diff --git a/compiler/rustc_codegen_ssa/src/back/lto.rs b/compiler/rustc_codegen_ssa/src/back/lto.rs index d6ae689f254..6dc8cb5038e 100644 --- a/compiler/rustc_codegen_ssa/src/back/lto.rs +++ b/compiler/rustc_codegen_ssa/src/back/lto.rs @@ -42,7 +42,7 @@ pub struct ThinShared { pub enum LtoModuleCodegen { Fat { - module: Option>, + module: ModuleCodegen, _serialized_bitcode: Vec>, }, @@ -64,19 +64,18 @@ impl LtoModuleCodegen { /// 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, ) -> Result, 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), } } diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 98dc5fe8d64..88293dec01c 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -889,7 +889,7 @@ fn execute_copy_from_cache_work_item( fn execute_lto_work_item( cgcx: &CodegenContext, - mut module: lto::LtoModuleCodegen, + module: lto::LtoModuleCodegen, module_config: &ModuleConfig, ) -> Result, FatalError> { let module = unsafe { module.optimize(cgcx)? }; diff --git a/compiler/rustc_codegen_ssa/src/traits/write.rs b/compiler/rustc_codegen_ssa/src/traits/write.rs index 4914de20b05..ed0f6591809 100644 --- a/compiler/rustc_codegen_ssa/src/traits/write.rs +++ b/compiler/rustc_codegen_ssa/src/traits/write.rs @@ -48,7 +48,7 @@ pub trait WriteBackendMethods: 'static + Sized + Clone { ) -> Result<(), FatalError>; unsafe fn optimize_thin( cgcx: &CodegenContext, - thin: &mut ThinModule, + thin: ThinModule, ) -> Result, FatalError>; unsafe fn codegen( cgcx: &CodegenContext, -- cgit 1.4.1-3-g733a5