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
This commit is contained in:
kennytm 2018-05-24 16:02:39 +08:00 committed by GitHub
commit 4db2241212
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {