|
3 | 3 | //! There is another interface for dataflow in the compiler in `librustc_mir/dataflow/mod.rs`. The |
4 | 4 | //! interface in this module will eventually [replace that one][design-meeting]. |
5 | 5 | //! |
6 | | -//! To actually use this framework, you must implement either the `Analysis` or the |
7 | | -//! `GenKillAnalysis` trait. If your transfer function can be expressed with only gen/kill |
8 | | -//! operations, prefer `GenKillAnalysis` as it will perform better. Create an `Engine` using the |
9 | | -//! appropriate constructor and call `iterate_to_fixpoint`. You can use a `ResultsCursor` to |
| 6 | +//! To actually use this framework, you must implement either the `Analysis` or the `GenKillAnalysis` |
| 7 | +//! trait. If your transfer function can be expressed with only gen/kill operations, prefer |
| 8 | +//! `GenKillAnalysis` since it will run faster while iterating to fixpoint. Create an `Engine` using |
| 9 | +//! the appropriate constructor and call `iterate_to_fixpoint`. You can use a `ResultsCursor` to |
10 | 10 | //! inspect the fixpoint solution to your dataflow problem. |
11 | 11 | //! |
12 | 12 | //! ```ignore(cross-crate-imports) |
@@ -273,6 +273,14 @@ where |
273 | 273 | } |
274 | 274 |
|
275 | 275 | /// The legal operations for a transfer function in a gen/kill problem. |
| 276 | +/// |
| 277 | +/// This abstraction exists because there are two different contexts in which we call the methods in |
| 278 | +/// `GenKillAnalysis`. Sometimes we need to store a single transfer function that can be efficiently |
| 279 | +/// applied multiple times, such as when computing the cumulative transfer function for each block. |
| 280 | +/// These cases require a `GenKillSet`, which in turn requires two `BitSet`s of storage. Oftentimes, |
| 281 | +/// however, we only need to apply an effect once. In *these* cases, it is more efficient to pass the |
| 282 | +/// `BitSet` representing the state vector directly into the `*_effect` methods as opposed to |
| 283 | +/// building up a `GenKillSet` and then throwing it away. |
276 | 284 | pub trait GenKill<T> { |
277 | 285 | /// Inserts `elem` into the state vector. |
278 | 286 | fn gen(&mut self, elem: T); |
|
0 commit comments