Skip to content

Commit 2c0dccb

Browse files
committed
Move some code out of CodegenBackend::{codegen_crate,link}
1 parent bdd0a78 commit 2c0dccb

File tree

4 files changed

+26
-34
lines changed

4 files changed

+26
-34
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -298,21 +298,19 @@ impl CodegenBackend for LlvmCodegenBackend {
298298
codegen_results: CodegenResults,
299299
outputs: &OutputFilenames,
300300
) -> Result<(), ErrorReported> {
301+
use crate::back::archive::LlvmArchiveBuilder;
302+
use rustc_codegen_ssa::back::link::link_binary;
303+
301304
// Run the linker on any artifacts that resulted from the LLVM run.
302305
// This should produce either a finished executable or library.
303-
sess.time("link_crate", || {
304-
use crate::back::archive::LlvmArchiveBuilder;
305-
use rustc_codegen_ssa::back::link::link_binary;
306-
307-
let target_cpu = crate::llvm_util::target_cpu(sess);
308-
link_binary::<LlvmArchiveBuilder<'_>>(
309-
sess,
310-
&codegen_results,
311-
outputs,
312-
&codegen_results.crate_name.as_str(),
313-
target_cpu,
314-
);
315-
});
306+
let target_cpu = crate::llvm_util::target_cpu(sess);
307+
link_binary::<LlvmArchiveBuilder<'_>>(
308+
sess,
309+
&codegen_results,
310+
outputs,
311+
&codegen_results.crate_name.as_str(),
312+
target_cpu,
313+
);
316314

317315
Ok(())
318316
}

compiler/rustc_codegen_ssa/src/base.rs

-21
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use rustc_session::cgu_reuse_tracker::CguReuse;
4646
use rustc_session::config::{self, EntryFnType};
4747
use rustc_session::utils::NativeLibKind;
4848
use rustc_session::Session;
49-
use rustc_symbol_mangling::test as symbol_names_test;
5049
use rustc_target::abi::{Align, LayoutOf, VariantIdx};
5150

5251
use std::cmp;
@@ -486,8 +485,6 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
486485

487486
ongoing_codegen.codegen_finished(tcx);
488487

489-
finalize_tcx(tcx);
490-
491488
ongoing_codegen.check_for_errors(tcx.sess);
492489

493490
return ongoing_codegen;
@@ -688,14 +685,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
688685
total_codegen_time.into_inner(),
689686
);
690687

691-
rustc_incremental::assert_module_sources::assert_module_sources(tcx);
692-
693-
symbol_names_test::report_symbol_names(tcx);
694-
695688
ongoing_codegen.check_for_errors(tcx.sess);
696689

697-
finalize_tcx(tcx);
698-
699690
ongoing_codegen.into_inner()
700691
}
701692

@@ -746,18 +737,6 @@ impl<B: ExtraBackendMethods> Drop for AbortCodegenOnDrop<B> {
746737
}
747738
}
748739

749-
fn finalize_tcx(tcx: TyCtxt<'_>) {
750-
tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx));
751-
tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx));
752-
753-
// We assume that no queries are run past here. If there are new queries
754-
// after this point, they'll show up as "<unknown>" in self-profiling data.
755-
{
756-
let _prof_timer = tcx.prof.generic_activity("self_profile_alloc_query_strings");
757-
tcx.alloc_self_profile_query_strings();
758-
}
759-
}
760-
761740
impl CrateInfo {
762741
pub fn new(tcx: TyCtxt<'_>) -> CrateInfo {
763742
let mut info = CrateInfo {

compiler/rustc_interface/src/passes.rs

+14
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,20 @@ pub fn start_codegen<'tcx>(
996996
codegen_backend.codegen_crate(tcx, metadata, need_metadata_module)
997997
});
998998

999+
rustc_incremental::assert_module_sources::assert_module_sources(tcx);
1000+
1001+
rustc_symbol_mangling::test::report_symbol_names(tcx);
1002+
1003+
tcx.sess.time("assert_dep_graph", || rustc_incremental::assert_dep_graph(tcx));
1004+
tcx.sess.time("serialize_dep_graph", || rustc_incremental::save_dep_graph(tcx));
1005+
1006+
// We assume that no queries are run past here. If there are new queries
1007+
// after this point, they'll show up as "<unknown>" in self-profiling data.
1008+
{
1009+
let _prof_timer = tcx.prof.generic_activity("self_profile_alloc_query_strings");
1010+
tcx.alloc_self_profile_query_strings();
1011+
}
1012+
9991013
info!("Post-codegen\n{:?}", tcx.debug_stats());
10001014

10011015
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {

compiler/rustc_interface/src/queries.rs

+1
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ impl Linker {
399399
return Ok(());
400400
}
401401

402+
let _timer = sess.prof.verbose_generic_activity("link_crate");
402403
self.codegen_backend.link(&self.sess, codegen_results, &self.prepare_outputs)
403404
}
404405
}

0 commit comments

Comments
 (0)