@@ -30,7 +30,6 @@ use rustc_data_structures::sync::{Lrc, Lock};
3030use rustc_data_structures:: by_move:: { Move , MoveSlot } ;
3131use std:: mem;
3232use std:: ptr;
33- use std:: intrinsics:: unlikely;
3433use std:: collections:: hash_map:: Entry ;
3534use syntax_pos:: Span ;
3635use syntax:: source_map:: DUMMY_SP ;
@@ -220,7 +219,8 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
220219}
221220
222221impl < ' a , ' tcx , Q : QueryDescription < ' tcx > > Drop for JobOwner < ' a , ' tcx , Q > {
223- #[ inline]
222+ #[ inline( never) ]
223+ #[ cold]
224224 fn drop ( & mut self ) {
225225 // Poison the query so jobs waiting on it panic
226226 self . cache . borrow_mut ( ) . active . insert ( self . key . clone ( ) , QueryResult :: Poisoned ) ;
@@ -486,37 +486,48 @@ impl<'a, 'gcx> TyCtxt<'a, 'gcx, 'gcx> {
486486
487487 // If -Zincremental-verify-ich is specified, re-hash results from
488488 // the cache and make sure that they have the expected fingerprint.
489- if unsafe { unlikely ( self . sess . opts . debugging_opts . incremental_verify_ich ) } {
490- use rustc_data_structures :: stable_hasher :: { StableHasher , HashStable } ;
491- use ich :: Fingerprint ;
489+ if unlikely ! ( self . sess. opts. debugging_opts. incremental_verify_ich) {
490+ self . incremental_verify_ich :: < Q > ( & result , dep_node , dep_node_index ) ;
491+ }
492492
493- assert ! ( Some ( self . dep_graph. fingerprint_of( dep_node_index) ) ==
494- self . dep_graph. prev_fingerprint_of( dep_node) ,
495- "Fingerprint for green query instance not loaded \
496- from cache: {:?}", dep_node) ;
493+ if unlikely ! ( self . sess. opts. debugging_opts. query_dep_graph) {
494+ self . dep_graph . mark_loaded_from_cache ( dep_node_index, true ) ;
495+ }
497496
498- debug ! ( "BEGIN verify_ich({:?})" , dep_node) ;
499- let mut hcx = self . create_stable_hashing_context ( ) ;
500- let mut hasher = StableHasher :: new ( ) ;
497+ job. complete ( & result, dep_node_index) ;
501498
502- result. hash_stable ( & mut hcx, & mut hasher) ;
499+ Ok ( result)
500+ }
503501
504- let new_hash: Fingerprint = hasher. finish ( ) ;
505- debug ! ( "END verify_ich({:?})" , dep_node) ;
502+ #[ inline( never) ]
503+ #[ cold]
504+ fn incremental_verify_ich < Q : QueryDescription < ' gcx > > (
505+ self ,
506+ result : & Q :: Value ,
507+ dep_node : & DepNode ,
508+ dep_node_index : DepNodeIndex ,
509+ ) {
510+ use rustc_data_structures:: stable_hasher:: { StableHasher , HashStable } ;
511+ use ich:: Fingerprint ;
506512
507- let old_hash = self . dep_graph . fingerprint_of ( dep_node_index) ;
513+ assert ! ( Some ( self . dep_graph. fingerprint_of( dep_node_index) ) ==
514+ self . dep_graph. prev_fingerprint_of( dep_node) ,
515+ "Fingerprint for green query instance not loaded \
516+ from cache: {:?}", dep_node) ;
508517
509- assert ! ( new_hash == old_hash , "Found unstable fingerprints \
510- for {:?}" , dep_node ) ;
511- }
518+ debug ! ( "BEGIN verify_ich({:?})" , dep_node ) ;
519+ let mut hcx = self . create_stable_hashing_context ( ) ;
520+ let mut hasher = StableHasher :: new ( ) ;
512521
513- if unsafe { unlikely ( self . sess . opts . debugging_opts . query_dep_graph ) } {
514- self . dep_graph . mark_loaded_from_cache ( dep_node_index, true ) ;
515- }
522+ result. hash_stable ( & mut hcx, & mut hasher) ;
516523
517- job. complete ( & result, dep_node_index) ;
524+ let new_hash: Fingerprint = hasher. finish ( ) ;
525+ debug ! ( "END verify_ich({:?})" , dep_node) ;
518526
519- Ok ( result)
527+ let old_hash = self . dep_graph . fingerprint_of ( dep_node_index) ;
528+
529+ assert ! ( new_hash == old_hash, "Found unstable fingerprints \
530+ for {:?}", dep_node) ;
520531 }
521532
522533 // Inlined so LLVM can tell what kind of DepNode we are using
@@ -544,7 +555,7 @@ impl<'a, 'gcx> TyCtxt<'a, 'gcx, 'gcx> {
544555 p. record_query ( Q :: CATEGORY ) ;
545556 } ) ;
546557
547- let res = if dep_node. kind . is_eval_always ( ) {
558+ let ( result , dep_node_index ) = if dep_node. kind . is_eval_always ( ) {
548559 self . dep_graph . with_eval_always_task ( self , dep_node, |task| {
549560 job. compute ( self , task, key)
550561 } )
@@ -557,9 +568,7 @@ impl<'a, 'gcx> TyCtxt<'a, 'gcx, 'gcx> {
557568 self . sess . profiler ( |p| p. end_activity ( Q :: CATEGORY ) ) ;
558569 profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
559570
560- let ( result, dep_node_index) = res;
561-
562- if unsafe { unlikely ( self . sess . opts . debugging_opts . query_dep_graph ) } {
571+ if unlikely ! ( self . sess. opts. debugging_opts. query_dep_graph) {
563572 self . dep_graph . mark_loaded_from_cache ( dep_node_index, false ) ;
564573 }
565574
0 commit comments