diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-07-21 13:32:29 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-07-31 16:21:02 +1000 |
| commit | 90ce358afa1ac796e320f9c60463b604f30c7eeb (patch) | |
| tree | 43fcdcb64198ffe3afdc637230bd19b92d601008 /compiler/rustc_codegen_ssa/src | |
| parent | 3b44f5b0ebf7bdacde8b6e3e50582b5ea329da15 (diff) | |
| download | rust-90ce358afa1ac796e320f9c60463b604f30c7eeb.tar.gz rust-90ce358afa1ac796e320f9c60463b604f30c7eeb.zip | |
Introduce `running_with_any_token` closure.
It makes things a little clearer.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/write.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 67916ba12a2..1f6d73994cf 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -1300,12 +1300,16 @@ fn start_executing_work<B: ExtraBackendMethods>( let mut main_thread_state = MainThreadState::Idle; // How many LLVM worker threads are running while holding a Token. This - // *excludes* the LLVM worker thread that the main thread is lending a - // Token to (when the main thread is in the `Lending` state). - // In other words, the number of LLVM threads is actually equal to - // `running + if main_thread_state == Lending { 1 } else { 0 }`. + // *excludes* any that the main thread is lending a Token to. let mut running_with_own_token = 0; + // How many LLVM worker threads are running in total. This *includes* + // any that the main thread is lending a Token to. + let running_with_any_token = |main_thread_state, running_with_own_token| { + running_with_own_token + + if main_thread_state == MainThreadState::Lending { 1 } else { 0 } + }; + let mut llvm_start_time: Option<VerboseTimingGuard<'_>> = None; // Run the message loop while there's still anything that needs message @@ -1352,8 +1356,7 @@ fn start_executing_work<B: ExtraBackendMethods>( } } } else if codegen_state == Completed { - if running_with_own_token == 0 - && main_thread_state == MainThreadState::Idle + if running_with_any_token(main_thread_state, running_with_own_token) == 0 && work_items.is_empty() { // All codegen work is done. Do we have LTO work to do? @@ -1427,7 +1430,7 @@ fn start_executing_work<B: ExtraBackendMethods>( // Don't queue up any more work if codegen was aborted, we're // just waiting for our existing children to finish. assert!(codegen_state == Aborted); - if running_with_own_token == 0 && main_thread_state != MainThreadState::Lending { + if running_with_any_token(main_thread_state, running_with_own_token) == 0 { break; } } |
