Skip to content

Commit e0f6d18

Browse files
committed
Fix self_profiling
1 parent 799538a commit e0f6d18

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/librustc/session/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ pub struct Session {
130130
/// Used by -Z profile-queries in util::common
131131
pub profile_channel: Lock<Option<mpsc::Sender<ProfileQueriesMsg>>>,
132132

133+
/// Used by -Z self-profile
134+
pub self_profiling_active: bool,
135+
133136
/// Used by -Z self-profile
134137
pub self_profiling: Lock<SelfProfiler>,
135138

@@ -830,15 +833,13 @@ impl Session {
830833
#[inline(never)]
831834
#[cold]
832835
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);
837838
}
838839

839840
#[inline(always)]
840841
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) {
842843
self.profiler_active(f)
843844
}
844845
}
@@ -1160,6 +1161,9 @@ pub fn build_session_(
11601161
CguReuseTracker::new_disabled()
11611162
};
11621163

1164+
let self_profiling_active = sopts.debugging_opts.self_profile ||
1165+
sopts.debugging_opts.profile_json;
1166+
11631167
let sess = Session {
11641168
target: target_cfg,
11651169
host,
@@ -1190,6 +1194,7 @@ pub fn build_session_(
11901194
imported_macro_spans: OneThread::new(RefCell::new(FxHashMap::default())),
11911195
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
11921196
cgu_reuse_tracker,
1197+
self_profiling_active,
11931198
self_profiling: Lock::new(SelfProfiler::new()),
11941199
profile_channel: Lock::new(None),
11951200
perf_stats: PerfStats {

0 commit comments

Comments
 (0)