Skip to content

Commit e414d25

Browse files
committed
Make partition more consistent.
Always put the `create_size_estimate` calls and `debug_dump` calls within a timed scopes. This makes the four main steps look more similar to each other.
1 parent 57a7c8f commit e414d25

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,16 @@ where
155155
// functions and statics defined in the local crate.
156156
let PlacedRootMonoItems { mut codegen_units, internalization_candidates, unique_inlined_stats } = {
157157
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_roots");
158-
place_root_mono_items(cx, mono_items)
159-
};
158+
let mut placed = place_root_mono_items(cx, mono_items);
160159

161-
for cgu in &mut codegen_units {
162-
cgu.create_size_estimate(tcx);
163-
}
160+
for cgu in &mut placed.codegen_units {
161+
cgu.create_size_estimate(tcx);
162+
}
164163

165-
debug_dump(tcx, "ROOTS", &codegen_units, unique_inlined_stats);
164+
debug_dump(tcx, "ROOTS", &placed.codegen_units, placed.unique_inlined_stats);
165+
166+
placed
167+
};
166168

167169
// Merge until we have at most `max_cgu_count` codegen units.
168170
// `merge_codegen_units` is responsible for updating the CGU size
@@ -179,22 +181,25 @@ where
179181
// local functions the definition of which is marked with `#[inline]`.
180182
{
181183
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_place_inline_items");
182-
place_inlined_mono_items(cx, &mut codegen_units)
183-
};
184+
place_inlined_mono_items(cx, &mut codegen_units);
184185

185-
for cgu in &mut codegen_units {
186-
cgu.create_size_estimate(tcx);
187-
}
186+
for cgu in &mut codegen_units {
187+
cgu.create_size_estimate(tcx);
188+
}
188189

189-
debug_dump(tcx, "INLINE", &codegen_units, unique_inlined_stats);
190+
debug_dump(tcx, "INLINE", &codegen_units, unique_inlined_stats);
191+
}
190192

191193
// Next we try to make as many symbols "internal" as possible, so LLVM has
192194
// more freedom to optimize.
193195
if !tcx.sess.link_dead_code() {
194196
let _prof_timer = tcx.prof.generic_activity("cgu_partitioning_internalize_symbols");
195197
internalize_symbols(cx, &mut codegen_units, internalization_candidates);
198+
199+
debug_dump(tcx, "INTERNALIZE", &codegen_units, unique_inlined_stats);
196200
}
197201

202+
// Mark one CGU for dead code, if necessary.
198203
let instrument_dead_code =
199204
tcx.sess.instrument_coverage() && !tcx.sess.instrument_coverage_except_unused_functions();
200205
if instrument_dead_code {
@@ -204,8 +209,6 @@ where
204209
// Ensure CGUs are sorted by name, so that we get deterministic results.
205210
assert!(codegen_units.is_sorted_by(|a, b| Some(a.name().as_str().cmp(b.name().as_str()))));
206211

207-
debug_dump(tcx, "FINAL", &codegen_units, unique_inlined_stats);
208-
209212
codegen_units
210213
}
211214

0 commit comments

Comments
 (0)