diff options
Diffstat (limited to 'lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp')
| -rw-r--r-- | lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp index fa8906869b3a..6eb6256080ff 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp @@ -14,8 +14,10 @@ #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDisassembler/MCDisassembler.h" #include "llvm/MC/MCInst.h" +#include "llvm/Support/MSVCErrorWorkarounds.h" #include "llvm/Support/Path.h" #include <cctype> +#include <future> #include <memory> #include <utility> @@ -729,15 +731,35 @@ bool RuntimeDyldCheckerImpl::checkAllRulesInBuffer(StringRef RulePrefix, return DidAllTestsPass && (NumRules != 0); } +Expected<JITSymbolResolver::LookupResult> RuntimeDyldCheckerImpl::lookup( + const JITSymbolResolver::LookupSet &Symbols) const { + +#ifdef _MSC_VER + using ExpectedLookupResult = MSVCPExpected<JITSymbolResolver::LookupResult>; +#else + using ExpectedLookupResult = Expected<JITSymbolResolver::LookupResult>; +#endif + + auto ResultP = std::make_shared<std::promise<ExpectedLookupResult>>(); + 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 +773,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; |
