File tree 2 files changed +11
-7
lines changed
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -38,10 +38,11 @@ use rustc_span::symbol::sym;
38
38
use rustc_span:: Symbol ;
39
39
use rustc_target:: abi:: { Align , FIRST_VARIANT } ;
40
40
41
- use std:: cmp;
42
41
use std:: collections:: BTreeSet ;
43
42
use std:: time:: { Duration , Instant } ;
44
43
44
+ use itertools:: Itertools ;
45
+
45
46
pub fn bin_op_to_icmp_predicate ( op : hir:: BinOpKind , signed : bool ) -> IntPredicate {
46
47
match op {
47
48
hir:: BinOpKind :: Eq => IntPredicate :: IntEQ ,
@@ -673,8 +674,10 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
673
674
// are large size variations, this can reduce memory usage significantly.
674
675
let codegen_units: Vec < _ > = {
675
676
let mut sorted_cgus = codegen_units. iter ( ) . collect :: < Vec < _ > > ( ) ;
676
- sorted_cgus. sort_by_cached_key ( |cgu| cmp:: Reverse ( cgu. size_estimate ( ) ) ) ;
677
- sorted_cgus
677
+ sorted_cgus. sort_by_cached_key ( |cgu| cgu. size_estimate ( ) ) ;
678
+
679
+ let ( first_half, second_half) = sorted_cgus. split_at ( sorted_cgus. len ( ) / 2 ) ;
680
+ second_half. iter ( ) . rev ( ) . interleave ( first_half) . copied ( ) . collect ( )
678
681
} ;
679
682
680
683
// Calculate the CGU reuse
Original file line number Diff line number Diff line change @@ -313,7 +313,7 @@ fn merge_codegen_units<'tcx>(
313
313
// worse generated code. So we don't allow CGUs smaller than this (unless
314
314
// there is just one CGU, of course). Note that CGU sizes of 100,000+ are
315
315
// common in larger programs, so this isn't all that large.
316
- const NON_INCR_MIN_CGU_SIZE : usize = 1500 ;
316
+ const NON_INCR_MIN_CGU_SIZE : usize = 2000 ;
317
317
318
318
// Repeatedly merge the two smallest codegen units as long as:
319
319
// - we have more CGUs than the upper limit, or
@@ -353,9 +353,10 @@ fn merge_codegen_units<'tcx>(
353
353
// codegen_units[codegen_units.len() - 1].size_estimate());
354
354
355
355
( codegen_units[ 0 ] . size_estimate ( ) as f64 * 0.8 )
356
- >= ( codegen_units[ codegen_units. len ( ) - 2 ] . size_estimate ( )
357
- + codegen_units[ codegen_units. len ( ) - 1 ] . size_estimate ( ) ) as f64
358
- } ;
356
+ >= ( codegen_units[ codegen_units. len ( ) - 2 ] . size_estimate ( )
357
+ + codegen_units[ codegen_units. len ( ) - 1 ] . size_estimate ( ) )
358
+ as f64
359
+ } ;
359
360
360
361
if !( merge1 || merge2 || merge3) {
361
362
break ;
You can’t perform that action at this time.
0 commit comments