return work_products;
}
+ let _timer = sess.timer("incr_comp_copy_cgu_workproducts");
+
for module in compiled_modules.modules.iter().filter(|m| m.kind == ModuleKind::Regular) {
let mut files = vec![];
worker_id: usize,
},
Done {
- result: Result<CompiledModule, ()>,
+ result: Result<CompiledModule, Option<WorkerFatalError>>,
worker_id: usize,
},
CodegenDone {
main_thread_worker_state = MainThreadWorkerState::Idle;
}
// If the thread failed that means it panicked, so we abort immediately.
- Message::Done { result: Err(()), worker_id: _ } => {
+ Message::Done { result: Err(None), worker_id: _ } => {
bug!("worker thread panicked");
}
+ Message::Done { result: Err(Some(WorkerFatalError)), worker_id: _ } => {
+ return Err(());
+ }
Message::CodegenItem => bug!("the coordinator should not receive codegen requests"),
}
}
llvm_start_time: &mut Option<VerboseTimingGuard<'a>>,
) {
if config.time_module && llvm_start_time.is_none() {
- *llvm_start_time = Some(prof.generic_pass("LLVM passes"));
+ *llvm_start_time = Some(prof.extra_verbose_generic_activity("LLVM_passes"));
}
}
}
pub const CODEGEN_WORKER_ID: usize = ::std::usize::MAX;
+/// `FatalError` is explicitly not `Send`.
+#[must_use]
+pub struct WorkerFatalError;
+
fn spawn_work<B: ExtraBackendMethods>(cgcx: CodegenContext<B>, work: WorkItem<B>) {
thread::spawn(move || {
// Set up a destructor which will fire off a message that we're done as
// we exit.
struct Bomb<B: ExtraBackendMethods> {
coordinator_send: Sender<Box<dyn Any + Send>>,
- result: Option<WorkItemResult<B>>,
+ result: Option<Result<WorkItemResult<B>, FatalError>>,
worker_id: usize,
}
impl<B: ExtraBackendMethods> Drop for Bomb<B> {
fn drop(&mut self) {
let worker_id = self.worker_id;
let msg = match self.result.take() {
- Some(WorkItemResult::Compiled(m)) => {
+ Some(Ok(WorkItemResult::Compiled(m))) => {
Message::Done::<B> { result: Ok(m), worker_id }
}
- Some(WorkItemResult::NeedsFatLTO(m)) => {
+ Some(Ok(WorkItemResult::NeedsFatLTO(m))) => {
Message::NeedsFatLTO::<B> { result: m, worker_id }
}
- Some(WorkItemResult::NeedsThinLTO(name, thin_buffer)) => {
+ Some(Ok(WorkItemResult::NeedsThinLTO(name, thin_buffer))) => {
Message::NeedsThinLTO::<B> { name, thin_buffer, worker_id }
}
- None => Message::Done::<B> { result: Err(()), worker_id },
+ Some(Err(FatalError)) => {
+ Message::Done::<B> { result: Err(Some(WorkerFatalError)), worker_id }
+ }
+ None => Message::Done::<B> { result: Err(None), worker_id },
};
drop(self.coordinator_send.send(Box::new(msg)));
}
// surface that there was an error in this worker.
bomb.result = {
let _prof_timer = cgcx.prof.generic_activity(work.profiling_event_id());
- execute_work_item(&cgcx, work).ok()
+ Some(execute_work_item(&cgcx, work))
};
});
}
d.code(code);
}
handler.emit_diagnostic(&d);
- handler.abort_if_errors_and_should_abort();
}
Ok(SharedEmitterMessage::InlineAsmError(cookie, msg)) => {
sess.span_err(ExpnId::from_u32(cookie).expn_data().call_site, &msg)
impl<B: ExtraBackendMethods> OngoingCodegen<B> {
pub fn join(self, sess: &Session) -> (CodegenResults, FxHashMap<WorkProductId, WorkProduct>) {
+ let _timer = sess.timer("finish_ongoing_codegen");
+
self.shared_emitter_main.check(sess, true);
- let compiled_modules = match self.future.join() {
+ let future = self.future;
+ let compiled_modules = sess.time("join_worker_thread", || match future.join() {
Ok(Ok(compiled_modules)) => compiled_modules,
Ok(Err(())) => {
sess.abort_if_errors();
Err(_) => {
bug!("panic during codegen/LLVM phase");
}
- };
+ });
sess.cgu_reuse_tracker.check_expected_reuse(sess.diagnostic());