Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bef6ff6

Browse files
committedJul 14, 2023
Auto merge of #113684 - nnethercote:streamline-size-estimates, r=<try>
Streamline size estimates Makes things nicer and a tiny bit faster. r? `@wesleywiser`
2 parents ad96323 + f4c4602 commit bef6ff6

File tree

8 files changed

+85
-97
lines changed

8 files changed

+85
-97
lines changed
 

‎compiler/rustc_codegen_cranelift/src/driver/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! [`codegen_static`]: crate::constant::codegen_static
66
77
use rustc_data_structures::profiling::SelfProfilerRef;
8-
use rustc_middle::mir::mono::{Linkage as RLinkage, MonoItem, Visibility};
8+
use rustc_middle::mir::mono::{MonoItem, MonoItemData};
99

1010
use crate::prelude::*;
1111

@@ -16,11 +16,11 @@ pub(crate) mod jit;
1616
fn predefine_mono_items<'tcx>(
1717
tcx: TyCtxt<'tcx>,
1818
module: &mut dyn Module,
19-
mono_items: &[(MonoItem<'tcx>, (RLinkage, Visibility))],
19+
mono_items: &[(MonoItem<'tcx>, MonoItemData)],
2020
) {
2121
tcx.prof.generic_activity("predefine functions").run(|| {
2222
let is_compiler_builtins = tcx.is_compiler_builtins(LOCAL_CRATE);
23-
for &(mono_item, (linkage, visibility)) in mono_items {
23+
for &(mono_item, data) in mono_items {
2424
match mono_item {
2525
MonoItem::Fn(instance) => {
2626
let name = tcx.symbol_name(instance).name;
@@ -29,8 +29,8 @@ fn predefine_mono_items<'tcx>(
2929
get_function_sig(tcx, module.target_config().default_call_conv, instance);
3030
let linkage = crate::linkage::get_clif_linkage(
3131
mono_item,
32-
linkage,
33-
visibility,
32+
data.linkage,
33+
data.visibility,
3434
is_compiler_builtins,
3535
);
3636
module.declare_function(name, linkage, &sig).unwrap();

‎compiler/rustc_codegen_gcc/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol, supports_128bit_i
159159
let cx = CodegenCx::new(&context, cgu, tcx, supports_128bit_integers);
160160

161161
let mono_items = cgu.items_in_deterministic_order(tcx);
162-
for &(mono_item, (linkage, visibility)) in &mono_items {
163-
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, linkage, visibility);
162+
for &(mono_item, data) in &mono_items {
163+
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
164164
}
165165

166166
// ... and now that we have everything pre-defined, fill out those definitions.

‎compiler/rustc_codegen_llvm/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ pub fn compile_codegen_unit(tcx: TyCtxt<'_>, cgu_name: Symbol) -> (ModuleCodegen
8686
{
8787
let cx = CodegenCx::new(tcx, cgu, &llvm_module);
8888
let mono_items = cx.codegen_unit.items_in_deterministic_order(cx.tcx);
89-
for &(mono_item, (linkage, visibility)) in &mono_items {
90-
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, linkage, visibility);
89+
for &(mono_item, data) in &mono_items {
90+
mono_item.predefine::<Builder<'_, '_, '_>>(&cx, data.linkage, data.visibility);
9191
}
9292

9393
// ... and now that we have everything pre-defined, fill out those definitions.

‎compiler/rustc_codegen_ssa/src/back/symbol_export.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,14 @@ fn exported_symbols_provider_local(
328328

329329
let (_, cgus) = tcx.collect_and_partition_mono_items(());
330330

331-
for (mono_item, &(linkage, visibility)) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
332-
if linkage != Linkage::External {
331+
for (mono_item, data) in cgus.iter().flat_map(|cgu| cgu.items().iter()) {
332+
if data.linkage != Linkage::External {
333333
// We can only re-use things with external linkage, otherwise
334334
// we'll get a linker error
335335
continue;
336336
}
337337

338-
if need_visibility && visibility == Visibility::Hidden {
338+
if need_visibility && data.visibility == Visibility::Hidden {
339339
// If we potentially share things from Rust dylibs, they must
340340
// not be hidden
341341
continue;

‎compiler/rustc_middle/src/mir/mono.rs

+30-15
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
}
@@ -230,14 +237,22 @@ pub struct CodegenUnit<'tcx> {
230237
/// contain something unique to this crate (e.g., a module path)
231238
/// as well as the crate name and disambiguator.
232239
name: Symbol,
233-
items: FxHashMap<MonoItem<'tcx>, (Linkage, Visibility)>,
240+
items: FxHashMap<MonoItem<'tcx>, MonoItemData>,
234241
size_estimate: usize,
235242
primary: bool,
236243
/// True if this is CGU is used to hold code coverage information for dead code,
237244
/// false otherwise.
238245
is_code_coverage_dead_code_cgu: bool,
239246
}
240247

248+
/// Auxiliary info about a `MonoItem`.
249+
#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
250+
pub struct MonoItemData {
251+
pub linkage: Linkage,
252+
pub visibility: Visibility,
253+
pub size_estimate: usize,
254+
}
255+
241256
/// Specifies the linkage type for a `MonoItem`.
242257
///
243258
/// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
@@ -292,12 +307,12 @@ impl<'tcx> CodegenUnit<'tcx> {
292307
}
293308

294309
/// The order of these items is non-determinstic.
295-
pub fn items(&self) -> &FxHashMap<MonoItem<'tcx>, (Linkage, Visibility)> {
310+
pub fn items(&self) -> &FxHashMap<MonoItem<'tcx>, MonoItemData> {
296311
&self.items
297312
}
298313

299314
/// The order of these items is non-determinstic.
300-
pub fn items_mut(&mut self) -> &mut FxHashMap<MonoItem<'tcx>, (Linkage, Visibility)> {
315+
pub fn items_mut(&mut self) -> &mut FxHashMap<MonoItem<'tcx>, MonoItemData> {
301316
&mut self.items
302317
}
303318

@@ -320,16 +335,16 @@ impl<'tcx> CodegenUnit<'tcx> {
320335
base_n::encode(hash, base_n::CASE_INSENSITIVE)
321336
}
322337

323-
pub fn compute_size_estimate(&mut self, tcx: TyCtxt<'tcx>) {
324-
// Estimate the size of a codegen unit as (approximately) the number of MIR
325-
// statements it corresponds to.
326-
self.size_estimate = self.items.keys().map(|mi| mi.size_estimate(tcx)).sum();
338+
pub fn compute_size_estimate(&mut self) {
339+
// The size of a codegen unit as the sum of the sizes of the items
340+
// within it.
341+
self.size_estimate = self.items.values().map(|data| data.size_estimate).sum();
327342
}
328343

329-
#[inline]
330344
/// Should only be called if [`compute_size_estimate`] has previously been called.
331345
///
332346
/// [`compute_size_estimate`]: Self::compute_size_estimate
347+
#[inline]
333348
pub fn size_estimate(&self) -> usize {
334349
// Items are never zero-sized, so if we have items the estimate must be
335350
// non-zero, unless we forgot to call `compute_size_estimate` first.
@@ -355,7 +370,7 @@ impl<'tcx> CodegenUnit<'tcx> {
355370
pub fn items_in_deterministic_order(
356371
&self,
357372
tcx: TyCtxt<'tcx>,
358-
) -> Vec<(MonoItem<'tcx>, (Linkage, Visibility))> {
373+
) -> Vec<(MonoItem<'tcx>, MonoItemData)> {
359374
// The codegen tests rely on items being process in the same order as
360375
// they appear in the file, so for local items, we sort by node_id first
361376
#[derive(PartialEq, Eq, PartialOrd, Ord)]
@@ -390,7 +405,7 @@ impl<'tcx> CodegenUnit<'tcx> {
390405
)
391406
}
392407

393-
let mut items: Vec<_> = self.items().iter().map(|(&i, &l)| (i, l)).collect();
408+
let mut items: Vec<_> = self.items().iter().map(|(&i, &data)| (i, data)).collect();
394409
items.sort_by_cached_key(|&(i, _)| item_sort_key(tcx, i));
395410
items
396411
}

‎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_monomorphize/src/partitioning.rs

+43-47
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
107107
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
108108
use rustc_middle::mir;
109109
use rustc_middle::mir::mono::{
110-
CodegenUnit, CodegenUnitNameBuilder, InstantiationMode, Linkage, MonoItem, Visibility,
110+
CodegenUnit, CodegenUnitNameBuilder, InstantiationMode, Linkage, MonoItem, MonoItemData,
111+
Visibility,
111112
};
112113
use rustc_middle::query::Providers;
113114
use rustc_middle::ty::print::{characteristic_def_id_of_type, with_no_trimmed_paths};
@@ -130,11 +131,6 @@ struct PlacedMonoItems<'tcx> {
130131
codegen_units: Vec<CodegenUnit<'tcx>>,
131132

132133
internalization_candidates: FxHashSet<MonoItem<'tcx>>,
133-
134-
/// These must be obtained when the iterator in `partition` runs. They
135-
/// can't be obtained later because some inlined functions might not be
136-
/// reachable.
137-
unique_inlined_stats: (usize, usize),
138134
}
139135

140136
// The output CGUs are sorted by name.
@@ -152,11 +148,11 @@ where
152148

153149
// Place all mono items into a codegen unit. `place_mono_items` is
154150
// responsible for initializing the CGU size estimates.
155-
let PlacedMonoItems { mut codegen_units, internalization_candidates, unique_inlined_stats } = {
151+
let PlacedMonoItems { mut codegen_units, internalization_candidates } = {
156152
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_items");
157153
let placed = place_mono_items(cx, mono_items);
158154

159-
debug_dump(tcx, "PLACE", &placed.codegen_units, placed.unique_inlined_stats);
155+
debug_dump(tcx, "PLACE", &placed.codegen_units);
160156

161157
placed
162158
};
@@ -167,7 +163,7 @@ where
167163
{
168164
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_merge_cgus");
169165
merge_codegen_units(cx, &mut codegen_units);
170-
debug_dump(tcx, "MERGE", &codegen_units, unique_inlined_stats);
166+
debug_dump(tcx, "MERGE", &codegen_units);
171167
}
172168

173169
// Make as many symbols "internal" as possible, so LLVM has more freedom to
@@ -176,7 +172,7 @@ where
176172
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_internalize_symbols");
177173
internalize_symbols(cx, &mut codegen_units, internalization_candidates);
178174

179-
debug_dump(tcx, "INTERNALIZE", &codegen_units, unique_inlined_stats);
175+
debug_dump(tcx, "INTERNALIZE", &codegen_units);
180176
}
181177

182178
// Mark one CGU for dead code, if necessary.
@@ -216,18 +212,12 @@ where
216212
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(cx.tcx);
217213
let cgu_name_cache = &mut FxHashMap::default();
218214

219-
let mut num_unique_inlined_items = 0;
220-
let mut unique_inlined_items_size = 0;
221215
for mono_item in mono_items {
222216
// Handle only root items directly here. Inlined items are handled at
223217
// the bottom of the loop based on reachability.
224218
match mono_item.instantiation_mode(cx.tcx) {
225219
InstantiationMode::GloballyShared { .. } => {}
226-
InstantiationMode::LocalCopy => {
227-
num_unique_inlined_items += 1;
228-
unique_inlined_items_size += mono_item.size_estimate(cx.tcx);
229-
continue;
230-
}
220+
InstantiationMode::LocalCopy => continue,
231221
}
232222

233223
let characteristic_def_id = characteristic_def_id_of_mono_item(cx.tcx, mono_item);
@@ -256,8 +246,9 @@ where
256246
if visibility == Visibility::Hidden && can_be_internalized {
257247
internalization_candidates.insert(mono_item);
258248
}
249+
let size_estimate = mono_item.size_estimate(cx.tcx);
259250

260-
cgu.items_mut().insert(mono_item, (linkage, visibility));
251+
cgu.items_mut().insert(mono_item, MonoItemData { linkage, visibility, size_estimate });
261252

262253
// Get all inlined items that are reachable from `mono_item` without
263254
// going via another root item. This includes drop-glue, functions from
@@ -271,7 +262,11 @@ where
271262
// the `insert` will be a no-op.
272263
for inlined_item in reachable_inlined_items {
273264
// This is a CGU-private copy.
274-
cgu.items_mut().insert(inlined_item, (Linkage::Internal, Visibility::Default));
265+
cgu.items_mut().entry(inlined_item).or_insert_with(|| MonoItemData {
266+
linkage: Linkage::Internal,
267+
visibility: Visibility::Default,
268+
size_estimate: inlined_item.size_estimate(cx.tcx),
269+
});
275270
}
276271
}
277272

@@ -286,14 +281,10 @@ where
286281
codegen_units.sort_by(|a, b| a.name().as_str().cmp(b.name().as_str()));
287282

288283
for cgu in codegen_units.iter_mut() {
289-
cgu.compute_size_estimate(cx.tcx);
284+
cgu.compute_size_estimate();
290285
}
291286

292-
return PlacedMonoItems {
293-
codegen_units,
294-
internalization_candidates,
295-
unique_inlined_stats: (num_unique_inlined_items, unique_inlined_items_size),
296-
};
287+
return PlacedMonoItems { codegen_units, internalization_candidates };
297288

298289
fn get_reachable_inlined_items<'tcx>(
299290
tcx: TyCtxt<'tcx>,
@@ -349,7 +340,7 @@ fn merge_codegen_units<'tcx>(
349340
&& codegen_units.iter().any(|cgu| cgu.size_estimate() < NON_INCR_MIN_CGU_SIZE))
350341
{
351342
// Sort small cgus to the back.
352-
codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate()));
343+
codegen_units.sort_by_key(|cgu| cmp::Reverse(cgu.size_estimate()));
353344

354345
let mut smallest = codegen_units.pop().unwrap();
355346
let second_smallest = codegen_units.last_mut().unwrap();
@@ -358,7 +349,7 @@ fn merge_codegen_units<'tcx>(
358349
// may be duplicate inlined items, in which case the destination CGU is
359350
// unaffected. Recalculate size estimates afterwards.
360351
second_smallest.items_mut().extend(smallest.items_mut().drain());
361-
second_smallest.compute_size_estimate(cx.tcx);
352+
second_smallest.compute_size_estimate();
362353

363354
// Record that `second_smallest` now contains all the stuff that was
364355
// in `smallest` before.
@@ -492,7 +483,7 @@ fn internalize_symbols<'tcx>(
492483
for cgu in codegen_units {
493484
let home_cgu = MonoItemPlacement::SingleCgu(cgu.name());
494485

495-
for (item, linkage_and_visibility) in cgu.items_mut() {
486+
for (item, data) in cgu.items_mut() {
496487
if !internalization_candidates.contains(item) {
497488
// This item is no candidate for internalizing, so skip it.
498489
continue;
@@ -520,7 +511,8 @@ fn internalize_symbols<'tcx>(
520511

521512
// If we got here, we did not find any uses from other CGUs, so
522513
// it's fine to make this monomorphization internal.
523-
*linkage_and_visibility = (Linkage::Internal, Visibility::Default);
514+
data.linkage = Linkage::Internal;
515+
data.visibility = Visibility::Default;
524516
}
525517
}
526518
}
@@ -537,7 +529,7 @@ fn mark_code_coverage_dead_code_cgu<'tcx>(codegen_units: &mut [CodegenUnit<'tcx>
537529
// function symbols to be included via `-u` or `/include` linker args.
538530
let dead_code_cgu = codegen_units
539531
.iter_mut()
540-
.filter(|cgu| cgu.items().iter().any(|(_, (linkage, _))| *linkage == Linkage::External))
532+
.filter(|cgu| cgu.items().iter().any(|(_, data)| data.linkage == Linkage::External))
541533
.min_by_key(|cgu| cgu.size_estimate());
542534

543535
// If there are no CGUs that have externally linked items, then we just
@@ -851,12 +843,7 @@ fn default_visibility(tcx: TyCtxt<'_>, id: DefId, is_generic: bool) -> Visibilit
851843
}
852844
}
853845

854-
fn debug_dump<'a, 'tcx: 'a>(
855-
tcx: TyCtxt<'tcx>,
856-
label: &str,
857-
cgus: &[CodegenUnit<'tcx>],
858-
(unique_inlined_items, unique_inlined_size): (usize, usize),
859-
) {
846+
fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<'tcx>]) {
860847
let dump = move || {
861848
use std::fmt::Write;
862849

@@ -865,28 +852,36 @@ fn debug_dump<'a, 'tcx: 'a>(
865852

866853
// Note: every unique root item is placed exactly once, so the number
867854
// of unique root items always equals the number of placed root items.
855+
//
856+
// Also, unreached inlined items won't be counted here. This is fine.
857+
858+
let mut inlined_items = FxHashSet::default();
868859

869860
let mut root_items = 0;
870-
// unique_inlined_items is passed in above.
861+
let mut unique_inlined_items = 0;
871862
let mut placed_inlined_items = 0;
872863

873864
let mut root_size = 0;
874-
// unique_inlined_size is passed in above.
865+
let mut unique_inlined_size = 0;
875866
let mut placed_inlined_size = 0;
876867

877868
for cgu in cgus.iter() {
878869
num_cgus += 1;
879870
all_cgu_sizes.push(cgu.size_estimate());
880871

881-
for (item, _) in cgu.items() {
872+
for (item, data) in cgu.items() {
882873
match item.instantiation_mode(tcx) {
883874
InstantiationMode::GloballyShared { .. } => {
884875
root_items += 1;
885-
root_size += item.size_estimate(tcx);
876+
root_size += data.size_estimate;
886877
}
887878
InstantiationMode::LocalCopy => {
879+
if inlined_items.insert(item) {
880+
unique_inlined_items += 1;
881+
unique_inlined_size += data.size_estimate;
882+
}
888883
placed_inlined_items += 1;
889-
placed_inlined_size += item.size_estimate(tcx);
884+
placed_inlined_size += data.size_estimate;
890885
}
891886
}
892887
}
@@ -928,7 +923,7 @@ fn debug_dump<'a, 'tcx: 'a>(
928923
let mean_size = size as f64 / num_items as f64;
929924

930925
let mut placed_item_sizes: Vec<_> =
931-
cgu.items().iter().map(|(item, _)| item.size_estimate(tcx)).collect();
926+
cgu.items().values().map(|data| data.size_estimate).collect();
932927
placed_item_sizes.sort_unstable_by_key(|&n| cmp::Reverse(n));
933928
let sizes = list(&placed_item_sizes);
934929

@@ -937,15 +932,16 @@ fn debug_dump<'a, 'tcx: 'a>(
937932
let _ =
938933
writeln!(s, " - items: {num_items}, mean size: {mean_size:.1}, sizes: {sizes}",);
939934

940-
for (item, linkage) in cgu.items_in_deterministic_order(tcx) {
935+
for (item, data) in cgu.items_in_deterministic_order(tcx) {
936+
let linkage = data.linkage;
941937
let symbol_name = item.symbol_name(tcx).name;
942938
let symbol_hash_start = symbol_name.rfind('h');
943939
let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
944-
let size = item.size_estimate(tcx);
945940
let kind = match item.instantiation_mode(tcx) {
946941
InstantiationMode::GloballyShared { .. } => "root",
947942
InstantiationMode::LocalCopy => "inlined",
948943
};
944+
let size = data.size_estimate;
949945
let _ = with_no_trimmed_paths!(writeln!(
950946
s,
951947
" - {item} [{linkage:?}] [{symbol_hash}] ({kind}, size: {size})"
@@ -1100,8 +1096,8 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
11001096
let mut item_to_cgus: FxHashMap<_, Vec<_>> = Default::default();
11011097

11021098
for cgu in codegen_units {
1103-
for (&mono_item, &linkage) in cgu.items() {
1104-
item_to_cgus.entry(mono_item).or_default().push((cgu.name(), linkage));
1099+
for (&mono_item, &data) in cgu.items() {
1100+
item_to_cgus.entry(mono_item).or_default().push((cgu.name(), data.linkage));
11051101
}
11061102
}
11071103

@@ -1114,7 +1110,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
11141110
let cgus = item_to_cgus.get_mut(i).unwrap_or(&mut empty);
11151111
cgus.sort_by_key(|(name, _)| *name);
11161112
cgus.dedup();
1117-
for &(ref cgu_name, (linkage, _)) in cgus.iter() {
1113+
for &(ref cgu_name, linkage) in cgus.iter() {
11181114
output.push(' ');
11191115
output.push_str(cgu_name.as_str());
11201116

‎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)
Please sign in to comment.