12#define DEBUG_TYPE "orc"
18constexpr StringRef JumpStubSectionName =
"__orc_stubs";
19constexpr StringRef StubPtrSectionName =
"__orc_stub_ptrs";
20constexpr StringRef StubSuffix =
"$__stub_ptr";
24 std::unique_ptr<MaterializationResponsibility> R,
SymbolMap InitialDests) {
26 auto &ES = ObjLinkingLayer.getExecutionSession();
27 auto G = std::make_unique<jitlink::LinkGraph>(
28 (
"<indirect stubs graph #" +
Twine(++StubGraphIdx) +
">").str(),
31 auto &PointerSection =
37 for (
auto &[Name, Def] : InitialDests) {
40 TargetSym = &
G->addAbsoluteSymbol(
41 G->allocateName(*Name +
"$__init_tgt"), Def.getAddress(), 0,
44 auto PtrName = ES.intern((*Name + StubSuffix).str());
45 auto &
Ptr = AnonymousPtrCreator(*
G, PointerSection, TargetSym, 0);
48 auto &Stub = PtrJumpStubCreator(*
G, StubsSection,
Ptr);
58 if (
auto Err = R->defineMaterializing(std::move(NewSymbols))) {
59 ES.reportError(std::move(Err));
60 return R->failMaterialization();
63 ObjLinkingLayer.emit(std::move(R), std::move(
G));
68 auto &ES = ObjLinkingLayer.getExecutionSession();
71 for (
auto &[StubName, Sym] : NewDests) {
72 auto PtrName = ES.intern((*StubName + StubSuffix).str());
74 LS.add(std::move(PtrName));
79 return PtrSyms.takeError();
81 std::vector<tpctypes::PointerWrite> PtrWrites;
82 for (
auto &[PtrName, PtrSym] : *PtrSyms) {
84 assert(DestSymI != NewDests.
end() &&
"Bad ptr -> stub mapping");
85 auto &DestSym = DestSymI->second;
86 PtrWrites.push_back({PtrSym.getAddress(), DestSym.getAddress()});
89 return ObjLinkingLayer.getExecutionSession()
90 .getExecutorProcessControl()
92 .writePointers(PtrWrites);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
iterator find(const_arg_type_t< KeyT > Val)
Lightweight error class with error context and mandatory checking.
Flags for symbols in the JIT.
StringRef - Represent a constant reference to a string, i.e.
Manages the enabling and disabling of subtarget specific features.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Represents a JIT'd dynamic library.
void emitRedirectableSymbols(std::unique_ptr< MaterializationResponsibility > R, SymbolMap InitialDests) override
Emit redirectable symbol.
Error redirect(JITDylib &JD, const SymbolMap &NewDests) override
Change the redirection destination of given symbols to new destination symbols.
Non-owning SymbolStringPool entry pointer.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
LLVM_ABI const char * getGenericEdgeKindName(Edge::Kind K)
Returns the string name of the given generic edge kind, or "unknown" otherwise.
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
This is an optimization pass for GlobalISel generic memory operations.