[ORC] Remove the optional MaterializationResponsibility argument from lookup.
The lookup function provides blocking symbol resolution for JIT clients (not layers themselves) so it does not need to track symbol dependencies via a MaterializationResponsibility. llvm-svn: 332897
This commit is contained in:
parent
1cf9987f6e
commit
add9b6805c
|
@ -614,19 +614,11 @@ private:
|
||||||
/// VSOs will be searched in order and no VSO pointer may be null.
|
/// VSOs will be searched in order and no VSO pointer may be null.
|
||||||
/// All symbols must be found within the given VSOs or an error
|
/// All symbols must be found within the given VSOs or an error
|
||||||
/// will be returned.
|
/// will be returned.
|
||||||
///
|
Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names);
|
||||||
/// If this lookup is being performed on behalf of a
|
|
||||||
/// MaterializationResponsibility then it must be passed in as R
|
|
||||||
/// (in order to record the symbol dependencies).
|
|
||||||
/// If this lookup is not being performed on behalf of a
|
|
||||||
/// MaterializationResponsibility then R should be left null.
|
|
||||||
Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names,
|
|
||||||
MaterializationResponsibility *R);
|
|
||||||
|
|
||||||
/// Look up a symbol by searching a list of VSOs.
|
/// Look up a symbol by searching a list of VSOs.
|
||||||
Expected<JITEvaluatedSymbol> lookup(const std::vector<VSO *> VSOs,
|
Expected<JITEvaluatedSymbol> lookup(const std::vector<VSO *> VSOs,
|
||||||
SymbolStringPtr Name,
|
SymbolStringPtr Name);
|
||||||
MaterializationResponsibility *R);
|
|
||||||
|
|
||||||
} // End namespace orc
|
} // End namespace orc
|
||||||
} // End namespace llvm
|
} // End namespace llvm
|
||||||
|
|
|
@ -843,8 +843,7 @@ VSO &ExecutionSession::createVSO(std::string Name) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names,
|
Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names) {
|
||||||
MaterializationResponsibility *R) {
|
|
||||||
#if LLVM_ENABLE_THREADS
|
#if LLVM_ENABLE_THREADS
|
||||||
// In the threaded case we use promises to return the results.
|
// In the threaded case we use promises to return the results.
|
||||||
std::promise<SymbolMap> PromisedResult;
|
std::promise<SymbolMap> PromisedResult;
|
||||||
|
@ -854,11 +853,9 @@ Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names,
|
||||||
Error ReadyError = Error::success();
|
Error ReadyError = Error::success();
|
||||||
auto OnResolve =
|
auto OnResolve =
|
||||||
[&](Expected<AsynchronousSymbolQuery::ResolutionResult> Result) {
|
[&](Expected<AsynchronousSymbolQuery::ResolutionResult> Result) {
|
||||||
if (Result) {
|
if (Result)
|
||||||
if (R)
|
|
||||||
R->addDependencies(Result->Dependencies);
|
|
||||||
PromisedResult.set_value(std::move(Result->Symbols));
|
PromisedResult.set_value(std::move(Result->Symbols));
|
||||||
} else {
|
else {
|
||||||
{
|
{
|
||||||
ErrorAsOutParameter _(&ResolutionError);
|
ErrorAsOutParameter _(&ResolutionError);
|
||||||
std::lock_guard<std::mutex> Lock(ErrMutex);
|
std::lock_guard<std::mutex> Lock(ErrMutex);
|
||||||
|
@ -880,14 +877,12 @@ Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names,
|
||||||
Error ResolutionError = Error::success();
|
Error ResolutionError = Error::success();
|
||||||
Error ReadyError = Error::success();
|
Error ReadyError = Error::success();
|
||||||
|
|
||||||
auto OnResolve = [&](Expected<AsynchronousSymbolQuery::ResolutionResult> RR) {
|
auto OnResolve = [&](Expected<AsynchronousSymbolQuery::ResolutionResult> R) {
|
||||||
ErrorAsOutParameter _(&ResolutionError);
|
ErrorAsOutParameter _(&ResolutionError);
|
||||||
if (RR) {
|
if (R)
|
||||||
if (R)
|
Result = std::move(R->Symbols);
|
||||||
R->addDependencies(RR->Dependencies);
|
else
|
||||||
Result = std::move(RR->Symbols);
|
ResolutionError = R.takeError();
|
||||||
} else
|
|
||||||
ResolutionError = RR.takeError();
|
|
||||||
};
|
};
|
||||||
auto OnReady = [&](Error Err) {
|
auto OnReady = [&](Error Err) {
|
||||||
ErrorAsOutParameter _(&ReadyError);
|
ErrorAsOutParameter _(&ReadyError);
|
||||||
|
@ -949,10 +944,9 @@ Expected<SymbolMap> lookup(const std::vector<VSO *> &VSOs, SymbolNameSet Names,
|
||||||
|
|
||||||
/// Look up a symbol by searching a list of VSOs.
|
/// Look up a symbol by searching a list of VSOs.
|
||||||
Expected<JITEvaluatedSymbol> lookup(const std::vector<VSO *> VSOs,
|
Expected<JITEvaluatedSymbol> lookup(const std::vector<VSO *> VSOs,
|
||||||
SymbolStringPtr Name,
|
SymbolStringPtr Name) {
|
||||||
MaterializationResponsibility *R) {
|
|
||||||
SymbolNameSet Names({Name});
|
SymbolNameSet Names({Name});
|
||||||
if (auto ResultMap = lookup(VSOs, std::move(Names), R)) {
|
if (auto ResultMap = lookup(VSOs, std::move(Names))) {
|
||||||
assert(ResultMap->size() == 1 && "Unexpected number of results");
|
assert(ResultMap->size() == 1 && "Unexpected number of results");
|
||||||
assert(ResultMap->count(Name) && "Missing result for symbol");
|
assert(ResultMap->count(Name) && "Missing result for symbol");
|
||||||
return std::move(ResultMap->begin()->second);
|
return std::move(ResultMap->begin()->second);
|
||||||
|
|
|
@ -641,7 +641,7 @@ TEST(CoreAPIsTest, TestLookupWithUnthreadedMaterialization) {
|
||||||
|
|
||||||
cantFail(V.define(MU));
|
cantFail(V.define(MU));
|
||||||
|
|
||||||
auto FooLookupResult = cantFail(lookup({&V}, Foo, nullptr));
|
auto FooLookupResult = cantFail(lookup({&V}, Foo));
|
||||||
|
|
||||||
EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress())
|
EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress())
|
||||||
<< "lookup returned an incorrect address";
|
<< "lookup returned an incorrect address";
|
||||||
|
@ -668,7 +668,7 @@ TEST(CoreAPIsTest, TestLookupWithThreadedMaterialization) {
|
||||||
auto &V = ES.createVSO("V");
|
auto &V = ES.createVSO("V");
|
||||||
cantFail(V.define(absoluteSymbols({{Foo, FooSym}})));
|
cantFail(V.define(absoluteSymbols({{Foo, FooSym}})));
|
||||||
|
|
||||||
auto FooLookupResult = cantFail(lookup({&V}, Foo, nullptr));
|
auto FooLookupResult = cantFail(lookup({&V}, Foo));
|
||||||
|
|
||||||
EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress())
|
EXPECT_EQ(FooLookupResult.getAddress(), FooSym.getAddress())
|
||||||
<< "lookup returned an incorrect address";
|
<< "lookup returned an incorrect address";
|
||||||
|
|
Loading…
Reference in New Issue