@@ -408,14 +408,16 @@ fn generate_lto_work<B: ExtraBackendMethods>(
408
408
409
409
if !needs_fat_lto. is_empty ( ) {
410
410
assert ! ( needs_thin_lto. is_empty( ) ) ;
411
- let mut module =
411
+ let module =
412
412
B :: run_fat_lto ( cgcx, needs_fat_lto, import_only_modules) . unwrap_or_else ( |e| e. raise ( ) ) ;
413
413
if cgcx. lto == Lto :: Fat && !autodiff. is_empty ( ) {
414
414
let config = cgcx. config ( ModuleKind :: Regular ) ;
415
- module = module. autodiff ( cgcx, autodiff, config) . unwrap_or_else ( |e| e. raise ( ) ) ;
415
+ if let Err ( err) = B :: autodiff ( cgcx, & module, autodiff, config) {
416
+ err. raise ( ) ;
417
+ }
416
418
}
417
419
// We are adding a single work item, so the cost doesn't matter.
418
- vec ! [ ( WorkItem :: LTO ( module) , 0 ) ]
420
+ vec ! [ ( WorkItem :: FatLto ( module) , 0 ) ]
419
421
} else {
420
422
if !autodiff. is_empty ( ) {
421
423
let dcx = cgcx. create_dcx ( ) ;
@@ -428,7 +430,7 @@ fn generate_lto_work<B: ExtraBackendMethods>(
428
430
. into_iter ( )
429
431
. map ( |module| {
430
432
let cost = module. cost ( ) ;
431
- ( WorkItem :: LTO ( module) , cost)
433
+ ( WorkItem :: ThinLto ( module) , cost)
432
434
} )
433
435
. chain ( copy_jobs. into_iter ( ) . map ( |wp| {
434
436
(
@@ -736,15 +738,19 @@ pub(crate) enum WorkItem<B: WriteBackendMethods> {
736
738
/// Copy the post-LTO artifacts from the incremental cache to the output
737
739
/// directory.
738
740
CopyPostLtoArtifacts ( CachedModuleCodegen ) ,
739
- /// Performs (Thin)LTO on the given module.
740
- LTO ( lto:: LtoModuleCodegen < B > ) ,
741
+ /// Performs fat LTO on the given module.
742
+ FatLto ( ModuleCodegen < B :: Module > ) ,
743
+ /// Performs thin-LTO on the given module.
744
+ ThinLto ( lto:: ThinModule < B > ) ,
741
745
}
742
746
743
747
impl < B : WriteBackendMethods > WorkItem < B > {
744
748
fn module_kind ( & self ) -> ModuleKind {
745
749
match * self {
746
750
WorkItem :: Optimize ( ref m) => m. kind ,
747
- WorkItem :: CopyPostLtoArtifacts ( _) | WorkItem :: LTO ( _) => ModuleKind :: Regular ,
751
+ WorkItem :: CopyPostLtoArtifacts ( _) | WorkItem :: FatLto ( _) | WorkItem :: ThinLto ( _) => {
752
+ ModuleKind :: Regular
753
+ }
748
754
}
749
755
}
750
756
@@ -792,7 +798,8 @@ impl<B: WriteBackendMethods> WorkItem<B> {
792
798
match self {
793
799
WorkItem :: Optimize ( m) => desc ( "opt" , "optimize module" , & m. name ) ,
794
800
WorkItem :: CopyPostLtoArtifacts ( m) => desc ( "cpy" , "copy LTO artifacts for" , & m. name ) ,
795
- WorkItem :: LTO ( m) => desc ( "lto" , "LTO module" , m. name ( ) ) ,
801
+ WorkItem :: FatLto ( _) => desc ( "lto" , "fat LTO module" , "everything" ) ,
802
+ WorkItem :: ThinLto ( m) => desc ( "lto" , "thin-LTO module" , m. name ( ) ) ,
796
803
}
797
804
}
798
805
}
@@ -996,12 +1003,21 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
996
1003
} )
997
1004
}
998
1005
999
- fn execute_lto_work_item < B : ExtraBackendMethods > (
1006
+ fn execute_fat_lto_work_item < B : ExtraBackendMethods > (
1007
+ cgcx : & CodegenContext < B > ,
1008
+ mut module : ModuleCodegen < B :: Module > ,
1009
+ module_config : & ModuleConfig ,
1010
+ ) -> Result < WorkItemResult < B > , FatalError > {
1011
+ B :: optimize_fat ( cgcx, & mut module) ?;
1012
+ finish_intra_module_work ( cgcx, module, module_config)
1013
+ }
1014
+
1015
+ fn execute_thin_lto_work_item < B : ExtraBackendMethods > (
1000
1016
cgcx : & CodegenContext < B > ,
1001
- module : lto:: LtoModuleCodegen < B > ,
1017
+ module : lto:: ThinModule < B > ,
1002
1018
module_config : & ModuleConfig ,
1003
1019
) -> Result < WorkItemResult < B > , FatalError > {
1004
- let module = module . optimize ( cgcx) ?;
1020
+ let module = B :: optimize_thin ( cgcx, module ) ?;
1005
1021
finish_intra_module_work ( cgcx, module, module_config)
1006
1022
}
1007
1023
@@ -1842,10 +1858,16 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
1842
1858
) ;
1843
1859
Ok ( execute_copy_from_cache_work_item ( & cgcx, m, module_config) )
1844
1860
}
1845
- WorkItem :: LTO ( m) => {
1861
+ WorkItem :: FatLto ( m) => {
1862
+ let _timer = cgcx
1863
+ . prof
1864
+ . generic_activity_with_arg ( "codegen_module_perform_lto" , "everything" ) ;
1865
+ execute_fat_lto_work_item ( & cgcx, m, module_config)
1866
+ }
1867
+ WorkItem :: ThinLto ( m) => {
1846
1868
let _timer =
1847
1869
cgcx. prof . generic_activity_with_arg ( "codegen_module_perform_lto" , m. name ( ) ) ;
1848
- execute_lto_work_item ( & cgcx, m, module_config)
1870
+ execute_thin_lto_work_item ( & cgcx, m, module_config)
1849
1871
}
1850
1872
} )
1851
1873
} ;
0 commit comments