mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 20:45:45 +03:00
Auto merge of #75076 - tmiasko:simplify-goto, r=oli-obk
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. Fixes #75074 Fixes #75051
This commit is contained in:
@@ -142,8 +142,6 @@ pub fn simplify(mut self) {
|
||||
}
|
||||
|
||||
self.basic_blocks[bb].terminator = Some(terminator);
|
||||
|
||||
changed |= inner_changed;
|
||||
}
|
||||
|
||||
if !changed {
|
||||
@@ -212,6 +210,7 @@ fn collapse_goto_chain(&mut self, start: &mut BasicBlock, changed: &mut bool) {
|
||||
Terminator { kind: TerminatorKind::Goto { ref mut target }, .. } => target,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
*changed |= *target != last;
|
||||
*target = last;
|
||||
debug!("collapsing goto chain from {:?} to {:?}", current, target);
|
||||
|
||||
@@ -223,7 +222,6 @@ fn collapse_goto_chain(&mut self, start: &mut BasicBlock, changed: &mut bool) {
|
||||
self.pred_count[*target] += 1;
|
||||
self.pred_count[current] -= 1;
|
||||
}
|
||||
*changed = true;
|
||||
self.basic_blocks[current].terminator = Some(terminator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Caused an infinite loop during SimlifyCfg MIR transform previously.
|
||||
//
|
||||
// build-pass
|
||||
|
||||
fn main() {
|
||||
loop { continue; }
|
||||
}
|
||||
Reference in New Issue
Block a user