Skip to content

Commit

Permalink
Rollup merge of rust-lang#58507 - Zoxc:time-extended, r=michaelwoerister
Browse files Browse the repository at this point in the history
Add a -Z time option which prints only passes which runs once

This ensures `-Z time-passes` fits on my screen =P

r? @michaelwoerister
  • Loading branch information
Centril authored Apr 1, 2019
2 parents eab3eb3 + e842f57 commit 9f9529a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"),
time_passes: bool = (false, parse_bool, [UNTRACKED],
"measure time of each rustc pass"),
time: bool = (false, parse_bool, [UNTRACKED],
"measure time of rustc processes"),
count_llvm_insns: bool = (false, parse_bool,
[UNTRACKED_WITH_WARNING(true,
"The output generated by `-Z count_llvm_insns` might not be reliable \
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ impl Session {
self.opts.debugging_opts.verbose
}
pub fn time_passes(&self) -> bool {
self.opts.debugging_opts.time_passes || self.opts.debugging_opts.time
}
pub fn time_extended(&self) -> bool {
self.opts.debugging_opts.time_passes
}
pub fn profile_queries(&self) -> bool {
Expand Down
29 changes: 14 additions & 15 deletions src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::session::{CrateDisambiguator, Session};
use crate::ty;
use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
use crate::ty::context::TyCtxt;
use crate::util::common::time;
use crate::util::common::{time, time_ext};

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

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

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

// Record position of the cache entry
query_result_index.push((dep_node, AbsoluteBytePos::new(encoder.position())));

// Encode the type check tables with the SerializedDepNodeIndex
// as tag.
encoder.encode_tagged(dep_node, &entry.value)?;
// Encode the type check tables with the SerializedDepNodeIndex
// as tag.
encoder.encode_tagged(dep_node, &entry.value)?;
}
}
}

Ok(())
Ok(())
})
}
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc::session::Session;
use rustc::middle::cstore::{NativeLibrary, NativeLibraryKind};
use rustc::middle::dependency_format::Linkage;
use rustc_codegen_ssa::CodegenResults;
use rustc::util::common::time;
use rustc::util::common::{time, time_ext};
use rustc_fs_util::fix_windows_verbatim_for_gcc;
use rustc::hir::def_id::CrateNum;
use tempfile::{Builder as TempFileBuilder, TempDir};
Expand Down Expand Up @@ -1319,7 +1319,7 @@ fn add_upstream_rust_crates(cmd: &mut dyn Linker,
let name = cratepath.file_name().unwrap().to_str().unwrap();
let name = &name[3..name.len() - 5]; // chop off lib/.rlib

time(sess, &format!("altering {}.rlib", name), || {
time_ext(sess.time_extended(), Some(sess), &format!("altering {}.rlib", name), || {
let cfg = archive_config(sess, &dst, Some(cratepath));
let mut archive = ArchiveBuilder::new(cfg);
archive.update_symbols();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl ModuleConfig {
self.verify_llvm_ir = sess.verify_llvm_ir();
self.no_prepopulate_passes = sess.opts.cg.no_prepopulate_passes;
self.no_builtins = no_builtins || sess.target.target.options.no_builtins;
self.time_passes = sess.time_passes();
self.time_passes = sess.time_extended();
self.inline_threshold = sess.opts.cg.inline_threshold;
self.obj_is_bitcode = sess.target.target.options.obj_is_bitcode ||
sess.opts.cg.linker_plugin_lto.enabled();
Expand Down Expand Up @@ -1091,7 +1091,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
fewer_names: sess.fewer_names(),
save_temps: sess.opts.cg.save_temps,
opts: Arc::new(sess.opts.clone()),
time_passes: sess.time_passes(),
time_passes: sess.time_extended(),
profiler: sess.self_profiling.clone(),
exported_symbols,
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ impl<'tcx> RegionInferenceContext<'tcx> {
mir_def_id: DefId,
errors_buffer: &mut Vec<Diagnostic>,
) -> Option<ClosureRegionRequirements<'gcx>> {
common::time(
infcx.tcx.sess,
common::time_ext(
infcx.tcx.sess.time_extended(),
Some(infcx.tcx.sess),
&format!("solve_nll_region_constraints({:?})", mir_def_id),
|| self.solve_inner(infcx, mir, mir_def_id, errors_buffer),
)
Expand Down

0 comments on commit 9f9529a

Please sign in to comment.