Skip to content

Commit be3d1d6

Browse files
committed
Tweak cgu partitioning
1 parent 64ad709 commit be3d1d6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/librustc_ty/ty.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use rustc_data_structures::svh::Svh;
22
use rustc_hir as hir;
33
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
44
use rustc_middle::hir::map as hir_map;
5+
use rustc_middle::mir::StatementKind;
56
use rustc_middle::ty::subst::Subst;
67
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, WithConstness};
78
use rustc_session::CrateDisambiguator;
@@ -299,7 +300,23 @@ fn instance_def_size_estimate<'tcx>(
299300
match instance_def {
300301
InstanceDef::Item(..) | InstanceDef::DropGlue(..) => {
301302
let mir = tcx.instance_mir(instance_def);
302-
mir.basic_blocks().iter().map(|bb| bb.statements.len()).sum()
303+
mir.basic_blocks()
304+
.iter()
305+
.map(|bb| {
306+
bb.statements
307+
.iter()
308+
.filter(|stmt| match stmt.kind {
309+
StatementKind::StorageLive(_)
310+
| StatementKind::StorageDead(_)
311+
| StatementKind::AscribeUserType(..)
312+
| StatementKind::FakeRead(..)
313+
| StatementKind::Retag(..)
314+
| StatementKind::Nop => false,
315+
_ => true,
316+
})
317+
.count()
318+
})
319+
.sum()
303320
}
304321
// Estimate the size of other compiler-generated shims to be 1.
305322
_ => 1,

0 commit comments

Comments
 (0)