Skip to content

Commit 4ef18ab

Browse files
committed
Allow pretty printing paths with -Zself-profile-events=args
1 parent a955f1c commit 4ef18ab

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

compiler/rustc_data_structures/src/profiling.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ impl SelfProfilerRef {
551551
pub fn get_self_profiler(&self) -> Option<Arc<SelfProfiler>> {
552552
self.profiler.clone()
553553
}
554+
555+
/// Is expensive recording of query keys and/or function arguments enabled?
556+
pub fn is_args_recording_enabled(&self) -> bool {
557+
self.enabled() && self.event_filter_mask.intersects(EventFilter::ARGS)
558+
}
554559
}
555560

556561
/// A helper for recording costly arguments to self-profiling events. Used with

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ impl Session {
313313
|| self.opts.unstable_opts.query_dep_graph
314314
|| self.opts.unstable_opts.dump_mir.is_some()
315315
|| self.opts.unstable_opts.unpretty.is_some()
316+
|| self.prof.is_args_recording_enabled()
316317
|| self.opts.output_types.contains_key(&OutputType::Mir)
317318
|| std::env::var_os("RUSTC_LOG").is_some()
318319
{

tests/ui/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,10 @@ Exercises sanitizer support. See [Sanitizer | The rustc book](https://doc.rust-l
12331233

12341234
Tests with erroneous ways of using `self`, such as using `this.x` syntax as seen in other languages, having it not be the first argument, or using it in a non-associated function (no `impl` or `trait`). It also contains correct uses of `self` which have previously been observed to cause ICEs.
12351235

1236+
## `tests/ui/self-profile/`: self-profiling
1237+
1238+
Tests related to the self-profiler (`-Zself-profile`) functionality of rustc.
1239+
12361240
## `tests/ui/sepcomp/`: Separate Compilation
12371241

12381242
In this directory, multiple crates are compiled, but some of them have `inline` functions, meaning they must be inlined into a different crate despite having been compiled separately.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Checks that when we use `-Zself-profile-events=args`, it is possible to pretty print paths
2+
// using `trimmed_def_paths` even without producing diagnostics.
3+
//
4+
// Issue: <https://github.com/rust-lang/rust/issues/144457>.
5+
6+
//@ compile-flags: -Zself-profile={{build-base}} -Zself-profile-events=args
7+
//@ build-pass
8+
9+
use std::sync::atomic::AtomicUsize;
10+
use std::sync::atomic::Ordering::Relaxed;
11+
12+
fn main() {
13+
AtomicUsize::new(0).load(Relaxed);
14+
}

0 commit comments

Comments
 (0)