@@ -112,14 +112,6 @@ use rustc_span::symbol::Symbol;
112
112
use crate :: monomorphize:: collector:: InliningMap ;
113
113
use crate :: monomorphize:: collector:: { self , MonoItemCollectionMode } ;
114
114
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
-
123
115
// Anything we can't find a proper codegen unit for goes into this.
124
116
fn fallback_cgu_name ( name_builder : & mut CodegenUnitNameBuilder < ' _ > ) -> Symbol {
125
117
name_builder. build_cgu_name ( LOCAL_CRATE , & [ "fallback" ] , Some ( "cgu" ) )
@@ -128,7 +120,7 @@ fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_>) -> Symbol {
128
120
pub fn partition < ' tcx , I > (
129
121
tcx : TyCtxt < ' tcx > ,
130
122
mono_items : I ,
131
- strategy : PartitioningStrategy ,
123
+ max_cgu_count : usize ,
132
124
inlining_map : & InliningMap < ' tcx > ,
133
125
) -> Vec < CodegenUnit < ' tcx > >
134
126
where
@@ -148,11 +140,10 @@ where
148
140
149
141
debug_dump ( tcx, "INITIAL PARTITIONING:" , initial_partitioning. codegen_units . iter ( ) ) ;
150
142
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
+ {
154
145
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 ) ;
156
147
debug_dump ( tcx, "POST MERGING:" , initial_partitioning. codegen_units . iter ( ) ) ;
157
148
}
158
149
@@ -875,13 +866,7 @@ fn collect_and_partition_mono_items(
875
866
let ( codegen_units, _) = tcx. sess . time ( "partition_and_assert_distinct_symbols" , || {
876
867
sync:: join (
877
868
|| {
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)
885
870
. into_iter ( )
886
871
. map ( Arc :: new)
887
872
. collect :: < Vec < _ > > ( )
0 commit comments