Skip to content

Commit 8127461

Browse files
committed
Move -Zprint-type-sizes and -Zprint-vtable-sizes into codegen_and_build_linker
1 parent 2975a21 commit 8127461

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ use rustc_session::getopts::{self, Matches};
4141
use rustc_session::lint::{Lint, LintId};
4242
use rustc_session::output::collect_crate_types;
4343
use rustc_session::{config, filesearch, EarlyDiagCtxt, Session};
44-
use rustc_span::def_id::LOCAL_CRATE;
4544
use rustc_span::source_map::FileLoader;
4645
use rustc_span::symbol::sym;
4746
use rustc_span::FileName;
@@ -448,21 +447,7 @@ fn run_compiler(
448447
return early_exit();
449448
}
450449

451-
let linker = queries.codegen_and_build_linker()?;
452-
453-
// This must run after monomorphization so that all generic types
454-
// have been instantiated.
455-
if sess.opts.unstable_opts.print_type_sizes {
456-
sess.code_stats.print_type_sizes();
457-
}
458-
459-
if sess.opts.unstable_opts.print_vtable_sizes {
460-
let crate_name = queries.global_ctxt()?.enter(|tcx| tcx.crate_name(LOCAL_CRATE));
461-
462-
sess.code_stats.print_vtable_sizes(crate_name);
463-
}
464-
465-
Ok(Some(linker))
450+
Ok(Some(queries.codegen_and_build_linker()?))
466451
})?;
467452

468453
// Linking is done outside the `compiler.enter()` so that the

compiler/rustc_interface/src/queries.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ impl<'tcx> Queries<'tcx> {
121121
self.global_ctxt()?.enter(|tcx| {
122122
let ongoing_codegen = passes::start_codegen(&*self.compiler.codegen_backend, tcx)?;
123123

124+
// This must run after monomorphization so that all generic types
125+
// have been instantiated.
126+
if tcx.sess.opts.unstable_opts.print_type_sizes {
127+
tcx.sess.code_stats.print_type_sizes();
128+
}
129+
130+
if tcx.sess.opts.unstable_opts.print_vtable_sizes {
131+
let crate_name = tcx.crate_name(LOCAL_CRATE);
132+
133+
tcx.sess.code_stats.print_vtable_sizes(crate_name);
134+
}
135+
124136
Ok(Linker {
125137
dep_graph: tcx.dep_graph.clone(),
126138
output_filenames: tcx.output_filenames(()).clone(),

0 commit comments

Comments
 (0)