Skip to content

Commit 7b4dca2

Browse files
Document all methods
1 parent 2ce7b61 commit 7b4dca2

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/librustc_mir/dataflow/generic/engine.rs

+6
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,17 @@ where
121121
}
122122
}
123123

124+
/// Signals that we do not want dataflow state to propagate across unwind edges for these
125+
/// `BasicBlock`s.
126+
///
127+
/// You must take care that `dead_unwinds` does not contain a `BasicBlock` that *can* actually
128+
/// unwind during execution. Otherwise, your dataflow results will not be correct.
124129
pub fn dead_unwinds(mut self, dead_unwinds: &'a BitSet<BasicBlock>) -> Self {
125130
self.dead_unwinds = Some(dead_unwinds);
126131
self
127132
}
128133

134+
/// Computes the fixpoint for this dataflow problem and returns it.
129135
pub fn iterate_to_fixpoint(mut self) -> Results<'tcx, A> {
130136
let mut temp_state = BitSet::new_empty(self.bits_per_block);
131137

src/librustc_mir/dataflow/generic/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ impl<A> Results<'tcx, A>
6060
where
6161
A: Analysis<'tcx>,
6262
{
63-
pub fn into_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
63+
/// Creates a `ResultsCursor` that can inspect these `Results`.
64+
pub fn into_results_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
6465
ResultsCursor::new(body, self)
6566
}
6667

67-
pub fn on_block_entry(&self, block: BasicBlock) -> &BitSet<A::Idx> {
68+
/// Gets the entry set for the given block.
69+
pub fn entry_set_for_block(&self, block: BasicBlock) -> &BitSet<A::Idx> {
6870
&self.entry_sets[block]
6971
}
7072
}
@@ -288,12 +290,14 @@ pub trait GenKill<T> {
288290
/// Removes `elem` from the state vector.
289291
fn kill(&mut self, elem: T);
290292

293+
/// Calls `gen` for each element in `elems`.
291294
fn gen_all(&mut self, elems: impl IntoIterator<Item = T>) {
292295
for elem in elems {
293296
self.gen(elem);
294297
}
295298
}
296299

300+
/// Calls `kill` for each element in `elems`.
297301
fn kill_all(&mut self, elems: impl IntoIterator<Item = T>) {
298302
for elem in elems {
299303
self.kill(elem);
@@ -304,7 +308,7 @@ pub trait GenKill<T> {
304308
/// Stores a transfer function for a gen/kill problem.
305309
///
306310
/// Calling `gen`/`kill` on a `GenKillSet` will "build up" a transfer function so that it can be
307-
/// applied to a state vector efficiently. When there are multiple calls to `gen` and/or `kill` for
311+
/// applied multiple times efficiently. When there are multiple calls to `gen` and/or `kill` for
308312
/// the same element, the most recent one takes precedence.
309313
#[derive(Clone)]
310314
pub struct GenKillSet<T: Idx> {

src/librustc_mir/dataflow/generic/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ fn cursor_seek() {
276276
let body = &body;
277277
let analysis = MockAnalysis { body };
278278

279-
let mut cursor = Results { entry_sets: analysis.mock_entry_sets(), analysis }.into_cursor(body);
279+
let mut cursor =
280+
Results { entry_sets: analysis.mock_entry_sets(), analysis }.into_results_cursor(body);
280281

281282
// Sanity check: the mock call return effect is unique and actually being applied.
282283
let call_terminator_loc = Location { block: BasicBlock::from_usize(2), statement_index: 2 };

0 commit comments

Comments
 (0)