@@ -802,6 +802,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
802802/// in any other compilation unit. Give these symbols internal linkage.
803803fn internalize_symbols < ' a , ' tcx > ( sess : & Session ,
804804 scx : & SharedCrateContext < ' a , ' tcx > ,
805+ translation_items : & FxHashSet < TransItem < ' tcx > > ,
805806 llvm_modules : & [ ModuleLlvm ] ,
806807 symbol_map : & SymbolMap < ' tcx > ,
807808 exported_symbols : & ExportedSymbols ) {
@@ -854,7 +855,7 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session,
854855 let mut locally_defined_symbols = FxHashSet ( ) ;
855856 let mut linkage_fixed_explicitly = FxHashSet ( ) ;
856857
857- for trans_item in scx . translation_items ( ) . borrow ( ) . iter ( ) {
858+ for trans_item in translation_items {
858859 let symbol_name = symbol_map. get_or_compute ( scx, * trans_item) ;
859860 if trans_item. explicit_linkage ( tcx) . is_some ( ) {
860861 linkage_fixed_explicitly. insert ( symbol_name. clone ( ) ) ;
@@ -1109,7 +1110,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11091110
11101111 // Run the translation item collector and partition the collected items into
11111112 // codegen units.
1112- let ( codegen_units, symbol_map) = collect_and_partition_translation_items ( & shared_ccx) ;
1113+ let ( translation_items, codegen_units, symbol_map) =
1114+ collect_and_partition_translation_items ( & shared_ccx) ;
11131115
11141116 let symbol_map = Rc :: new ( symbol_map) ;
11151117
@@ -1289,6 +1291,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12891291 time ( shared_ccx. sess ( ) . time_passes ( ) , "internalize symbols" , || {
12901292 internalize_symbols ( sess,
12911293 & shared_ccx,
1294+ & translation_items,
12921295 & llvm_modules,
12931296 & symbol_map,
12941297 & exported_symbols) ;
@@ -1517,7 +1520,9 @@ fn gather_type_sizes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
15171520}
15181521
15191522fn collect_and_partition_translation_items < ' a , ' tcx > ( scx : & SharedCrateContext < ' a , ' tcx > )
1520- -> ( Vec < CodegenUnit < ' tcx > > , SymbolMap < ' tcx > ) {
1523+ -> ( FxHashSet < TransItem < ' tcx > > ,
1524+ Vec < CodegenUnit < ' tcx > > ,
1525+ SymbolMap < ' tcx > ) {
15211526 let time_passes = scx. sess ( ) . time_passes ( ) ;
15221527
15231528 let collection_mode = match scx. sess ( ) . opts . debugging_opts . print_trans_items {
@@ -1563,13 +1568,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
15631568 assert ! ( scx. tcx( ) . sess. opts. cg. codegen_units == codegen_units. len( ) ||
15641569 scx. tcx( ) . sess. opts. debugging_opts. incremental. is_some( ) ) ;
15651570
1566- {
1567- let mut ccx_map = scx. translation_items ( ) . borrow_mut ( ) ;
1568-
1569- for trans_item in items. iter ( ) . cloned ( ) {
1570- ccx_map. insert ( trans_item) ;
1571- }
1572- }
1571+ let translation_items: FxHashSet < TransItem < ' tcx > > = items. iter ( ) . cloned ( ) . collect ( ) ;
15731572
15741573 if scx. sess ( ) . opts . debugging_opts . print_trans_items . is_some ( ) {
15751574 let mut item_to_cgus = FxHashMap ( ) ;
@@ -1624,5 +1623,5 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
16241623 }
16251624 }
16261625
1627- ( codegen_units, symbol_map)
1626+ ( translation_items , codegen_units, symbol_map)
16281627}
0 commit comments