21#define DEBUG_TYPE "orc"
29template <
typename SPSSerializer,
typename... ArgTs>
31getArgDataBufferType(
const ArgTs &...Args) {
33 ArgData.
resize(SPSSerializer::size(Args...));
36 if (SPSSerializer::serialize(OB, Args...))
41std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(
ELFNixPlatform &MOP,
47 switch (TT.getArch()) {
68 return std::make_unique<jitlink::LinkGraph>(
74class ELFNixPlatformCompleteBootstrapMaterializationUnit
77 ELFNixPlatformCompleteBootstrapMaterializationUnit(
85 MOP(MOP), PlatformJDName(PlatformJDName),
86 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
87 DeferredAAsMap(std::move(DeferredAAs)),
88 ELFNixHeaderAddr(ELFNixHeaderAddr),
89 PlatformBootstrap(PlatformBootstrap),
90 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
91 DeregisterJITDylib(DeregisterJITDylib) {}
94 return "ELFNixPlatformCompleteBootstrap";
97 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
98 using namespace jitlink;
99 auto G = createPlatformGraph(MOP,
"<OrcRTCompleteBootstrap>");
100 auto &PlaceholderSection =
101 G->createSection(
"__orc_rt_cplt_bs", MemProt::Read);
102 auto &PlaceholderBlock =
103 G->createZeroFillBlock(PlaceholderSection, 1,
ExecutorAddr(), 1, 0);
104 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
105 Linkage::Strong, Scope::Hidden,
false,
true);
108 G->allocActions().push_back(
110 PlatformBootstrap, ELFNixHeaderAddr)),
115 G->allocActions().push_back(
118 RegisterJITDylib, PlatformJDName, ELFNixHeaderAddr)),
120 DeregisterJITDylib, ELFNixHeaderAddr))});
123 for (
auto &[Fn, CallDatas] : DeferredAAsMap) {
124 for (
auto &CallData : CallDatas) {
125 G->allocActions().push_back(
153 createDSOHandleSectionInterface(ENP, DSOHandleSymbol)),
158 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
159 unsigned PointerSize;
164 switch (TT.getArch()) {
190 auto G = std::make_unique<jitlink::LinkGraph>(
193 auto &DSOHandleSection =
194 G->createSection(
".data.__dso_handle", MemProt::Read);
195 auto &DSOHandleBlock =
G->createContentBlock(
198 auto &DSOHandleSymbol =
G->addDefinedSymbol(
199 DSOHandleBlock, 0, *R->getInitializerSymbol(), DSOHandleBlock.getSize(),
200 jitlink::Linkage::Strong, jitlink::Scope::Default,
false,
true);
201 DSOHandleBlock.addEdge(EdgeKind, 0, DSOHandleSymbol, 0);
219 static const char Content[8] = {0};
235 std::unique_ptr<DefinitionGenerator> OrcRuntime,
236 std::optional<SymbolAliasMap> RuntimeAliases) {
242 return make_error<StringError>(
"Unsupported ELFNixPlatform triple: " +
249 if (!RuntimeAliases) {
251 if (!StandardRuntimeAliases)
252 return StandardRuntimeAliases.takeError();
253 RuntimeAliases = std::move(*StandardRuntimeAliases);
258 return std::move(Err);
261 if (
auto Err = PlatformJD.
define(
263 {EPC.getJITDispatchInfo().JITDispatchFunction,
265 {ES.
intern(
"__orc_rt_jit_dispatch_ctx"),
266 {EPC.getJITDispatchInfo().JITDispatchContext,
268 return std::move(Err);
273 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
275 return std::move(Err);
281 JITDylib &PlatformJD,
const char *OrcRuntimePath,
282 std::optional<SymbolAliasMap> RuntimeAliases) {
285 auto OrcRuntimeArchiveGenerator =
287 if (!OrcRuntimeArchiveGenerator)
288 return OrcRuntimeArchiveGenerator.takeError();
290 return Create(ObjLinkingLayer, PlatformJD,
291 std::move(*OrcRuntimeArchiveGenerator),
292 std::move(RuntimeAliases));
296 if (
auto Err = JD.
define(std::make_unique<DSOHandleMaterializationUnit>(
297 *
this, DSOHandleSymbol)))
300 return ES.
lookup({&JD}, DSOHandleSymbol).takeError();
304 std::lock_guard<std::mutex> Lock(PlatformMutex);
305 auto I = JITDylibToHandleAddr.find(&JD);
306 if (
I != JITDylibToHandleAddr.end()) {
307 assert(HandleAddrToJITDylib.count(
I->second) &&
308 "HandleAddrToJITDylib missing entry");
309 HandleAddrToJITDylib.erase(
I->second);
310 JITDylibToHandleAddr.erase(
I);
323 RegisteredInitSymbols[&JD].add(InitSym,
326 dbgs() <<
"ELFNixPlatform: Registered init symbol " << *InitSym
327 <<
" for MU " << MU.
getName() <<
"\n";
337 ArrayRef<std::pair<const char *, const char *>> AL) {
338 for (
auto &KV : AL) {
339 auto AliasName = ES.
intern(KV.first);
340 assert(!Aliases.
count(AliasName) &&
"Duplicate symbol name in alias map");
341 Aliases[std::move(AliasName)] = {ES.
intern(KV.second),
358 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
359 {
"__cxa_atexit",
"__orc_rt_elfnix_cxa_atexit"},
360 {
"atexit",
"__orc_rt_elfnix_atexit"}};
367 static const std::pair<const char *, const char *>
368 StandardRuntimeUtilityAliases[] = {
369 {
"__orc_rt_run_program",
"__orc_rt_elfnix_run_program"},
370 {
"__orc_rt_jit_dlerror",
"__orc_rt_elfnix_jit_dlerror"},
371 {
"__orc_rt_jit_dlopen",
"__orc_rt_elfnix_jit_dlopen"},
372 {
"__orc_rt_jit_dlupdate",
"__orc_rt_elfnix_jit_dlupdate"},
373 {
"__orc_rt_jit_dlclose",
"__orc_rt_elfnix_jit_dlclose"},
374 {
"__orc_rt_jit_dlsym",
"__orc_rt_elfnix_jit_dlsym"},
375 {
"__orc_rt_log_error",
"__orc_rt_log_error_to_stderr"}};
378 StandardRuntimeUtilityAliases);
383 static const std::pair<const char *, const char *>
384 StandardLazyCompilationAliases[] = {
385 {
"__orc_rt_reenter",
"__orc_rt_sysv_reenter"}};
388 StandardLazyCompilationAliases);
391bool ELFNixPlatform::supportedTarget(
const Triple &TT) {
392 switch (TT.getArch()) {
404ELFNixPlatform::ELFNixPlatform(
406 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
Error &Err)
407 : ES(ObjLinkingLayer.getExecutionSession()), PlatformJD(PlatformJD),
408 ObjLinkingLayer(ObjLinkingLayer),
409 DSOHandleSymbol(ES.intern(
"__dso_handle")) {
411 ObjLinkingLayer.
addPlugin(std::make_unique<ELFNixPlatformPlugin>(*
this));
413 PlatformJD.
addGenerator(std::move(OrcRuntimeGenerator));
430 {PlatformBootstrap.
Name, PlatformShutdown.
Name,
431 RegisterJITDylib.
Name, DeregisterJITDylib.
Name,
432 RegisterInitSections.
Name, DeregisterInitSections.
Name,
433 RegisterObjectSections.
Name,
434 DeregisterObjectSections.
Name, CreatePThreadKey.
Name}))
440 std::unique_lock<std::mutex> Lock(BI.Mutex);
441 BI.CV.wait(Lock, [&]() {
return BI.ActiveGraphs == 0; });
446 auto BootstrapCompleteSymbol =
447 ES.
intern(
"__orc_rt_elfnix_complete_bootstrap");
448 if ((Err = PlatformJD.
define(
449 std::make_unique<ELFNixPlatformCompleteBootstrapMaterializationUnit>(
450 *
this, PlatformJD.
getName(), BootstrapCompleteSymbol,
451 std::move(BI.DeferredRTFnMap), BI.ELFNixHeaderAddr,
452 PlatformBootstrap.
Addr, PlatformShutdown.
Addr,
453 RegisterJITDylib.
Addr, DeregisterJITDylib.
Addr))))
457 std::move(BootstrapCompleteSymbol))
462 if (
auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
468Error ELFNixPlatform::associateRuntimeSupportFunctions(
JITDylib &PlatformJD) {
471 using RecordInitializersSPSSig =
473 WFs[ES.
intern(
"__orc_rt_elfnix_push_initializers_tag")] =
475 this, &ELFNixPlatform::rt_recordInitializers);
477 using LookupSymbolSPSSig =
479 WFs[ES.
intern(
"__orc_rt_elfnix_symbol_lookup_tag")] =
481 &ELFNixPlatform::rt_lookupSymbol);
486void ELFNixPlatform::pushInitializersLoop(
487 PushInitializersSendResultFn SendResult,
JITDylibSP JD) {
493 while (!Worklist.empty()) {
496 auto DepJD = Worklist.back();
500 if (JDDepMap.count(DepJD))
504 auto &DM = JDDepMap[DepJD];
505 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
507 if (KV.first == DepJD)
509 DM.push_back(KV.first);
510 Worklist.push_back(KV.first);
515 auto RISItr = RegisteredInitSymbols.find(DepJD);
516 if (RISItr != RegisteredInitSymbols.end()) {
517 NewInitSymbols[DepJD] = std::move(RISItr->second);
518 RegisteredInitSymbols.erase(RISItr);
525 if (NewInitSymbols.
empty()) {
534 std::lock_guard<std::mutex> Lock(PlatformMutex);
535 for (
auto &KV : JDDepMap) {
536 auto I = JITDylibToHandleAddr.find(KV.first);
537 if (
I != JITDylibToHandleAddr.end())
538 HeaderAddrs[KV.first] =
I->second;
544 DIM.reserve(JDDepMap.size());
545 for (
auto &KV : JDDepMap) {
546 auto HI = HeaderAddrs.
find(KV.first);
548 if (HI == HeaderAddrs.
end())
552 for (
auto &Dep : KV.second) {
553 auto HJ = HeaderAddrs.
find(Dep);
554 if (HJ != HeaderAddrs.
end())
555 DepInfo.push_back(HJ->second);
557 DIM.push_back(std::make_pair(
H, std::move(DepInfo)));
564 lookupInitSymbolsAsync(
565 [
this, SendResult = std::move(SendResult), JD](
Error Err)
mutable {
567 SendResult(std::move(Err));
569 pushInitializersLoop(std::move(SendResult), JD);
571 ES, std::move(NewInitSymbols));
574void ELFNixPlatform::rt_recordInitializers(
575 PushInitializersSendResultFn SendResult,
ExecutorAddr JDHeaderAddr) {
578 std::lock_guard<std::mutex> Lock(PlatformMutex);
579 auto I = HandleAddrToJITDylib.find(JDHeaderAddr);
580 if (
I != HandleAddrToJITDylib.end())
585 dbgs() <<
"ELFNixPlatform::rt_recordInitializers(" << JDHeaderAddr <<
") ";
587 dbgs() <<
"pushing initializers for " << JD->
getName() <<
"\n";
589 dbgs() <<
"No JITDylib for header address.\n";
593 SendResult(make_error<StringError>(
"No JITDylib with header addr " +
594 formatv(
"{0:x}", JDHeaderAddr),
599 pushInitializersLoop(std::move(SendResult), JD);
602void ELFNixPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
606 dbgs() <<
"ELFNixPlatform::rt_lookupSymbol(\"" << Handle <<
"\")\n";
612 std::lock_guard<std::mutex> Lock(PlatformMutex);
613 auto I = HandleAddrToJITDylib.find(Handle);
614 if (
I != HandleAddrToJITDylib.end())
619 LLVM_DEBUG(
dbgs() <<
" No JITDylib for handle " << Handle <<
"\n");
620 SendResult(make_error<StringError>(
"No JITDylib associated with handle " +
627 class RtLookupNotifyComplete {
629 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
630 : SendResult(
std::
move(SendResult)) {}
633 assert(
Result->size() == 1 &&
"Unexpected result map count");
634 SendResult(
Result->begin()->second.getAddress());
636 SendResult(
Result.takeError());
641 SendSymbolAddressFn SendResult;
645 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
650Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineStart(
653 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
654 ++MP.Bootstrap.load()->ActiveGraphs;
658Error ELFNixPlatform::ELFNixPlatformPlugin::
661 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
662 {*MP.DSOHandleSymbol, &MP.Bootstrap.load()->ELFNixHeaderAddr},
663 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
664 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
665 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
666 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
667 {*MP.RegisterObjectSections.Name, &MP.RegisterObjectSections.Addr},
668 {*MP.DeregisterObjectSections.Name, &MP.DeregisterObjectSections.Addr},
669 {*MP.RegisterInitSections.Name, &MP.RegisterInitSections.Addr},
670 {*MP.DeregisterInitSections.Name, &MP.DeregisterInitSections.Addr},
671 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr}};
673 bool RegisterELFNixHeader =
false;
675 for (
auto *
Sym :
G.defined_symbols()) {
676 for (
auto &RTSym : RuntimeSymbols) {
677 if (
Sym->hasName() && *
Sym->getName() == RTSym.first) {
679 return make_error<StringError>(
680 "Duplicate " + RTSym.first +
681 " detected during ELFNixPlatform bootstrap",
684 if (*
Sym->getName() == *MP.DSOHandleSymbol)
685 RegisterELFNixHeader =
true;
687 *RTSym.second =
Sym->getAddress();
692 if (RegisterELFNixHeader) {
695 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
696 MP.JITDylibToHandleAddr[&MP.PlatformJD] =
697 MP.Bootstrap.load()->ELFNixHeaderAddr;
698 MP.HandleAddrToJITDylib[MP.Bootstrap.load()->ELFNixHeaderAddr] =
705Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineEnd(
707 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
708 assert(MP.Bootstrap &&
"DeferredAAs reset before bootstrap completed");
709 --MP.Bootstrap.load()->ActiveGraphs;
712 if (MP.Bootstrap.load()->ActiveGraphs == 0)
713 MP.Bootstrap.load()->CV.notify_all();
717Error ELFNixPlatform::registerPerObjectSections(
719 bool IsBootstrapping) {
720 using SPSRegisterPerObjSectionsArgs =
724 Bootstrap.load()->addArgumentsToRTFnMap(
725 &RegisterObjectSections, &DeregisterObjectSections,
726 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR),
727 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR));
731 G.allocActions().push_back(
732 {
cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
733 RegisterObjectSections.Addr, POSR)),
734 cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
735 DeregisterObjectSections.Addr, POSR))});
741 if (!CreatePThreadKey.Addr)
742 return make_error<StringError>(
743 "Attempting to create pthread key in target, but runtime support has "
744 "not been loaded yet",
749 CreatePThreadKey.Addr,
Result))
750 return std::move(Err);
754void ELFNixPlatform::ELFNixPlatformPlugin::modifyPassConfig(
757 using namespace jitlink;
759 bool InBootstrapPhase =
763 if (InBootstrapPhase) {
764 Config.PrePrunePasses.push_back(
765 [
this](LinkGraph &
G) {
return bootstrapPipelineStart(
G); });
766 Config.PostAllocationPasses.push_back([
this](LinkGraph &
G) {
767 return bootstrapPipelineRecordRuntimeFunctions(
G);
774 if (InitSymbol == MP.DSOHandleSymbol && !InBootstrapPhase) {
775 addDSOHandleSupportPasses(MR,
Config);
782 Config.PrePrunePasses.push_back(
784 if (
auto Err = preserveInitSections(
G, MR))
791 addEHAndTLVSupportPasses(MR,
Config, InBootstrapPhase);
796 return registerInitSections(G, JD, InBootstrapPhase);
801 if (InBootstrapPhase)
802 Config.PostFixupPasses.push_back(
803 [
this](LinkGraph &
G) {
return bootstrapPipelineEnd(
G); });
806void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
811 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
812 return Sym->getName() == MP.DSOHandleSymbol;
814 assert(
I !=
G.defined_symbols().end() &&
"Missing DSO handle symbol");
816 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
817 auto HandleAddr = (*I)->getAddress();
818 MP.HandleAddrToJITDylib[HandleAddr] = &JD;
819 MP.JITDylibToHandleAddr[&JD] = HandleAddr;
821 G.allocActions().push_back(
824 MP.RegisterJITDylib.Addr, JD.getName(), HandleAddr)),
826 MP.DeregisterJITDylib.Addr, HandleAddr))});
832void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
834 bool IsBootstrapping) {
841 Config.PostPrunePasses.push_back(
843 return fixTLVSectionsAndEdges(G, JD);
848 Config.PostFixupPasses.push_back([
this, IsBootstrapping](
853 jitlink::SectionRange R(*EHFrameSection);
855 POSR.EHFrameSection = R.getRange();
868 if (ThreadDataSection)
869 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
871 ThreadDataSection = ThreadBSSSection;
876 if (ThreadDataSection) {
883 if (
auto Err = MP.registerPerObjectSections(
G, POSR, IsBootstrapping))
891Error ELFNixPlatform::ELFNixPlatformPlugin::preserveInitSections(
898 for (
auto &InitSection :
G.sections()) {
907 auto &
B = **InitSection.blocks().begin();
908 InitSym = &
G.addDefinedSymbol(
909 B, 0, *InitSymName,
B.getSize(), jitlink::Linkage::Strong,
910 jitlink::Scope::SideEffectsOnly,
false,
true);
914 for (
auto *
B : InitSection.blocks()) {
918 auto &S =
G.addAnonymousSymbol(*
B, 0,
B->getSize(),
false,
true);
927Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
933 for (
auto &Sec :
G.sections())
943 if (RHS->getName().starts_with(
".init_array")) {
944 StringRef LHSPrioStr(LHS->getName());
945 StringRef RHSPrioStr(RHS->getName());
946 uint64_t LHSPriority;
947 bool LHSHasPriority = LHSPrioStr.consume_front(
".init_array.") &&
948 !LHSPrioStr.getAsInteger(10, LHSPriority);
949 uint64_t RHSPriority;
950 bool RHSHasPriority = RHSPrioStr.consume_front(
".init_array.") &&
951 !RHSPrioStr.getAsInteger(10, RHSPriority);
953 return RHSHasPriority ? LHSPriority < RHSPriority : true;
954 else if (RHSHasPriority)
966 for (
auto &Sec : OrderedInitSections)
971 dbgs() <<
"ELFNixPlatform: Scraped " <<
G.getName() <<
" init sections:\n";
972 for (
auto &Sec :
G.sections()) {
974 dbgs() <<
" " << Sec.getName() <<
": " <<
R.getRange() <<
"\n";
980 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
981 auto I = MP.JITDylibToHandleAddr.find(&JD);
982 assert(
I != MP.JITDylibToHandleAddr.end() &&
"No header registered for JD");
983 assert(
I->second &&
"Null header registered for JD");
984 HeaderAddr =
I->second;
987 using SPSRegisterInitSectionsArgs =
991 MP.Bootstrap.load()->addArgumentsToRTFnMap(
992 &MP.RegisterInitSections, &MP.DeregisterInitSections,
993 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
995 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
996 ELFNixPlatformSecs));
1000 G.allocActions().push_back(
1001 {
cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
1002 MP.RegisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs)),
1003 cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
1004 MP.DeregisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs))});
1009Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
1011 auto TLSGetAddrSymbolName =
G.intern(
"__tls_get_addr");
1012 auto TLSDescResolveSymbolName =
G.intern(
"__tlsdesc_resolver");
1013 for (
auto *
Sym :
G.external_symbols()) {
1014 if (
Sym->getName() == TLSGetAddrSymbolName) {
1016 MP.getExecutionSession().intern(
"___orc_rt_elfnix_tls_get_addr");
1017 Sym->setName(std::move(TLSGetAddr));
1018 }
else if (
Sym->getName() == TLSDescResolveSymbolName) {
1020 MP.getExecutionSession().intern(
"___orc_rt_elfnix_tlsdesc_resolver");
1021 Sym->setName(std::move(TLSGetAddr));
1025 auto *TLSInfoEntrySection =
G.findSectionByName(
"$__TLSINFO");
1027 if (TLSInfoEntrySection) {
1028 std::optional<uint64_t>
Key;
1030 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1031 auto I = MP.JITDylibToPThreadKey.find(&JD);
1032 if (
I != MP.JITDylibToPThreadKey.end())
1036 if (
auto KeyOrErr = MP.createPThreadKey())
1039 return KeyOrErr.takeError();
1045 for (
auto *
B : TLSInfoEntrySection->blocks()) {
1048 assert(
B->getSize() == (
G.getPointerSize() * 2) &&
1049 "TLS descriptor must be 2 words length");
1050 auto TLSInfoEntryContent =
B->getMutableContent(
G);
1051 memcpy(TLSInfoEntryContent.data(), &PlatformKeyBits,
G.getPointerSize());
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_UNLIKELY(EXPR)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
iterator find(const_arg_type_t< KeyT > Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
Helper for Errors used as out-parameters.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
StringRef - Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Triple - Helper class for working with autoconf configuration names.
const std::string & str() const
StringRef getName() const
Return a constant reference to the value's name.
void addEdge(Edge::Kind K, Edge::OffsetT Offset, Symbol &Target, Edge::AddendT Addend)
Add an edge to this block.
const std::string & getName() const
Get the name for this JITLinkDylib.
Represents a section address range via a pair of Block pointers to the first and last Blocks in the s...
orc::ExecutorAddrRange getRange() const
Represents an object file section.
Block & getBlock()
Return the Block for this Symbol (Symbol must be defined).
An ExecutionSession represents a running JIT program.
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
const Triple & getTargetTriple() const
Return the triple for the executor.
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H)
Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produc...
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Get the SymbolStringPool for this instance.
void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
Error registerJITDispatchHandlers(JITDylib &JD, JITDispatchHandlerAssociationMap WFs)
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of...
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
ExecutionSession & getExecutionSession()
LinkGraphLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
virtual StringRef getName() const =0
Return the name of this materialization unit.
SymbolFlagsMap SymbolFlags
virtual void materialize(std::unique_ptr< MaterializationResponsibility > R)=0
Implementations of this method should materialize all symbols in the materialzation unit,...
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
An ObjectLayer implementation built on JITLink.
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Emit an object file.
API to remove / transfer ownership of JIT resources.
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibraryDefinitionGenerator from the given path.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
A utility class for serializing to a blob from a variadic list.
SPS tag type for expecteds, which are either a T or a string representing an error.
Output char buffer with overflow check.
SPS tag type for sequences.
Represents a serialized wrapper function call.
static Expected< WrapperFunctionCall > Create(ExecutorAddr FnAddr, const ArgTs &...Args)
Create a WrapperFunctionCall using the given SPS serializer to serialize the arguments.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Pointer64
A plain 64-bit pointer value relocation.
@ Pointer64
A plain 64-bit pointer value relocation.
const char * getGenericEdgeKindName(Edge::Kind K)
Returns the string name of the given generic edge kind, or "unknown" otherwise.
StringRef ELFThreadBSSSectionName
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...
std::vector< std::pair< ExecutorAddr, ELFNixJITDylibDepInfo > > ELFNixJITDylibDepInfoMap
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
std::vector< ExecutorAddr > ELFNixJITDylibDepInfo
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
StringRef ELFEHFrameSectionName
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * > > AL)
StringRef ELFThreadDataSectionName
std::unordered_map< std::pair< RuntimeFunction *, RuntimeFunction * >, SmallVector< std::pair< shared::WrapperFunctionCall::ArgDataBufferType, shared::WrapperFunctionCall::ArgDataBufferType > >, FunctionPairKeyHash, FunctionPairKeyEqual > DeferredRuntimeFnMap
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
bool isELFInitializerSection(StringRef SecName)
value_type byte_swap(value_type value, endianness endian)
This is an optimization pass for GlobalISel generic memory operations.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...
ExecutorAddrRange EHFrameSection
ExecutorAddrRange ThreadDataSection