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) {
27 Triple TT = ES.getTargetTriple();
29 auto G = std::make_unique<jitlink::LinkGraph>(
30 (
"<indirect stubs graph #" +
Twine(++StubGraphIdx) +
">").str(),
31 ES.getSymbolStringPool(), TT, TT.isArch64Bit() ? 8 : 4,
34 auto &PointerSection =
40 for (
auto &[
Name, Def] : InitialDests) {
43 TargetSym = &
G->addAbsoluteSymbol(
44 G->allocateName(*
Name +
"$__init_tgt"), Def.getAddress(), 0,
47 auto PtrName = ES.intern((*
Name + StubSuffix).str());
48 auto &
Ptr = AnonymousPtrCreator(*
G, PointerSection, TargetSym, 0);
51 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));
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()});
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Error writePointers(ArrayRef< tpctypes::PointerWrite > Ws)
MemoryAccess & getMemoryAccess() const
Return a MemoryAccess object for the target process.
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.
ExecutionSession & getExecutionSession()
Non-owning SymbolStringPool entry pointer.
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Emit an object file.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
const char * getGenericEdgeKindName(Edge::Kind K)
Returns the string name of the given generic edge kind, or "unknown" otherwise.
This is an optimization pass for GlobalISel generic memory operations.