@@ -503,37 +503,48 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
503503
504504 // If -Zincremental-verify-ich is specified, re-hash results from
505505 // the cache and make sure that they have the expected fingerprint.
506- if self . sess . opts . debugging_opts . incremental_verify_ich {
507- use rustc_data_structures :: stable_hasher :: { StableHasher , HashStable } ;
508- use ich :: Fingerprint ;
506+ if unlikely ! ( self . sess. opts. debugging_opts. incremental_verify_ich) {
507+ self . incremental_verify_ich :: < Q > ( & result , dep_node , dep_node_index ) ;
508+ }
509509
510- assert ! ( Some ( self . dep_graph. fingerprint_of( dep_node_index) ) ==
511- self . dep_graph. prev_fingerprint_of( dep_node) ,
512- "Fingerprint for green query instance not loaded \
513- from cache: {:?}", dep_node) ;
510+ if unlikely ! ( self . sess. opts. debugging_opts. query_dep_graph) {
511+ self . dep_graph . mark_loaded_from_cache ( dep_node_index, true ) ;
512+ }
514513
515- debug ! ( "BEGIN verify_ich({:?})" , dep_node) ;
516- let mut hcx = self . create_stable_hashing_context ( ) ;
517- let mut hasher = StableHasher :: new ( ) ;
514+ job. complete ( & result, dep_node_index) ;
518515
519- result. hash_stable ( & mut hcx, & mut hasher) ;
516+ Ok ( result)
517+ }
520518
521- let new_hash: Fingerprint = hasher. finish ( ) ;
522- debug ! ( "END verify_ich({:?})" , dep_node) ;
519+ #[ inline( never) ]
520+ #[ cold]
521+ fn incremental_verify_ich < Q : QueryDescription < ' gcx > > (
522+ self ,
523+ result : & Q :: Value ,
524+ dep_node : & DepNode ,
525+ dep_node_index : DepNodeIndex ,
526+ ) {
527+ use rustc_data_structures:: stable_hasher:: { StableHasher , HashStable } ;
528+ use ich:: Fingerprint ;
523529
524- let old_hash = self . dep_graph . fingerprint_of ( dep_node_index) ;
530+ assert ! ( Some ( self . dep_graph. fingerprint_of( dep_node_index) ) ==
531+ self . dep_graph. prev_fingerprint_of( dep_node) ,
532+ "Fingerprint for green query instance not loaded \
533+ from cache: {:?}", dep_node) ;
525534
526- assert ! ( new_hash == old_hash , "Found unstable fingerprints \
527- for {:?}" , dep_node ) ;
528- }
535+ debug ! ( "BEGIN verify_ich({:?})" , dep_node ) ;
536+ let mut hcx = self . create_stable_hashing_context ( ) ;
537+ let mut hasher = StableHasher :: new ( ) ;
529538
530- if self . sess . opts . debugging_opts . query_dep_graph {
531- self . dep_graph . mark_loaded_from_cache ( dep_node_index, true ) ;
532- }
539+ result. hash_stable ( & mut hcx, & mut hasher) ;
533540
534- job. complete ( & result, dep_node_index) ;
541+ let new_hash: Fingerprint = hasher. finish ( ) ;
542+ debug ! ( "END verify_ich({:?})" , dep_node) ;
535543
536- Ok ( result)
544+ let old_hash = self . dep_graph . fingerprint_of ( dep_node_index) ;
545+
546+ assert ! ( new_hash == old_hash, "Found unstable fingerprints \
547+ for {:?}", dep_node) ;
537548 }
538549
539550 fn force_query_with_job < Q : QueryDescription < ' gcx > > (
@@ -578,7 +589,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
578589
579590 let ( ( result, dep_node_index) , diagnostics) = res;
580591
581- if self . sess . opts . debugging_opts . query_dep_graph {
592+ if unlikely ! ( self . sess. opts. debugging_opts. query_dep_graph) {
582593 self . dep_graph . mark_loaded_from_cache ( dep_node_index, false ) ;
583594 }
584595
0 commit comments