1
Fork 0

mir-opt: a sub-BB of a cleanup BB must also be a cleanup BB

This commit is contained in:
DianQK 2024-09-24 22:51:36 +08:00
parent 7a0b78da91
commit 15fa788cc3
No known key found for this signature in database
4 changed files with 322 additions and 1 deletions

View file

@ -179,7 +179,7 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
let eq_targets = SwitchTargets::new(eq_new_targets, parent_targets.otherwise());
// Create `bbEq` in example above
let eq_switch = BasicBlockData::new(Some(Terminator {
let mut eq_switch = BasicBlockData::new(Some(Terminator {
source_info: bbs[parent].terminator().source_info,
kind: TerminatorKind::SwitchInt {
// switch on the first discriminant, so we can mark the second one as dead
@ -187,6 +187,7 @@ impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
targets: eq_targets,
},
}));
eq_switch.is_cleanup = bbs[parent].is_cleanup;
let eq_bb = patch.new_block(eq_switch);