1
Fork 0

Move predecessors from Body to BasicBlocks

This commit is contained in:
Tomasz Miąsko 2022-07-05 00:00:00 +00:00
parent 2446b17745
commit 39d9c1cb1f
9 changed files with 10 additions and 16 deletions

View file

@ -39,7 +39,7 @@ impl<'tcx> MirPass<'tcx> for AddCallGuards {
impl AddCallGuards {
pub fn add_call_guards(&self, body: &mut Body<'_>) {
let mut pred_count: IndexVec<_, _> =
body.predecessors().iter().map(|ps| ps.len()).collect();
body.basic_blocks.predecessors().iter().map(|ps| ps.len()).collect();
pred_count[START_BLOCK] += 1;
// We need a place to store the new blocks generated

View file

@ -95,7 +95,7 @@ impl CoverageGraph {
let mut basic_blocks = Vec::new();
for (bb, data) in mir_cfg_without_unwind {
if let Some(last) = basic_blocks.last() {
let predecessors = &mir_body.predecessors()[bb];
let predecessors = &mir_body.basic_blocks.predecessors()[bb];
if predecessors.len() > 1 || !predecessors.contains(last) {
// The `bb` has more than one _incoming_ edge, and should start its own
// `BasicCoverageBlockData`. (Note, the `basic_blocks` vector does not yet

View file

@ -133,7 +133,7 @@ fn find_local_assigned_to_return_place(
return local;
}
match body.predecessors()[block].as_slice() {
match body.basic_blocks.predecessors()[block].as_slice() {
&[pred] => block = pred,
_ => return None,
}

View file

@ -61,7 +61,7 @@ impl<'tcx> MirPass<'tcx> for SeparateConstSwitch {
/// Returns the amount of blocks that were duplicated
pub fn separate_const_switch(body: &mut Body<'_>) -> usize {
let mut new_blocks: SmallVec<[(BasicBlock, BasicBlock); 6]> = SmallVec::new();
let predecessors = body.predecessors();
let predecessors = body.basic_blocks.predecessors();
'block_iter: for (block_id, block) in body.basic_blocks().iter_enumerated() {
if let TerminatorKind::SwitchInt {
discr: Operand::Copy(switch_place) | Operand::Move(switch_place),