mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-17 09:26:07 +00:00

The new method name/behavior more closely models the way it was being used. It also fixes an assertion that can occur when using the new ORC Core APIs, where flags alone don't necessarily provide enough context to decide whether the caller is responsible for materializing a given symbol (which was always the reason this API existed). The default implementation of getResponsibilitySet uses lookupFlags to determine responsibility as before, so existing JITSymbolResolvers should continue to work. llvm-svn: 340874
69 lines
2.0 KiB
C++
69 lines
2.0 KiB
C++
//===------- Legacy.cpp - Adapters for ExecutionEngine API interop --------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ExecutionEngine/Orc/Legacy.h"
|
|
|
|
namespace llvm {
|
|
namespace orc {
|
|
|
|
void SymbolResolver::anchor() {}
|
|
|
|
JITSymbolResolverAdapter::JITSymbolResolverAdapter(
|
|
ExecutionSession &ES, SymbolResolver &R, MaterializationResponsibility *MR)
|
|
: ES(ES), R(R), MR(MR) {}
|
|
|
|
Expected<JITSymbolResolverAdapter::LookupResult>
|
|
JITSymbolResolverAdapter::lookup(const LookupSet &Symbols) {
|
|
SymbolNameSet InternedSymbols;
|
|
for (auto &S : Symbols)
|
|
InternedSymbols.insert(ES.getSymbolStringPool().intern(S));
|
|
|
|
auto LookupFn = [&, this](std::shared_ptr<AsynchronousSymbolQuery> Q,
|
|
SymbolNameSet Unresolved) {
|
|
return R.lookup(std::move(Q), std::move(Unresolved));
|
|
};
|
|
|
|
auto RegisterDependencies = [&](const SymbolDependenceMap &Deps) {
|
|
if (MR)
|
|
MR->addDependenciesForAll(Deps);
|
|
};
|
|
|
|
auto InternedResult =
|
|
ES.legacyLookup(ES, std::move(LookupFn), std::move(InternedSymbols),
|
|
false, RegisterDependencies);
|
|
|
|
if (!InternedResult)
|
|
return InternedResult.takeError();
|
|
|
|
JITSymbolResolver::LookupResult Result;
|
|
for (auto &KV : *InternedResult)
|
|
Result[*KV.first] = KV.second;
|
|
|
|
return Result;
|
|
}
|
|
|
|
Expected<JITSymbolResolverAdapter::LookupSet>
|
|
JITSymbolResolverAdapter::getResponsibilitySet(const LookupSet &Symbols) {
|
|
SymbolNameSet InternedSymbols;
|
|
for (auto &S : Symbols)
|
|
InternedSymbols.insert(ES.getSymbolStringPool().intern(S));
|
|
|
|
auto InternedResult = R.getResponsibilitySet(InternedSymbols);
|
|
LookupSet Result;
|
|
for (auto &S : InternedResult) {
|
|
ResolvedStrings.insert(S);
|
|
Result.insert(*S);
|
|
}
|
|
|
|
return Result;
|
|
}
|
|
|
|
} // End namespace orc.
|
|
} // End namespace llvm.
|