From dd49c6ffd1eb2ce5919b7ce8788a55ecc4fe13b5 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Wed, 13 May 2020 09:42:56 -0700 Subject: [PATCH] Document assumptions made in generator transform for analyses The generator transform needs to inspect all possible dataflow states. This can be done with half the number of bitset union operations if we can assume that the relevant analyses do not use "before" effects. --- src/librustc_mir/dataflow/impls/borrowed_locals.rs | 3 +++ src/librustc_mir/dataflow/impls/init_locals.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs index f929b2ddde0..b61dc56407e 100644 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -99,6 +99,9 @@ impl GenKillAnalysis<'tcx> for MaybeBorrowedLocals where K: BorrowAnalysisKind<'tcx>, { + // The generator transform relies on the fact that this analysis does **not** use "before" + // effects. + fn statement_effect( &self, trans: &mut impl GenKill, diff --git a/src/librustc_mir/dataflow/impls/init_locals.rs b/src/librustc_mir/dataflow/impls/init_locals.rs index 01cb794a2e0..726330b1f03 100644 --- a/src/librustc_mir/dataflow/impls/init_locals.rs +++ b/src/librustc_mir/dataflow/impls/init_locals.rs @@ -33,6 +33,9 @@ fn initialize_start_block(&self, body: &mir::Body<'tcx>, entry_set: &mut BitSet< } impl dataflow::GenKillAnalysis<'tcx> for MaybeInitializedLocals { + // The generator transform relies on the fact that this analysis does **not** use "before" + // effects. + fn statement_effect( &self, trans: &mut impl GenKill,