about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/back
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-05-03 14:58:57 +0900
committerGitHub <noreply@github.com>2022-05-03 14:58:57 +0900
commit329a73dbd69367abc73698d9d6154bb5b5f6c749 (patch)
treeb2e5d4eb20aa361068d84b60ca2a3c754ae3c7e6 /compiler/rustc_codegen_ssa/src/back
parent27d7615bb4f20cd3546bf98d7ad2f812d5dc4e3c (diff)
parent78c65a52db0016f489862ecea92a09ad66a2b960 (diff)
downloadrust-329a73dbd69367abc73698d9d6154bb5b5f6c749.tar.gz
rust-329a73dbd69367abc73698d9d6154bb5b5f6c749.zip
Rollup merge of #96587 - bjorn3:refactor_backend_write, r=michaelwoerister
Refactor the WriteBackendMethods and ExtraBackendMethods traits

The new interface is slightly less confusing and is easier to implement for non-LLVM backends.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/lto.rs16
-rw-r--r--compiler/rustc_codegen_ssa/src/back/write.rs2
2 files changed, 7 insertions, 11 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/lto.rs b/compiler/rustc_codegen_ssa/src/back/lto.rs
index d6ae689f254..cb6244050df 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<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,15 @@ 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();
-                {
-                    let config = cgcx.config(module.kind);
-                    B::run_lto_pass_manager(cgcx, &module, config, false)?;
-                }
+        match self {
+            LtoModuleCodegen::Fat { mut module, .. } => {
+                B::optimize_fat(cgcx, &mut module)?;
                 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<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)? };