Skip to content

Commit 364af5f

Browse files
committed
Prefetch upstream_monomorphizations
1 parent f01c07a commit 364af5f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
//! regardless of whether it is actually needed or not.
166166
167167
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
168-
use rustc_data_structures::sync::{par_for_each_in, MTLock, MTLockRef};
168+
use rustc_data_structures::sync::{join, par_for_each_in, MTLock, MTLockRef};
169169
use rustc_hir as hir;
170170
use rustc_hir::def::DefKind;
171171
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId};
@@ -258,8 +258,19 @@ pub fn collect_crate_mono_items(
258258
) -> (FxHashSet<MonoItem<'_>>, UsageMap<'_>) {
259259
let _prof_timer = tcx.prof.generic_activity("monomorphization_collector");
260260

261-
let roots =
262-
tcx.sess.time("monomorphization_collector_root_collections", || collect_roots(tcx, mode));
261+
let (roots, _) = join(
262+
|| {
263+
tcx.sess
264+
.time("monomorphization_collector_root_collections", || collect_roots(tcx, mode))
265+
},
266+
|| {
267+
if tcx.sess.opts.share_generics() {
268+
// Prefetch upstream_monomorphizations as it's very likely to be used in
269+
// code generation later and this is decent spot to compute it.
270+
tcx.ensure().upstream_monomorphizations(());
271+
}
272+
},
273+
);
263274

264275
debug!("building mono item graph, beginning at roots");
265276

0 commit comments

Comments
 (0)