@@ -470,6 +470,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
470
470
backend : B ,
471
471
tcx : TyCtxt < ' _ > ,
472
472
target_cpu : String ,
473
+ autodiff_items : & [ AutoDiffItem ] ,
473
474
) -> OngoingCodegen < B > {
474
475
let ( coordinator_send, coordinator_receive) = channel ( ) ;
475
476
@@ -488,6 +489,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
488
489
backend. clone ( ) ,
489
490
tcx,
490
491
& crate_info,
492
+ autodiff_items,
491
493
shared_emitter,
492
494
codegen_worker_send,
493
495
coordinator_receive,
@@ -1044,9 +1046,6 @@ pub(crate) enum Message<B: WriteBackendMethods> {
1044
1046
/// Sent from a backend worker thread.
1045
1047
WorkItem { result : Result < WorkItemResult < B > , Option < WorkerFatalError > > , worker_id : usize } ,
1046
1048
1047
- /// A vector containing all the AutoDiff tasks that we have to pass to Enzyme.
1048
- AddAutoDiffItems ( Vec < AutoDiffItem > ) ,
1049
-
1050
1049
/// The frontend has finished generating something (backend IR or a
1051
1050
/// post-LTO artifact) for a codegen unit, and it should be passed to the
1052
1051
/// backend. Sent from the main thread.
@@ -1113,6 +1112,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1113
1112
backend : B ,
1114
1113
tcx : TyCtxt < ' _ > ,
1115
1114
crate_info : & CrateInfo ,
1115
+ autodiff_items : & [ AutoDiffItem ] ,
1116
1116
shared_emitter : SharedEmitter ,
1117
1117
codegen_worker_send : Sender < CguMessage > ,
1118
1118
coordinator_receive : Receiver < Box < dyn Any + Send > > ,
@@ -1122,6 +1122,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1122
1122
) -> thread:: JoinHandle < Result < CompiledModules , ( ) > > {
1123
1123
let coordinator_send = tx_to_llvm_workers;
1124
1124
let sess = tcx. sess ;
1125
+ let autodiff_items = autodiff_items. to_vec ( ) ;
1125
1126
1126
1127
let mut each_linked_rlib_for_lto = Vec :: new ( ) ;
1127
1128
drop ( link:: each_linked_rlib ( crate_info, None , & mut |cnum, path| {
@@ -1375,7 +1376,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
1375
1376
1376
1377
// This is where we collect codegen units that have gone all the way
1377
1378
// through codegen and LLVM.
1378
- let mut autodiff_items = Vec :: new ( ) ;
1379
1379
let mut compiled_modules = vec ! [ ] ;
1380
1380
let mut compiled_allocator_module = None ;
1381
1381
let mut needs_link = Vec :: new ( ) ;
@@ -1645,10 +1645,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
1645
1645
main_thread_state = MainThreadState :: Idle ;
1646
1646
}
1647
1647
1648
- Message :: AddAutoDiffItems ( mut items) => {
1649
- autodiff_items. append ( & mut items) ;
1650
- }
1651
-
1652
1648
Message :: CodegenComplete => {
1653
1649
if codegen_state != Aborted {
1654
1650
codegen_state = Completed ;
@@ -2117,10 +2113,6 @@ impl<B: ExtraBackendMethods> OngoingCodegen<B> {
2117
2113
drop ( self . coordinator . sender . send ( Box :: new ( Message :: CodegenComplete :: < B > ) ) ) ;
2118
2114
}
2119
2115
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
-
2124
2116
pub ( crate ) fn check_for_errors ( & self , sess : & Session ) {
2125
2117
self . shared_emitter_main . check ( sess, false ) ;
2126
2118
}
0 commit comments