Estimate size of InstanceDef::DropGlue more accurately
Also a little bit of clean up.
This commit is contained in:
parent
5c9a8b5041
commit
62703cfd26
2 changed files with 7 additions and 6 deletions
|
|
@ -157,8 +157,7 @@ impl<'tcx> CodegenUnit<'tcx> {
|
|||
|
||||
pub fn size_estimate(&self) -> usize {
|
||||
// Should only be called if `estimate_size` has previously been called.
|
||||
assert!(self.size_estimate.is_some());
|
||||
self.size_estimate.unwrap()
|
||||
self.size_estimate.expect("estimate_size must be called before getting a size_estimate")
|
||||
}
|
||||
|
||||
pub fn modify_size_estimate(&mut self, delta: usize) {
|
||||
|
|
@ -176,7 +175,8 @@ impl<'tcx> HashStable<StableHashingContext<'tcx>> for CodegenUnit<'tcx> {
|
|||
let CodegenUnit {
|
||||
ref items,
|
||||
name,
|
||||
..
|
||||
// The size estimate is not relevant to the hash
|
||||
size_estimate: _,
|
||||
} = *self;
|
||||
|
||||
name.hash_stable(hcx, hasher);
|
||||
|
|
|
|||
|
|
@ -2673,11 +2673,12 @@ fn instance_def_size_estimate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
instance_def: InstanceDef<'tcx>)
|
||||
-> usize {
|
||||
match instance_def {
|
||||
InstanceDef::Item(def_id) => {
|
||||
let mir = tcx.optimized_mir(def_id);
|
||||
InstanceDef::Item(..) |
|
||||
InstanceDef::DropGlue(..) => {
|
||||
let mir = tcx.instance_mir(instance_def);
|
||||
mir.basic_blocks().iter().map(|bb| bb.statements.len()).sum()
|
||||
},
|
||||
// Estimate the size of compiler-generated shims to be 1.
|
||||
// Estimate the size of other compiler-generated shims to be 1.
|
||||
_ => 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue