Index: llvm/lib/Support/Parallel.cpp =================================================================== --- llvm/lib/Support/Parallel.cpp +++ llvm/lib/Support/Parallel.cpp @@ -89,7 +89,7 @@ void add(std::function F) override { { std::lock_guard Lock(Mutex); - WorkStack.push(F); + WorkStack.push(std::move(F)); } Cond.notify_one(); } @@ -102,7 +102,7 @@ Cond.wait(Lock, [&] { return Stop || !WorkStack.empty(); }); if (Stop) break; - auto Task = WorkStack.top(); + auto Task = std::move(WorkStack.top()); WorkStack.pop(); Lock.unlock(); Task(); @@ -161,7 +161,7 @@ void TaskGroup::spawn(std::function F) { if (Parallel) { L.inc(); - Executor::getDefaultExecutor()->add([&, F] { + Executor::getDefaultExecutor()->add([&, F = std::move(F)] { F(); L.dec(); });