@@ -397,25 +397,6 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
397
397
}
398
398
}
399
399
400
- fn generate_fat_lto_work < B : ExtraBackendMethods > (
401
- cgcx : & CodegenContext < B > ,
402
- autodiff : Vec < AutoDiffItem > ,
403
- needs_fat_lto : Vec < FatLtoInput < B > > ,
404
- import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
405
- ) -> WorkItem < B > {
406
- let _prof_timer = cgcx. prof . generic_activity ( "codegen_generate_lto_work" ) ;
407
-
408
- let module =
409
- B :: run_fat_lto ( cgcx, needs_fat_lto, import_only_modules) . unwrap_or_else ( |e| e. raise ( ) ) ;
410
- if cgcx. lto == Lto :: Fat && !autodiff. is_empty ( ) {
411
- let config = cgcx. config ( ModuleKind :: Regular ) ;
412
- if let Err ( err) = B :: autodiff ( cgcx, & module, autodiff, config) {
413
- err. raise ( ) ;
414
- }
415
- }
416
- WorkItem :: FatLto ( module)
417
- }
418
-
419
400
fn generate_thin_lto_work < B : ExtraBackendMethods > (
420
401
cgcx : & CodegenContext < B > ,
421
402
needs_thin_lto : Vec < ( String , B :: ThinBuffer ) > ,
@@ -739,7 +720,11 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
739
720
/// directory.
740
721
CopyPostLtoArtifacts ( CachedModuleCodegen ) ,
741
722
/// Performs fat LTO on the given module.
742
- FatLto ( ModuleCodegen < B :: Module > ) ,
723
+ FatLto {
724
+ needs_fat_lto : Vec < FatLtoInput < B > > ,
725
+ import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
726
+ autodiff : Vec < AutoDiffItem > ,
727
+ } ,
743
728
/// Performs thin-LTO on the given module.
744
729
ThinLto ( lto:: ThinModule < B > ) ,
745
730
}
@@ -748,7 +733,7 @@ impl<B: WriteBackendMethods> WorkItem<B> {
748
733
fn module_kind ( & self ) -> ModuleKind {
749
734
match * self {
750
735
WorkItem :: Optimize ( ref m) => m. kind ,
751
- WorkItem :: CopyPostLtoArtifacts ( _) | WorkItem :: FatLto ( _ ) | WorkItem :: ThinLto ( _) => {
736
+ WorkItem :: CopyPostLtoArtifacts ( _) | WorkItem :: FatLto { .. } | WorkItem :: ThinLto ( _) => {
752
737
ModuleKind :: Regular
753
738
}
754
739
}
@@ -798,7 +783,7 @@ impl<B: WriteBackendMethods> WorkItem<B> {
798
783
match self {
799
784
WorkItem :: Optimize ( m) => desc ( "opt" , "optimize module" , & m. name ) ,
800
785
WorkItem :: CopyPostLtoArtifacts ( m) => desc ( "cpy" , "copy LTO artifacts for" , & m. name ) ,
801
- WorkItem :: FatLto ( _ ) => desc ( "lto" , "fat LTO module" , "everything" ) ,
786
+ WorkItem :: FatLto { .. } => desc ( "lto" , "fat LTO module" , "everything" ) ,
802
787
WorkItem :: ThinLto ( m) => desc ( "lto" , "thin-LTO module" , m. name ( ) ) ,
803
788
}
804
789
}
@@ -1005,9 +990,21 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
1005
990
1006
991
fn execute_fat_lto_work_item < B : ExtraBackendMethods > (
1007
992
cgcx : & CodegenContext < B > ,
1008
- mut module : ModuleCodegen < B :: Module > ,
993
+ needs_fat_lto : Vec < FatLtoInput < B > > ,
994
+ import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
995
+ autodiff : Vec < AutoDiffItem > ,
1009
996
module_config : & ModuleConfig ,
1010
997
) -> Result < WorkItemResult < B > , FatalError > {
998
+ let mut module =
999
+ B :: run_fat_lto ( cgcx, needs_fat_lto, import_only_modules) . unwrap_or_else ( |e| e. raise ( ) ) ;
1000
+
1001
+ if cgcx. lto == Lto :: Fat && !autodiff. is_empty ( ) {
1002
+ let config = cgcx. config ( ModuleKind :: Regular ) ;
1003
+ if let Err ( err) = B :: autodiff ( cgcx, & module, autodiff, config) {
1004
+ err. raise ( ) ;
1005
+ }
1006
+ }
1007
+
1011
1008
B :: optimize_fat ( cgcx, & mut module) ?;
1012
1009
1013
1010
let module = B :: codegen ( cgcx, module, module_config) ?;
@@ -1490,13 +1487,14 @@ fn start_executing_work<B: ExtraBackendMethods>(
1490
1487
if !needs_fat_lto. is_empty ( ) {
1491
1488
assert ! ( needs_thin_lto. is_empty( ) ) ;
1492
1489
1493
- let work = generate_fat_lto_work (
1494
- & cgcx,
1495
- autodiff_items. clone ( ) ,
1496
- needs_fat_lto,
1497
- import_only_modules,
1498
- ) ;
1499
- work_items. push ( ( work, 0 ) ) ;
1490
+ work_items. push ( (
1491
+ WorkItem :: FatLto {
1492
+ needs_fat_lto,
1493
+ import_only_modules,
1494
+ autodiff : autodiff_items. clone ( ) ,
1495
+ } ,
1496
+ 0 ,
1497
+ ) ) ;
1500
1498
if cgcx. parallel {
1501
1499
helper. request_token ( ) ;
1502
1500
}
@@ -1867,11 +1865,17 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
1867
1865
) ;
1868
1866
Ok ( execute_copy_from_cache_work_item ( & cgcx, m, module_config) )
1869
1867
}
1870
- WorkItem :: FatLto ( m ) => {
1868
+ WorkItem :: FatLto { needs_fat_lto , import_only_modules , autodiff } => {
1871
1869
let _timer = cgcx
1872
1870
. prof
1873
1871
. generic_activity_with_arg ( "codegen_module_perform_lto" , "everything" ) ;
1874
- execute_fat_lto_work_item ( & cgcx, m, module_config)
1872
+ execute_fat_lto_work_item (
1873
+ & cgcx,
1874
+ needs_fat_lto,
1875
+ import_only_modules,
1876
+ autodiff,
1877
+ module_config,
1878
+ )
1875
1879
}
1876
1880
WorkItem :: ThinLto ( m) => {
1877
1881
let _timer =
0 commit comments