Skip to content

Commit a2d9687

Browse files
committed
Add comment.
1 parent a16b49b commit a2d9687

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

compiler/rustc_mir_transform/src/simplify.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ impl SimplifyCfg {
7575

7676
pub(super) fn simplify_cfg<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
7777
if CfgSimplifier::new(tcx, body).simplify() {
78+
// `simplify` returns that it changed something. We must invalidate the CFG caches as they
79+
// are not consistent with the modified CFG any more.
7880
body.basic_blocks.invalidate_cfg_cache();
7981
}
8082
remove_dead_blocks(body);
@@ -123,6 +125,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
123125
// Preserve `SwitchInt` reads on built and analysis MIR, or if `-Zmir-preserve-ub`.
124126
let preserve_switch_reads = matches!(body.phase, MirPhase::Built | MirPhase::Analysis(_))
125127
|| tcx.sess.opts.unstable_opts.mir_preserve_ub;
128+
// Do not clear caches yet. The caller to `simplify` will do it if anything changed.
126129
let basic_blocks = body.basic_blocks.as_mut_preserves_cfg();
127130

128131
CfgSimplifier { preserve_switch_reads, basic_blocks, pred_count }

0 commit comments

Comments
 (0)