@@ -470,6 +470,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
470470 backend : B ,
471471 tcx : TyCtxt < ' _ > ,
472472 target_cpu : String ,
473+ autodiff_items : & [ AutoDiffItem ] ,
473474) -> OngoingCodegen < B > {
474475 let ( coordinator_send, coordinator_receive) = channel ( ) ;
475476
@@ -488,6 +489,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
488489 backend. clone ( ) ,
489490 tcx,
490491 & crate_info,
492+ autodiff_items,
491493 shared_emitter,
492494 codegen_worker_send,
493495 coordinator_receive,
@@ -1044,9 +1046,6 @@ pub(crate) enum Message<B: WriteBackendMethods> {
10441046 /// Sent from a backend worker thread.
10451047 WorkItem { result : Result < WorkItemResult < B > , Option < WorkerFatalError > > , worker_id : usize } ,
10461048
1047- /// A vector containing all the AutoDiff tasks that we have to pass to Enzyme.
1048- AddAutoDiffItems ( Vec < AutoDiffItem > ) ,
1049-
10501049 /// The frontend has finished generating something (backend IR or a
10511050 /// post-LTO artifact) for a codegen unit, and it should be passed to the
10521051 /// backend. Sent from the main thread.
@@ -1113,6 +1112,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
11131112 backend : B ,
11141113 tcx : TyCtxt < ' _ > ,
11151114 crate_info : & CrateInfo ,
1115+ autodiff_items : & [ AutoDiffItem ] ,
11161116 shared_emitter : SharedEmitter ,
11171117 codegen_worker_send : Sender < CguMessage > ,
11181118 coordinator_receive : Receiver < Box < dyn Any + Send > > ,
@@ -1122,6 +1122,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
11221122) -> thread:: JoinHandle < Result < CompiledModules , ( ) > > {
11231123 let coordinator_send = tx_to_llvm_workers;
11241124 let sess = tcx. sess ;
1125+ let autodiff_items = autodiff_items. to_vec ( ) ;
11251126
11261127 let mut each_linked_rlib_for_lto = Vec :: new ( ) ;
11271128 drop ( link:: each_linked_rlib ( crate_info, None , & mut |cnum, path| {
@@ -1375,7 +1376,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
13751376
13761377 // This is where we collect codegen units that have gone all the way
13771378 // through codegen and LLVM.
1378- let mut autodiff_items = Vec :: new ( ) ;
13791379 let mut compiled_modules = vec ! [ ] ;
13801380 let mut compiled_allocator_module = None ;
13811381 let mut needs_link = Vec :: new ( ) ;
@@ -1645,10 +1645,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
16451645 main_thread_state = MainThreadState :: Idle ;
16461646 }
16471647
1648- Message :: AddAutoDiffItems ( mut items) => {
1649- autodiff_items. append ( & mut items) ;
1650- }
1651-
16521648 Message :: CodegenComplete => {
16531649 if codegen_state != Aborted {
16541650 codegen_state = Completed ;
@@ -2117,10 +2113,6 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
21172113 drop ( self . coordinator . sender . send ( Box :: new ( Message :: CodegenComplete :: < B > ) ) ) ;
21182114 }
21192115
2120- pub ( crate ) fn submit_autodiff_items ( & self , items : Vec < AutoDiffItem > ) {
2121- drop ( self . coordinator . sender . send ( Box :: new ( Message :: < B > :: AddAutoDiffItems ( items) ) ) ) ;
2122- }
2123-
21242116 pub ( crate ) fn check_for_errors ( & self , sess : & Session ) {
21252117 self . shared_emitter_main . check ( sess, false ) ;
21262118 }
0 commit comments