@@ -253,7 +253,7 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
253
253
fn generate_lto_work < B : ExtraBackendMethods > (
254
254
cgcx : & CodegenContext < B > ,
255
255
needs_fat_lto : Vec < ModuleCodegen < B :: Module > > ,
256
- needs_thin_lto : Vec < ModuleCodegen < B :: Module > > ,
256
+ needs_thin_lto : Vec < ( String , B :: ThinBuffer ) > ,
257
257
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) >
258
258
) -> Vec < ( WorkItem < B > , u64 ) > {
259
259
let mut timeline = cgcx. time_graph . as_ref ( ) . map ( |tg| {
@@ -678,17 +678,17 @@ impl<B: WriteBackendMethods> WorkItem<B> {
678
678
}
679
679
}
680
680
681
- enum WorkItemResult < M > {
681
+ enum WorkItemResult < B : WriteBackendMethods > {
682
682
Compiled ( CompiledModule ) ,
683
- NeedsFatLTO ( ModuleCodegen < M > ) ,
684
- NeedsThinLTO ( ModuleCodegen < M > ) ,
683
+ NeedsFatLTO ( ModuleCodegen < B :: Module > ) ,
684
+ NeedsThinLTO ( String , B :: ThinBuffer ) ,
685
685
}
686
686
687
687
fn execute_work_item < B : ExtraBackendMethods > (
688
688
cgcx : & CodegenContext < B > ,
689
689
work_item : WorkItem < B > ,
690
690
timeline : & mut Timeline
691
- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
691
+ ) -> Result < WorkItemResult < B > , FatalError > {
692
692
let module_config = cgcx. config ( work_item. module_kind ( ) ) ;
693
693
694
694
match work_item {
@@ -716,7 +716,7 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
716
716
module : ModuleCodegen < B :: Module > ,
717
717
module_config : & ModuleConfig ,
718
718
timeline : & mut Timeline
719
- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
719
+ ) -> Result < WorkItemResult < B > , FatalError > {
720
720
let diag_handler = cgcx. create_diag_handler ( ) ;
721
721
722
722
unsafe {
@@ -772,7 +772,10 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
772
772
} ;
773
773
WorkItemResult :: Compiled ( module)
774
774
}
775
- ComputedLtoType :: Thin => WorkItemResult :: NeedsThinLTO ( module) ,
775
+ ComputedLtoType :: Thin => {
776
+ let ( name, thin_buffer) = B :: prepare_thin ( cgcx, module) ;
777
+ WorkItemResult :: NeedsThinLTO ( name, thin_buffer)
778
+ }
776
779
ComputedLtoType :: Fat => WorkItemResult :: NeedsFatLTO ( module) ,
777
780
} )
778
781
}
@@ -782,7 +785,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
782
785
module : CachedModuleCodegen ,
783
786
module_config : & ModuleConfig ,
784
787
_: & mut Timeline
785
- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
788
+ ) -> Result < WorkItemResult < B > , FatalError > {
786
789
let incr_comp_session_dir = cgcx. incr_comp_session_dir
787
790
. as_ref ( )
788
791
. unwrap ( ) ;
@@ -844,7 +847,7 @@ fn execute_lto_work_item<B: ExtraBackendMethods>(
844
847
mut module : lto:: LtoModuleCodegen < B > ,
845
848
module_config : & ModuleConfig ,
846
849
timeline : & mut Timeline
847
- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
850
+ ) -> Result < WorkItemResult < B > , FatalError > {
848
851
let diag_handler = cgcx. create_diag_handler ( ) ;
849
852
850
853
unsafe {
@@ -861,7 +864,8 @@ pub enum Message<B: WriteBackendMethods> {
861
864
worker_id : usize ,
862
865
} ,
863
866
NeedsThinLTO {
864
- result : ModuleCodegen < B :: Module > ,
867
+ name : String ,
868
+ thin_buffer : B :: ThinBuffer ,
865
869
worker_id : usize ,
866
870
} ,
867
871
Done {
@@ -1423,10 +1427,10 @@ fn start_executing_work<B: ExtraBackendMethods>(
1423
1427
free_worker ( worker_id) ;
1424
1428
needs_fat_lto. push ( result) ;
1425
1429
}
1426
- Message :: NeedsThinLTO { result , worker_id } => {
1430
+ Message :: NeedsThinLTO { name , thin_buffer , worker_id } => {
1427
1431
assert ! ( !started_lto) ;
1428
1432
free_worker ( worker_id) ;
1429
- needs_thin_lto. push ( result ) ;
1433
+ needs_thin_lto. push ( ( name , thin_buffer ) ) ;
1430
1434
}
1431
1435
Message :: AddImportOnlyModule { module_data, work_product } => {
1432
1436
assert ! ( !started_lto) ;
@@ -1514,7 +1518,7 @@ fn spawn_work<B: ExtraBackendMethods>(
1514
1518
// we exit.
1515
1519
struct Bomb < B : ExtraBackendMethods > {
1516
1520
coordinator_send : Sender < Box < dyn Any + Send > > ,
1517
- result : Option < WorkItemResult < B :: Module > > ,
1521
+ result : Option < WorkItemResult < B > > ,
1518
1522
worker_id : usize ,
1519
1523
}
1520
1524
impl < B : ExtraBackendMethods > Drop for Bomb < B > {
@@ -1527,8 +1531,8 @@ fn spawn_work<B: ExtraBackendMethods>(
1527
1531
Some ( WorkItemResult :: NeedsFatLTO ( m) ) => {
1528
1532
Message :: NeedsFatLTO :: < B > { result : m, worker_id }
1529
1533
}
1530
- Some ( WorkItemResult :: NeedsThinLTO ( m ) ) => {
1531
- Message :: NeedsThinLTO :: < B > { result : m , worker_id }
1534
+ Some ( WorkItemResult :: NeedsThinLTO ( name , thin_buffer ) ) => {
1535
+ Message :: NeedsThinLTO :: < B > { name , thin_buffer , worker_id }
1532
1536
}
1533
1537
None => Message :: Done :: < B > { result : Err ( ( ) ) , worker_id }
1534
1538
} ;
0 commit comments