COFF: Fix thread-safety bug.
LTOModule doesn't seem to be thread-safe, so guard that with mutex.
llvm-svn: 248102
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index df92c43..6fdb8e2 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -310,6 +310,9 @@
}
void BitcodeFile::parse() {
+ // Usually parse() is thread-safe, but bitcode file is an exception.
+ std::lock_guard<std::mutex> Lock(Mu);
+
std::string Err;
M.reset(LTOModule::createFromBuffer(MB.getBufferStart(),
MB.getBufferSize(),
@@ -356,5 +359,7 @@
}
}
+std::mutex BitcodeFile::Mu;
+
} // namespace coff
} // namespace lld