diff --git a/llvm/lib/Support/Parallel.cpp b/llvm/lib/Support/Parallel.cpp index 110693be17640..91a16ff8f07f1 100644 --- a/llvm/lib/Support/Parallel.cpp +++ b/llvm/lib/Support/Parallel.cpp @@ -278,9 +278,12 @@ void llvm::parallelFor(size_t Begin, size_t End, } }; + // Run one worker on the calling thread: starts working immediately and + // avoids an idle thread. TaskGroup TG; - for (size_t I = 0; I != NumWorkers; ++I) + while (--NumWorkers) TG.spawn(Worker); + Worker(); return; } #endif