13 #ifndef LLVM_EXECUTIONENGINE_ORC_SPECULATION_H 14 #define LLVM_EXECUTIONENGINE_ORC_SPECULATION_H 26 #include <type_traits> 52 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
60 std::mutex ConcurrentAccess;
74 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
75 GlobalSpecMap.insert({ImplAddr, std::move(likelySymbols)});
83 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
84 auto It = GlobalSpecMap.find(FAddr);
85 if (It == GlobalSpecMap.end())
87 CandidateSet = It->getSecond();
92 for (
auto &
Callee : CandidateSet) {
93 auto ImplSymbol = AliaseeImplTable.getImplFor(
Callee);
95 if (!ImplSymbol.hasValue())
97 const auto &ImplSymbolName = ImplSymbol.getPointer()->first;
98 JITDylib *ImplJD = ImplSymbol.getPointer()->second;
99 auto &SymbolsInJD = SpeculativeLookUpImpls[ImplJD];
100 SymbolsInJD.
insert(ImplSymbolName);
104 for (
auto &
I : SpeculativeLookUpImpls) {
105 llvm::dbgs() <<
"\n In " <<
I.first->getName() <<
" JITDylib ";
106 for (
auto &
N :
I.second)
113 for (
auto &LookupPair : SpeculativeLookUpImpls)
120 if (auto Err = Result.takeError())
121 ES.reportError(std::move(Err));
128 : AliaseeImplTable(Impl), ES(ref), GlobalSpecMap(0) {}
145 for (
auto &SymPair : Candidates) {
146 auto Target = SymPair.first;
147 auto Likely = SymPair.second;
149 auto OnReadyFixUp = [Likely,
Target,
152 auto RAddr = (*ReadySymbol)[Target].getAddress();
153 registerSymbolsWithAddr(RAddr, std::move(Likely));
155 this->getES().reportError(ReadySymbol.takeError());
169 static void speculateForEntryPoint(
Speculator *Ptr, uint64_t StubId);
170 std::mutex ConcurrentAccess;
179 using ResultEval = std::function<IRlikiesStrRef(Function &)>;
185 :
IRLayer(ES, BaseLayer.getManglingOptions()), NextLayer(BaseLayer),
186 S(Spec), Mangle(Mangle), QueryAnalysis(Interpreter) {}
193 assert(!IRNames.empty() &&
"No IRNames received to Intern?");
196 for (
auto &NamePair : IRNames) {
197 for (
auto &TargetNames : NamePair.second)
198 TargetJITNames.
insert(Mangle(TargetNames));
200 InternedNames[Mangle(NamePair.first)] = std::move(TargetJITNames);
202 return InternedNames;
214 #endif // LLVM_EXECUTIONENGINE_ORC_SPECULATION_H Speculator(ImplSymbolMap &Impl, ExecutionSession &ref)
Interfaces for registering analysis passes, producing common pass manager configurations, and parsing of pass pipelines.
This class represents lattice values for constants.
JITTargetAddress TargetFAddr
std::function< IRlikiesStrRef(Function &)> ResultEval
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Mangles symbol names then uniques them in the context of an ExecutionSession.
Tagged union holding either a T or a Error.
Position
Position to insert a new instruction relative to an existing instruction.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
void speculateFor(TargetFAddr StubAddr)
uint64_t JITTargetAddress
Represents an address in the target process's address space.
void trackImpls(SymbolAliasMap ImplMaps, JITDylib *SrcJD)
Pointer to a pooled string representing a symbol name.
iterator find(const_arg_type_t< KeyT > Val)
std::pair< SymbolStringPtr, JITDylib * > AliaseeDetails
std::pair< iterator, bool > insert(const ValueT &V)
IRSpeculationLayer(ExecutionSession &ES, IRCompileLayer &BaseLayer, Speculator &Spec, MangleAndInterner &Mangle, ResultEval Interpreter)
void registerSymbols(FunctionCandidatesMap Candidates, JITDylib *JD)
An LLVM Module together with a shared ThreadSafeContext.
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...
Interface for layers that accept LLVM IR.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Emitted to memory, but waiting on transitive dependencies.
An ExecutionSession represents a running JIT program.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Target - Wrapper for Target specific information.
amdgpu Simplify well known AMD library false FunctionCallee Callee
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
This header defines various interfaces for pass management in LLVM.
ExecutionSession & getES()
A symbol table that supports asynchoronous symbol queries.