]> git.lizzy.rs Git - rust.git/commitdiff
add polonius activities to -Z self-profile
authorRemy Rakic <remy.rakic@gmail.com>
Mon, 9 Dec 2019 18:16:48 +0000 (19:16 +0100)
committerRemy Rakic <remy.rakic@gmail.com>
Tue, 10 Dec 2019 10:44:44 +0000 (11:44 +0100)
- "polonius_fact_generation" is dedicated to profiling the Polonius fact generation, from the MIR and NLL constraints
- "polonius_analysis" is dedicated to profiling the duration of the Polonius computations themselves: move/init analysis, liveness, borrowck-ing

src/librustc_mir/borrow_check/nll/constraint_generation.rs
src/librustc_mir/borrow_check/nll/invalidation.rs
src/librustc_mir/borrow_check/nll/mod.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/polonius.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs

index cae303039a19430e5f371da8de73e362d4ced40e..dbeccab966bbb15566f6ff694d456e27bc67ecd0 100644 (file)
@@ -97,6 +97,7 @@ fn visit_statement(
         location: Location,
     ) {
         if let Some(all_facts) = self.all_facts {
+            let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
             all_facts.cfg_edge.push((
                 self.location_table.start_index(location),
                 self.location_table.mid_index(location),
@@ -142,6 +143,7 @@ fn visit_terminator(
         location: Location,
     ) {
         if let Some(all_facts) = self.all_facts {
+            let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
             all_facts.cfg_edge.push((
                 self.location_table.start_index(location),
                 self.location_table.mid_index(location),
@@ -205,6 +207,8 @@ fn add_regular_live_constraint<T>(&mut self, live_ty: T, location: Location)
     /// as `killed`. For example, when assigning to a local, or on a call's return destination.
     fn record_killed_borrows_for_place(&mut self, place: &Place<'tcx>, location: Location) {
         if let Some(all_facts) = self.all_facts {
+            let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
+
             // Depending on the `Place` we're killing:
             // - if it's a local, or a single deref of a local,
             //   we kill all the borrows on the local.
index 2442bdf8a9b4e50962d714c60232ffd2e3ede8af..e442f9c9e322fed252a628c21b18328de61c964f 100644 (file)
@@ -31,6 +31,7 @@ pub(super) fn generate_invalidates<'tcx>(
     }
 
     if let Some(all_facts) = all_facts {
+        let _prof_timer = tcx.prof.generic_activity("polonius_fact_generation");
         let dominators = body.dominators();
         let mut ig = InvalidationGenerator {
             all_facts,
index bbcb823c8f91c003551c3f1b7d5bb19b46d13dd4..9ea3bd8899b9d59fdec568b50ab9b989a674c1a2 100644 (file)
@@ -201,6 +201,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
     );
 
     if let Some(all_facts) = &mut all_facts {
+        let _prof_timer = infcx.tcx.prof.generic_activity("polonius_fact_generation");
         all_facts
             .universal_region
             .extend(universal_regions.universal_regions());
@@ -302,6 +303,7 @@ pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
                 .unwrap_or_else(|_| String::from("Naive"));
             let algorithm = Algorithm::from_str(&algorithm).unwrap();
             debug!("compute_regions: using polonius algorithm {:?}", algorithm);
+            let _prof_timer = infcx.tcx.prof.generic_activity("polonius_analysis");
             Some(Rc::new(Output::compute(
                 &all_facts,
                 algorithm,
index 49b39c01daa0bb05fe91ab84305f8ff47c0c7c63..0354b0d6b92c525b52d153a55ab41dd06275fdfd 100644 (file)
@@ -109,6 +109,7 @@ pub(super) fn populate_access_facts(
 
         for (local, local_decl) in body.local_decls.iter_enumerated() {
             debug!("add var_uses_regions facts - local={:?}, type={:?}", local, local_decl.ty);
+            let _prof_timer = typeck.infcx.tcx.prof.generic_activity("polonius_fact_generation");
             let universal_regions = &typeck.borrowck_context.universal_regions;
             typeck.infcx.tcx.for_each_free_region(&local_decl.ty, |region| {
                 let region_vid = universal_regions.to_region_vid(region);
@@ -127,6 +128,7 @@ pub(super) fn add_var_drops_regions(
 ) {
     debug!("add_var_drops_region(local={:?}, kind={:?}", local, kind);
     if let Some(facts) = typeck.borrowck_context.all_facts.as_mut() {
+        let _prof_timer = typeck.infcx.tcx.prof.generic_activity("polonius_fact_generation");
         let universal_regions = &typeck.borrowck_context.universal_regions;
         typeck.infcx.tcx.for_each_free_region(kind, |drop_live_region| {
             let region_vid = universal_regions.to_region_vid(drop_live_region);
index 8d4e76cadbfc2cee142e8bb1fb406cb37700ddc1..cddc3b4a271d4de64c76c73a0c02e551348eff3e 100644 (file)
@@ -182,7 +182,7 @@ pub(crate) fn type_check<'tcx>(
                 move_data,
                 location_table);
 
-            translate_outlives_facts(cx.borrowck_context);
+            translate_outlives_facts(&mut cx);
         },
     );
 
@@ -228,8 +228,10 @@ fn type_check_internal<'a, 'tcx, R>(
     extra(&mut checker)
 }
 
-fn translate_outlives_facts(cx: &mut BorrowCheckContext<'_, '_>) {
+fn translate_outlives_facts(typeck: &mut TypeChecker<'_, '_>) {
+    let cx = &mut typeck.borrowck_context;
     if let Some(facts) = cx.all_facts {
+        let _prof_timer = typeck.infcx.tcx.prof.generic_activity("polonius_fact_generation");
         let location_table = cx.location_table;
         facts
             .outlives
@@ -2489,6 +2491,7 @@ fn add_reborrow_constraint(
         // that occurs when we are borrowing an unsafe place, for
         // example).
         if let Some(all_facts) = all_facts {
+            let _prof_timer = self.infcx.tcx.prof.generic_activity("polonius_fact_generation");
             if let Some(borrow_index) = borrow_set.location_map.get(&location) {
                 let region_vid = borrow_region.to_region_vid();
                 all_facts.borrow_region.push((