Skip to content

Commit 005a70e

Browse files
committed
Remove instance_def_size_estimate query.
It doesn't seem worthwhile now that `MonoItem::size_estimate` is called much less often.
1 parent 87c509d commit 005a70e

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

compiler/rustc_middle/src/mir/mono.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,19 @@ impl<'tcx> MonoItem<'tcx> {
5959
pub fn size_estimate(&self, tcx: TyCtxt<'tcx>) -> usize {
6060
match *self {
6161
MonoItem::Fn(instance) => {
62-
// Estimate the size of a function based on how many statements
63-
// it contains.
64-
tcx.instance_def_size_estimate(instance.def)
62+
match instance.def {
63+
// "Normal" functions size estimate: the number of
64+
// statements, plus one for the terminator.
65+
InstanceDef::Item(..) | InstanceDef::DropGlue(..) => {
66+
let mir = tcx.instance_mir(instance.def);
67+
mir.basic_blocks.iter().map(|bb| bb.statements.len() + 1).sum()
68+
}
69+
// Other compiler-generated shims size estimate: 1
70+
_ => 1,
71+
}
6572
}
66-
// Conservatively estimate the size of a static declaration
67-
// or assembly to be 1.
73+
// Conservatively estimate the size of a static declaration or
74+
// assembly item to be 1.
6875
MonoItem::Static(_) | MonoItem::GlobalAsm(_) => 1,
6976
}
7077
}

compiler/rustc_middle/src/query/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -2080,12 +2080,6 @@ rustc_queries! {
20802080
desc { "looking up supported target features" }
20812081
}
20822082

2083-
/// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.
2084-
query instance_def_size_estimate(def: ty::InstanceDef<'tcx>)
2085-
-> usize {
2086-
desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) }
2087-
}
2088-
20892083
query features_query(_: ()) -> &'tcx rustc_feature::Features {
20902084
feedable
20912085
desc { "looking up enabled feature gates" }

compiler/rustc_ty_utils/src/ty.rs

-17
Original file line numberDiff line numberDiff line change
@@ -311,22 +311,6 @@ fn param_env_reveal_all_normalized(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamE
311311
tcx.param_env(def_id).with_reveal_all_normalized(tcx)
312312
}
313313

314-
fn instance_def_size_estimate<'tcx>(
315-
tcx: TyCtxt<'tcx>,
316-
instance_def: ty::InstanceDef<'tcx>,
317-
) -> usize {
318-
use ty::InstanceDef;
319-
320-
match instance_def {
321-
InstanceDef::Item(..) | InstanceDef::DropGlue(..) => {
322-
let mir = tcx.instance_mir(instance_def);
323-
mir.basic_blocks.iter().map(|bb| bb.statements.len() + 1).sum()
324-
}
325-
// Estimate the size of other compiler-generated shims to be 1.
326-
_ => 1,
327-
}
328-
}
329-
330314
/// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`.
331315
///
332316
/// See [`ty::ImplOverlapKind::Issue33140`] for more details.
@@ -432,7 +416,6 @@ pub fn provide(providers: &mut Providers) {
432416
adt_sized_constraint,
433417
param_env,
434418
param_env_reveal_all_normalized,
435-
instance_def_size_estimate,
436419
issue33140_self_ty,
437420
defaultness,
438421
unsizing_params_for_adt,

0 commit comments

Comments
 (0)