]> git.lizzy.rs Git - rust.git/commitdiff
Add a -Z time option which prints only passes which runs once
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Wed, 13 Feb 2019 12:11:50 +0000 (13:11 +0100)
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>
Wed, 20 Mar 2019 06:54:46 +0000 (07:54 +0100)
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc/ty/query/on_disk_cache.rs
src/librustc_codegen_llvm/back/link.rs
src/librustc_codegen_ssa/back/write.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs

index 0ae7c10cf563022cb3c13c8f0c5e210756d4662f..1912ff7a9d711c6c3a971b459e509ca10fbd98b5 100644 (file)
@@ -1200,6 +1200,8 @@ fn parse_merge_functions(slot: &mut Option<MergeFunctions>, v: Option<&str>) ->
         "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 \
index 75a0a8195bc2ef1dcd5b114e92eeecf36d5e3eac..ac4f6270869291bb8e6638017f89f37a21466347 100644 (file)
@@ -501,6 +501,9 @@ pub fn verbose(&self) -> bool {
         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 {
index c16f861dedb50442a88f1c3bf6bb60a0dd72125f..aaadbf289356811091d4ff393b53f845a562fd44 100644 (file)
@@ -12,7 +12,7 @@
 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;
@@ -1082,23 +1082,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(())
     })
 }
index 6c175ff4247cadf6e90aa97aa9532dbb45f04f51..f10bc0516e5bf38a9c049ab3e053bd3d9d40dd93 100644 (file)
@@ -18,7 +18,7 @@
 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};
@@ -1319,7 +1319,7 @@ fn add_static_crate(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();
index 859dfb99d92b8598306d5af13c6fdfef1c218ed8..9980ffd737120110e7e798c67a566d75ab53b3ef 100644 (file)
@@ -125,7 +125,7 @@ fn set_flags(&mut self, sess: &Session, no_builtins: bool) {
         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();
@@ -1085,7 +1085,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(),
index f0d3a0d2986e53bda4a3ae1b9e3aae5a0bc1c37d..ac10683598aa7e183262881ffc85669db03dfc23 100644 (file)
@@ -403,8 +403,9 @@ pub(super) fn solve<'gcx>(
         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),
         )