1010
1111use syntax:: ast:: { self , MetaItem } ;
1212
13- use rustc_data_structures:: bitslice:: { bitwise, BitwiseOperator , Word } ;
13+ use rustc_data_structures:: bitslice:: { bitwise, BitwiseOperator } ;
1414use rustc_data_structures:: indexed_set:: { HybridIdxSetBuf , IdxSet , IdxSetBuf } ;
1515use rustc_data_structures:: indexed_vec:: Idx ;
1616use rustc_data_structures:: work_queue:: WorkQueue ;
@@ -23,7 +23,6 @@ use rustc::session::Session;
2323use std:: borrow:: Borrow ;
2424use std:: fmt;
2525use std:: io;
26- use std:: mem;
2726use std:: path:: PathBuf ;
2827use std:: usize;
2928
@@ -287,18 +286,6 @@ impl<'a, 'tcx: 'a, BD> DataflowBuilder<'a, 'tcx, BD> where BD: BitDenotation
287286 }
288287}
289288
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-
302289/// DataflowResultsConsumer abstracts over walking the MIR with some
303290/// already constructed dataflow results.
304291///
@@ -464,12 +451,8 @@ pub struct AllSets<E: Idx> {
464451 /// Analysis bitwidth for each block.
465452 bits_per_block : usize ,
466453
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-
471454 /// For each block, bits valid on entry to the block.
472- on_entry_sets : Bits < E > ,
455+ on_entry_sets : Vec < IdxSetBuf < E > > ,
473456
474457 /// For each block, bits generated by executing the statements in
475458 /// the block. (For comparison, the Terminator for each block is
@@ -559,19 +542,15 @@ impl<'a, E:Idx> BlockSets<'a, E> {
559542impl < E : Idx > AllSets < E > {
560543 pub fn bits_per_block ( & self ) -> usize { self . bits_per_block }
561544 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 ) ;
564545 BlockSets {
565- on_entry : self . on_entry_sets . bits . range_mut ( & range ) ,
546+ on_entry : & mut self . on_entry_sets [ block_idx ] ,
566547 gen_set : & mut self . gen_sets [ block_idx] ,
567548 kill_set : & mut self . kill_sets [ block_idx] ,
568549 }
569550 }
570551
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]
575554 }
576555 pub fn gen_set_for ( & self , block_idx : usize ) -> & HybridIdxSetBuf < E > {
577556 & self . gen_sets [ block_idx]
@@ -731,29 +710,25 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
731710 dead_unwinds : & ' a IdxSet < mir:: BasicBlock > ,
732711 denotation : D ) -> Self where D : InitialFlow {
733712 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
737713 let num_blocks = mir. basic_blocks ( ) . len ( ) ;
738- let num_overall = num_blocks * bits_per_block_rounded_up;
739714
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 ]
742717 } 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 ( ) ;
746722
747723 DataflowAnalysis {
748724 mir,
749725 dead_unwinds,
750726 flow_state : DataflowState {
751727 sets : AllSets {
752728 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,
757732 } ,
758733 operator : denotation,
759734 }
@@ -873,5 +848,4 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
873848 dirty_queue. insert ( bb) ;
874849 }
875850 }
876-
877851}
0 commit comments