Skip to content

Commit

Permalink
Auto merge of rust-lang#86777 - tmiasko:estimate-terminators, r=estebank
Browse files Browse the repository at this point in the history
Include terminators in instance size estimate

For example, drop glue generated for struct below, doesn't have any
statements, only terminators. Previously it received an estimate of 0,
the new estimate is 13 (6+5 drop terminators, +1 resume, +1 return).

```rust
struct S {
    a: String,
    b: String,
    c: String,
    d: String,
    e: String,
    f: String,
}
```

Originally reported in rust-lang#69382 (comment)
  • Loading branch information
bors committed Jul 2, 2021
2 parents 56dee7c + 5621987 commit 7a9ff74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_ty_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ fn instance_def_size_estimate<'tcx>(
match instance_def {
InstanceDef::Item(..) | InstanceDef::DropGlue(..) => {
let mir = tcx.instance_mir(instance_def);
mir.basic_blocks().iter().map(|bb| bb.statements.len()).sum()
mir.basic_blocks().iter().map(|bb| bb.statements.len() + 1).sum()
}
// Estimate the size of other compiler-generated shims to be 1.
_ => 1,
Expand Down

0 comments on commit 7a9ff74

Please sign in to comment.