Go to the documentation of this file.
13 #ifndef LLVM_EXECUTIONENGINE_ORC_SPECULATION_H
14 #define LLVM_EXECUTIONENGINE_ORC_SPECULATION_H
23 #include <type_traits>
48 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
49 auto Position = Maps.
find(StubSymbol);
50 if (Position != Maps.
end())
51 return Position->getSecond();
56 std::mutex ConcurrentAccess;
70 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
79 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
80 auto It = GlobalSpecMap.
find(FAddr);
81 if (It == GlobalSpecMap.
end())
83 CandidateSet = It->getSecond();
88 for (
auto &Callee : CandidateSet) {
89 auto ImplSymbol = AliaseeImplTable.getImplFor(Callee);
91 if (!ImplSymbol.hasValue())
93 const auto &ImplSymbolName = ImplSymbol.getPointer()->first;
94 JITDylib *ImplJD = ImplSymbol.getPointer()->second;
95 auto &SymbolsInJD = SpeculativeLookUpImpls[ImplJD];
96 SymbolsInJD.insert(ImplSymbolName);
100 for (
auto &
I : SpeculativeLookUpImpls) {
101 llvm::dbgs() <<
"\n In " <<
I.first->getName() <<
" JITDylib ";
102 for (
auto &
N :
I.second)
109 for (
auto &LookupPair : SpeculativeLookUpImpls)
115 [
this](Expected<SymbolMap>
Result) {
116 if (
auto Err =
Result.takeError())
124 : AliaseeImplTable(Impl), ES(ref), GlobalSpecMap(0) {}
141 for (
auto &SymPair : Candidates) {
142 auto Target = SymPair.first;
143 auto Likely = SymPair.second;
145 auto OnReadyFixUp = [Likely,
Target,
148 auto RAddr = (*ReadySymbol)[
Target].getAddress();
149 registerSymbolsWithAddr(RAddr,
std::move(Likely));
166 std::mutex ConcurrentAccess;
181 S(Spec), Mangle(Mangle), QueryAnalysis(
Interpreter) {}
183 void emit(std::unique_ptr<MaterializationResponsibility> R,
189 assert(!IRNames.empty() &&
"No IRNames received to Intern?");
191 for (
auto &NamePair : IRNames) {
193 for (
auto &TargetNames : NamePair.second)
194 TargetJITNames.
insert(Mangle(TargetNames));
195 InternedNames[Mangle(NamePair.first)] =
std::move(TargetJITNames);
197 return InternedNames;
202 MangleAndInterner &Mangle;
209 #endif // LLVM_EXECUTIONENGINE_ORC_SPECULATION_H
This is an optimization pass for GlobalISel generic memory operations.
Represents a JIT'd dynamic library.
void reportError(Error Err)
Report a error for this execution session.
void speculateFor(TargetFAddr StubAddr)
std::pair< SymbolStringPtr, JITDylib * > AliaseeDetails
Target - Wrapper for Target specific information.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
const IRSymbolMapper::ManglingOptions *& getManglingOptions() const
Get the mangling options for this layer.
Tagged union holding either a T or a Error.
std::pair< iterator, bool > insert(const ValueT &V)
std::function< IRlikiesStrRef(Function &)> ResultEval
Speculator & operator=(const Speculator &)=delete
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
IRSpeculationLayer(ExecutionSession &ES, IRLayer &BaseLayer, Speculator &Spec, MangleAndInterner &Mangle, ResultEval Interpreter)
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Speculator(ImplSymbolMap &Impl, ExecutionSession &ref)
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Error addSpeculationRuntime(JITDylib &JD, MangleAndInterner &Mangle)
Define symbols for this Speculator object (__orc_speculator) and the speculation runtime entry point ...
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
iterator find(const_arg_type_t< KeyT > Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Optional< DenseMap< StringRef, DenseSet< StringRef > >> IRlikiesStrRef
void registerSymbols(FunctionCandidatesMap Candidates, JITDylib *JD)
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
@ Ready
Emitted to memory, but waiting on transitive dependencies.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
DenseMap< SymbolStringPtr, SymbolNameSet > TargetAndLikelies
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
Mangles symbol names then uniques them in the context of an ExecutionSession.
void trackImpls(SymbolAliasMap ImplMaps, JITDylib *SrcJD)
Lightweight error class with error context and mandatory checking.
IRLayer(ExecutionSession &ES, const IRSymbolMapper::ManglingOptions *&MO)
An ExecutionSession represents a running JIT program.
ExecutionSession & getES()
DenseMap< TargetFAddr, SymbolNameSet > StubAddrLikelies
uint64_t JITTargetAddress
Represents an address in the target process's address space.
void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
DenseMap< Alias, AliaseeDetails > ImapTy
An LLVM Module together with a shared ThreadSafeContext.
void emit(std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
Emit should materialize the given IR.
Interface for layers that accept LLVM IR.
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...