Skip to content

Commit dbc2ef2

Browse files
committed
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
2 parents 1b0ff9e + 7f9f2ff commit dbc2ef2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/librustc_mir/transform/simplify.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
142142
}
143143

144144
self.basic_blocks[bb].terminator = Some(terminator);
145-
146-
changed |= inner_changed;
147145
}
148146

149147
if !changed {
@@ -212,6 +210,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
212210
Terminator { kind: TerminatorKind::Goto { ref mut target }, .. } => target,
213211
_ => unreachable!(),
214212
};
213+
*changed |= *target != last;
215214
*target = last;
216215
debug!("collapsing goto chain from {:?} to {:?}", current, target);
217216

@@ -223,7 +222,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
223222
self.pred_count[*target] += 1;
224223
self.pred_count[current] -= 1;
225224
}
226-
*changed = true;
227225
self.basic_blocks[current].terminator = Some(terminator);
228226
}
229227
}

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

+7
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)