diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-06-21 16:38:47 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-06-22 09:33:06 +1000 |
| commit | abde9ba527704449ae84848673b52a8ab0f5cbd1 (patch) | |
| tree | ef6dfc650330ed12c8606df58ca7071bca6df5ac /compiler/rustc_monomorphize/src/partitioning.rs | |
| parent | 105ac1c26d5ea9de84f6b4af583e85eb8991e749 (diff) | |
| download | rust-abde9ba527704449ae84848673b52a8ab0f5cbd1.tar.gz rust-abde9ba527704449ae84848673b52a8ab0f5cbd1.zip | |
Tweak CGU size estimate code.
- Rename `create_size_estimate` as `compute_size_estimate`, because that makes more sense for the second and subsequent calls for each CGU. - Change `CodegenUnit::size_estimate` from `Option<usize>` to `usize`. We can still assert that `compute_size_estimate` is called first. - Move the size estimation for `place_mono_items` inside the function, for consistency with `merge_codegen_units`.
Diffstat (limited to 'compiler/rustc_monomorphize/src/partitioning.rs')
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index 4e9a4f91ddf..97e3748b8b8 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -150,14 +150,11 @@ where let cx = &PartitioningCx { tcx, usage_map }; - // Place all mono items into a codegen unit. + // Place all mono items into a codegen unit. `place_mono_items` is + // responsible for initializing the CGU size estimates. let PlacedMonoItems { mut codegen_units, internalization_candidates, unique_inlined_stats } = { let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_items"); - let mut placed = place_mono_items(cx, mono_items); - - for cgu in &mut placed.codegen_units { - cgu.create_size_estimate(tcx); - } + let placed = place_mono_items(cx, mono_items); debug_dump(tcx, "PLACE", &placed.codegen_units, placed.unique_inlined_stats); @@ -282,6 +279,10 @@ where let mut codegen_units: Vec<_> = codegen_units.into_values().collect(); codegen_units.sort_by(|a, b| a.name().as_str().cmp(b.name().as_str())); + for cgu in codegen_units.iter_mut() { + cgu.compute_size_estimate(cx.tcx); + } + return PlacedMonoItems { codegen_units, internalization_candidates, @@ -351,7 +352,7 @@ fn merge_codegen_units<'tcx>( // may be duplicate inlined items, in which case the destination CGU is // unaffected. Recalculate size estimates afterwards. second_smallest.items_mut().extend(smallest.items_mut().drain()); - second_smallest.create_size_estimate(cx.tcx); + second_smallest.compute_size_estimate(cx.tcx); // Record that `second_smallest` now contains all the stuff that was // in `smallest` before. |
