@@ -369,6 +369,10 @@ pub struct CodegenContext<B: WriteBackendMethods> {
369
369
pub incr_comp_session_dir : Option < PathBuf > ,
370
370
/// Channel back to the main control thread to send messages to
371
371
pub coordinator_send : Sender < Box < dyn Any + Send > > ,
372
+ /// `true` if the codegen should be run in parallel.
373
+ ///
374
+ /// Depends on [`CodegenBackend::supports_parallel()`] and `-Zno_parallel_backend`.
375
+ pub parallel : bool ,
372
376
}
373
377
374
378
impl < B : WriteBackendMethods > CodegenContext < B > {
@@ -1129,6 +1133,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1129
1133
target_arch : tcx. sess . target . arch . to_string ( ) ,
1130
1134
split_debuginfo : tcx. sess . split_debuginfo ( ) ,
1131
1135
split_dwarf_kind : tcx. sess . opts . unstable_opts . split_dwarf_kind ,
1136
+ parallel : backend. supports_parallel ( ) && !sess. opts . unstable_opts . no_parallel_backend ,
1132
1137
} ;
1133
1138
1134
1139
// This is the "main loop" of parallel work happening for parallel codegen.
@@ -1399,7 +1404,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1399
1404
. binary_search_by_key ( & cost, |& ( _, cost) | cost)
1400
1405
. unwrap_or_else ( |e| e) ;
1401
1406
work_items. insert ( insertion_index, ( work, cost) ) ;
1402
- if ! cgcx. opts . unstable_opts . no_parallel_backend {
1407
+ if cgcx. parallel {
1403
1408
helper. request_token ( ) ;
1404
1409
}
1405
1410
}
@@ -1522,7 +1527,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1522
1527
} ;
1523
1528
work_items. insert ( insertion_index, ( llvm_work_item, cost) ) ;
1524
1529
1525
- if ! cgcx. opts . unstable_opts . no_parallel_backend {
1530
+ if cgcx. parallel {
1526
1531
helper. request_token ( ) ;
1527
1532
}
1528
1533
assert_eq ! ( main_thread_state, MainThreadState :: Codegenning ) ;
0 commit comments