diff options
| author | kennytm <kennytm@gmail.com> | 2018-05-24 16:02:39 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-24 16:02:39 +0800 |
| commit | 4db2241212bfda4f764df8f57acd87b72ed35d6a (patch) | |
| tree | 56f3effc69475f8b58df63c7f5f1cf170c476475 | |
| parent | 02d53f2de7b420cdaab6e98d8fd958489cca42de (diff) | |
| parent | 599b79ebf522aa9e7507a602844b2da573160347 (diff) | |
| download | rust-4db2241212bfda4f764df8f57acd87b72ed35d6a.tar.gz rust-4db2241212bfda4f764df8f57acd87b72ed35d6a.zip | |
Rollup merge of #50964 - michaelwoerister:query-symbol-names, r=nikomatsakis
Make sure that queries have predictable symbol names. Some recent refactorings led to query names not showing up in the corresponding symbol names. [perf-focus](https://github.com/nikomatsakis/perf-focus) and manual profiling have been broken by this. This PR makes sure that query providers always get their own symbol and that that symbol has a predictable name. Since this adds `#[inline(never)]` to a function that wraps the provider call, let's check if this does not regress performance before merging. r? @nikomatsakis
| -rw-r--r-- | src/librustc/ty/maps/plumbing.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index c43b7e95b35..4a9d44b7403 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -701,6 +701,16 @@ macro_rules! define_maps { })* } + // This module and the functions in it exist only to provide a + // predictable symbol name prefix for query providers. This is helpful + // for analyzing queries in profilers. + pub(super) mod __query_compute { + $(#[inline(never)] + pub fn $name<F: FnOnce() -> R, R>(f: F) -> R { + f() + })* + } + $(impl<$tcx> QueryConfig<$tcx> for queries::$name<$tcx> { type Key = $K; type Value = $V; @@ -722,9 +732,12 @@ macro_rules! define_maps { DepNode::new(tcx, $node(*key)) } + #[inline] fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value { - let provider = tcx.maps.providers[key.map_crate()].$name; - provider(tcx.global_tcx(), key) + __query_compute::$name(move || { + let provider = tcx.maps.providers[key.map_crate()].$name; + provider(tcx.global_tcx(), key) + }) } fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value { |
