diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 4ccef98afc3f6..a1f252fe672ce 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -951,10 +951,13 @@ pub enum Message { work_product: WorkProduct, }, CodegenComplete, - CodegenItem, CodegenAborted, } +/// A message sent from the coordinator thread to the main thread telling it to +/// process another codegen unit. +pub struct CguMessage; + type DiagnosticArgName<'source> = Cow<'source, str>; struct Diagnostic { @@ -976,7 +979,7 @@ fn start_executing_work( tcx: TyCtxt<'_>, crate_info: &CrateInfo, shared_emitter: SharedEmitter, - codegen_worker_send: Sender>, + codegen_worker_send: Sender, coordinator_receive: Receiver>, total_cgus: usize, jobserver: Client, @@ -1284,9 +1287,9 @@ fn start_executing_work( let anticipated_running = running + additional_running + 1; if !queue_full_enough(work_items.len(), anticipated_running) { - // The queue is not full enough, codegen more items: - if codegen_worker_send.send(Message::CodegenItem).is_err() { - panic!("Could not send Message::CodegenItem to main thread") + // The queue is not full enough, process more codegen units: + if codegen_worker_send.send(CguMessage).is_err() { + panic!("Could not send CguMessage to main thread") } main_thread_worker_state = MainThreadWorkerState::Codegenning; } else { @@ -1522,7 +1525,6 @@ fn start_executing_work( codegen_done = true; codegen_aborted = true; } - Message::CodegenItem => bug!("the coordinator should not receive codegen requests"), } } @@ -1879,7 +1881,7 @@ pub struct OngoingCodegen { pub metadata: EncodedMetadata, pub metadata_module: Option, pub crate_info: CrateInfo, - pub codegen_worker_receive: Receiver>, + pub codegen_worker_receive: Receiver, pub shared_emitter_main: SharedEmitterMain, pub output_filenames: Arc, pub coordinator: Coordinator, @@ -1953,10 +1955,9 @@ impl OngoingCodegen { pub fn wait_for_signal_to_codegen_item(&self) { match self.codegen_worker_receive.recv() { - Ok(Message::CodegenItem) => { - // Nothing to do + Ok(CguMessage) => { + // Ok to proceed. } - Ok(_) => panic!("unexpected message"), Err(_) => { // One of the LLVM threads must have panicked, fall through so // error handling can be reached.