@@ -422,33 +422,22 @@ fn place_inlined_mono_items<'tcx>(
422
422
423
423
let single_codegen_unit = codegen_units. len ( ) == 1 ;
424
424
425
- for old_codegen_unit in codegen_units. iter_mut ( ) {
425
+ for cgu in codegen_units. iter_mut ( ) {
426
426
// Collect all items that need to be available in this codegen unit.
427
427
let mut reachable = FxHashSet :: default ( ) ;
428
- for root in old_codegen_unit . items ( ) . keys ( ) {
428
+ for root in cgu . items ( ) . keys ( ) {
429
429
follow_inlining ( cx. tcx , * root, cx. usage_map , & mut reachable) ;
430
430
}
431
431
432
- let mut new_codegen_unit = CodegenUnit :: new ( old_codegen_unit. name ( ) ) ;
433
-
434
432
// Add all monomorphizations that are not already there.
435
433
for mono_item in reachable {
436
- if let Some ( linkage) = old_codegen_unit. items ( ) . get ( & mono_item) {
437
- // This is a root, just copy it over.
438
- new_codegen_unit. items_mut ( ) . insert ( mono_item, * linkage) ;
439
- } else {
434
+ if !cgu. items ( ) . contains_key ( & mono_item) {
440
435
if roots. contains ( & mono_item) {
441
- bug ! (
442
- "GloballyShared mono-item inlined into other CGU: \
443
- {:?}",
444
- mono_item
445
- ) ;
436
+ bug ! ( "GloballyShared mono-item inlined into other CGU: {:?}" , mono_item) ;
446
437
}
447
438
448
439
// This is a CGU-private copy.
449
- new_codegen_unit
450
- . items_mut ( )
451
- . insert ( mono_item, ( Linkage :: Internal , Visibility :: Default ) ) ;
440
+ cgu. items_mut ( ) . insert ( mono_item, ( Linkage :: Internal , Visibility :: Default ) ) ;
452
441
}
453
442
454
443
if !single_codegen_unit {
@@ -458,23 +447,17 @@ fn place_inlined_mono_items<'tcx>(
458
447
Entry :: Occupied ( e) => {
459
448
let placement = e. into_mut ( ) ;
460
449
debug_assert ! ( match * placement {
461
- MonoItemPlacement :: SingleCgu { cgu_name } => {
462
- cgu_name != new_codegen_unit. name( )
463
- }
450
+ MonoItemPlacement :: SingleCgu { cgu_name } => cgu_name != cgu. name( ) ,
464
451
MonoItemPlacement :: MultipleCgus => true ,
465
452
} ) ;
466
453
* placement = MonoItemPlacement :: MultipleCgus ;
467
454
}
468
455
Entry :: Vacant ( e) => {
469
- e. insert ( MonoItemPlacement :: SingleCgu {
470
- cgu_name : new_codegen_unit. name ( ) ,
471
- } ) ;
456
+ e. insert ( MonoItemPlacement :: SingleCgu { cgu_name : cgu. name ( ) } ) ;
472
457
}
473
458
}
474
459
}
475
460
}
476
-
477
- * old_codegen_unit = new_codegen_unit;
478
461
}
479
462
480
463
return mono_item_placements;
0 commit comments