Skip to content

Commit

Permalink
Auto merge of #75076 - tmiasko:simplify-goto, r=oli-obk
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Aug 3, 2020
2 parents 1b0ff9e + 7f9f2ff commit dbc2ef2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/librustc_mir/transform/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
}

self.basic_blocks[bb].terminator = Some(terminator);

changed |= inner_changed;
}

if !changed {
Expand Down Expand Up @@ -212,6 +210,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);

Expand All @@ -223,7 +222,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);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/issues/issue-75704.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Caused an infinite loop during SimlifyCfg MIR transform previously.
//
// build-pass

fn main() {
loop { continue; }
}

0 comments on commit dbc2ef2

Please sign in to comment.