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 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);
55 if (
auto Err = R->defineMaterializing(std::move(NewSymbols))) {
56 ES.reportError(std::move(Err));
57 return R->failMaterialization();
60 ObjLinkingLayer.
emit(std::move(R), std::move(
G));
68 for (
auto &[StubName,
Sym] : NewDests) {
69 auto PtrName = ES.intern((*StubName + StubSuffix).str());
71 LS.add(std::move(PtrName));
76 return PtrSyms.takeError();
78 std::vector<tpctypes::PointerWrite> PtrWrites;
79 for (
auto &[PtrName, PtrSym] : *PtrSyms) {
81 assert(DestSymI != NewDests.
end() &&
"Bad ptr -> stub mapping");
82 auto &DestSym = DestSymI->second;
83 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.
Manages the enabling and disabling of subtarget specific features.
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.