From 4f598b852cf536a96234a1043a0af9f72d7e37e6 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 20 Jul 2023 11:19:52 +1000 Subject: [PATCH] Add comments to `WorkItemResult`. And rename the `Compiled` variant as `Finished`, because that name makes it clearer there is nothing left to do, contrasting nicely with the `Needs*` variants. --- compiler/rustc_codegen_ssa/src/back/write.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index df68cf1e28b..2ef0a7c1eac 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -751,9 +751,19 @@ impl WorkItem { /// A result produced by the backend. pub(crate) enum WorkItemResult { - Compiled(CompiledModule), + /// The backend has finished compiling a CGU, nothing more required. + Finished(CompiledModule), + + /// The backend has finished compiling a CGU, which now needs linking + /// because `-Zcombine-cgu` was specified. NeedsLink(ModuleCodegen), + + /// The backend has finished compiling a CGU, which now needs to go through + /// fat LTO. NeedsFatLTO(FatLTOInput), + + /// The backend has finished compiling a CGU, which now needs to go through + /// thin LTO. NeedsThinLTO(String, B::ThinBuffer), } @@ -906,7 +916,7 @@ fn execute_copy_from_cache_work_item( load_from_incr_comp_dir(dwarf_obj_out, &saved_dwarf_object_file) }); - WorkItemResult::Compiled(CompiledModule { + WorkItemResult::Finished(CompiledModule { name: module.name, kind: ModuleKind::Regular, object, @@ -936,7 +946,7 @@ fn finish_intra_module_work( || module.kind == ModuleKind::Allocator { let module = unsafe { B::codegen(cgcx, &diag_handler, module, module_config)? }; - Ok(WorkItemResult::Compiled(module)) + Ok(WorkItemResult::Finished(module)) } else { Ok(WorkItemResult::NeedsLink(module)) } @@ -1522,7 +1532,7 @@ fn start_executing_work( free_worker(worker_id); match result { - Ok(WorkItemResult::Compiled(compiled_module)) => { + Ok(WorkItemResult::Finished(compiled_module)) => { match compiled_module.kind { ModuleKind::Regular => { compiled_modules.push(compiled_module);