about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2025-05-27 21:17:01 +0000
committerRémy Rakic <remy.rakic+github@gmail.com>2025-05-27 21:21:28 +0000
commit703e051f36013e620eece08151fd3f6e435fd278 (patch)
tree385f62a1aab1269c7772ffad4de387bc61eb41b6
parent430e23044914f759f5674cfae542a366f6cca7e9 (diff)
downloadrust-703e051f36013e620eece08151fd3f6e435fd278.tar.gz
rust-703e051f36013e620eece08151fd3f6e435fd278.zip
add perf fixme for `MaybeInitializedPlaces` domain
-rw-r--r--compiler/rustc_borrowck/src/type_check/liveness/trace.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
index cf7bd9751e1..5d30fa71e92 100644
--- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
+++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs
@@ -472,6 +472,18 @@ impl<'a, 'typeck, 'tcx> LivenessContext<'a, 'typeck, 'tcx> {
         self.flow_inits.get_or_insert_with(|| {
             let tcx = self.typeck.tcx();
             let body = self.typeck.body;
+            // FIXME: reduce the `MaybeInitializedPlaces` domain to the useful `MovePath`s.
+            //
+            // This dataflow analysis computes maybe-initializedness of all move paths, which
+            // explains why it can be expensive on big functions. But this data is only used in
+            // drop-liveness. Therefore, most of the move paths computed here are ultimately unused,
+            // even if the results are computed lazily and "no relevant live locals with drop
+            // points" is the common case.
+            //
+            // So we only need the ones for 1) relevant live locals 2) that have drop points. That's
+            // a much, much smaller domain: in our benchmarks, when it's not zero (the most likely
+            // case), there are a few dozens compared to e.g. thousands or tens of thousands of
+            // locals and move paths.
             let flow_inits = MaybeInitializedPlaces::new(tcx, body, self.move_data)
                 .iterate_to_fixpoint(tcx, body, Some("borrowck"))
                 .into_results_cursor(body);