summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-09-25 04:43:38 +0000
committerLang Hames <lhames@gmail.com>2018-09-25 04:43:38 +0000
commit0e5b60326e306cba3f4434692e5d37ffee8a2ae9 (patch)
treef3861542b7857a06845397b7708d143f16f494e7 /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
parent3c3e1c62650abb8692b43ba96b0f252418bc5057 (diff)
downloadbcm5719-llvm-0e5b60326e306cba3f4434692e5d37ffee8a2ae9.tar.gz
bcm5719-llvm-0e5b60326e306cba3f4434692e5d37ffee8a2ae9.zip
[ORC] Switch to asynchronous resolution in JITSymbolResolver.
Asynchronous resolution (where the caller receives a callback once the requested set of symbols are resolved) is a core part of the new concurrent ORC APIs. This change extends the asynchronous resolution model down to RuntimeDyld, which is necessary to prevent deadlocks when compiling/linking on a fixed number of threads: If RuntimeDyld's linking process were a blocking operation, then any complete K-graph in a program will require at least K threads to link in the worst case, as each thread would block waiting for all the others to complete. Using callbacks instead allows the work to be passed between dependent threads until it is complete. For backwards compatibility, all existing RuntimeDyld functions will continue to operate in blocking mode as before. This change will enable the introduction of a new async finalization process in a subsequent patch to enable asynchronous JIT linking. llvm-svn: 342939
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
index fa8906869b3..79a1bbb1a77 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
@@ -16,6 +16,7 @@
#include "llvm/MC/MCInst.h"
#include "llvm/Support/Path.h"
#include <cctype>
+#include <future>
#include <memory>
#include <utility>
@@ -729,15 +730,29 @@ bool RuntimeDyldCheckerImpl::checkAllRulesInBuffer(StringRef RulePrefix,
return DidAllTestsPass && (NumRules != 0);
}
+Expected<JITSymbolResolver::LookupResult> RuntimeDyldCheckerImpl::lookup(
+ const JITSymbolResolver::LookupSet &Symbols) const {
+ auto ResultP = std::make_shared<
+ std::promise<Expected<JITSymbolResolver::LookupResult>>>();
+ auto ResultF = ResultP->get_future();
+
+ getRTDyld().Resolver.lookup(
+ Symbols, [=](Expected<JITSymbolResolver::LookupResult> Result) {
+ ResultP->set_value(std::move(Result));
+ });
+ return ResultF.get();
+}
+
bool RuntimeDyldCheckerImpl::isSymbolValid(StringRef Symbol) const {
if (getRTDyld().getSymbol(Symbol))
return true;
- JITSymbolResolver::LookupSet Symbols({Symbol});
- auto Result = getRTDyld().Resolver.lookup(Symbols);
+ auto Result = lookup({Symbol});
+
if (!Result) {
logAllUnhandledErrors(Result.takeError(), errs(), "RTDyldChecker: ");
return false;
}
+
assert(Result->count(Symbol) && "Missing symbol result");
return true;
}
@@ -751,8 +766,7 @@ uint64_t RuntimeDyldCheckerImpl::getSymbolRemoteAddr(StringRef Symbol) const {
if (auto InternalSymbol = getRTDyld().getSymbol(Symbol))
return InternalSymbol.getAddress();
- JITSymbolResolver::LookupSet Symbols({Symbol});
- auto Result = getRTDyld().Resolver.lookup(Symbols);
+ auto Result = lookup({Symbol});
if (!Result) {
logAllUnhandledErrors(Result.takeError(), errs(), "RTDyldChecker: ");
return 0;
OpenPOWER on IntegriCloud