@@ -253,7 +253,7 @@ impl<B: WriteBackendMethods> CodegenContext<B> {
253253fn generate_lto_work < B : ExtraBackendMethods > (
254254 cgcx : & CodegenContext < B > ,
255255 needs_fat_lto : Vec < ModuleCodegen < B :: Module > > ,
256- needs_thin_lto : Vec < ModuleCodegen < B :: Module > > ,
256+ needs_thin_lto : Vec < ( String , B :: ThinBuffer ) > ,
257257 import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) >
258258) -> Vec < ( WorkItem < B > , u64 ) > {
259259 let mut timeline = cgcx. time_graph . as_ref ( ) . map ( |tg| {
@@ -678,17 +678,17 @@ impl<B: WriteBackendMethods> WorkItem<B> {
678678 }
679679}
680680
681- enum WorkItemResult < M > {
681+ enum WorkItemResult < B : WriteBackendMethods > {
682682 Compiled ( CompiledModule ) ,
683- NeedsFatLTO ( ModuleCodegen < M > ) ,
684- NeedsThinLTO ( ModuleCodegen < M > ) ,
683+ NeedsFatLTO ( ModuleCodegen < B :: Module > ) ,
684+ NeedsThinLTO ( String , B :: ThinBuffer ) ,
685685}
686686
687687fn execute_work_item < B : ExtraBackendMethods > (
688688 cgcx : & CodegenContext < B > ,
689689 work_item : WorkItem < B > ,
690690 timeline : & mut Timeline
691- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
691+ ) -> Result < WorkItemResult < B > , FatalError > {
692692 let module_config = cgcx. config ( work_item. module_kind ( ) ) ;
693693
694694 match work_item {
@@ -716,7 +716,7 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
716716 module : ModuleCodegen < B :: Module > ,
717717 module_config : & ModuleConfig ,
718718 timeline : & mut Timeline
719- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
719+ ) -> Result < WorkItemResult < B > , FatalError > {
720720 let diag_handler = cgcx. create_diag_handler ( ) ;
721721
722722 unsafe {
@@ -772,7 +772,10 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
772772 } ;
773773 WorkItemResult :: Compiled ( module)
774774 }
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+ }
776779 ComputedLtoType :: Fat => WorkItemResult :: NeedsFatLTO ( module) ,
777780 } )
778781}
@@ -782,7 +785,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
782785 module : CachedModuleCodegen ,
783786 module_config : & ModuleConfig ,
784787 _: & mut Timeline
785- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
788+ ) -> Result < WorkItemResult < B > , FatalError > {
786789 let incr_comp_session_dir = cgcx. incr_comp_session_dir
787790 . as_ref ( )
788791 . unwrap ( ) ;
@@ -844,7 +847,7 @@ fn execute_lto_work_item<B: ExtraBackendMethods>(
844847 mut module : lto:: LtoModuleCodegen < B > ,
845848 module_config : & ModuleConfig ,
846849 timeline : & mut Timeline
847- ) -> Result < WorkItemResult < B :: Module > , FatalError > {
850+ ) -> Result < WorkItemResult < B > , FatalError > {
848851 let diag_handler = cgcx. create_diag_handler ( ) ;
849852
850853 unsafe {
@@ -861,7 +864,8 @@ pub enum Message<B: WriteBackendMethods> {
861864 worker_id : usize ,
862865 } ,
863866 NeedsThinLTO {
864- result : ModuleCodegen < B :: Module > ,
867+ name : String ,
868+ thin_buffer : B :: ThinBuffer ,
865869 worker_id : usize ,
866870 } ,
867871 Done {
@@ -1423,10 +1427,10 @@ fn start_executing_work<B: ExtraBackendMethods>(
14231427 free_worker ( worker_id) ;
14241428 needs_fat_lto. push ( result) ;
14251429 }
1426- Message :: NeedsThinLTO { result , worker_id } => {
1430+ Message :: NeedsThinLTO { name , thin_buffer , worker_id } => {
14271431 assert ! ( !started_lto) ;
14281432 free_worker ( worker_id) ;
1429- needs_thin_lto. push ( result ) ;
1433+ needs_thin_lto. push ( ( name , thin_buffer ) ) ;
14301434 }
14311435 Message :: AddImportOnlyModule { module_data, work_product } => {
14321436 assert ! ( !started_lto) ;
@@ -1514,7 +1518,7 @@ fn spawn_work<B: ExtraBackendMethods>(
15141518 // we exit.
15151519 struct Bomb < B : ExtraBackendMethods > {
15161520 coordinator_send : Sender < Box < dyn Any + Send > > ,
1517- result : Option < WorkItemResult < B :: Module > > ,
1521+ result : Option < WorkItemResult < B > > ,
15181522 worker_id : usize ,
15191523 }
15201524 impl < B : ExtraBackendMethods > Drop for Bomb < B > {
@@ -1527,8 +1531,8 @@ fn spawn_work<B: ExtraBackendMethods>(
15271531 Some ( WorkItemResult :: NeedsFatLTO ( m) ) => {
15281532 Message :: NeedsFatLTO :: < B > { result : m, worker_id }
15291533 }
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 }
15321536 }
15331537 None => Message :: Done :: < B > { result : Err ( ( ) ) , worker_id }
15341538 } ;
0 commit comments