@@ -802,6 +802,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
802
802
/// in any other compilation unit. Give these symbols internal linkage.
803
803
fn internalize_symbols < ' a , ' tcx > ( sess : & Session ,
804
804
scx : & SharedCrateContext < ' a , ' tcx > ,
805
+ translation_items : & FxHashSet < TransItem < ' tcx > > ,
805
806
llvm_modules : & [ ModuleLlvm ] ,
806
807
symbol_map : & SymbolMap < ' tcx > ,
807
808
exported_symbols : & ExportedSymbols ) {
@@ -854,7 +855,7 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session,
854
855
let mut locally_defined_symbols = FxHashSet ( ) ;
855
856
let mut linkage_fixed_explicitly = FxHashSet ( ) ;
856
857
857
- for trans_item in scx . translation_items ( ) . borrow ( ) . iter ( ) {
858
+ for trans_item in translation_items {
858
859
let symbol_name = symbol_map. get_or_compute ( scx, * trans_item) ;
859
860
if trans_item. explicit_linkage ( tcx) . is_some ( ) {
860
861
linkage_fixed_explicitly. insert ( symbol_name. clone ( ) ) ;
@@ -1109,7 +1110,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1109
1110
1110
1111
// Run the translation item collector and partition the collected items into
1111
1112
// 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) ;
1113
1115
1114
1116
let symbol_map = Rc :: new ( symbol_map) ;
1115
1117
@@ -1289,6 +1291,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1289
1291
time ( shared_ccx. sess ( ) . time_passes ( ) , "internalize symbols" , || {
1290
1292
internalize_symbols ( sess,
1291
1293
& shared_ccx,
1294
+ & translation_items,
1292
1295
& llvm_modules,
1293
1296
& symbol_map,
1294
1297
& exported_symbols) ;
@@ -1517,7 +1520,9 @@ fn gather_type_sizes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
1517
1520
}
1518
1521
1519
1522
fn 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 > ) {
1521
1526
let time_passes = scx. sess ( ) . time_passes ( ) ;
1522
1527
1523
1528
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
1563
1568
assert ! ( scx. tcx( ) . sess. opts. cg. codegen_units == codegen_units. len( ) ||
1564
1569
scx. tcx( ) . sess. opts. debugging_opts. incremental. is_some( ) ) ;
1565
1570
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 ( ) ;
1573
1572
1574
1573
if scx. sess ( ) . opts . debugging_opts . print_trans_items . is_some ( ) {
1575
1574
let mut item_to_cgus = FxHashMap ( ) ;
@@ -1624,5 +1623,5 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
1624
1623
}
1625
1624
}
1626
1625
1627
- ( codegen_units, symbol_map)
1626
+ ( translation_items , codegen_units, symbol_map)
1628
1627
}
0 commit comments