Fix change detection in CfgSimplifier::collapse_goto_chain

Check that the old target is different from the new collapsed one,
before concluding that anything changed.
This commit is contained in:
Tomasz Miąsko 2020-08-03 00:00:00 +00:00
parent 19cefa6864
commit 82651db9b2
2 changed files with 8 additions and 1 deletions

View File

@ -212,6 +212,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
Terminator { kind: TerminatorKind::Goto { ref mut target }, .. } => target,
_ => unreachable!(),
};
*changed |= *target != last;
*target = last;
debug!("collapsing goto chain from {:?} to {:?}", current, target);
@ -223,7 +224,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
self.pred_count[*target] += 1;
self.pred_count[current] -= 1;
}
*changed = true;
self.basic_blocks[current].terminator = Some(terminator);
}
}

View File

@ -0,0 +1,7 @@
// Caused an infinite loop during SimlifyCfg MIR transform previously.
//
// build-pass
fn main() {
loop { continue; }
}