Skip to content

Commit 4db2241

Browse files
authored
Rollup merge of rust-lang#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
2 parents 02d53f2 + 599b79e commit 4db2241

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/librustc/ty/maps/plumbing.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,16 @@ macro_rules! define_maps {
701701
})*
702702
}
703703

704+
// This module and the functions in it exist only to provide a
705+
// predictable symbol name prefix for query providers. This is helpful
706+
// for analyzing queries in profilers.
707+
pub(super) mod __query_compute {
708+
$(#[inline(never)]
709+
pub fn $name<F: FnOnce() -> R, R>(f: F) -> R {
710+
f()
711+
})*
712+
}
713+
704714
$(impl<$tcx> QueryConfig<$tcx> for queries::$name<$tcx> {
705715
type Key = $K;
706716
type Value = $V;
@@ -722,9 +732,12 @@ macro_rules! define_maps {
722732
DepNode::new(tcx, $node(*key))
723733
}
724734

735+
#[inline]
725736
fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value {
726-
let provider = tcx.maps.providers[key.map_crate()].$name;
727-
provider(tcx.global_tcx(), key)
737+
__query_compute::$name(move || {
738+
let provider = tcx.maps.providers[key.map_crate()].$name;
739+
provider(tcx.global_tcx(), key)
740+
})
728741
}
729742

730743
fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value {

0 commit comments

Comments
 (0)