@@ -486,21 +486,7 @@ fn internalize_symbols<'tcx>(
486
486
mono_item_placements : FxHashMap < MonoItem < ' tcx > , MonoItemPlacement > ,
487
487
internalization_candidates : FxHashSet < MonoItem < ' tcx > > ,
488
488
) {
489
- if codegen_units. len ( ) == 1 {
490
- // Fast path for when there is only one codegen unit. In this case we
491
- // can internalize all candidates, since there is nowhere else they
492
- // could be used from.
493
- for cgu in codegen_units {
494
- for ( item, linkage_and_visibility) in cgu. items_mut ( ) {
495
- if !internalization_candidates. contains ( item) {
496
- // This item is no candidate for internalizing, so skip it.
497
- continue ;
498
- }
499
- * linkage_and_visibility = ( Linkage :: Internal , Visibility :: Default ) ;
500
- }
501
- }
502
- return ;
503
- }
489
+ let single_codegen_unit = codegen_units. len ( ) == 1 ;
504
490
505
491
// For each internalization candidates in each codegen unit, check if it is
506
492
// used from outside its defining codegen unit.
@@ -512,21 +498,24 @@ fn internalize_symbols<'tcx>(
512
498
// This item is no candidate for internalizing, so skip it.
513
499
continue ;
514
500
}
515
- debug_assert_eq ! ( mono_item_placements[ item] , home_cgu) ;
516
-
517
- if let Some ( user_items) = cx. usage_map . get_user_items ( * item) {
518
- if user_items
519
- . iter ( )
520
- . filter_map ( |user_item| {
521
- // Some user mono items might not have been
522
- // instantiated. We can safely ignore those.
523
- mono_item_placements. get ( user_item)
524
- } )
525
- . any ( |placement| * placement != home_cgu)
526
- {
527
- // Found a user from another CGU, so skip to the next item
528
- // without marking this one as internal.
529
- continue ;
501
+
502
+ if !single_codegen_unit {
503
+ debug_assert_eq ! ( mono_item_placements[ item] , home_cgu) ;
504
+
505
+ if let Some ( user_items) = cx. usage_map . get_user_items ( * item) {
506
+ if user_items
507
+ . iter ( )
508
+ . filter_map ( |user_item| {
509
+ // Some user mono items might not have been
510
+ // instantiated. We can safely ignore those.
511
+ mono_item_placements. get ( user_item)
512
+ } )
513
+ . any ( |placement| * placement != home_cgu)
514
+ {
515
+ // Found a user from another CGU, so skip to the next item
516
+ // without marking this one as internal.
517
+ continue ;
518
+ }
530
519
}
531
520
}
532
521
0 commit comments