10
10
11
11
use syntax:: ast:: { self , MetaItem } ;
12
12
13
- use rustc_data_structures:: bitslice:: { bitwise, BitwiseOperator , Word } ;
13
+ use rustc_data_structures:: bitslice:: { bitwise, BitwiseOperator } ;
14
14
use rustc_data_structures:: indexed_set:: { HybridIdxSetBuf , IdxSet , IdxSetBuf } ;
15
15
use rustc_data_structures:: indexed_vec:: Idx ;
16
16
use rustc_data_structures:: work_queue:: WorkQueue ;
@@ -23,7 +23,6 @@ use rustc::session::Session;
23
23
use std:: borrow:: Borrow ;
24
24
use std:: fmt;
25
25
use std:: io;
26
- use std:: mem;
27
26
use std:: path:: PathBuf ;
28
27
use std:: usize;
29
28
@@ -287,18 +286,6 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation
287
286
}
288
287
}
289
288
290
- /// Maps each block to a set of bits
291
- #[ derive( Clone , Debug ) ]
292
- pub ( crate ) struct Bits < E : Idx > {
293
- bits : IdxSetBuf < E > ,
294
- }
295
-
296
- impl < E : Idx > Bits < E > {
297
- fn new ( bits : IdxSetBuf < E > ) -> Self {
298
- Bits { bits : bits }
299
- }
300
- }
301
-
302
289
/// DataflowResultsConsumer abstracts over walking the MIR with some
303
290
/// already constructed dataflow results.
304
291
///
@@ -464,12 +451,8 @@ pub struct AllSets<E: Idx> {
464
451
/// Analysis bitwidth for each block.
465
452
bits_per_block : usize ,
466
453
467
- /// Number of words associated with each block entry
468
- /// equal to bits_per_block / (mem::size_of::<Word> * 8), rounded up.
469
- words_per_block : usize ,
470
-
471
454
/// For each block, bits valid on entry to the block.
472
- on_entry_sets : Bits < E > ,
455
+ on_entry_sets : Vec < IdxSetBuf < E > > ,
473
456
474
457
/// For each block, bits generated by executing the statements in
475
458
/// the block. (For comparison, the Terminator for each block is
@@ -559,19 +542,15 @@ impl<'a, E:Idx> BlockSets<'a, E> {
559
542
impl < E : Idx > AllSets < E > {
560
543
pub fn bits_per_block ( & self ) -> usize { self . bits_per_block }
561
544
pub fn for_block ( & mut self , block_idx : usize ) -> BlockSets < E > {
562
- let offset = self . words_per_block * block_idx;
563
- let range = E :: new ( offset) ..E :: new ( offset + self . words_per_block ) ;
564
545
BlockSets {
565
- on_entry : self . on_entry_sets . bits . range_mut ( & range ) ,
546
+ on_entry : & mut self . on_entry_sets [ block_idx ] ,
566
547
gen_set : & mut self . gen_sets [ block_idx] ,
567
548
kill_set : & mut self . kill_sets [ block_idx] ,
568
549
}
569
550
}
570
551
571
- pub fn on_entry_set_for ( & self , block_idx : usize ) -> & IdxSet < E > {
572
- let offset = self . words_per_block * block_idx;
573
- let range = E :: new ( offset) ..E :: new ( offset + self . words_per_block ) ;
574
- self . on_entry_sets . bits . range ( & range)
552
+ pub fn on_entry_set_for ( & self , block_idx : usize ) -> & IdxSetBuf < E > {
553
+ & self . on_entry_sets [ block_idx]
575
554
}
576
555
pub fn gen_set_for ( & self , block_idx : usize ) -> & HybridIdxSetBuf < E > {
577
556
& self . gen_sets [ block_idx]
@@ -731,29 +710,25 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
731
710
dead_unwinds : & ' a IdxSet < mir:: BasicBlock > ,
732
711
denotation : D ) -> Self where D : InitialFlow {
733
712
let bits_per_block = denotation. bits_per_block ( ) ;
734
- let bits_per_word = mem:: size_of :: < Word > ( ) * 8 ;
735
- let words_per_block = ( bits_per_block + bits_per_word - 1 ) / bits_per_word;
736
- let bits_per_block_rounded_up = words_per_block * bits_per_word; // a multiple of word size
737
713
let num_blocks = mir. basic_blocks ( ) . len ( ) ;
738
- let num_overall = num_blocks * bits_per_block_rounded_up;
739
714
740
- let on_entry = Bits :: new ( if D :: bottom_value ( ) {
741
- IdxSetBuf :: new_filled ( num_overall )
715
+ let on_entry_sets = if D :: bottom_value ( ) {
716
+ vec ! [ IdxSetBuf :: new_filled( bits_per_block ) ; num_blocks ]
742
717
} else {
743
- IdxSetBuf :: new_empty ( num_overall)
744
- } ) ;
745
- let empties = vec ! [ HybridIdxSetBuf :: new_empty( bits_per_block) ; num_blocks] ;
718
+ vec ! [ IdxSetBuf :: new_empty( bits_per_block) ; num_blocks]
719
+ } ;
720
+ let gen_sets = vec ! [ HybridIdxSetBuf :: new_empty( bits_per_block) ; num_blocks] ;
721
+ let kill_sets = gen_sets. clone ( ) ;
746
722
747
723
DataflowAnalysis {
748
724
mir,
749
725
dead_unwinds,
750
726
flow_state : DataflowState {
751
727
sets : AllSets {
752
728
bits_per_block,
753
- words_per_block,
754
- on_entry_sets : on_entry,
755
- gen_sets : empties. clone ( ) ,
756
- kill_sets : empties,
729
+ on_entry_sets,
730
+ gen_sets,
731
+ kill_sets,
757
732
} ,
758
733
operator : denotation,
759
734
}
@@ -873,5 +848,4 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
873
848
dirty_queue. insert ( bb) ;
874
849
}
875
850
}
876
-
877
851
}
0 commit comments