diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2018-05-22 15:00:50 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2018-05-22 15:00:50 +0200 |
| commit | 599b79ebf522aa9e7507a602844b2da573160347 (patch) | |
| tree | 520ec245b2a3d214c4afd78d8d1c6b4bc282203b | |
| parent | 1bbae5f38677e823ba6e23f1e0e105ceee4c6f8a (diff) | |
Make sure that queries have predictable symbol names.
| -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 065b7939ac3..e8863daecd8 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -697,6 +697,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; @@ -718,9 +728,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 { |
