@@ -114,7 +114,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
114
114
let mut lock = cache. borrow_mut ( ) ;
115
115
if let Some ( value) = lock. results . get ( key) {
116
116
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 ) ) ;
118
118
let result = ( value. value . clone ( ) , value. index ) ;
119
119
#[ cfg( debug_assertions) ]
120
120
{
@@ -130,7 +130,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
130
130
//in another thread has completed. Record how long we wait in the
131
131
//self-profiler
132
132
#[ 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 ) ) ;
134
134
135
135
job. clone ( )
136
136
} ,
@@ -172,7 +172,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
172
172
#[ cfg( parallel_compiler) ]
173
173
{
174
174
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 ) ) ;
176
176
177
177
if let Err ( cycle) = result {
178
178
return TryGetJob :: Cycle ( Q :: handle_cycle_error ( tcx, cycle) ) ;
@@ -358,14 +358,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
358
358
key : Q :: Key )
359
359
-> Q :: Value {
360
360
debug ! ( "ty::query::get_query<{}>(key={:?}, span={:?})" ,
361
- Q :: NAME ,
361
+ Q :: NAME . as_str ( ) ,
362
362
key,
363
363
span) ;
364
364
365
365
profq_msg ! ( self ,
366
366
ProfileQueriesMsg :: QueryBegin (
367
367
span. data( ) ,
368
- profq_query_msg!( Q :: NAME , self , key) ,
368
+ profq_query_msg!( Q :: NAME . as_str ( ) , self , key) ,
369
369
)
370
370
) ;
371
371
@@ -389,7 +389,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
389
389
390
390
if dep_node. kind . is_anon ( ) {
391
391
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 ) ) ;
393
393
394
394
let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
395
395
self . start_query ( job. job . clone ( ) , diagnostics, |tcx| {
@@ -399,7 +399,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
399
399
} )
400
400
} ) ;
401
401
402
- self . sess . profiler ( |p| p. end_query ( Q :: NAME , Q :: CATEGORY ) ) ;
402
+ self . sess . profiler ( |p| p. end_query ( Q :: NAME ) ) ;
403
403
profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
404
404
405
405
self . dep_graph . read_index ( dep_node_index) ;
@@ -474,22 +474,22 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
474
474
475
475
let result = if let Some ( result) = result {
476
476
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 ) ) ;
478
478
479
479
result
480
480
} else {
481
481
// We could not load a result from the on-disk cache, so
482
482
// recompute.
483
483
484
- self . sess . profiler ( |p| p. start_query ( Q :: NAME , Q :: CATEGORY ) ) ;
484
+ self . sess . profiler ( |p| p. start_query ( Q :: NAME ) ) ;
485
485
486
486
// The dep-graph for this computation is already in
487
487
// place
488
488
let result = self . dep_graph . with_ignore ( || {
489
489
Q :: compute ( self , key)
490
490
} ) ;
491
491
492
- self . sess . profiler ( |p| p. end_query ( Q :: NAME , Q :: CATEGORY ) ) ;
492
+ self . sess . profiler ( |p| p. end_query ( Q :: NAME ) ) ;
493
493
result
494
494
} ;
495
495
@@ -552,7 +552,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
552
552
key, dep_node) ;
553
553
554
554
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 ) ) ;
556
556
557
557
let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
558
558
self . start_query ( job. job . clone ( ) , diagnostics, |tcx| {
@@ -572,7 +572,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
572
572
} )
573
573
} ) ;
574
574
575
- self . sess . profiler ( |p| p. end_query ( Q :: NAME , Q :: CATEGORY ) ) ;
575
+ self . sess . profiler ( |p| p. end_query ( Q :: NAME ) ) ;
576
576
profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
577
577
578
578
if unlikely ! ( self . sess. opts. debugging_opts. query_dep_graph) {
@@ -619,7 +619,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
619
619
let _ = self . get_query :: < Q > ( DUMMY_SP , key) ;
620
620
} else {
621
621
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 ) ) ;
623
623
}
624
624
}
625
625
@@ -632,7 +632,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
632
632
) {
633
633
profq_msg ! (
634
634
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) )
636
637
) ;
637
638
638
639
// We may be concurrently trying both execute and force a query
@@ -725,18 +726,6 @@ macro_rules! define_queries_inner {
725
726
}
726
727
}
727
728
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
-
740
729
#[ cfg( parallel_compiler) ]
741
730
pub fn collect_active_jobs( & self ) -> Vec <Lrc <QueryJob <$tcx>>> {
742
731
let mut jobs = Vec :: new( ) ;
@@ -854,6 +843,24 @@ macro_rules! define_queries_inner {
854
843
}
855
844
}
856
845
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
+
857
864
#[ allow( nonstandard_style) ]
858
865
#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
859
866
pub enum Query <$tcx> {
@@ -894,6 +901,12 @@ macro_rules! define_queries_inner {
894
901
$( Query :: $name( key) => key. default_span( tcx) , ) *
895
902
}
896
903
}
904
+
905
+ pub fn query_name( & self ) -> QueryName {
906
+ match self {
907
+ $( Query :: $name( _) => QueryName :: $name, ) *
908
+ }
909
+ }
897
910
}
898
911
899
912
impl <' a, $tcx> HashStable <StableHashingContext <' a>> for Query <$tcx> {
@@ -930,7 +943,7 @@ macro_rules! define_queries_inner {
930
943
type Key = $K;
931
944
type Value = $V;
932
945
933
- const NAME : & ' static str = stringify! ( $name) ;
946
+ const NAME : QueryName = QueryName :: $name;
934
947
const CATEGORY : ProfileCategory = $category;
935
948
}
936
949
0 commit comments