diff --git a/llvm/lib/Support/Parallel.cpp b/llvm/lib/Support/Parallel.cpp --- a/llvm/lib/Support/Parallel.cpp +++ b/llvm/lib/Support/Parallel.cpp @@ -53,7 +53,9 @@ Stop = true; Lock.unlock(); Cond.notify_all(); - // Wait for ~Latch. + // Explicitly wait threads to complete, otherwise the instance variables of + // this class can be prematurely destroyed. + Done.sync(); } void add(std::function F) override {