@@ -11,7 +11,9 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1111use rustc_data_structures:: profiling:: { QueryInvocationId , SelfProfilerRef } ;
1212use rustc_data_structures:: sharded:: { self , Sharded } ;
1313use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
14- use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , Lock , Lrc } ;
14+ #[ cfg( debug_assertions) ]
15+ use rustc_data_structures:: sync:: AtomicU64 ;
16+ use rustc_data_structures:: sync:: { AtomicU32 , Lock , Lrc } ;
1517use rustc_data_structures:: unord:: UnordMap ;
1618use rustc_index:: IndexVec ;
1719use rustc_macros:: { Decodable , Encodable } ;
@@ -484,9 +486,8 @@ impl<D: Deps> DepGraph<D> {
484486 } ;
485487 let task_deps = & mut * task_deps;
486488
487- if cfg ! ( debug_assertions) {
488- data. current . total_read_count . fetch_add ( 1 , Ordering :: Relaxed ) ;
489- }
489+ #[ cfg( debug_assertions) ]
490+ data. current . total_read_count . fetch_add ( 1 , Ordering :: Relaxed ) ;
490491
491492 // As long as we only have a low number of reads we can avoid doing a hash
492493 // insert and potentially allocating/reallocating the hashmap
@@ -514,7 +515,8 @@ impl<D: Deps> DepGraph<D> {
514515 }
515516 }
516517 }
517- } else if cfg ! ( debug_assertions) {
518+ } else {
519+ #[ cfg( debug_assertions) ]
518520 data. current . total_duplicate_read_count . fetch_add ( 1 , Ordering :: Relaxed ) ;
519521 }
520522 } )
@@ -962,10 +964,13 @@ impl<D: Deps> DepGraph<D> {
962964
963965 pub fn print_incremental_info ( & self ) {
964966 if let Some ( data) = & self . data {
967+ #[ cfg( debug_assertions) ]
965968 data. current . encoder . print_incremental_info (
966969 data. current . total_read_count . load ( Ordering :: Relaxed ) ,
967970 data. current . total_duplicate_read_count . load ( Ordering :: Relaxed ) ,
968- )
971+ ) ;
972+ #[ cfg( not( debug_assertions) ) ]
973+ data. current . encoder . print_incremental_info ( 0 , 0 )
969974 }
970975 }
971976
@@ -1082,7 +1087,10 @@ pub(super) struct CurrentDepGraph<D: Deps> {
10821087
10831088 /// These are simple counters that are for profiling and
10841089 /// debugging and only active with `debug_assertions`.
1090+ #[ cfg( debug_assertions) ]
10851091 total_read_count : AtomicU64 ,
1092+
1093+ #[ cfg( debug_assertions) ]
10861094 total_duplicate_read_count : AtomicU64 ,
10871095}
10881096
@@ -1135,7 +1143,9 @@ impl<D: Deps> CurrentDepGraph<D> {
11351143 forbidden_edge,
11361144 #[ cfg( debug_assertions) ]
11371145 fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
1146+ #[ cfg( debug_assertions) ]
11381147 total_read_count : AtomicU64 :: new ( 0 ) ,
1148+ #[ cfg( debug_assertions) ]
11391149 total_duplicate_read_count : AtomicU64 :: new ( 0 ) ,
11401150 }
11411151 }
0 commit comments