@@ -195,7 +195,12 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation
195
195
for ( bb, data) in self . mir . basic_blocks ( ) . iter_enumerated ( ) {
196
196
let & mir:: BasicBlockData { ref statements, ref terminator, is_cleanup : _ } = data;
197
197
198
+ let mut interim_state;
198
199
let sets = & mut self . flow_state . sets . for_block ( bb. index ( ) ) ;
200
+ if BD :: accumulates_intrablock_state ( ) {
201
+ interim_state = sets. on_entry . to_owned ( ) ;
202
+ sets. on_entry = & mut interim_state;
203
+ }
199
204
for j_stmt in 0 ..statements. len ( ) {
200
205
let location = Location { block : bb, statement_index : j_stmt } ;
201
206
self . flow_state . operator . statement_effect ( sets, location) ;
@@ -560,6 +565,31 @@ pub trait BitDenotation: BitwiseOperator {
560
565
/// Specifies what index type is used to access the bitvector.
561
566
type Idx : Idx ;
562
567
568
+ /// Some analyses want to accumulate knowledge within a block when
569
+ /// analyzing its statements for building the gen/kill sets. Override
570
+ /// this method to return true in such cases.
571
+ ///
572
+ /// When this returns true, the statement-effect (re)construction
573
+ /// will clone the `on_entry` state and pass along a reference via
574
+ /// `sets.on_entry` to that local clone into `statement_effect` and
575
+ /// `terminator_effect`).
576
+ ///
577
+ /// When its false, no local clone is constucted; instead a
578
+ /// reference directly into `on_entry` is passed along via
579
+ /// `sets.on_entry` instead, which represents the flow state at
580
+ /// the block's start, not necessarily the state immediately prior
581
+ /// to the statement/terminator under analysis.
582
+ ///
583
+ /// In either case, the passed reference is mutable; but this is a
584
+ /// wart from using the `BlockSets` type in the API; the intention
585
+ /// is that the `statement_effect` and `terminator_effect` methods
586
+ /// mutate only the gen/kill sets.
587
+ ///
588
+ /// FIXME: We should consider enforcing the intention described in
589
+ /// the previous paragraph by passing the three sets in separate
590
+ /// parameters to encode their distinct mutabilities.
591
+ fn accumulates_intrablock_state ( ) -> bool { false }
592
+
563
593
/// A name describing the dataflow analysis that this
564
594
/// BitDenotation is supporting. The name should be something
565
595
/// suitable for plugging in as part of a filename e.g. avoid
0 commit comments