Run combine_duplicate_switch_targets after the simplification that produces them
This commit is contained in:
parent
b658050846
commit
8ec49ad19a
4 changed files with 19 additions and 20 deletions
|
@ -278,6 +278,18 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn combine_duplicate_switch_targets(terminator: &mut Terminator<'_>) {
|
||||
if let TerminatorKind::SwitchInt { targets, .. } = &mut terminator.kind {
|
||||
let otherwise = targets.otherwise();
|
||||
if targets.iter().any(|t| t.1 == otherwise) {
|
||||
*targets = SwitchTargets::new(
|
||||
targets.iter().filter(|t| t.1 != otherwise),
|
||||
targets.otherwise(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_duplicate_unreachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
struct OptApplier<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -298,6 +310,8 @@ pub fn remove_duplicate_unreachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut B
|
|||
}
|
||||
}
|
||||
|
||||
combine_duplicate_switch_targets(terminator);
|
||||
|
||||
self.super_terminator(terminator, location);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue