@@ -155,14 +155,16 @@ where
155
155
// functions and statics defined in the local crate.
156
156
let PlacedRootMonoItems { mut codegen_units, internalization_candidates, unique_inlined_stats } = {
157
157
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) ;
160
159
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
+ }
164
163
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
+ } ;
166
168
167
169
// Merge until we have at most `max_cgu_count` codegen units.
168
170
// `merge_codegen_units` is responsible for updating the CGU size
@@ -179,22 +181,25 @@ where
179
181
// local functions the definition of which is marked with `#[inline]`.
180
182
{
181
183
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) ;
184
185
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
+ }
188
189
189
- debug_dump ( tcx, "INLINE" , & codegen_units, unique_inlined_stats) ;
190
+ debug_dump ( tcx, "INLINE" , & codegen_units, unique_inlined_stats) ;
191
+ }
190
192
191
193
// Next we try to make as many symbols "internal" as possible, so LLVM has
192
194
// more freedom to optimize.
193
195
if !tcx. sess . link_dead_code ( ) {
194
196
let _prof_timer = tcx. prof . generic_activity ( "cgu_partitioning_internalize_symbols" ) ;
195
197
internalize_symbols ( cx, & mut codegen_units, internalization_candidates) ;
198
+
199
+ debug_dump ( tcx, "INTERNALIZE" , & codegen_units, unique_inlined_stats) ;
196
200
}
197
201
202
+ // Mark one CGU for dead code, if necessary.
198
203
let instrument_dead_code =
199
204
tcx. sess . instrument_coverage ( ) && !tcx. sess . instrument_coverage_except_unused_functions ( ) ;
200
205
if instrument_dead_code {
@@ -204,8 +209,6 @@ where
204
209
// Ensure CGUs are sorted by name, so that we get deterministic results.
205
210
assert ! ( codegen_units. is_sorted_by( |a, b| Some ( a. name( ) . as_str( ) . cmp( b. name( ) . as_str( ) ) ) ) ) ;
206
211
207
- debug_dump ( tcx, "FINAL" , & codegen_units, unique_inlined_stats) ;
208
-
209
212
codegen_units
210
213
}
211
214
0 commit comments