Skip to content

Commit c5477dd

Browse files
committed
Auto merge of #50964 - michaelwoerister:query-symbol-names, r=<try>
Make sure that queries have predictable symbol names. Some recent refactorings led to queriy 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 ff8fa5c + 599b79e commit c5477dd

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/librustc/ty/maps/plumbing.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,16 @@ macro_rules! define_maps {
697697
})*
698698
}
699699

700+
// This module and the functions in it exist only to provide a
701+
// predictable symbol name prefix for query providers. This is helpful
702+
// for analyzing queries in profilers.
703+
pub(super) mod __query_compute {
704+
$(#[inline(never)]
705+
pub fn $name<F: FnOnce() -> R, R>(f: F) -> R {
706+
f()
707+
})*
708+
}
709+
700710
$(impl<$tcx> QueryConfig<$tcx> for queries::$name<$tcx> {
701711
type Key = $K;
702712
type Value = $V;
@@ -718,9 +728,12 @@ macro_rules! define_maps {
718728
DepNode::new(tcx, $node(*key))
719729
}
720730

731+
#[inline]
721732
fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value {
722-
let provider = tcx.maps.providers[key.map_crate()].$name;
723-
provider(tcx.global_tcx(), key)
733+
__query_compute::$name(move || {
734+
let provider = tcx.maps.providers[key.map_crate()].$name;
735+
provider(tcx.global_tcx(), key)
736+
})
724737
}
725738

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

0 commit comments

Comments
 (0)