@@ -369,6 +369,10 @@ pub struct CodegenContext<B: WriteBackendMethods> {
369369 pub incr_comp_session_dir : Option < PathBuf > ,
370370 /// Channel back to the main control thread to send messages to
371371 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 ,
372376}
373377
374378impl < B : WriteBackendMethods > CodegenContext < B > {
@@ -1129,6 +1133,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
11291133 target_arch : tcx. sess . target . arch . to_string ( ) ,
11301134 split_debuginfo : tcx. sess . split_debuginfo ( ) ,
11311135 split_dwarf_kind : tcx. sess . opts . unstable_opts . split_dwarf_kind ,
1136+ parallel : backend. supports_parallel ( ) && !sess. opts . unstable_opts . no_parallel_backend ,
11321137 } ;
11331138
11341139 // This is the "main loop" of parallel work happening for parallel codegen.
@@ -1399,7 +1404,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
13991404 . binary_search_by_key ( & cost, |& ( _, cost) | cost)
14001405 . unwrap_or_else ( |e| e) ;
14011406 work_items. insert ( insertion_index, ( work, cost) ) ;
1402- if ! cgcx. opts . unstable_opts . no_parallel_backend {
1407+ if cgcx. parallel {
14031408 helper. request_token ( ) ;
14041409 }
14051410 }
@@ -1522,7 +1527,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
15221527 } ;
15231528 work_items. insert ( insertion_index, ( llvm_work_item, cost) ) ;
15241529
1525- if ! cgcx. opts . unstable_opts . no_parallel_backend {
1530+ if cgcx. parallel {
15261531 helper. request_token ( ) ;
15271532 }
15281533 assert_eq ! ( main_thread_state, MainThreadState :: Codegenning ) ;
0 commit comments