Skip to content

Commit a37950d

Browse files
committed
Refactoring: Allow BlockSets.on_entry to denote locally accumulated intrablock state.
1 parent 07214bd commit a37950d

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
@@ -192,7 +192,12 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation
192192
for (bb, data) in self.mir.basic_blocks().iter_enumerated() {
193193
let &mir::BasicBlockData { ref statements, ref terminator, is_cleanup: _ } = data;
194194

195+
let mut interim_state;
195196
let sets = &mut self.flow_state.sets.for_block(bb.index());
197+
if BD::accumulates_intrablock_state() {
198+
interim_state = sets.on_entry.to_owned();
199+
sets.on_entry = &mut interim_state;
200+
}
196201
for j_stmt in 0..statements.len() {
197202
let location = Location { block: bb, statement_index: j_stmt };
198203
self.flow_state.operator.statement_effect(sets, location);
@@ -559,6 +564,20 @@ pub trait BitDenotation: BitwiseOperator {
559564
/// Specifies what index type is used to access the bitvector.
560565
type Idx: Idx;
561566

567+
/// Some analyses want to accumulate knowledge within a block when
568+
/// analyzing its statements for building the gen/kill sets. Override
569+
/// this method to return true in such cases.
570+
///
571+
/// When this returns true, the statement-effect (re)construction
572+
/// will clone the `on_entry` state and pass along a reference via
573+
/// `SetTriple.on_entry` to that local clone into
574+
/// `statement_effect` and `terminator_effect`).
575+
///
576+
/// When its false, no local clone is constucted; instead a
577+
/// mutable reference directly into `on_entry` is passed along via
578+
/// `SetTriple.on_entry` instead.
579+
fn accumulates_intrablock_state() -> bool { false }
580+
562581
/// A name describing the dataflow analysis that this
563582
/// BitDenotation is supporting. The name should be something
564583
/// suitable for plugging in as part of a filename e.g. avoid

0 commit comments

Comments
 (0)