Skip to content

Commit 64ee4e1

Browse files
committed
Base CGU estimates on basic block count, not statement count.
1 parent 8084f39 commit 64ee4e1

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'tcx> MonoItem<'tcx> {
6161
MonoItem::Fn(instance) => {
6262
// Estimate the size of a function based on how many statements
6363
// it contains.
64-
tcx.instance_def_size_estimate(instance.def)
64+
1 + tcx.instance_def_size_estimate(instance.def)
6565
}
6666
// Conservatively estimate the size of a static declaration
6767
// or assembly to be 1.

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ fn merge_codegen_units<'tcx>(
322322
// Having multiple CGUs can drastically speed up compilation. But for
323323
// non-incremental builds, tiny CGUs slow down compilation *and* result in
324324
// worse generated code. So we don't allow CGUs smaller than this (unless
325-
// there is just one CGU, of course). Note that CGU sizes of 100,000+ are
325+
// there is just one CGU, of course). Note that CGU sizes of 20,000+ are
326326
// common in larger programs, so this isn't all that large.
327-
const NON_INCR_MIN_CGU_SIZE: usize = 1800;
327+
const NON_INCR_MIN_CGU_SIZE: usize = 500;
328328

329329
// Repeatedly merge the two smallest codegen units as long as:
330330
// - we have more CGUs than the upper limit, or

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ fn instance_def_size_estimate<'tcx>(
459459
match instance_def {
460460
InstanceDef::Item(..) | InstanceDef::DropGlue(..) => {
461461
let mir = tcx.instance_mir(instance_def);
462-
mir.basic_blocks.iter().map(|bb| bb.statements.len() + 1).sum()
462+
mir.basic_blocks.len()
463463
}
464464
// Estimate the size of other compiler-generated shims to be 1.
465465
_ => 1,

0 commit comments

Comments
 (0)