@@ -114,7 +114,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
114114 let mut lock = cache. borrow_mut ( ) ;
115115 if let Some ( value) = lock. results . get ( key) {
116116 profq_msg ! ( tcx, ProfileQueriesMsg :: CacheHit ) ;
117- tcx. sess . profiler ( |p| p. record_query_hit ( Q :: NAME , Q :: CATEGORY ) ) ;
117+ tcx. sess . profiler ( |p| p. record_query_hit ( Q :: NAME ) ) ;
118118 let result = ( value. value . clone ( ) , value. index ) ;
119119 #[ cfg( debug_assertions) ]
120120 {
@@ -130,7 +130,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
130130 //in another thread has completed. Record how long we wait in the
131131 //self-profiler
132132 #[ cfg( parallel_compiler) ]
133- tcx. sess . profiler ( |p| p. query_blocked_start ( Q :: NAME , Q :: CATEGORY ) ) ;
133+ tcx. sess . profiler ( |p| p. query_blocked_start ( Q :: NAME ) ) ;
134134
135135 job. clone ( )
136136 } ,
@@ -172,7 +172,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
172172 #[ cfg( parallel_compiler) ]
173173 {
174174 let result = job. r#await ( tcx, span) ;
175- tcx. sess . profiler ( |p| p. query_blocked_end ( Q :: NAME , Q :: CATEGORY ) ) ;
175+ tcx. sess . profiler ( |p| p. query_blocked_end ( Q :: NAME ) ) ;
176176
177177 if let Err ( cycle) = result {
178178 return TryGetJob :: Cycle ( Q :: handle_cycle_error ( tcx, cycle) ) ;
@@ -358,14 +358,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
358358 key : Q :: Key )
359359 -> Q :: Value {
360360 debug ! ( "ty::query::get_query<{}>(key={:?}, span={:?})" ,
361- Q :: NAME ,
361+ Q :: NAME . as_str ( ) ,
362362 key,
363363 span) ;
364364
365365 profq_msg ! ( self ,
366366 ProfileQueriesMsg :: QueryBegin (
367367 span. data( ) ,
368- profq_query_msg!( Q :: NAME , self , key) ,
368+ profq_query_msg!( Q :: NAME . as_str ( ) , self , key) ,
369369 )
370370 ) ;
371371
@@ -389,7 +389,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
389389
390390 if dep_node. kind . is_anon ( ) {
391391 profq_msg ! ( self , ProfileQueriesMsg :: ProviderBegin ) ;
392- self . sess . profiler ( |p| p. start_query ( Q :: NAME , Q :: CATEGORY ) ) ;
392+ self . sess . profiler ( |p| p. start_query ( Q :: NAME ) ) ;
393393
394394 let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
395395 self . start_query ( job. job . clone ( ) , diagnostics, |tcx| {
@@ -399,7 +399,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
399399 } )
400400 } ) ;
401401
402- self . sess . profiler ( |p| p. end_query ( Q :: NAME , Q :: CATEGORY ) ) ;
402+ self . sess . profiler ( |p| p. end_query ( Q :: NAME ) ) ;
403403 profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
404404
405405 self . dep_graph . read_index ( dep_node_index) ;
@@ -474,22 +474,22 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
474474
475475 let result = if let Some ( result) = result {
476476 profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
477- self . sess . profiler ( |p| p. record_query_hit ( Q :: NAME , Q :: CATEGORY ) ) ;
477+ self . sess . profiler ( |p| p. record_query_hit ( Q :: NAME ) ) ;
478478
479479 result
480480 } else {
481481 // We could not load a result from the on-disk cache, so
482482 // recompute.
483483
484- self . sess . profiler ( |p| p. start_query ( Q :: NAME , Q :: CATEGORY ) ) ;
484+ self . sess . profiler ( |p| p. start_query ( Q :: NAME ) ) ;
485485
486486 // The dep-graph for this computation is already in
487487 // place
488488 let result = self . dep_graph . with_ignore ( || {
489489 Q :: compute ( self , key)
490490 } ) ;
491491
492- self . sess . profiler ( |p| p. end_query ( Q :: NAME , Q :: CATEGORY ) ) ;
492+ self . sess . profiler ( |p| p. end_query ( Q :: NAME ) ) ;
493493 result
494494 } ;
495495
@@ -552,7 +552,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
552552 key, dep_node) ;
553553
554554 profq_msg ! ( self , ProfileQueriesMsg :: ProviderBegin ) ;
555- self . sess . profiler ( |p| p. start_query ( Q :: NAME , Q :: CATEGORY ) ) ;
555+ self . sess . profiler ( |p| p. start_query ( Q :: NAME ) ) ;
556556
557557 let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
558558 self . start_query ( job. job . clone ( ) , diagnostics, |tcx| {
@@ -572,7 +572,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
572572 } )
573573 } ) ;
574574
575- self . sess . profiler ( |p| p. end_query ( Q :: NAME , Q :: CATEGORY ) ) ;
575+ self . sess . profiler ( |p| p. end_query ( Q :: NAME ) ) ;
576576 profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
577577
578578 if unlikely ! ( self . sess. opts. debugging_opts. query_dep_graph) {
@@ -619,7 +619,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
619619 let _ = self . get_query :: < Q > ( DUMMY_SP , key) ;
620620 } else {
621621 profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
622- self . sess . profiler ( |p| p. record_query_hit ( Q :: NAME , Q :: CATEGORY ) ) ;
622+ self . sess . profiler ( |p| p. record_query_hit ( Q :: NAME ) ) ;
623623 }
624624 }
625625
@@ -632,7 +632,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
632632 ) {
633633 profq_msg ! (
634634 self ,
635- ProfileQueriesMsg :: QueryBegin ( span. data( ) , profq_query_msg!( Q :: NAME , self , key) )
635+ ProfileQueriesMsg :: QueryBegin ( span. data( ) ,
636+ profq_query_msg!( Q :: NAME . as_str( ) , self , key) )
636637 ) ;
637638
638639 // We may be concurrently trying both execute and force a query
@@ -725,18 +726,6 @@ macro_rules! define_queries_inner {
725726 }
726727 }
727728
728- pub fn record_computed_queries( & self , sess: & Session ) {
729- sess. profiler( |p| {
730- $(
731- p. record_computed_queries(
732- <queries:: $name<' _> as QueryConfig <' _>>:: NAME ,
733- <queries:: $name<' _> as QueryConfig <' _>>:: CATEGORY ,
734- self . $name. lock( ) . results. len( )
735- ) ;
736- ) *
737- } ) ;
738- }
739-
740729 #[ cfg( parallel_compiler) ]
741730 pub fn collect_active_jobs( & self ) -> Vec <Lrc <QueryJob <$tcx>>> {
742731 let mut jobs = Vec :: new( ) ;
@@ -854,6 +843,24 @@ macro_rules! define_queries_inner {
854843 }
855844 }
856845
846+ #[ allow( nonstandard_style) ]
847+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
848+ pub enum QueryName {
849+ $( $name) ,*
850+ }
851+
852+ impl QueryName {
853+ pub fn register_with_profiler( profiler: & crate :: util:: profiling:: SelfProfiler ) {
854+ $( profiler. register_query_name( QueryName :: $name) ; ) *
855+ }
856+
857+ pub fn as_str( & self ) -> & ' static str {
858+ match self {
859+ $( QueryName :: $name => stringify!( $name) , ) *
860+ }
861+ }
862+ }
863+
857864 #[ allow( nonstandard_style) ]
858865 #[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
859866 pub enum Query <$tcx> {
@@ -894,6 +901,12 @@ macro_rules! define_queries_inner {
894901 $( Query :: $name( key) => key. default_span( tcx) , ) *
895902 }
896903 }
904+
905+ pub fn query_name( & self ) -> QueryName {
906+ match self {
907+ $( Query :: $name( _) => QueryName :: $name, ) *
908+ }
909+ }
897910 }
898911
899912 impl <' a, $tcx> HashStable <StableHashingContext <' a>> for Query <$tcx> {
@@ -930,7 +943,7 @@ macro_rules! define_queries_inner {
930943 type Key = $K;
931944 type Value = $V;
932945
933- const NAME : & ' static str = stringify! ( $name) ;
946+ const NAME : QueryName = QueryName :: $name;
934947 const CATEGORY : ProfileCategory = $category;
935948 }
936949
0 commit comments