summaryrefslogtreecommitdiffstats
path: root/lld/lib/Core/File.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-01-16 15:54:13 +0000
committerRui Ueyama <ruiu@google.com>2015-01-16 15:54:13 +0000
commitd4730ea555f1ac7a84a12199a2e9627dc9e4e31c (patch)
tree5a39727b21f5f77c72da370a861fbe9d16473484 /lld/lib/Core/File.cpp
parent694cb5d9b7724a0c6dba3adbf7c855e847a6f0de (diff)
downloadbcm5719-llvm-d4730ea555f1ac7a84a12199a2e9627dc9e4e31c.tar.gz
bcm5719-llvm-d4730ea555f1ac7a84a12199a2e9627dc9e4e31c.zip
Run the resolver in parallel with the reader.
This patch makes File::parse() multi-thread safe. If one thread is running File::parse(), other threads will block if they try to call the same method. File::parse() is idempotent, so you can safely call multiple times. With this change, we don't have to wait for all worker threads to finish in Driver::link(). Previously, Driver::link() calls TaskGroup::sync() to wait for all threads running File::parse(). This was not ideal because we couldn't start the resolver until we parse all files. This patch increase parallelism by making Driver::link() to not wait for worker threads. The resolver calls parse() to make sure that the file being read has been parsed, and then uses the file. In this approach, the resolver can run with the parser threads in parallel. http://reviews.llvm.org/D6994 llvm-svn: 226281
Diffstat (limited to 'lld/lib/Core/File.cpp')
-rw-r--r--lld/lib/Core/File.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lld/lib/Core/File.cpp b/lld/lib/Core/File.cpp
index 624fca9386d..dbac86b368a 100644
--- a/lld/lib/Core/File.cpp
+++ b/lld/lib/Core/File.cpp
@@ -9,6 +9,7 @@
#include "lld/Core/File.h"
#include "lld/Core/LLVM.h"
+#include <mutex>
namespace lld {
@@ -19,4 +20,11 @@ File::atom_collection_empty<UndefinedAtom> File::_noUndefinedAtoms;
File::atom_collection_empty<SharedLibraryAtom> File::_noSharedLibraryAtoms;
File::atom_collection_empty<AbsoluteAtom> File::_noAbsoluteAtoms;
+std::error_code File::parse() {
+ std::lock_guard<std::mutex> lock(_parseMutex);
+ if (!_lastError.hasValue())
+ _lastError = doParse();
+ return _lastError.getValue();
+}
+
} // namespace lld
OpenPOWER on IntegriCloud