Split cgus into todo and done before the main module codegen loop
This commit is contained in:
parent
9ee010cc34
commit
50b34279c3
@ -78,11 +78,6 @@ pub(super) fn acquire(&mut self, dcx: &rustc_errors::DiagCtxt) -> ConcurrencyLim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn job_already_done(&mut self) {
|
|
||||||
let mut state = self.state.lock().unwrap();
|
|
||||||
state.job_already_done();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn finished(mut self) {
|
pub(crate) fn finished(mut self) {
|
||||||
self.helper_thread.take();
|
self.helper_thread.take();
|
||||||
|
|
||||||
@ -190,14 +185,6 @@ pub(super) fn job_finished(&mut self) {
|
|||||||
self.assert_invariants();
|
self.assert_invariants();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn job_already_done(&mut self) {
|
|
||||||
self.assert_invariants();
|
|
||||||
self.pending_jobs -= 1;
|
|
||||||
self.assert_invariants();
|
|
||||||
self.drop_excess_capacity();
|
|
||||||
self.assert_invariants();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn poison(&mut self, error: String) {
|
pub(super) fn poison(&mut self, error: String) {
|
||||||
self.poisoned = true;
|
self.poisoned = true;
|
||||||
self.stored_error = Some(error);
|
self.stored_error = Some(error);
|
||||||
|
@ -604,16 +604,20 @@ pub(crate) fn run_aot(
|
|||||||
|
|
||||||
let global_asm_config = Arc::new(crate::global_asm::GlobalAsmConfig::new(tcx));
|
let global_asm_config = Arc::new(crate::global_asm::GlobalAsmConfig::new(tcx));
|
||||||
|
|
||||||
let mut concurrency_limiter = ConcurrencyLimiter::new(tcx.sess, cgus.len());
|
let (todo_cgus, done_cgus) =
|
||||||
|
cgus.into_iter().enumerate().partition::<Vec<_>, _>(|&(i, _)| match cgu_reuse[i] {
|
||||||
|
_ if backend_config.disable_incr_cache => true,
|
||||||
|
CguReuse::No => true,
|
||||||
|
CguReuse::PreLto | CguReuse::PostLto => false,
|
||||||
|
});
|
||||||
|
|
||||||
let modules = tcx.sess.time("codegen mono items", || {
|
let mut concurrency_limiter = ConcurrencyLimiter::new(tcx.sess, todo_cgus.len());
|
||||||
cgus.iter()
|
|
||||||
.enumerate()
|
let modules =
|
||||||
.map(|(i, cgu)| {
|
tcx.sess.time("codegen mono items", || {
|
||||||
let cgu_reuse =
|
todo_cgus
|
||||||
if backend_config.disable_incr_cache { CguReuse::No } else { cgu_reuse[i] };
|
.into_iter()
|
||||||
match cgu_reuse {
|
.map(|(_, cgu)| {
|
||||||
CguReuse::No => {
|
|
||||||
let dep_node = cgu.codegen_dep_node(tcx);
|
let dep_node = cgu.codegen_dep_node(tcx);
|
||||||
tcx.dep_graph
|
tcx.dep_graph
|
||||||
.with_task(
|
.with_task(
|
||||||
@ -629,13 +633,10 @@ pub(crate) fn run_aot(
|
|||||||
Some(rustc_middle::dep_graph::hash_result),
|
Some(rustc_middle::dep_graph::hash_result),
|
||||||
)
|
)
|
||||||
.0
|
.0
|
||||||
}
|
|
||||||
CguReuse::PreLto | CguReuse::PostLto => {
|
|
||||||
concurrency_limiter.job_already_done();
|
|
||||||
OngoingModuleCodegen::Sync(reuse_workproduct_for_cgu(tcx, cgu))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
.chain(done_cgus.into_iter().map(|(_, cgu)| {
|
||||||
|
OngoingModuleCodegen::Sync(reuse_workproduct_for_cgu(tcx, cgu))
|
||||||
|
}))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user