@@ -121,7 +121,6 @@ use crate::errors::{CouldntDumpMonoStats, SymbolAlreadyDefined, UnknownCguCollec
121121
122122struct PartitioningCx < ' a , ' tcx > {
123123 tcx : TyCtxt < ' tcx > ,
124- target_cgu_count : usize ,
125124 usage_map : & ' a UsageMap < ' tcx > ,
126125}
127126
@@ -136,15 +135,14 @@ struct PlacedRootMonoItems<'tcx> {
136135fn partition < ' tcx , I > (
137136 tcx : TyCtxt < ' tcx > ,
138137 mono_items : I ,
139- max_cgu_count : usize ,
140138 usage_map : & UsageMap < ' tcx > ,
141139) -> Vec < CodegenUnit < ' tcx > >
142140where
143141 I : Iterator < Item = MonoItem < ' tcx > > ,
144142{
145143 let _prof_timer = tcx. prof . generic_activity ( "cgu_partitioning" ) ;
146144
147- let cx = & PartitioningCx { tcx, target_cgu_count : max_cgu_count , usage_map } ;
145+ let cx = & PartitioningCx { tcx, usage_map } ;
148146
149147 // In the first step, we place all regular monomorphizations into their
150148 // respective 'home' codegen unit. Regular monomorphizations are all
@@ -309,7 +307,7 @@ fn merge_codegen_units<'tcx>(
309307 cx : & PartitioningCx < ' _ , ' tcx > ,
310308 codegen_units : & mut Vec < CodegenUnit < ' tcx > > ,
311309) {
312- assert ! ( cx. target_cgu_count >= 1 ) ;
310+ assert ! ( cx. tcx . sess . codegen_units ( ) >= 1 ) ;
313311
314312 // A sorted order here ensures merging is deterministic.
315313 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>(
320318
321319 // Merge the two smallest codegen units until the target size is
322320 // reached.
323- while codegen_units. len ( ) > cx. target_cgu_count {
321+ while codegen_units. len ( ) > cx. tcx . sess . codegen_units ( ) {
324322 // Sort small cgus to the back
325323 codegen_units. sort_by_cached_key ( |cgu| cmp:: Reverse ( cgu. size_estimate ( ) ) ) ;
326324 let mut smallest = codegen_units. pop ( ) . unwrap ( ) ;
@@ -922,8 +920,7 @@ fn collect_and_partition_mono_items(tcx: TyCtxt<'_>, (): ()) -> (&DefIdSet, &[Co
922920 let ( codegen_units, _) = tcx. sess . time ( "partition_and_assert_distinct_symbols" , || {
923921 sync:: join (
924922 || {
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) ;
927924 codegen_units[ 0 ] . make_primary ( ) ;
928925 & * tcx. arena . alloc_from_iter ( codegen_units)
929926 } ,
0 commit comments