Skip to content

Commit 82651db

Browse files
committed
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.
1 parent 19cefa6 commit 82651db

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/librustc_mir/transform/simplify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
212212
Terminator { kind: TerminatorKind::Goto { ref mut target }, .. } => target,
213213
_ => unreachable!(),
214214
};
215+
*changed |= *target != last;
215216
*target = last;
216217
debug!("collapsing goto chain from {:?} to {:?}", current, target);
217218

@@ -223,7 +224,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
223224
self.pred_count[*target] += 1;
224225
self.pred_count[current] -= 1;
225226
}
226-
*changed = true;
227227
self.basic_blocks[current].terminator = Some(terminator);
228228
}
229229
}

src/test/ui/issues/issue-75704.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Caused an infinite loop during SimlifyCfg MIR transform previously.
2+
//
3+
// build-pass
4+
5+
fn main() {
6+
loop { continue; }
7+
}

0 commit comments

Comments
 (0)