From a521ba400dbfb2e9907238a4e7a5650d22bf2068 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Tue, 20 Jun 2023 12:57:38 +1000 Subject: [PATCH] Add comments to `Message` and `WorkItem`. This is particularly useful for `Message`. --- compiler/rustc_codegen_ssa/src/back/write.rs | 30 ++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 7eb6916ec84..9f4d767067e 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -731,6 +731,7 @@ impl WorkItem { } } +/// A result produced by the backend. pub(crate) enum WorkItemResult { Compiled(CompiledModule), NeedsLink(ModuleCodegen), @@ -923,21 +924,34 @@ fn finish_intra_module_work( } } +/// Messages sent to the coordinator. pub(crate) enum Message { + /// A jobserver token has become available. Sent from the jobserver helper + /// thread. Token(io::Result), - WorkItem { - result: Result, Option>, - worker_id: usize, - }, - CodegenDone { - llvm_work_item: WorkItem, - cost: u64, - }, + + /// The backend has finished processing a work item for a codegen unit. + /// Sent from a backend worker thread. + WorkItem { result: Result, Option>, worker_id: usize }, + + /// The frontend has finished generating something (backend IR or a + /// post-LTO artifact) for a codegen unit, and it should be passed to the + /// backend. Sent from the main thread. + CodegenDone { llvm_work_item: WorkItem, cost: u64 }, + + /// Similar to `CodegenDone`, but for reusing a pre-LTO artifact + /// Sent from the main thread. AddImportOnlyModule { module_data: SerializedModule, work_product: WorkProduct, }, + + /// The frontend has finished generating everything for all codegen units. + /// Sent from the main thread. CodegenComplete, + + /// Some normal-ish compiler error occurred, and codegen should be wound + /// down. Sent from the main thread. CodegenAborted, }