@@ -374,6 +374,10 @@ pub struct CodegenContext<B: WriteBackendMethods> {
374374 pub incr_comp_session_dir : Option < PathBuf > ,
375375 /// Channel back to the main control thread to send messages to
376376 pub coordinator_send : Sender < Box < dyn Any + Send > > ,
377+ /// `true` if the codegen should be run in parallel.
378+ ///
379+ /// Depends on [`CodegenBackend::supports_parallel()`] and `-Zno_parallel_backend`.
380+ pub parallel : bool ,
377381}
378382
379383impl < B : WriteBackendMethods > CodegenContext < B > {
@@ -1152,6 +1156,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
11521156 target_arch : tcx. sess . target . arch . to_string ( ) ,
11531157 split_debuginfo : tcx. sess . split_debuginfo ( ) ,
11541158 split_dwarf_kind : tcx. sess . opts . unstable_opts . split_dwarf_kind ,
1159+ parallel : backend. supports_parallel ( ) && !sess. opts . unstable_opts . no_parallel_backend ,
11551160 } ;
11561161
11571162 // This is the "main loop" of parallel work happening for parallel codegen.
@@ -1422,7 +1427,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
14221427 . binary_search_by_key ( & cost, |& ( _, cost) | cost)
14231428 . unwrap_or_else ( |e| e) ;
14241429 work_items. insert ( insertion_index, ( work, cost) ) ;
1425- if ! cgcx. opts . unstable_opts . no_parallel_llvm {
1430+ if cgcx. parallel {
14261431 helper. request_token ( ) ;
14271432 }
14281433 }
@@ -1545,7 +1550,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
15451550 } ;
15461551 work_items. insert ( insertion_index, ( llvm_work_item, cost) ) ;
15471552
1548- if ! cgcx. opts . unstable_opts . no_parallel_llvm {
1553+ if cgcx. parallel {
15491554 helper. request_token ( ) ;
15501555 }
15511556 assert_eq ! ( main_thread_state, MainThreadState :: Codegenning ) ;
0 commit comments