use crate::traits::*;
use crate::{CachedModuleCodegen, CrateInfo, MemFlags, ModuleCodegen, ModuleKind};
-use rustc::hir;
-use rustc::hir::def_id::{DefId, LOCAL_CRATE};
+use rustc::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc::middle::cstore::EncodedMetadata;
use rustc::middle::cstore::{self, LinkagePreference};
use rustc::middle::lang_items::StartFnLangItem;
use rustc::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
use rustc::ty::query::Providers;
use rustc::ty::{self, Instance, Ty, TyCtxt};
-use rustc::util::common::{print_time_passes_entry, set_time_depth, time, time_depth};
-use rustc::util::nodemap::FxHashMap;
use rustc_codegen_utils::{check_for_rustc_errors_attr, symbol_names_test};
+use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::profiling::print_time_passes_entry;
+use rustc_hir as hir;
+use rustc_hir::def_id::{DefId, LOCAL_CRATE};
use rustc_index::vec::Idx;
use rustc_session::cgu_reuse_tracker::CguReuse;
use rustc_span::Span;
}
op => bug!(
"comparison_op_to_icmp_predicate: expected comparison operator, \
- found {:?}",
+ found {:?}",
op
),
}
op => {
bug!(
"comparison_op_to_fcmp_predicate: expected comparison operator, \
- found {:?}",
+ found {:?}",
op
);
}
ongoing_codegen.codegen_finished(tcx);
- assert_and_save_dep_graph(tcx);
+ finalize_tcx(tcx);
ongoing_codegen.check_for_errors(tcx.sess);
let llmod_id =
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
let mut modules = backend.new_metadata(tcx, &llmod_id);
- time(tcx.sess, "write allocator module", || {
- backend.codegen_allocator(tcx, &mut modules, kind)
- });
+ tcx.sess
+ .time("write_allocator_module", || backend.codegen_allocator(tcx, &mut modules, kind));
Some(ModuleCodegen { name: llmod_id, module_llvm: modules, kind: ModuleKind::Allocator })
} else {
let metadata_cgu_name =
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")).to_string();
let mut metadata_llvm_module = backend.new_metadata(tcx, &metadata_cgu_name);
- time(tcx.sess, "write compressed metadata", || {
+ tcx.sess.time("write_compressed_metadata", || {
backend.write_compressed_metadata(
tcx,
&ongoing_codegen.metadata,
// Since the main thread is sometimes blocked during codegen, we keep track
// -Ztime-passes output manually.
- let time_depth = time_depth();
- set_time_depth(time_depth + 1);
- print_time_passes_entry(tcx.sess.time_passes(), "codegen to LLVM IR", total_codegen_time);
- set_time_depth(time_depth);
+ print_time_passes_entry(tcx.sess.time_passes(), "codegen_to_LLVM_IR", total_codegen_time);
::rustc_incremental::assert_module_sources::assert_module_sources(tcx);
ongoing_codegen.check_for_errors(tcx.sess);
- assert_and_save_dep_graph(tcx);
+ finalize_tcx(tcx);
+
ongoing_codegen.into_inner()
}
}
}
-fn assert_and_save_dep_graph(tcx: TyCtxt<'_>) {
- time(tcx.sess, "assert dep graph", || ::rustc_incremental::assert_dep_graph(tcx));
+fn finalize_tcx(tcx: TyCtxt<'_>) {
+ tcx.sess.time("assert_dep_graph", || ::rustc_incremental::assert_dep_graph(tcx));
+ tcx.sess.time("serialize_dep_graph", || ::rustc_incremental::save_dep_graph(tcx));
- time(tcx.sess, "serialize dep graph", || ::rustc_incremental::save_dep_graph(tcx));
+ // We assume that no queries are run past here. If there are new queries
+ // after this point, they'll show up as "<unknown>" in self-profiling data.
+ {
+ let _prof_timer = tcx.prof.generic_activity("self_profile_alloc_query_strings");
+ tcx.alloc_self_profile_query_strings();
+ }
}
impl CrateInfo {
let (defids, _) = tcx.collect_and_partition_mono_items(cratenum);
for id in &*defids {
- let hir::CodegenFnAttrs { optimize, .. } = tcx.codegen_fn_attrs(*id);
+ let CodegenFnAttrs { optimize, .. } = tcx.codegen_fn_attrs(*id);
match optimize {
attr::OptimizeAttr::None => continue,
attr::OptimizeAttr::Size => continue,