@@ -130,6 +130,9 @@ pub struct Session {
130
130
/// Used by -Z profile-queries in util::common
131
131
pub profile_channel : Lock < Option < mpsc:: Sender < ProfileQueriesMsg > > > ,
132
132
133
+ /// Used by -Z self-profile
134
+ pub self_profiling_active : bool ,
135
+
133
136
/// Used by -Z self-profile
134
137
pub self_profiling : Lock < SelfProfiler > ,
135
138
@@ -830,15 +833,13 @@ impl Session {
830
833
#[ inline( never) ]
831
834
#[ cold]
832
835
fn profiler_active < F : FnOnce ( & mut SelfProfiler ) -> ( ) > ( & self , f : F ) {
833
- if self . opts . debugging_opts . self_profile || self . opts . debugging_opts . profile_json {
834
- let mut profiler = self . self_profiling . borrow_mut ( ) ;
835
- f ( & mut profiler) ;
836
- }
836
+ let mut profiler = self . self_profiling . borrow_mut ( ) ;
837
+ f ( & mut profiler) ;
837
838
}
838
839
839
840
#[ inline( always) ]
840
841
pub fn profiler < F : FnOnce ( & mut SelfProfiler ) -> ( ) > ( & self , f : F ) {
841
- if unlikely ! ( self . opts . debugging_opts . self_profile || self . opts . debugging_opts . profile_json ) {
842
+ if unlikely ! ( self . self_profiling_active ) {
842
843
self . profiler_active ( f)
843
844
}
844
845
}
@@ -1160,6 +1161,9 @@ pub fn build_session_(
1160
1161
CguReuseTracker :: new_disabled ( )
1161
1162
} ;
1162
1163
1164
+ let self_profiling_active = sopts. debugging_opts . self_profile ||
1165
+ sopts. debugging_opts . profile_json ;
1166
+
1163
1167
let sess = Session {
1164
1168
target : target_cfg,
1165
1169
host,
@@ -1190,6 +1194,7 @@ pub fn build_session_(
1190
1194
imported_macro_spans : OneThread :: new ( RefCell :: new ( FxHashMap :: default ( ) ) ) ,
1191
1195
incr_comp_session : OneThread :: new ( RefCell :: new ( IncrCompSession :: NotInitialized ) ) ,
1192
1196
cgu_reuse_tracker,
1197
+ self_profiling_active,
1193
1198
self_profiling : Lock :: new ( SelfProfiler :: new ( ) ) ,
1194
1199
profile_channel : Lock :: new ( None ) ,
1195
1200
perf_stats : PerfStats {
0 commit comments