@@ -30,7 +30,6 @@ use rustc_data_structures::sync::{Lrc, Lock};
30
30
use rustc_data_structures:: by_move:: { Move , MoveSlot } ;
31
31
use std:: mem;
32
32
use std:: ptr;
33
- use std:: intrinsics:: unlikely;
34
33
use std:: collections:: hash_map:: Entry ;
35
34
use syntax_pos:: Span ;
36
35
use syntax:: source_map:: DUMMY_SP ;
@@ -220,7 +219,8 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
220
219
}
221
220
222
221
impl < ' a , ' tcx , Q : QueryDescription < ' tcx > > Drop for JobOwner < ' a , ' tcx , Q > {
223
- #[ inline]
222
+ #[ inline( never) ]
223
+ #[ cold]
224
224
fn drop ( & mut self ) {
225
225
// Poison the query so jobs waiting on it panic
226
226
self . cache . borrow_mut ( ) . active . insert ( self . key . clone ( ) , QueryResult :: Poisoned ) ;
@@ -486,37 +486,48 @@ impl<'a, 'gcx> TyCtxt<'a, 'gcx, 'gcx> {
486
486
487
487
// If -Zincremental-verify-ich is specified, re-hash results from
488
488
// 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
+ }
492
492
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
+ }
497
496
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) ;
501
498
502
- result. hash_stable ( & mut hcx, & mut hasher) ;
499
+ Ok ( result)
500
+ }
503
501
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 ;
506
512
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) ;
508
517
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 ( ) ;
512
521
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) ;
516
523
517
- job. complete ( & result, dep_node_index) ;
524
+ let new_hash: Fingerprint = hasher. finish ( ) ;
525
+ debug ! ( "END verify_ich({:?})" , dep_node) ;
518
526
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) ;
520
531
}
521
532
522
533
// Inlined so LLVM can tell what kind of DepNode we are using
@@ -544,7 +555,7 @@ impl<'a, 'gcx> TyCtxt<'a, 'gcx, 'gcx> {
544
555
p. record_query ( Q :: CATEGORY ) ;
545
556
} ) ;
546
557
547
- let res = if dep_node. kind . is_eval_always ( ) {
558
+ let ( result , dep_node_index ) = if dep_node. kind . is_eval_always ( ) {
548
559
self . dep_graph . with_eval_always_task ( self , dep_node, |task| {
549
560
job. compute ( self , task, key)
550
561
} )
@@ -557,9 +568,7 @@ impl<'a, 'gcx> TyCtxt<'a, 'gcx, 'gcx> {
557
568
self . sess . profiler ( |p| p. end_activity ( Q :: CATEGORY ) ) ;
558
569
profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
559
570
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) {
563
572
self . dep_graph . mark_loaded_from_cache ( dep_node_index, false ) ;
564
573
}
565
574
0 commit comments