Skip to content

Commit

Permalink
Remove limit
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Jan 8, 2023
1 parent ee29825 commit 3b77094
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions compiler/rustc_mir_transform/src/deduplicate_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ impl<'tcx> MirPass<'tcx> for DeduplicateBlocks {
}

fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// Basic blocks can get really big, so to avoid checking for duplicates in basic blocks
// that are unlikely to have duplicates, we stop early. The early bail number has been
// found experimentally by eprintln while compiling the crates in the rustc-perf suite.
let limit = if tcx.sess.mir_opt_level() < 3 { 3 } else { 10 };

debug!("Running DeduplicateBlocks on `{:?}`", body.source);
let duplicates = find_duplicates(body, limit);
let duplicates = find_duplicates(body);
let has_opts_to_apply = !duplicates.is_empty();

if has_opts_to_apply {
Expand Down Expand Up @@ -59,7 +54,7 @@ impl<'tcx> MutVisitor<'tcx> for OptApplier<'tcx> {
}
}

fn find_duplicates(body: &Body<'_>, limit: usize) -> FxHashMap<BasicBlock, BasicBlock> {
fn find_duplicates(body: &Body<'_>) -> FxHashMap<BasicBlock, BasicBlock> {
let mut duplicates = FxHashMap::default();

let bbs_to_go_through =
Expand All @@ -77,10 +72,6 @@ fn find_duplicates(body: &Body<'_>, limit: usize) -> FxHashMap<BasicBlock, Basic
// with replacement bb3.
// When the duplicates are removed, we will end up with only bb3.
for (bb, bbd) in body.basic_blocks.iter_enumerated().rev().filter(|(_, bbd)| !bbd.is_cleanup) {
if bbd.statements.len() > limit {
continue;
}

let to_hash = BasicBlockHashable { basic_block_data: bbd };
let entry = same_hashes.entry(to_hash);
match entry {
Expand Down

0 comments on commit 3b77094

Please sign in to comment.