Skip to content

Commit 9e4c713

Browse files
committed
Move print_pass_timings and print_statistics calls to rustc_interface
1 parent d4bd159 commit 9e4c713

6 files changed

Lines changed: 23 additions & 28 deletions

File tree

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,6 @@ impl WriteBackendMethods for GccCodegenBackend {
464464
unreachable!()
465465
}
466466

467-
fn print_pass_timings(&self) {
468-
unimplemented!();
469-
}
470-
471-
fn print_statistics(&self) {
472-
unimplemented!()
473-
}
474-
475467
fn optimize(
476468
_cgcx: &CodegenContext,
477469
_prof: &SelfProfilerRef,

compiler/rustc_codegen_llvm/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ impl WriteBackendMethods for LlvmCodegenBackend {
136136
type TargetMachine = OwnedTargetMachine;
137137
type ThinData = back::lto::ThinData;
138138
type ThinBuffer = back::lto::ThinBuffer;
139-
fn print_pass_timings(&self) {
140-
let timings = llvm::build_string(|s| unsafe { llvm::LLVMRustPrintPassTimings(s) }).unwrap();
141-
print!("{timings}");
142-
}
143-
fn print_statistics(&self) {
144-
let stats = llvm::build_string(|s| unsafe { llvm::LLVMRustPrintStatistics(s) }).unwrap();
145-
print!("{stats}");
146-
}
147139
fn run_and_optimize_fat_lto(
148140
cgcx: &CodegenContext,
149141
prof: &SelfProfilerRef,
@@ -375,6 +367,16 @@ impl CodegenBackend for LlvmCodegenBackend {
375367
(codegen_results, work_products)
376368
}
377369

370+
fn print_pass_timings(&self) {
371+
let timings = llvm::build_string(|s| unsafe { llvm::LLVMRustPrintPassTimings(s) }).unwrap();
372+
print!("{timings}");
373+
}
374+
375+
fn print_statistics(&self) {
376+
let stats = llvm::build_string(|s| unsafe { llvm::LLVMRustPrintStatistics(s) }).unwrap();
377+
print!("{stats}");
378+
}
379+
378380
fn link(
379381
&self,
380382
sess: &Session,

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,16 +2266,6 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
22662266
copy_all_cgu_workproducts_to_incr_comp_cache_dir(sess, &compiled_modules);
22672267
produce_final_output_artifacts(sess, &compiled_modules, &self.output_filenames);
22682268

2269-
// FIXME: time_llvm_passes support - does this use a global context or
2270-
// something?
2271-
if sess.codegen_units().as_usize() == 1 && sess.opts.unstable_opts.time_llvm_passes {
2272-
self.backend.print_pass_timings()
2273-
}
2274-
2275-
if sess.print_llvm_stats() {
2276-
self.backend.print_statistics()
2277-
}
2278-
22792269
(
22802270
CodegenResults {
22812271
crate_info: self.crate_info,

compiler/rustc_codegen_ssa/src/traits/backend.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ pub trait CodegenBackend {
117117
outputs: &OutputFilenames,
118118
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>);
119119

120+
fn print_pass_timings(&self) {}
121+
122+
fn print_statistics(&self) {}
123+
120124
/// This is called on the returned [`CodegenResults`] from [`join_codegen`](Self::join_codegen).
121125
fn link(
122126
&self,

compiler/rustc_codegen_ssa/src/traits/write.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ pub trait WriteBackendMethods: Clone + 'static {
4040
modules: Vec<(String, Self::ThinBuffer)>,
4141
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
4242
) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>);
43-
fn print_pass_timings(&self);
44-
fn print_statistics(&self);
4543
fn optimize(
4644
cgcx: &CodegenContext,
4745
prof: &SelfProfilerRef,

compiler/rustc_interface/src/queries.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ impl Linker {
5656
}
5757
}
5858
});
59+
60+
if sess.codegen_units().as_usize() == 1 && sess.opts.unstable_opts.time_llvm_passes {
61+
codegen_backend.print_pass_timings()
62+
}
63+
64+
if sess.print_llvm_stats() {
65+
codegen_backend.print_statistics()
66+
}
67+
5968
sess.timings.end_section(sess.dcx(), TimingSection::Codegen);
6069

6170
if sess.opts.incremental.is_some()

0 commit comments

Comments
 (0)