Skip to content

Commit

Permalink
Inline and remove DataflowAnalysis::num_bits_overall().
Browse files Browse the repository at this point in the history
It has a single callsite, and duplicates some code from that callsite.
The code is more concise and clearer this way.
  • Loading branch information
nnethercote committed Jul 13, 2018
1 parent 960f604 commit 05742ff
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,9 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
let bits_per_block = denotation.bits_per_block();
let usize_bits = mem::size_of::<usize>() * 8;
let words_per_block = (bits_per_block + usize_bits - 1) / usize_bits;
let num_overall = Self::num_bits_overall(mir, bits_per_block);
let bits_per_block_rounded_up = words_per_block * usize_bits; // a multiple of word size
let num_blocks = mir.basic_blocks().len();
let num_overall = num_blocks * bits_per_block_rounded_up;

let zeroes = Bits::new(IdxSetBuf::new_empty(num_overall));
let on_entry = Bits::new(if D::bottom_value() {
Expand Down Expand Up @@ -774,18 +776,6 @@ impl<'a, 'tcx, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
}
}
}

fn num_bits_overall(mir: &Mir, bits_per_block: usize) -> usize {
let usize_bits = mem::size_of::<usize>() * 8;
let words_per_block = (bits_per_block + usize_bits - 1) / usize_bits;

// (now rounded up to multiple of word size)
let bits_per_block = words_per_block * usize_bits;

let num_blocks = mir.basic_blocks().len();
let num_overall = num_blocks * bits_per_block;
num_overall
}
}

impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation
Expand Down

0 comments on commit 05742ff

Please sign in to comment.