@@ -35,7 +35,7 @@ pub trait Dataflow {
35
35
}
36
36
37
37
impl < ' a , ' tcx : ' a , BD > Dataflow for MirBorrowckCtxtPreDataflow < ' a , ' tcx , BD >
38
- where BD : BitDenotation , BD :: Bit : Debug , BD :: Ctxt : HasMoveData < ' tcx >
38
+ where BD : BitDenotation + DataflowOperator , BD :: Bit : Debug , BD :: Ctxt : HasMoveData < ' tcx >
39
39
{
40
40
fn dataflow ( & mut self ) {
41
41
self . flow_state . build_sets ( ) ;
@@ -53,7 +53,7 @@ struct PropagationContext<'b, 'a: 'b, 'tcx: 'a, O>
53
53
}
54
54
55
55
impl < ' a , ' tcx : ' a , BD > DataflowAnalysis < ' a , ' tcx , BD >
56
- where BD : BitDenotation , BD :: Ctxt : HasMoveData < ' tcx >
56
+ where BD : BitDenotation + DataflowOperator , BD :: Ctxt : HasMoveData < ' tcx >
57
57
{
58
58
fn propagate ( & mut self ) {
59
59
let mut temp = vec ! [ 0 ; self . flow_state. sets. words_per_block] ;
@@ -100,10 +100,10 @@ impl<'a, 'tcx: 'a, BD> DataflowAnalysis<'a, 'tcx, BD>
100
100
}
101
101
102
102
impl < ' b , ' a : ' b , ' tcx : ' a , BD > PropagationContext < ' b , ' a , ' tcx , BD >
103
- where BD : BitDenotation , BD :: Ctxt : HasMoveData < ' tcx >
103
+ where BD : BitDenotation + DataflowOperator , BD :: Ctxt : HasMoveData < ' tcx >
104
104
{
105
105
fn reset ( & mut self , bits : & mut [ usize ] ) {
106
- let e = if BD :: initial_value ( ) { usize:: MAX } else { 0 } ;
106
+ let e = if BD :: bottom_value ( ) { usize:: MAX } else { 0 } ;
107
107
for b in bits {
108
108
* b = e;
109
109
}
@@ -317,17 +317,17 @@ impl<O: BitDenotation> DataflowState<O> {
317
317
}
318
318
319
319
pub trait BitwiseOperator {
320
- /// Joins two predecessor bits together, typically either `|` or `&`
320
+ /// Applies some bit-operation pointwise to each of the bits in the two inputs.
321
321
fn join ( & self , pred1 : usize , pred2 : usize ) -> usize ;
322
322
}
323
323
324
324
/// Parameterization for the precise form of data flow that is used.
325
- pub trait DataflowOperator : BitwiseOperator {
325
+ pub trait DataflowOperator : BitwiseOperator {
326
326
/// Specifies the initial value for each bit in the `on_entry` set
327
- fn initial_value ( ) -> bool ;
327
+ fn bottom_value ( ) -> bool ;
328
328
}
329
329
330
- pub trait BitDenotation : DataflowOperator {
330
+ pub trait BitDenotation {
331
331
/// Specifies what is represented by each bit in the dataflow bitvector.
332
332
type Bit ;
333
333
@@ -425,7 +425,7 @@ pub trait BitDenotation: DataflowOperator {
425
425
}
426
426
427
427
impl < ' a , ' tcx : ' a , D > DataflowAnalysis < ' a , ' tcx , D >
428
- where D : BitDenotation , D :: Ctxt : HasMoveData < ' tcx >
428
+ where D : BitDenotation + DataflowOperator , D :: Ctxt : HasMoveData < ' tcx >
429
429
{
430
430
pub fn new ( _tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
431
431
mir : & ' a Mir < ' tcx > ,
@@ -437,7 +437,7 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D>
437
437
let num_blocks = mir. basic_blocks . len ( ) ;
438
438
let num_words = num_blocks * words_per_block;
439
439
440
- let entry = if D :: initial_value ( ) { usize:: MAX } else { 0 } ;
440
+ let entry = if D :: bottom_value ( ) { usize:: MAX } else { 0 } ;
441
441
442
442
let zeroes = Bits :: new ( 0 , num_words) ;
443
443
let on_entry = Bits :: new ( entry, num_words) ;
@@ -460,7 +460,7 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D>
460
460
}
461
461
462
462
impl < ' a , ' tcx : ' a , D > DataflowAnalysis < ' a , ' tcx , D >
463
- where D : BitDenotation , D :: Ctxt : HasMoveData < ' tcx >
463
+ where D : BitDenotation + DataflowOperator , D :: Ctxt : HasMoveData < ' tcx >
464
464
{
465
465
/// Propagates the bits of `in_out` into all the successors of `bb`,
466
466
/// using bitwise operator denoted by `self.operator`.
@@ -851,7 +851,6 @@ impl<'a, 'tcx> BitDenotation for MaybeInitializedLvals<'a, 'tcx> {
851
851
fn interpret < ' c > ( & self , ctxt : & ' c Self :: Ctxt , idx : usize ) -> & ' c Self :: Bit {
852
852
& ctxt. 2 . move_paths [ MovePathIndex :: new ( idx) ]
853
853
}
854
-
855
854
fn start_block_effect ( & self , ctxt : & Self :: Ctxt , sets : & mut BlockSets )
856
855
{
857
856
super :: drop_flag_effects_for_function_entry (
@@ -1072,12 +1071,10 @@ impl<'a, 'tcx> BitwiseOperator for DefinitelyInitializedLvals<'a, 'tcx> {
1072
1071
}
1073
1072
}
1074
1073
1075
- // FIXME: `DataflowOperator::initial_value` should be named
1076
- // `bottom_value`. The way that dataflow fixed point iteration works,
1077
- // you want to start at bottom and work your way to a fixed point.
1078
- // This needs to include the detail that the control-flow merges will
1079
- // apply the `join` operator above to current state (which starts at
1080
- // that bottom value).
1074
+ // The way that dataflow fixed point iteration works, you want to
1075
+ // start at bottom and work your way to a fixed point. Control-flow
1076
+ // merges will apply the `join` operator to each block entry's current
1077
+ // state (which starts at that bottom value).
1081
1078
//
1082
1079
// This means, for propagation across the graph, that you either want
1083
1080
// to start at all-zeroes and then use Union as your merge when
@@ -1086,28 +1083,28 @@ impl<'a, 'tcx> BitwiseOperator for DefinitelyInitializedLvals<'a, 'tcx> {
1086
1083
1087
1084
impl < ' a , ' tcx > DataflowOperator for MovingOutStatements < ' a , ' tcx > {
1088
1085
#[ inline]
1089
- fn initial_value ( ) -> bool {
1086
+ fn bottom_value ( ) -> bool {
1090
1087
false // bottom = no loans in scope by default
1091
1088
}
1092
1089
}
1093
1090
1094
1091
impl < ' a , ' tcx > DataflowOperator for MaybeInitializedLvals < ' a , ' tcx > {
1095
1092
#[ inline]
1096
- fn initial_value ( ) -> bool {
1093
+ fn bottom_value ( ) -> bool {
1097
1094
false // bottom = uninitialized
1098
1095
}
1099
1096
}
1100
1097
1101
1098
impl < ' a , ' tcx > DataflowOperator for MaybeUninitializedLvals < ' a , ' tcx > {
1102
1099
#[ inline]
1103
- fn initial_value ( ) -> bool {
1100
+ fn bottom_value ( ) -> bool {
1104
1101
false // bottom = initialized (start_block_effect counters this at outset)
1105
1102
}
1106
1103
}
1107
1104
1108
1105
impl < ' a , ' tcx > DataflowOperator for DefinitelyInitializedLvals < ' a , ' tcx > {
1109
1106
#[ inline]
1110
- fn initial_value ( ) -> bool {
1107
+ fn bottom_value ( ) -> bool {
1111
1108
true // bottom = initialized
1112
1109
}
1113
1110
}
0 commit comments