LLVM  7.0.0
Legacy.cpp
Go to the documentation of this file.
1 //===------- Legacy.cpp - Adapters for ExecutionEngine API interop --------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
11 
12 namespace llvm {
13 namespace orc {
14 
15 void SymbolResolver::anchor() {}
16 
19  : ES(ES), R(R), MR(MR) {}
20 
23  SymbolNameSet InternedSymbols;
24  for (auto &S : Symbols)
25  InternedSymbols.insert(ES.getSymbolStringPool().intern(S));
26 
27  auto LookupFn = [&, this](std::shared_ptr<AsynchronousSymbolQuery> Q,
28  SymbolNameSet Unresolved) {
29  return R.lookup(std::move(Q), std::move(Unresolved));
30  };
31 
32  auto RegisterDependencies = [&](const SymbolDependenceMap &Deps) {
33  if (MR)
34  MR->addDependenciesForAll(Deps);
35  };
36 
37  auto InternedResult =
38  ES.legacyLookup(ES, std::move(LookupFn), std::move(InternedSymbols),
39  false, RegisterDependencies);
40 
41  if (!InternedResult)
42  return InternedResult.takeError();
43 
45  for (auto &KV : *InternedResult)
46  Result[*KV.first] = KV.second;
47 
48  return Result;
49 }
50 
53  SymbolNameSet InternedSymbols;
54  for (auto &S : Symbols)
55  InternedSymbols.insert(ES.getSymbolStringPool().intern(S));
56 
57  SymbolFlagsMap SymbolFlags = R.lookupFlags(InternedSymbols);
59  for (auto &KV : SymbolFlags) {
60  ResolvedStrings.insert(KV.first);
61  Result[*KV.first] = KV.second;
62  }
63 
64  return Result;
65 }
66 
67 } // End namespace orc.
68 } // End namespace llvm.
std::map< StringRef, JITSymbolFlags > LookupFlagsResult
Definition: JITSymbol.h:296
Expected< LookupResult > lookup(const LookupSet &Symbols) override
Returns the fully resolved address and flags for each of the given symbols.
Definition: Legacy.cpp:22
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
std::set< StringRef > LookupSet
Definition: JITSymbol.h:294
std::map< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
Definition: Core.h:57
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:124
JITSymbolResolverAdapter(ExecutionSession &ES, SymbolResolver &R, MaterializationResponsibility *MR)
Definition: Legacy.cpp:17
SymbolStringPtr intern(StringRef S)
Create a symbol string pointer from the given string.
SymbolStringPool & getSymbolStringPool() const
Returns the SymbolStringPool for this ExecutionSession.
Definition: Core.h:367
virtual SymbolFlagsMap lookupFlags(const SymbolNameSet &Symbols)=0
Returns the flags for each symbol in Symbols that can be found, along with the set of symbol that cou...
void addDependenciesForAll(const SymbolDependenceMap &Dependencies)
Add dependencies that apply to all symbols covered by this instance.
Definition: Core.cpp:695
std::map< VSO *, SymbolNameSet > SymbolDependenceMap
A base class for materialization failures that allows the failing symbols to be obtained for logging...
Definition: Core.h:64
An ExecutionSession represents a running JIT program.
Definition: Core.h:735
SymbolResolver is a composable interface for looking up symbol flags and addresses using the Asynchro...
Definition: Legacy.h:30
virtual SymbolNameSet lookup(std::shared_ptr< AsynchronousSymbolQuery > Query, SymbolNameSet Symbols)=0
For each symbol in Symbols that can be found, assigns that symbols value in Query.
Expected< SymbolMap > legacyLookup(ExecutionSessionBase &ES, LegacyAsyncLookupFunction AsyncLookup, SymbolNameSet Names, bool WaiUntilReady, RegisterDependenciesFunction RegisterDependencies)
A legacy lookup function for JITSymbolResolverAdapter.
Definition: Core.cpp:161
std::map< StringRef, JITEvaluatedSymbol > LookupResult
Definition: JITSymbol.h:295
Expected< LookupFlagsResult > lookupFlags(const LookupSet &Symbols) override
Returns the symbol flags for each of the given symbols.
Definition: Legacy.cpp:52
std::set< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
Definition: Core.h:44