From c075e245de4eee21b1c32785271eabf05359ab09 Mon Sep 17 00:00:00 2001 From: lqd Date: Mon, 7 Jan 2019 19:48:45 +0100 Subject: [PATCH] Codegen: run the collector only once Use the `collect_and_partition_mono_items ` query to avoid calling the collector --- src/librustc_codegen_utils/codegen_backend.rs | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/librustc_codegen_utils/codegen_backend.rs b/src/librustc_codegen_utils/codegen_backend.rs index 09adaf848be1b..1b50ce5ced6a1 100644 --- a/src/librustc_codegen_utils/codegen_backend.rs +++ b/src/librustc_codegen_utils/codegen_backend.rs @@ -31,7 +31,6 @@ use rustc::middle::cstore::EncodedMetadata; use rustc::middle::cstore::MetadataLoader; use rustc::dep_graph::DepGraph; use rustc_target::spec::Target; -use rustc_mir::monomorphize::collector; use link::out_filename; pub use rustc_data_structures::sync::MetadataRef; @@ -136,24 +135,15 @@ impl CodegenBackend for MetadataOnlyCodegenBackend { ::symbol_names_test::report_symbol_names(tcx); ::rustc_incremental::assert_dep_graph(tcx); ::rustc_incremental::assert_module_sources::assert_module_sources(tcx); - ::rustc_mir::monomorphize::assert_symbols_are_distinct(tcx, - collector::collect_crate_mono_items( - tcx, - collector::MonoItemCollectionMode::Eager - ).0.iter() - ); // FIXME: Fix this // ::rustc::middle::dependency_format::calculate(tcx); let _ = tcx.link_args(LOCAL_CRATE); let _ = tcx.native_libraries(LOCAL_CRATE); - for mono_item in - collector::collect_crate_mono_items( - tcx, - collector::MonoItemCollectionMode::Eager - ).0 { + let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE); + for (mono_item, _) in cgus.iter().flat_map(|cgu| cgu.items().iter()) { if let MonoItem::Fn(inst) = mono_item { let def_id = inst.def_id(); - if def_id.is_local() { + if def_id.is_local() { let _ = inst.def.is_inline(tcx); let _ = tcx.codegen_fn_attrs(def_id); }