Add profile code around metadata object generation

cc #719
This commit is contained in:
bjorn3 2019-09-22 16:47:45 +02:00
parent a1bf96f630
commit 1e5cea09d5

View File

@ -215,26 +215,32 @@ fn run_aot(
rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE));
let metadata_module = if need_metadata_module {
use rustc::mir::mono::CodegenUnitNameBuilder;
tcx.sess.profiler(|p| p.start_activity("codegen crate metadata"));
let (metadata_cgu_name, tmp_file) = rustc::util::common::time(tcx.sess, "write compressed metadata", || {
use rustc::mir::mono::CodegenUnitNameBuilder;
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
let metadata_cgu_name = cgu_name_builder
.build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata"))
.as_str()
.to_string();
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
let metadata_cgu_name = cgu_name_builder
.build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata"))
.as_str()
.to_string();
let mut metadata_artifact = faerie::Artifact::new(
crate::build_isa(tcx.sess, true).triple().clone(),
metadata_cgu_name.clone(),
);
crate::metadata::write_metadata(tcx, &mut metadata_artifact);
let mut metadata_artifact = faerie::Artifact::new(
crate::build_isa(tcx.sess, true).triple().clone(),
metadata_cgu_name.clone(),
);
crate::metadata::write_metadata(tcx, &mut metadata_artifact);
let tmp_file = tcx
.output_filenames(LOCAL_CRATE)
.temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
let tmp_file = tcx
.output_filenames(LOCAL_CRATE)
.temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
let obj = metadata_artifact.emit().unwrap();
std::fs::write(&tmp_file, obj).unwrap();
let obj = metadata_artifact.emit().unwrap();
std::fs::write(&tmp_file, obj).unwrap();
(metadata_cgu_name, tmp_file)
});
tcx.sess.profiler(|p| p.end_activity("codegen crate metadata"));
Some(CompiledModule {
name: metadata_cgu_name,