@@ -11,7 +11,9 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
11
11
use rustc_data_structures:: profiling:: { QueryInvocationId , SelfProfilerRef } ;
12
12
use rustc_data_structures:: sharded:: { self , Sharded } ;
13
13
use 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 } ;
15
17
use rustc_data_structures:: unord:: UnordMap ;
16
18
use rustc_index:: IndexVec ;
17
19
use rustc_macros:: { Decodable , Encodable } ;
@@ -484,9 +486,8 @@ impl<D: Deps> DepGraph<D> {
484
486
} ;
485
487
let task_deps = & mut * task_deps;
486
488
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 ) ;
490
491
491
492
// As long as we only have a low number of reads we can avoid doing a hash
492
493
// insert and potentially allocating/reallocating the hashmap
@@ -514,7 +515,8 @@ impl<D: Deps> DepGraph<D> {
514
515
}
515
516
}
516
517
}
517
- } else if cfg ! ( debug_assertions) {
518
+ } else {
519
+ #[ cfg( debug_assertions) ]
518
520
data. current . total_duplicate_read_count . fetch_add ( 1 , Ordering :: Relaxed ) ;
519
521
}
520
522
} )
@@ -962,10 +964,13 @@ impl<D: Deps> DepGraph<D> {
962
964
963
965
pub fn print_incremental_info ( & self ) {
964
966
if let Some ( data) = & self . data {
967
+ #[ cfg( debug_assertions) ]
965
968
data. current . encoder . print_incremental_info (
966
969
data. current . total_read_count . load ( Ordering :: Relaxed ) ,
967
970
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 )
969
974
}
970
975
}
971
976
@@ -1082,7 +1087,10 @@ pub(super) struct CurrentDepGraph<D: Deps> {
1082
1087
1083
1088
/// These are simple counters that are for profiling and
1084
1089
/// debugging and only active with `debug_assertions`.
1090
+ #[ cfg( debug_assertions) ]
1085
1091
total_read_count : AtomicU64 ,
1092
+
1093
+ #[ cfg( debug_assertions) ]
1086
1094
total_duplicate_read_count : AtomicU64 ,
1087
1095
}
1088
1096
@@ -1135,7 +1143,9 @@ impl<D: Deps> CurrentDepGraph<D> {
1135
1143
forbidden_edge,
1136
1144
#[ cfg( debug_assertions) ]
1137
1145
fingerprints : Lock :: new ( IndexVec :: from_elem_n ( None , new_node_count_estimate) ) ,
1146
+ #[ cfg( debug_assertions) ]
1138
1147
total_read_count : AtomicU64 :: new ( 0 ) ,
1148
+ #[ cfg( debug_assertions) ]
1139
1149
total_duplicate_read_count : AtomicU64 :: new ( 0 ) ,
1140
1150
}
1141
1151
}
0 commit comments