Skip to content

Commit 9f9529a

Browse files
authored
Rollup merge of rust-lang#58507 - Zoxc:time-extended, r=michaelwoerister
Add a -Z time option which prints only passes which runs once This ensures `-Z time-passes` fits on my screen =P r? @michaelwoerister
2 parents eab3eb3 + e842f57 commit 9f9529a

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

src/librustc/session/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12001200
"when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"),
12011201
time_passes: bool = (false, parse_bool, [UNTRACKED],
12021202
"measure time of each rustc pass"),
1203+
time: bool = (false, parse_bool, [UNTRACKED],
1204+
"measure time of rustc processes"),
12031205
count_llvm_insns: bool = (false, parse_bool,
12041206
[UNTRACKED_WITH_WARNING(true,
12051207
"The output generated by `-Z count_llvm_insns` might not be reliable \

src/librustc/session/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,9 @@ impl Session {
504504
self.opts.debugging_opts.verbose
505505
}
506506
pub fn time_passes(&self) -> bool {
507+
self.opts.debugging_opts.time_passes || self.opts.debugging_opts.time
508+
}
509+
pub fn time_extended(&self) -> bool {
507510
self.opts.debugging_opts.time_passes
508511
}
509512
pub fn profile_queries(&self) -> bool {

src/librustc/ty/query/on_disk_cache.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::session::{CrateDisambiguator, Session};
1212
use crate::ty;
1313
use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
1414
use crate::ty::context::TyCtxt;
15-
use crate::util::common::time;
15+
use crate::util::common::{time, time_ext};
1616

1717
use errors::Diagnostic;
1818
use rustc_data_structures::fx::FxHashMap;
@@ -1080,23 +1080,22 @@ fn encode_query_results<'enc, 'a, 'tcx, Q, E>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10801080
let desc = &format!("encode_query_results for {}",
10811081
unsafe { ::std::intrinsics::type_name::<Q>() });
10821082

1083-
time(tcx.sess, desc, || {
1083+
time_ext(tcx.sess.time_extended(), Some(tcx.sess), desc, || {
1084+
let map = Q::query_cache(tcx).borrow();
1085+
assert!(map.active.is_empty());
1086+
for (key, entry) in map.results.iter() {
1087+
if Q::cache_on_disk(tcx, key.clone()) {
1088+
let dep_node = SerializedDepNodeIndex::new(entry.index.index());
10841089

1085-
let map = Q::query_cache(tcx).borrow();
1086-
assert!(map.active.is_empty());
1087-
for (key, entry) in map.results.iter() {
1088-
if Q::cache_on_disk(tcx, key.clone()) {
1089-
let dep_node = SerializedDepNodeIndex::new(entry.index.index());
1090+
// Record position of the cache entry
1091+
query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position())));
10901092

1091-
// Record position of the cache entry
1092-
query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position())));
1093-
1094-
// Encode the type check tables with the SerializedDepNodeIndex
1095-
// as tag.
1096-
encoder.encode_tagged(dep_node, &entry.value)?;
1093+
// Encode the type check tables with the SerializedDepNodeIndex
1094+
// as tag.
1095+
encoder.encode_tagged(dep_node, &entry.value)?;
1096+
}
10971097
}
1098-
}
10991098

1100-
Ok(())
1099+
Ok(())
11011100
})
11021101
}

src/librustc_codegen_llvm/back/link.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::session::Session;
1818
use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind};
1919
use rustc::middle::dependency_format::Linkage;
2020
use rustc_codegen_ssa::CodegenResults;
21-
use rustc::util::common::time;
21+
use rustc::util::common::{time, time_ext};
2222
use rustc_fs_util::fix_windows_verbatim_for_gcc;
2323
use rustc::hir::def_id::CrateNum;
2424
use tempfile::{Builder as TempFileBuilder, TempDir};
@@ -1319,7 +1319,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
13191319
let name = cratepath.file_name().unwrap().to_str().unwrap();
13201320
let name = &name[3..name.len() - 5]; // chop off lib/.rlib
13211321

1322-
time(sess, &format!("altering {}.rlib", name), || {
1322+
time_ext(sess.time_extended(), Some(sess), &format!("altering {}.rlib", name), || {
13231323
let cfg = archive_config(sess, &dst, Some(cratepath));
13241324
let mut archive = ArchiveBuilder::new(cfg);
13251325
archive.update_symbols();

src/librustc_codegen_ssa/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl ModuleConfig {
125125
self.verify_llvm_ir = sess.verify_llvm_ir();
126126
self.no_prepopulate_passes = sess.opts.cg.no_prepopulate_passes;
127127
self.no_builtins = no_builtins || sess.target.target.options.no_builtins;
128-
self.time_passes = sess.time_passes();
128+
self.time_passes = sess.time_extended();
129129
self.inline_threshold = sess.opts.cg.inline_threshold;
130130
self.obj_is_bitcode = sess.target.target.options.obj_is_bitcode ||
131131
sess.opts.cg.linker_plugin_lto.enabled();
@@ -1091,7 +1091,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
10911091
fewer_names: sess.fewer_names(),
10921092
save_temps: sess.opts.cg.save_temps,
10931093
opts: Arc::new(sess.opts.clone()),
1094-
time_passes: sess.time_passes(),
1094+
time_passes: sess.time_extended(),
10951095
profiler: sess.self_profiling.clone(),
10961096
exported_symbols,
10971097
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
403403
mir_def_id: DefId,
404404
errors_buffer: &mut Vec<Diagnostic>,
405405
) -> Option<ClosureRegionRequirements<'gcx>> {
406-
common::time(
407-
infcx.tcx.sess,
406+
common::time_ext(
407+
infcx.tcx.sess.time_extended(),
408+
Some(infcx.tcx.sess),
408409
&format!("solve_nll_region_constraints({:?})", mir_def_id),
409410
|| self.solve_inner(infcx, mir, mir_def_id, errors_buffer),
410411
)

0 commit comments

Comments
 (0)