diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:16:04 +0900 |
commit | 0aa930a41f2d1ebf1fa90ec42da8f96d15a4dcbb (patch) | |
tree | 6a77b463f700e090df586672c26b9fe765fd115b /llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp | |
parent | ec6892d1c979ce0b84c86918d5cdbb03037b409a (diff) | |
parent | 6d16b1c5c468a79ecf867293023c89ac518ecdda (diff) | |
download | llvm-users/chapuni/cov/single/nextcount-base.zip llvm-users/chapuni/cov/single/nextcount-base.tar.gz llvm-users/chapuni/cov/single/nextcount-base.tar.bz2 |
Merge branch 'users/chapuni/cov/single/pair' into users/chapuni/cov/single/nextcount-baseusers/chapuni/cov/single/nextcount-base
Diffstat (limited to 'llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp b/llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp index fbe4b09..1af17e8 100644 --- a/llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TaskDispatch.cpp @@ -31,6 +31,10 @@ void DynamicThreadPoolTaskDispatcher::dispatch(std::unique_ptr<Task> T) { { std::lock_guard<std::mutex> Lock(DispatchMutex); + // Reject new tasks if they're dispatched after a call to shutdown. + if (Shutdown) + return; + if (IsMaterializationTask) { // If this is a materialization task and there are too many running @@ -54,6 +58,14 @@ void DynamicThreadPoolTaskDispatcher::dispatch(std::unique_ptr<Task> T) { // Run the task. T->run(); + // Reset the task to free any resources. We need this to happen *before* + // we notify anyone (via Outstanding) that this thread is done to ensure + // that we don't proceed with JIT shutdown while still holding resources. + // (E.g. this was causing "Dangling SymbolStringPtr" assertions). + T.reset(); + + // Check the work queue state and either proceed with the next task or + // end this thread. std::lock_guard<std::mutex> Lock(DispatchMutex); if (!MaterializationTaskQueue.empty()) { // If there are any materialization tasks running then steal that work. @@ -64,7 +76,6 @@ void DynamicThreadPoolTaskDispatcher::dispatch(std::unique_ptr<Task> T) { IsMaterializationTask = true; } } else { - // Otherwise decrement work counters. if (IsMaterializationTask) --NumMaterializationThreads; --Outstanding; @@ -78,7 +89,7 @@ void DynamicThreadPoolTaskDispatcher::dispatch(std::unique_ptr<Task> T) { void DynamicThreadPoolTaskDispatcher::shutdown() { std::unique_lock<std::mutex> Lock(DispatchMutex); - Running = false; + Shutdown = true; OutstandingCV.wait(Lock, [this]() { return Outstanding == 0; }); } #endif |