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,
44 return std::make_unique<jitlink::LinkGraph>(
45 std::move(
Name), ES.getSymbolStringPool(), ES.getTargetTriple(),
50class ELFNixPlatformCompleteBootstrapMaterializationUnit
53 ELFNixPlatformCompleteBootstrapMaterializationUnit(
61 MOP(MOP), PlatformJDName(PlatformJDName),
62 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
63 DeferredAAsMap(std::move(DeferredAAs)),
64 ELFNixHeaderAddr(ELFNixHeaderAddr),
65 PlatformBootstrap(PlatformBootstrap),
66 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
67 DeregisterJITDylib(DeregisterJITDylib) {}
70 return "ELFNixPlatformCompleteBootstrap";
73 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
74 using namespace jitlink;
75 auto G = createPlatformGraph(MOP,
"<OrcRTCompleteBootstrap>");
76 auto &PlaceholderSection =
77 G->createSection(
"__orc_rt_cplt_bs", MemProt::Read);
78 auto &PlaceholderBlock =
79 G->createZeroFillBlock(PlaceholderSection, 1,
ExecutorAddr(), 1, 0);
80 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
81 Linkage::Strong, Scope::Hidden,
false,
true);
84 G->allocActions().push_back(
86 PlatformBootstrap, ELFNixHeaderAddr)),
91 G->allocActions().push_back(
94 RegisterJITDylib, PlatformJDName, ELFNixHeaderAddr)),
96 DeregisterJITDylib, ELFNixHeaderAddr))});
99 for (
auto &[Fn, CallDatas] : DeferredAAsMap) {
100 for (
auto &CallData : CallDatas) {
101 G->allocActions().push_back(
129 createDSOHandleSectionInterface(ENP, DSOHandleSymbol)),
134 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
140 switch (ES.getTargetTriple().getArch()) {
158 auto G = std::make_unique<jitlink::LinkGraph>(
159 "<DSOHandleMU>", ES.getSymbolStringPool(), ES.getTargetTriple(),
161 auto &DSOHandleSection =
162 G->createSection(
".data.__dso_handle", MemProt::Read);
163 auto &DSOHandleBlock =
G->createContentBlock(
164 DSOHandleSection, getDSOHandleContent(
G->getPointerSize()),
166 auto &DSOHandleSymbol =
G->addDefinedSymbol(
167 DSOHandleBlock, 0, *R->getInitializerSymbol(), DSOHandleBlock.getSize(),
168 jitlink::Linkage::Strong, jitlink::Scope::Default,
false,
true);
169 DSOHandleBlock.addEdge(EdgeKind, 0, DSOHandleSymbol, 0);
187 static const char Content[8] = {0};
203 std::unique_ptr<DefinitionGenerator> OrcRuntime,
204 std::optional<SymbolAliasMap> RuntimeAliases) {
210 return make_error<StringError>(
"Unsupported ELFNixPlatform triple: " +
217 if (!RuntimeAliases) {
219 if (!StandardRuntimeAliases)
220 return StandardRuntimeAliases.takeError();
221 RuntimeAliases = std::move(*StandardRuntimeAliases);
226 return std::move(Err);
229 if (
auto Err = PlatformJD.
define(
231 {EPC.getJITDispatchInfo().JITDispatchFunction,
233 {ES.
intern(
"__orc_rt_jit_dispatch_ctx"),
234 {EPC.getJITDispatchInfo().JITDispatchContext,
236 return std::move(Err);
241 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
243 return std::move(Err);
249 JITDylib &PlatformJD,
const char *OrcRuntimePath,
250 std::optional<SymbolAliasMap> RuntimeAliases) {
253 auto OrcRuntimeArchiveGenerator =
255 if (!OrcRuntimeArchiveGenerator)
256 return OrcRuntimeArchiveGenerator.takeError();
258 return Create(ObjLinkingLayer, PlatformJD,
259 std::move(*OrcRuntimeArchiveGenerator),
260 std::move(RuntimeAliases));
264 if (
auto Err = JD.
define(std::make_unique<DSOHandleMaterializationUnit>(
265 *
this, DSOHandleSymbol)))
268 return ES.
lookup({&JD}, DSOHandleSymbol).takeError();
272 std::lock_guard<std::mutex> Lock(PlatformMutex);
273 auto I = JITDylibToHandleAddr.find(&JD);
274 if (
I != JITDylibToHandleAddr.end()) {
275 assert(HandleAddrToJITDylib.count(
I->second) &&
276 "HandleAddrToJITDylib missing entry");
277 HandleAddrToJITDylib.erase(
I->second);
278 JITDylibToHandleAddr.erase(
I);
291 RegisteredInitSymbols[&JD].add(InitSym,
294 dbgs() <<
"ELFNixPlatform: Registered init symbol " << *InitSym
295 <<
" for MU " << MU.
getName() <<
"\n";
305 ArrayRef<std::pair<const char *, const char *>> AL) {
306 for (
auto &KV : AL) {
307 auto AliasName = ES.
intern(KV.first);
308 assert(!Aliases.
count(AliasName) &&
"Duplicate symbol name in alias map");
309 Aliases[std::move(AliasName)] = {ES.
intern(KV.second),
326 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
327 {
"__cxa_atexit",
"__orc_rt_elfnix_cxa_atexit"},
328 {
"atexit",
"__orc_rt_elfnix_atexit"}};
335 static const std::pair<const char *, const char *>
336 StandardRuntimeUtilityAliases[] = {
337 {
"__orc_rt_run_program",
"__orc_rt_elfnix_run_program"},
338 {
"__orc_rt_jit_dlerror",
"__orc_rt_elfnix_jit_dlerror"},
339 {
"__orc_rt_jit_dlopen",
"__orc_rt_elfnix_jit_dlopen"},
340 {
"__orc_rt_jit_dlupdate",
"__orc_rt_elfnix_jit_dlupdate"},
341 {
"__orc_rt_jit_dlclose",
"__orc_rt_elfnix_jit_dlclose"},
342 {
"__orc_rt_jit_dlsym",
"__orc_rt_elfnix_jit_dlsym"},
343 {
"__orc_rt_log_error",
"__orc_rt_log_error_to_stderr"}};
346 StandardRuntimeUtilityAliases);
351 static const std::pair<const char *, const char *>
352 StandardLazyCompilationAliases[] = {
353 {
"__orc_rt_reenter",
"__orc_rt_sysv_reenter"}};
356 StandardLazyCompilationAliases);
359bool ELFNixPlatform::supportedTarget(
const Triple &TT) {
360 switch (TT.getArch()) {
372ELFNixPlatform::ELFNixPlatform(
374 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
Error &Err)
375 : ES(ObjLinkingLayer.getExecutionSession()), PlatformJD(PlatformJD),
376 ObjLinkingLayer(ObjLinkingLayer),
377 DSOHandleSymbol(ES.intern(
"__dso_handle")) {
379 ObjLinkingLayer.
addPlugin(std::make_unique<ELFNixPlatformPlugin>(*
this));
381 PlatformJD.
addGenerator(std::move(OrcRuntimeGenerator));
398 {PlatformBootstrap.
Name, PlatformShutdown.
Name,
399 RegisterJITDylib.
Name, DeregisterJITDylib.
Name,
400 RegisterInitSections.
Name, DeregisterInitSections.
Name,
401 RegisterObjectSections.
Name,
402 DeregisterObjectSections.
Name, CreatePThreadKey.
Name}))
408 std::unique_lock<std::mutex> Lock(BI.Mutex);
409 BI.CV.wait(Lock, [&]() {
return BI.ActiveGraphs == 0; });
414 auto BootstrapCompleteSymbol =
415 ES.
intern(
"__orc_rt_elfnix_complete_bootstrap");
416 if ((Err = PlatformJD.
define(
417 std::make_unique<ELFNixPlatformCompleteBootstrapMaterializationUnit>(
418 *
this, PlatformJD.
getName(), BootstrapCompleteSymbol,
419 std::move(BI.DeferredRTFnMap), BI.ELFNixHeaderAddr,
420 PlatformBootstrap.
Addr, PlatformShutdown.
Addr,
421 RegisterJITDylib.
Addr, DeregisterJITDylib.
Addr))))
425 std::move(BootstrapCompleteSymbol))
430 if (
auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
436Error ELFNixPlatform::associateRuntimeSupportFunctions(
JITDylib &PlatformJD) {
439 using RecordInitializersSPSSig =
441 WFs[ES.
intern(
"__orc_rt_elfnix_push_initializers_tag")] =
443 this, &ELFNixPlatform::rt_recordInitializers);
445 using LookupSymbolSPSSig =
447 WFs[ES.
intern(
"__orc_rt_elfnix_symbol_lookup_tag")] =
449 &ELFNixPlatform::rt_lookupSymbol);
454void ELFNixPlatform::pushInitializersLoop(
455 PushInitializersSendResultFn SendResult,
JITDylibSP JD) {
461 while (!Worklist.empty()) {
464 auto DepJD = Worklist.back();
468 if (JDDepMap.count(DepJD))
472 auto &DM = JDDepMap[DepJD];
473 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
475 if (KV.first == DepJD)
477 DM.push_back(KV.first);
478 Worklist.push_back(KV.first);
483 auto RISItr = RegisteredInitSymbols.find(DepJD);
484 if (RISItr != RegisteredInitSymbols.end()) {
485 NewInitSymbols[DepJD] = std::move(RISItr->second);
486 RegisteredInitSymbols.erase(RISItr);
493 if (NewInitSymbols.
empty()) {
502 std::lock_guard<std::mutex> Lock(PlatformMutex);
503 for (
auto &KV : JDDepMap) {
504 auto I = JITDylibToHandleAddr.find(KV.first);
505 if (
I != JITDylibToHandleAddr.end())
506 HeaderAddrs[KV.first] =
I->second;
512 DIM.reserve(JDDepMap.size());
513 for (
auto &KV : JDDepMap) {
514 auto HI = HeaderAddrs.
find(KV.first);
516 if (HI == HeaderAddrs.
end())
520 for (
auto &Dep : KV.second) {
521 auto HJ = HeaderAddrs.
find(Dep);
522 if (HJ != HeaderAddrs.
end())
523 DepInfo.push_back(HJ->second);
525 DIM.push_back(std::make_pair(
H, std::move(DepInfo)));
532 lookupInitSymbolsAsync(
533 [
this, SendResult = std::move(SendResult), JD](
Error Err)
mutable {
535 SendResult(std::move(Err));
537 pushInitializersLoop(std::move(SendResult), JD);
539 ES, std::move(NewInitSymbols));
542void ELFNixPlatform::rt_recordInitializers(
543 PushInitializersSendResultFn SendResult,
ExecutorAddr JDHeaderAddr) {
546 std::lock_guard<std::mutex> Lock(PlatformMutex);
547 auto I = HandleAddrToJITDylib.find(JDHeaderAddr);
548 if (
I != HandleAddrToJITDylib.end())
553 dbgs() <<
"ELFNixPlatform::rt_recordInitializers(" << JDHeaderAddr <<
") ";
555 dbgs() <<
"pushing initializers for " << JD->
getName() <<
"\n";
557 dbgs() <<
"No JITDylib for header address.\n";
561 SendResult(make_error<StringError>(
"No JITDylib with header addr " +
562 formatv(
"{0:x}", JDHeaderAddr),
567 pushInitializersLoop(std::move(SendResult), JD);
570void ELFNixPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
574 dbgs() <<
"ELFNixPlatform::rt_lookupSymbol(\"" << Handle <<
"\")\n";
580 std::lock_guard<std::mutex> Lock(PlatformMutex);
581 auto I = HandleAddrToJITDylib.find(Handle);
582 if (
I != HandleAddrToJITDylib.end())
587 LLVM_DEBUG(
dbgs() <<
" No JITDylib for handle " << Handle <<
"\n");
588 SendResult(make_error<StringError>(
"No JITDylib associated with handle " +
595 class RtLookupNotifyComplete {
597 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
598 : SendResult(
std::
move(SendResult)) {}
601 assert(
Result->size() == 1 &&
"Unexpected result map count");
602 SendResult(
Result->begin()->second.getAddress());
604 SendResult(
Result.takeError());
609 SendSymbolAddressFn SendResult;
613 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
618Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineStart(
621 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
622 ++MP.Bootstrap.load()->ActiveGraphs;
626Error ELFNixPlatform::ELFNixPlatformPlugin::
629 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
630 {*MP.DSOHandleSymbol, &MP.Bootstrap.load()->ELFNixHeaderAddr},
631 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
632 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
633 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
634 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
635 {*MP.RegisterObjectSections.Name, &MP.RegisterObjectSections.Addr},
636 {*MP.DeregisterObjectSections.Name, &MP.DeregisterObjectSections.Addr},
637 {*MP.RegisterInitSections.Name, &MP.RegisterInitSections.Addr},
638 {*MP.DeregisterInitSections.Name, &MP.DeregisterInitSections.Addr},
639 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr}};
641 bool RegisterELFNixHeader =
false;
643 for (
auto *
Sym :
G.defined_symbols()) {
644 for (
auto &RTSym : RuntimeSymbols) {
645 if (
Sym->hasName() && *
Sym->getName() == RTSym.first) {
647 return make_error<StringError>(
648 "Duplicate " + RTSym.first +
649 " detected during ELFNixPlatform bootstrap",
652 if (*
Sym->getName() == *MP.DSOHandleSymbol)
653 RegisterELFNixHeader =
true;
655 *RTSym.second =
Sym->getAddress();
660 if (RegisterELFNixHeader) {
663 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
664 MP.JITDylibToHandleAddr[&MP.PlatformJD] =
665 MP.Bootstrap.load()->ELFNixHeaderAddr;
666 MP.HandleAddrToJITDylib[MP.Bootstrap.load()->ELFNixHeaderAddr] =
673Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineEnd(
675 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
676 assert(MP.Bootstrap &&
"DeferredAAs reset before bootstrap completed");
677 --MP.Bootstrap.load()->ActiveGraphs;
680 if (MP.Bootstrap.load()->ActiveGraphs == 0)
681 MP.Bootstrap.load()->CV.notify_all();
685Error ELFNixPlatform::registerPerObjectSections(
687 bool IsBootstrapping) {
688 using SPSRegisterPerObjSectionsArgs =
692 Bootstrap.load()->addArgumentsToRTFnMap(
693 &RegisterObjectSections, &DeregisterObjectSections,
694 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR),
695 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR));
699 G.allocActions().push_back(
700 {
cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
701 RegisterObjectSections.Addr, POSR)),
702 cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
703 DeregisterObjectSections.Addr, POSR))});
709 if (!CreatePThreadKey.Addr)
710 return make_error<StringError>(
711 "Attempting to create pthread key in target, but runtime support has "
712 "not been loaded yet",
717 CreatePThreadKey.Addr,
Result))
718 return std::move(Err);
722void ELFNixPlatform::ELFNixPlatformPlugin::modifyPassConfig(
725 using namespace jitlink;
727 bool InBootstrapPhase =
731 if (InBootstrapPhase) {
732 Config.PrePrunePasses.push_back(
733 [
this](LinkGraph &
G) {
return bootstrapPipelineStart(
G); });
734 Config.PostAllocationPasses.push_back([
this](LinkGraph &
G) {
735 return bootstrapPipelineRecordRuntimeFunctions(
G);
742 if (InitSymbol == MP.DSOHandleSymbol && !InBootstrapPhase) {
743 addDSOHandleSupportPasses(MR,
Config);
750 Config.PrePrunePasses.push_back(
752 if (
auto Err = preserveInitSections(
G, MR))
759 addEHAndTLVSupportPasses(MR,
Config, InBootstrapPhase);
764 return registerInitSections(G, JD, InBootstrapPhase);
769 if (InBootstrapPhase)
770 Config.PostFixupPasses.push_back(
771 [
this](LinkGraph &
G) {
return bootstrapPipelineEnd(
G); });
774void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
779 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
780 return Sym->getName() == MP.DSOHandleSymbol;
782 assert(
I !=
G.defined_symbols().end() &&
"Missing DSO handle symbol");
784 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
785 auto HandleAddr = (*I)->getAddress();
786 MP.HandleAddrToJITDylib[HandleAddr] = &JD;
787 MP.JITDylibToHandleAddr[&JD] = HandleAddr;
789 G.allocActions().push_back(
792 MP.RegisterJITDylib.Addr, JD.getName(), HandleAddr)),
794 MP.DeregisterJITDylib.Addr, HandleAddr))});
800void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
802 bool IsBootstrapping) {
809 Config.PostPrunePasses.push_back(
811 return fixTLVSectionsAndEdges(G, JD);
816 Config.PostFixupPasses.push_back([
this, IsBootstrapping](
821 jitlink::SectionRange R(*EHFrameSection);
823 POSR.EHFrameSection = R.getRange();
836 if (ThreadDataSection)
837 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
839 ThreadDataSection = ThreadBSSSection;
844 if (ThreadDataSection) {
851 if (
auto Err = MP.registerPerObjectSections(
G, POSR, IsBootstrapping))
859Error ELFNixPlatform::ELFNixPlatformPlugin::preserveInitSections(
866 for (
auto &InitSection :
G.sections()) {
875 auto &
B = **InitSection.blocks().begin();
876 InitSym = &
G.addDefinedSymbol(
877 B, 0, *InitSymName,
B.getSize(), jitlink::Linkage::Strong,
878 jitlink::Scope::SideEffectsOnly,
false,
true);
882 for (
auto *
B : InitSection.blocks()) {
886 auto &S =
G.addAnonymousSymbol(*
B, 0,
B->getSize(),
false,
true);
895Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
901 for (
auto &Sec :
G.sections())
911 if (RHS->getName().starts_with(
".init_array")) {
912 StringRef LHSPrioStr(LHS->getName());
913 StringRef RHSPrioStr(RHS->getName());
914 uint64_t LHSPriority;
915 bool LHSHasPriority = LHSPrioStr.consume_front(
".init_array.") &&
916 !LHSPrioStr.getAsInteger(10, LHSPriority);
917 uint64_t RHSPriority;
918 bool RHSHasPriority = RHSPrioStr.consume_front(
".init_array.") &&
919 !RHSPrioStr.getAsInteger(10, RHSPriority);
921 return RHSHasPriority ? LHSPriority < RHSPriority : true;
922 else if (RHSHasPriority)
934 for (
auto &Sec : OrderedInitSections)
939 dbgs() <<
"ELFNixPlatform: Scraped " <<
G.getName() <<
" init sections:\n";
940 for (
auto &Sec :
G.sections()) {
942 dbgs() <<
" " << Sec.getName() <<
": " <<
R.getRange() <<
"\n";
948 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
949 auto I = MP.JITDylibToHandleAddr.find(&JD);
950 assert(
I != MP.JITDylibToHandleAddr.end() &&
"No header registered for JD");
951 assert(
I->second &&
"Null header registered for JD");
952 HeaderAddr =
I->second;
955 using SPSRegisterInitSectionsArgs =
959 MP.Bootstrap.load()->addArgumentsToRTFnMap(
960 &MP.RegisterInitSections, &MP.DeregisterInitSections,
961 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
963 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
964 ELFNixPlatformSecs));
968 G.allocActions().push_back(
969 {
cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
970 MP.RegisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs)),
971 cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
972 MP.DeregisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs))});
977Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
979 auto TLSGetAddrSymbolName =
G.intern(
"__tls_get_addr");
980 auto TLSDescResolveSymbolName =
G.intern(
"__tlsdesc_resolver");
981 for (
auto *
Sym :
G.external_symbols()) {
982 if (
Sym->getName() == TLSGetAddrSymbolName) {
984 MP.getExecutionSession().intern(
"___orc_rt_elfnix_tls_get_addr");
985 Sym->setName(std::move(TLSGetAddr));
986 }
else if (
Sym->getName() == TLSDescResolveSymbolName) {
988 MP.getExecutionSession().intern(
"___orc_rt_elfnix_tlsdesc_resolver");
989 Sym->setName(std::move(TLSGetAddr));
993 auto *TLSInfoEntrySection =
G.findSectionByName(
"$__TLSINFO");
995 if (TLSInfoEntrySection) {
996 std::optional<uint64_t>
Key;
998 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
999 auto I = MP.JITDylibToPThreadKey.find(&JD);
1000 if (
I != MP.JITDylibToPThreadKey.end())
1004 if (
auto KeyOrErr = MP.createPThreadKey())
1007 return KeyOrErr.takeError();
1013 for (
auto *
B : TLSInfoEntrySection->blocks()) {
1016 assert(
B->getSize() == (
G.getPointerSize() * 2) &&
1017 "TLS descriptor must be 2 words length");
1018 auto TLSInfoEntryContent =
B->getMutableContent(
G);
1019 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.
Manages the enabling and disabling of subtarget specific features.
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...
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