@@ -121,7 +121,6 @@ use crate::errors::{CouldntDumpMonoStats, SymbolAlreadyDefined, UnknownCguCollec
121
121
122
122
struct PartitioningCx < ' a , ' tcx > {
123
123
tcx : TyCtxt < ' tcx > ,
124
- target_cgu_count : usize ,
125
124
usage_map : & ' a UsageMap < ' tcx > ,
126
125
}
127
126
@@ -136,15 +135,14 @@ struct PlacedRootMonoItems<'tcx> {
136
135
fn partition < ' tcx , I > (
137
136
tcx : TyCtxt < ' tcx > ,
138
137
mono_items : I ,
139
- max_cgu_count : usize ,
140
138
usage_map : & UsageMap < ' tcx > ,
141
139
) -> Vec < CodegenUnit < ' tcx > >
142
140
where
143
141
I : Iterator < Item = MonoItem < ' tcx > > ,
144
142
{
145
143
let _prof_timer = tcx. prof . generic_activity ( "cgu_partitioning" ) ;
146
144
147
- let cx = & PartitioningCx { tcx, target_cgu_count : max_cgu_count , usage_map } ;
145
+ let cx = & PartitioningCx { tcx, usage_map } ;
148
146
149
147
// In the first step, we place all regular monomorphizations into their
150
148
// respective 'home' codegen unit. Regular monomorphizations are all
@@ -309,7 +307,7 @@ fn merge_codegen_units<'tcx>(
309
307
cx : & PartitioningCx < ' _ , ' tcx > ,
310
308
codegen_units : & mut Vec < CodegenUnit < ' tcx > > ,
311
309
) {
312
- assert ! ( cx. target_cgu_count >= 1 ) ;
310
+ assert ! ( cx. tcx . sess . codegen_units ( ) >= 1 ) ;
313
311
314
312
// A sorted order here ensures merging is deterministic.
315
313
assert ! ( codegen_units. is_sorted_by( |a, b| Some ( a. name( ) . as_str( ) . cmp( b. name( ) . as_str( ) ) ) ) ) ;
@@ -320,7 +318,7 @@ fn merge_codegen_units<'tcx>(
320
318
321
319
// Merge the two smallest codegen units until the target size is
322
320
// reached.
323
- while codegen_units. len ( ) > cx. target_cgu_count {
321
+ while codegen_units. len ( ) > cx. tcx . sess . codegen_units ( ) {
324
322
// Sort small cgus to the back
325
323
codegen_units. sort_by_cached_key ( |cgu| cmp:: Reverse ( cgu. size_estimate ( ) ) ) ;
326
324
let mut smallest = codegen_units. pop ( ) . unwrap ( ) ;
@@ -922,8 +920,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
922
920
let ( codegen_units, _) = tcx. sess . time ( "partition_and_assert_distinct_symbols" , || {
923
921
sync:: join (
924
922
|| {
925
- let mut codegen_units =
926
- partition ( tcx, items. iter ( ) . copied ( ) , tcx. sess . codegen_units ( ) , & usage_map) ;
923
+ let mut codegen_units = partition ( tcx, items. iter ( ) . copied ( ) , & usage_map) ;
927
924
codegen_units[ 0 ] . make_primary ( ) ;
928
925
& * tcx. arena . alloc_from_iter ( codegen_units)
929
926
} ,
0 commit comments