Skip to content

Commit 15c411d

Browse files
committed
Added some documentation for the struct BlockSets in rustc_mir::dataflow.
1 parent 018784a commit 15c411d

File tree

1 file changed

+19
-0
lines changed
  • src/librustc_mir/dataflow

1 file changed

+19
-0
lines changed

src/librustc_mir/dataflow/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,28 @@ pub struct AllSets<E: Idx> {
446446
on_entry_sets: Bits<E>,
447447
}
448448

449+
/// Triple of sets associated with a given block.
450+
///
451+
/// Generally, one sets up `on_entry`, `gen_set`, and `kill_set` for
452+
/// each block individually, and then runs the dataflow analysis which
453+
/// iteratively modifies the various `on_entry` sets (but leaves the
454+
/// other two sets unchanged, since they represent the effect of the
455+
/// block, which should be invariant over the course of the analysis).
456+
///
457+
/// It is best to ensure that the intersection of `gen_set` and
458+
/// `kill_set` is empty; otherwise the results of the dataflow will
459+
/// have a hidden dependency on what order the bits are generated and
460+
/// killed during the iteration. (This is such a good idea that the
461+
/// `fn gen` and `fn kill` methods that set their state enforce this
462+
/// for you.)
449463
pub struct BlockSets<'a, E: Idx> {
464+
/// Dataflow state immediately before control flow enters the given block.
450465
pub(crate) on_entry: &'a mut IdxSet<E>,
466+
467+
/// Bits that are set to 1 by the time we exit the given block.
451468
pub(crate) gen_set: &'a mut IdxSet<E>,
469+
470+
/// Bits that are set to 0 by the time we exit the given block.
452471
pub(crate) kill_set: &'a mut IdxSet<E>,
453472
}
454473

0 commit comments

Comments
 (0)