Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8713973
std: simplify `NonNull` variance documentation
xizheyin Jun 3, 2025
5f0dd44
avoid `&mut P<T>` in `visit_expr` etc methods
fee1-dead Jun 11, 2025
810d99e
Prepare `rustc-dev` component un-remapping in the compiler
Urgau Jun 10, 2025
268fbfe
Un-remap `rustc-dev` component paths
Urgau Jun 11, 2025
a16b49b
Manually invalidate caches in SimplifyCfg.
cjgillot Jun 15, 2025
0e1db54
Windows: Use anonymous pipes in Command
ChrisDenton Jun 14, 2025
32c0cb0
Add union with default field values case test
jieyouxu Jun 16, 2025
a2d9687
Add comment.
cjgillot Jun 16, 2025
718df66
Two changes: Have BorrowError & BorrowMutError derive Debug and add
nealsid Jun 14, 2025
2fca05a
Rename BorrowFlag type to BorrowCounter
nealsid Jun 14, 2025
994794a
Handle same-crate macro for borrowck semicolon suggestion
Urgau Jun 16, 2025
2dd9cc1
Reject union default field values
jieyouxu Jun 16, 2025
1dbedaf
Refine run-make test ignores due to unpredictable `i686-pc-windows-gn…
jieyouxu Jun 16, 2025
aa8c6f8
Don't match on platform-specific directory not found message
jieyouxu Jun 17, 2025
0348a4a
Make performance of String::insert_str more precise
hkBst Mar 15, 2025
679a1a7
Rollup merge of #138538 - hkBst:patch-4, r=tgross35
workingjubilee Jun 17, 2025
be6b529
Rollup merge of #141946 - xizheyin:141933, r=jhpratt
workingjubilee Jun 17, 2025
4c48468
Rollup merge of #142216 - nealsid:refcell-logging, r=tgross35
workingjubilee Jun 17, 2025
0ab7ae0
Rollup merge of #142371 - fee1-dead-contrib:push-xqlkumzurkus, r=petr…
workingjubilee Jun 17, 2025
e39823f
Rollup merge of #142377 - Urgau:unremap-rustc-dev, r=jieyouxu
workingjubilee Jun 17, 2025
532edf5
Rollup merge of #142517 - ChrisDenton:anon-pipe, r=Mark-Simulacrum
workingjubilee Jun 17, 2025
540f68e
Rollup merge of #142542 - cjgillot:invalidate-simplify-cfg, r=SparrowLii
workingjubilee Jun 17, 2025
ac8a2cb
Rollup merge of #142563 - jieyouxu:no-more-i686-mingw, r=mati865
workingjubilee Jun 17, 2025
0945b2b
Rollup merge of #142570 - jieyouxu:disunion, r=estebank
workingjubilee Jun 17, 2025
c79a6c0
Rollup merge of #142584 - Urgau:span-borrowck-139049, r=fmease
workingjubilee Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Manually invalidate caches in SimplifyCfg.
  • Loading branch information
cjgillot committed Jun 15, 2025
commit a16b49bb933928facaff9ba9f3a22b98029f9923
16 changes: 13 additions & 3 deletions compiler/rustc_mir_transform/src/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ impl SimplifyCfg {
}

pub(super) fn simplify_cfg<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
CfgSimplifier::new(tcx, body).simplify();
if CfgSimplifier::new(tcx, body).simplify() {
body.basic_blocks.invalidate_cfg_cache();
}
remove_dead_blocks(body);

// FIXME: Should probably be moved into some kind of pass manager
Expand Down Expand Up @@ -121,19 +123,23 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
// Preserve `SwitchInt` reads on built and analysis MIR, or if `-Zmir-preserve-ub`.
let preserve_switch_reads = matches!(body.phase, MirPhase::Built | MirPhase::Analysis(_))
|| tcx.sess.opts.unstable_opts.mir_preserve_ub;
let basic_blocks = body.basic_blocks_mut();
let basic_blocks = body.basic_blocks.as_mut_preserves_cfg();

CfgSimplifier { preserve_switch_reads, basic_blocks, pred_count }
}

fn simplify(mut self) {
/// Returns whether we actually simplified anything. In that case, the caller *must* invalidate
/// the CFG caches of the MIR body.
#[must_use]
fn simplify(mut self) -> bool {
self.strip_nops();

// Vec of the blocks that should be merged. We store the indices here, instead of the
// statements itself to avoid moving the (relatively) large statements twice.
// We do not push the statements directly into the target block (`bb`) as that is slower
// due to additional reallocations
let mut merged_blocks = Vec::new();
let mut outer_changed = false;
loop {
let mut changed = false;

Expand Down Expand Up @@ -177,7 +183,11 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
if !changed {
break;
}

outer_changed = true;
}

outer_changed
}

/// This function will return `None` if
Expand Down
Loading