13#ifndef LLVM_EXECUTIONENGINE_ORC_SPECULATION_H
14#define LLVM_EXECUTIONENGINE_ORC_SPECULATION_H
46 std::optional<AliaseeDetails> getImplFor(
const SymbolStringPtr &StubSymbol) {
47 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
48 auto Position = Maps.
find(StubSymbol);
49 if (Position != Maps.
end())
50 return Position->getSecond();
55 std::mutex ConcurrentAccess;
69 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
70 GlobalSpecMap.
insert({ImplAddr, std::move(likelySymbols)});
78 std::lock_guard<std::mutex> Lockit(ConcurrentAccess);
79 auto It = GlobalSpecMap.
find(FAddr);
80 if (It == GlobalSpecMap.
end())
82 CandidateSet = It->getSecond();
87 for (
auto &
Callee : CandidateSet) {
88 auto ImplSymbol = AliaseeImplTable.getImplFor(
Callee);
92 const auto &ImplSymbolName = ImplSymbol->first;
93 JITDylib *ImplJD = ImplSymbol->second;
94 auto &SymbolsInJD = SpeculativeLookUpImpls[ImplJD];
95 SymbolsInJD.insert(ImplSymbolName);
99 for (
auto &
I : SpeculativeLookUpImpls) {
100 llvm::dbgs() <<
"\n In " <<
I.first->getName() <<
" JITDylib ";
101 for (
auto &
N :
I.second)
108 for (
auto &LookupPair : SpeculativeLookUpImpls)
114 [
this](Expected<SymbolMap>
Result) {
115 if (
auto Err =
Result.takeError())
123 : AliaseeImplTable(Impl), ES(ref), GlobalSpecMap(0) {}
140 for (
auto &SymPair : Candidates) {
141 auto Target = SymPair.first;
142 auto Likely = SymPair.second;
144 auto OnReadyFixUp = [Likely,
Target,
147 auto RAddr = (*ReadySymbol)[
Target].getAddress();
148 registerSymbolsWithAddr(RAddr, std::move(Likely));
165 std::mutex ConcurrentAccess;
174 std::optional<DenseMap<StringRef, DenseSet<StringRef>>>;
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;
amdgpu Simplify well known AMD library false FunctionCallee Callee
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
This file defines the DenseMap class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
std::pair< iterator, bool > insert(const ValueT &V)
An ExecutionSession represents a running JIT program.
void reportError(Error Err)
Report a error for this execution session.
void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
Interface for layers that accept LLVM IR.
const IRSymbolMapper::ManglingOptions *& getManglingOptions() const
Get the mangling options for this layer.
IRSpeculationLayer(ExecutionSession &ES, IRLayer &BaseLayer, Speculator &Spec, MangleAndInterner &Mangle, ResultEval Interpreter)
std::function< IRlikiesStrRef(Function &)> ResultEval
DenseMap< SymbolStringPtr, SymbolNameSet > TargetAndLikelies
std::optional< DenseMap< StringRef, DenseSet< StringRef > > > IRlikiesStrRef
void trackImpls(SymbolAliasMap ImplMaps, JITDylib *SrcJD)
DenseMap< Alias, AliaseeDetails > ImapTy
std::pair< SymbolStringPtr, JITDylib * > AliaseeDetails
Represents a JIT'd dynamic library.
Mangles symbol names then uniques them in the context of an ExecutionSession.
Speculator(ImplSymbolMap &Impl, ExecutionSession &ref)
ExecutionSession & getES()
Speculator & operator=(const Speculator &)=delete
Speculator & operator=(Speculator &&)=delete
DenseMap< TargetFAddr, SymbolNameSet > StubAddrLikelies
Speculator(Speculator &&)=delete
Error addSpeculationRuntime(JITDylib &JD, MangleAndInterner &Mangle)
Define symbols for this Speculator object (__orc_speculator) and the speculation runtime entry point ...
Speculator(const Speculator &)=delete
void registerSymbols(FunctionCandidatesMap Candidates, JITDylib *JD)
void speculateFor(TargetFAddr StubAddr)
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
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...
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
@ Ready
Emitted to memory, but waiting on transitive dependencies.
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
This is an optimization pass for GlobalISel generic memory operations.
uint64_t JITTargetAddress
Represents an address in the target process's address space.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.