Skip to content

Commit 5f08df1

Browse files
committed
Address review comments
1 parent 9158e17 commit 5f08df1

File tree

1 file changed

+9
-3
lines changed
  • src/librustc_mir/dataflow

1 file changed

+9
-3
lines changed

src/librustc_mir/dataflow/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,16 +651,22 @@ pub trait BottomValue {
651651

652652
/// Merges `in_set` into `inout_set`, returning `true` if `inout_set` changed.
653653
///
654-
/// You usually don't need to override this, since it automatically applies
654+
/// It is almost certainly wrong to override this, since it automatically applies
655655
/// * `inout_set & in_set` if `BOTTOM_VALUE == true`
656656
/// * `inout_set | in_set` if `BOTTOM_VALUE == false`
657657
///
658658
/// This means that if a bit is not `BOTTOM_VALUE`, it is propagated into all target blocks.
659659
/// For clarity, the above statement again from a different perspective:
660-
/// A block's initial bit value is `!BOTTOM_VALUE` if *any* predecessor block's bit value is
660+
/// A bit in the block's entry set is `!BOTTOM_VALUE` if *any* predecessor block's bit value is
661661
/// `!BOTTOM_VALUE`.
662+
///
662663
/// There are situations where you want the opposite behaviour: propagate only if *all*
663-
/// predecessor blocks's value is `!BOTTOM_VALUE`. In that case you need to
664+
/// predecessor blocks's value is `!BOTTOM_VALUE`.
665+
/// E.g. if you want to know whether a bit is *definitely* set at a specific location. This
666+
/// means that all code paths leading to the location must have set the bit, instead of any
667+
/// code path leading there.
668+
///
669+
/// If you want this kind of "definitely set" analysis, you need to
664670
/// 1. Invert `BOTTOM_VALUE`
665671
/// 2. Reset the `entry_set` in `start_block_effect` to `!BOTTOM_VALUE`
666672
/// 3. Override `join` to do the opposite from what it's doing now.

0 commit comments

Comments
 (0)