Skip to content

Commit

Permalink
Document all methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Jan 20, 2020
1 parent 2ce7b61 commit 7b4dca2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/librustc_mir/dataflow/generic/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ where
}
}

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

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

Expand Down
10 changes: 7 additions & 3 deletions src/librustc_mir/dataflow/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ impl<A> Results<'tcx, A>
where
A: Analysis<'tcx>,
{
pub fn into_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
/// Creates a `ResultsCursor` that can inspect these `Results`.
pub fn into_results_cursor(self, body: &'mir mir::Body<'tcx>) -> ResultsCursor<'mir, 'tcx, A> {
ResultsCursor::new(body, self)
}

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

/// Calls `gen` for each element in `elems`.
fn gen_all(&mut self, elems: impl IntoIterator<Item = T>) {
for elem in elems {
self.gen(elem);
}
}

/// Calls `kill` for each element in `elems`.
fn kill_all(&mut self, elems: impl IntoIterator<Item = T>) {
for elem in elems {
self.kill(elem);
Expand All @@ -304,7 +308,7 @@ pub trait GenKill<T> {
/// Stores a transfer function for a gen/kill problem.
///
/// Calling `gen`/`kill` on a `GenKillSet` will "build up" a transfer function so that it can be
/// applied to a state vector efficiently. When there are multiple calls to `gen` and/or `kill` for
/// applied multiple times efficiently. When there are multiple calls to `gen` and/or `kill` for
/// the same element, the most recent one takes precedence.
#[derive(Clone)]
pub struct GenKillSet<T: Idx> {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_mir/dataflow/generic/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ fn cursor_seek() {
let body = &body;
let analysis = MockAnalysis { body };

let mut cursor = Results { entry_sets: analysis.mock_entry_sets(), analysis }.into_cursor(body);
let mut cursor =
Results { entry_sets: analysis.mock_entry_sets(), analysis }.into_results_cursor(body);

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

0 comments on commit 7b4dca2

Please sign in to comment.