Add -Z time-passes-format
to allow specifying a JSON output for -Z time-passes
This commit is contained in:
parent
b0dc15c61b
commit
f60d2eb6c1
12 changed files with 105 additions and 27 deletions
|
@ -4,6 +4,7 @@ use crate::early_error;
|
|||
use crate::lint;
|
||||
use crate::search_paths::SearchPath;
|
||||
use crate::utils::NativeLib;
|
||||
use rustc_data_structures::profiling::TimePassesFormat;
|
||||
use rustc_errors::{LanguageIdentifier, TerminalUrl};
|
||||
use rustc_target::spec::{CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, SanitizerSet};
|
||||
use rustc_target::spec::{
|
||||
|
@ -365,6 +366,7 @@ mod desc {
|
|||
pub const parse_number: &str = "a number";
|
||||
pub const parse_opt_number: &str = parse_number;
|
||||
pub const parse_threads: &str = parse_number;
|
||||
pub const parse_time_passes_format: &str = "`text` (default) or `json`";
|
||||
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
|
||||
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
|
||||
pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
|
||||
|
@ -829,6 +831,21 @@ mod parse {
|
|||
true
|
||||
}
|
||||
|
||||
pub(crate) fn parse_time_passes_format(slot: &mut TimePassesFormat, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
None => true,
|
||||
Some("json") => {
|
||||
*slot = TimePassesFormat::Json;
|
||||
true
|
||||
}
|
||||
Some("text") => {
|
||||
*slot = TimePassesFormat::Text;
|
||||
true
|
||||
}
|
||||
Some(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_dump_mono_stats(slot: &mut DumpMonoStatsFormat, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
None => true,
|
||||
|
@ -1709,6 +1726,8 @@ options! {
|
|||
"measure time of each LLVM pass (default: no)"),
|
||||
time_passes: bool = (false, parse_bool, [UNTRACKED],
|
||||
"measure time of each rustc pass (default: no)"),
|
||||
time_passes_format: TimePassesFormat = (TimePassesFormat::Text, parse_time_passes_format, [UNTRACKED],
|
||||
"the format to use for -Z time-passes (`text` (default) or `json`)"),
|
||||
tiny_const_eval_limit: bool = (false, parse_bool, [TRACKED],
|
||||
"sets a tiny, non-configurable limit for const eval; useful for compiler tests"),
|
||||
#[rustc_lint_opt_deny_field_access("use `Session::tls_model` instead of this field")]
|
||||
|
|
|
@ -1487,7 +1487,10 @@ pub fn build_session(
|
|||
CguReuseTracker::new_disabled()
|
||||
};
|
||||
|
||||
let prof = SelfProfilerRef::new(self_profiler, sopts.unstable_opts.time_passes);
|
||||
let prof = SelfProfilerRef::new(
|
||||
self_profiler,
|
||||
sopts.unstable_opts.time_passes.then(|| sopts.unstable_opts.time_passes_format),
|
||||
);
|
||||
|
||||
let ctfe_backtrace = Lock::new(match env::var("RUSTC_CTFE_BACKTRACE") {
|
||||
Ok(ref val) if val == "immediate" => CtfeBacktrace::Immediate,
|
||||
|
|
|
@ -4,10 +4,10 @@ use std::path::{Path, PathBuf};
|
|||
|
||||
impl Session {
|
||||
pub fn timer(&self, what: &'static str) -> VerboseTimingGuard<'_> {
|
||||
self.prof.verbose_generic_activity(what)
|
||||
self.prof.unique_verbose_generic_activity(what)
|
||||
}
|
||||
pub fn time<R>(&self, what: &'static str, f: impl FnOnce() -> R) -> R {
|
||||
self.prof.verbose_generic_activity(what).run(f)
|
||||
self.prof.unique_verbose_generic_activity(what).run(f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue