diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-11-12 11:44:01 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-11-12 13:13:14 -0500 |
| commit | 2fd545485aea36d0dcb403375218fd801f4a2ca8 (patch) | |
| tree | 855a5633b0897e14f8cc0e79d591ce3b1c15f6e0 /src | |
| parent | f696b21c5f1017ebb451d1e9d2d8fe261b26507f (diff) | |
| download | rust-2fd545485aea36d0dcb403375218fd801f4a2ca8.tar.gz rust-2fd545485aea36d0dcb403375218fd801f4a2ca8.zip | |
Register queries with self profiler in rustc_interface
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/session/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc/ty/query/plumbing.rs | 4 | ||||
| -rw-r--r-- | src/librustc_data_structures/profiling.rs | 6 | ||||
| -rw-r--r-- | src/librustc_interface/util.rs | 4 |
4 files changed, 13 insertions, 2 deletions
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index bba377392b4..cedac74d774 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1099,7 +1099,6 @@ fn build_session_( ); match profiler { Ok(profiler) => { - crate::ty::query::QueryName::register_with_profiler(&profiler); Some(Arc::new(profiler)) }, Err(e) => { diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 0f77a637b4d..1c15b7d5f35 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -827,7 +827,9 @@ macro_rules! define_queries_inner { } impl QueryName { - pub fn register_with_profiler(profiler: &rustc_data_structures::profiling::SelfProfiler) { + pub fn register_with_profiler( + profiler: &rustc_data_structures::profiling::SelfProfiler, + ) { $(profiler.register_query_name(QueryName::$name);)* } diff --git a/src/librustc_data_structures/profiling.rs b/src/librustc_data_structures/profiling.rs index b89170cccdb..86f59bfabe6 100644 --- a/src/librustc_data_structures/profiling.rs +++ b/src/librustc_data_structures/profiling.rs @@ -205,6 +205,12 @@ impl SelfProfilerRef { TimingGuard::none() })); } + + pub fn register_queries(&self, f: impl FnOnce(&SelfProfiler)) { + if let Some(profiler) = &self.profiler { + f(&profiler) + } + } } pub struct SelfProfiler { diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 115345955ae..6b9d708cefa 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -108,6 +108,10 @@ pub fn create_session( process_configure_mod, ); + sess.prof.register_queries(|profiler| { + rustc::ty::query::QueryName::register_with_profiler(&profiler); + }); + let codegen_backend = get_codegen_backend(&sess); let mut cfg = config::build_configuration(&sess, config::to_crate_config(cfg)); |
