@@ -1300,12 +1300,16 @@ fn start_executing_work<B: ExtraBackendMethods>(
1300
1300
let mut main_thread_state = MainThreadState :: Idle ;
1301
1301
1302
1302
// How many LLVM worker threads are running while holding a Token. This
1303
- // *excludes* the LLVM worker thread that the main thread is lending a
1304
- // Token to (when the main thread is in the `Lending` state).
1305
- // In other words, the number of LLVM threads is actually equal to
1306
- // `running + if main_thread_state == Lending { 1 } else { 0 }`.
1303
+ // *excludes* any that the main thread is lending a Token to.
1307
1304
let mut running_with_own_token = 0 ;
1308
1305
1306
+ // How many LLVM worker threads are running in total. This *includes*
1307
+ // any that the main thread is lending a Token to.
1308
+ let running_with_any_token = |main_thread_state, running_with_own_token| {
1309
+ running_with_own_token
1310
+ + if main_thread_state == MainThreadState :: Lending { 1 } else { 0 }
1311
+ } ;
1312
+
1309
1313
let mut llvm_start_time: Option < VerboseTimingGuard < ' _ > > = None ;
1310
1314
1311
1315
// Run the message loop while there's still anything that needs message
@@ -1352,8 +1356,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1352
1356
}
1353
1357
}
1354
1358
} else if codegen_state == Completed {
1355
- if running_with_own_token == 0
1356
- && main_thread_state == MainThreadState :: Idle
1359
+ if running_with_any_token ( main_thread_state, running_with_own_token) == 0
1357
1360
&& work_items. is_empty ( )
1358
1361
{
1359
1362
// All codegen work is done. Do we have LTO work to do?
@@ -1427,7 +1430,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
1427
1430
// Don't queue up any more work if codegen was aborted, we're
1428
1431
// just waiting for our existing children to finish.
1429
1432
assert ! ( codegen_state == Aborted ) ;
1430
- if running_with_own_token == 0 && main_thread_state != MainThreadState :: Lending {
1433
+ if running_with_any_token ( main_thread_state , running_with_own_token) == 0 {
1431
1434
break ;
1432
1435
}
1433
1436
}
0 commit comments