Support plugging external profilers into the Cranelift timing infrastructure (#5749)

* Remove no-std code for cranelift_codegen::timings

no-std mode isn't supported by Cranelift anymore

* Simplify define_passes macro

* Add egraph opt timings

* Replace the add_to_current api with PassTimes::add

* Omit a couple of unused time measurements

* Reduce divergence between run and run_passes a bit

* Introduce a Profiler trait

This allows plugging in external profilers into the Cranelift profiling
framework.

* Add Pass::description method

* Remove duplicate usage of the compile pass timing

* Rustfmt
This commit is contained in:
bjorn3
2023-03-10 20:33:56 +01:00
committed by GitHub
parent 0751cba6e2
commit 108f7917c8
5 changed files with 181 additions and 181 deletions

View File

@@ -82,14 +82,16 @@ impl ConcurrentRunner {
/// Join all the worker threads.
/// Transfer pass timings from the worker threads to the current thread.
pub fn join(&mut self) {
pub fn join(&mut self) -> timing::PassTimes {
assert!(self.request_tx.is_none(), "must shutdown before join");
let mut pass_times = timing::PassTimes::default();
for h in self.handles.drain(..) {
match h.join() {
Ok(t) => timing::add_to_current(&t),
Ok(t) => pass_times.add(&t),
Err(e) => println!("worker panicked: {:?}", e),
}
}
pass_times
}
/// Add a new job to the queues.