@@ -112,14 +112,6 @@ use rustc_span::symbol::Symbol;
112112use crate :: monomorphize:: collector:: InliningMap ;
113113use crate :: monomorphize:: collector:: { self , MonoItemCollectionMode } ;
114114
115- pub enum PartitioningStrategy {
116- /// Generates one codegen unit per source-level module.
117- PerModule ,
118-
119- /// Partition the whole crate into a fixed number of codegen units.
120- FixedUnitCount ( usize ) ,
121- }
122-
123115// Anything we can't find a proper codegen unit for goes into this.
124116fn fallback_cgu_name ( name_builder : & mut CodegenUnitNameBuilder < ' _ > ) -> Symbol {
125117 name_builder. build_cgu_name ( LOCAL_CRATE , & [ "fallback" ] , Some ( "cgu" ) )
@@ -128,7 +120,7 @@ fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_>) -> Symbol {
128120pub fn partition < ' tcx , I > (
129121 tcx : TyCtxt < ' tcx > ,
130122 mono_items : I ,
131- strategy : PartitioningStrategy ,
123+ max_cgu_count : usize ,
132124 inlining_map : & InliningMap < ' tcx > ,
133125) -> Vec < CodegenUnit < ' tcx > >
134126where
@@ -148,11 +140,10 @@ where
148140
149141 debug_dump ( tcx, "INITIAL PARTITIONING:" , initial_partitioning. codegen_units . iter ( ) ) ;
150142
151- // If the partitioning should produce a fixed count of codegen units, merge
152- // until that count is reached.
153- if let PartitioningStrategy :: FixedUnitCount ( count) = strategy {
143+ // Merge until we have at most `max_cgu_count` codegen units.
144+ {
154145 let _prof_timer = tcx. prof . generic_activity ( "cgu_partitioning_merge_cgus" ) ;
155- merge_codegen_units ( tcx, & mut initial_partitioning, count ) ;
146+ merge_codegen_units ( tcx, & mut initial_partitioning, max_cgu_count ) ;
156147 debug_dump ( tcx, "POST MERGING:" , initial_partitioning. codegen_units . iter ( ) ) ;
157148 }
158149
@@ -875,13 +866,7 @@ fn collect_and_partition_mono_items(
875866 let ( codegen_units, _) = tcx. sess . time ( "partition_and_assert_distinct_symbols" , || {
876867 sync:: join (
877868 || {
878- let strategy = if tcx. sess . opts . incremental . is_some ( ) {
879- PartitioningStrategy :: PerModule
880- } else {
881- PartitioningStrategy :: FixedUnitCount ( tcx. sess . codegen_units ( ) )
882- } ;
883-
884- partition ( tcx, items. iter ( ) . cloned ( ) , strategy, & inlining_map)
869+ partition ( tcx, items. iter ( ) . cloned ( ) , tcx. sess . codegen_units ( ) , & inlining_map)
885870 . into_iter ( )
886871 . map ( Arc :: new)
887872 . collect :: < Vec < _ > > ( )
0 commit comments