@@ -192,7 +192,12 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD> where BD: BitDenotation
192
192
for ( bb, data) in self . mir . basic_blocks ( ) . iter_enumerated ( ) {
193
193
let & mir:: BasicBlockData { ref statements, ref terminator, is_cleanup : _ } = data;
194
194
195
+ let mut interim_state;
195
196
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
+ }
196
201
for j_stmt in 0 ..statements. len ( ) {
197
202
let location = Location { block : bb, statement_index : j_stmt } ;
198
203
self . flow_state . operator . statement_effect ( sets, location) ;
@@ -559,6 +564,20 @@ pub trait BitDenotation: BitwiseOperator {
559
564
/// Specifies what index type is used to access the bitvector.
560
565
type Idx : Idx ;
561
566
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
+
562
581
/// A name describing the dataflow analysis that this
563
582
/// BitDenotation is supporting. The name should be something
564
583
/// suitable for plugging in as part of a filename e.g. avoid
0 commit comments