@@ -607,6 +607,11 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
607
607
second_half. iter ( ) . rev ( ) . interleave ( first_half) . copied ( ) . collect ( )
608
608
} ;
609
609
610
+ // Calculate the CGU reuse
611
+ let cgu_reuse = tcx. sess . time ( "find_cgu_reuse" , || {
612
+ codegen_units. iter ( ) . map ( |cgu| determine_cgu_reuse ( tcx, & cgu) ) . collect :: < Vec < _ > > ( )
613
+ } ) ;
614
+
610
615
// The non-parallel compiler can only translate codegen units to LLVM IR
611
616
// on a single thread, leading to a staircase effect where the N LLVM
612
617
// threads have to wait on the single codegen threads to generate work
@@ -618,7 +623,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
618
623
// non-parallel compiler anymore, we can compile CGUs end-to-end in
619
624
// parallel and get rid of the complicated scheduling logic.
620
625
#[ cfg( parallel_compiler) ]
621
- let pre_compile_cgus = |cgu_reuse : & [ CguReuse ] | {
626
+ let pre_compile_cgus = || {
622
627
tcx. sess . time ( "compile_first_CGU_batch" , || {
623
628
// Try to find one CGU to compile per thread.
624
629
let cgus: Vec < _ > = cgu_reuse
@@ -643,9 +648,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
643
648
} ;
644
649
645
650
#[ cfg( not( parallel_compiler) ) ]
646
- let pre_compile_cgus = |_ : & [ CguReuse ] | ( FxHashMap :: default ( ) , Duration :: new ( 0 , 0 ) ) ;
651
+ let pre_compile_cgus = || ( FxHashMap :: default ( ) , Duration :: new ( 0 , 0 ) ) ;
647
652
648
- let mut cgu_reuse = Vec :: new ( ) ;
649
653
let mut pre_compiled_cgus: Option < FxHashMap < usize , _ > > = None ;
650
654
let mut total_codegen_time = Duration :: new ( 0 , 0 ) ;
651
655
let start_rss = tcx. sess . time_passes ( ) . then ( || get_resident_set_size ( ) ) ;
@@ -656,12 +660,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
656
660
657
661
// Do some setup work in the first iteration
658
662
if pre_compiled_cgus. is_none ( ) {
659
- // Calculate the CGU reuse
660
- cgu_reuse = tcx. sess . time ( "find_cgu_reuse" , || {
661
- codegen_units. iter ( ) . map ( |cgu| determine_cgu_reuse ( tcx, & cgu) ) . collect ( )
662
- } ) ;
663
663
// Pre compile some CGUs
664
- let ( compiled_cgus, codegen_time) = pre_compile_cgus ( & cgu_reuse ) ;
664
+ let ( compiled_cgus, codegen_time) = pre_compile_cgus ( ) ;
665
665
pre_compiled_cgus = Some ( compiled_cgus) ;
666
666
total_codegen_time += codegen_time;
667
667
}
0 commit comments