22#define DEBUG_TYPE "orc"
30template <
typename SPSSerializer,
typename... ArgTs>
32getArgDataBufferType(
const ArgTs &...Args) {
34 ArgData.
resize(SPSSerializer::size(Args...));
37 if (SPSSerializer::serialize(OB, Args...))
42std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(
ELFNixPlatform &MOP,
45 return std::make_unique<jitlink::LinkGraph>(
46 std::move(
Name), ES.getSymbolStringPool(), ES.getTargetTriple(),
51class ELFNixPlatformCompleteBootstrapMaterializationUnit
54 ELFNixPlatformCompleteBootstrapMaterializationUnit(
62 MOP(MOP), PlatformJDName(PlatformJDName),
63 CompleteBootstrapSymbol(std::move(CompleteBootstrapSymbol)),
64 DeferredAAsMap(std::move(DeferredAAs)),
65 ELFNixHeaderAddr(ELFNixHeaderAddr),
66 PlatformBootstrap(PlatformBootstrap),
67 PlatformShutdown(PlatformShutdown), RegisterJITDylib(RegisterJITDylib),
68 DeregisterJITDylib(DeregisterJITDylib) {}
71 return "ELFNixPlatformCompleteBootstrap";
74 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
75 using namespace jitlink;
76 auto G = createPlatformGraph(MOP,
"<OrcRTCompleteBootstrap>");
77 auto &PlaceholderSection =
78 G->createSection(
"__orc_rt_cplt_bs", MemProt::Read);
79 auto &PlaceholderBlock =
80 G->createZeroFillBlock(PlaceholderSection, 1,
ExecutorAddr(), 1, 0);
81 G->addDefinedSymbol(PlaceholderBlock, 0, *CompleteBootstrapSymbol, 1,
82 Linkage::Strong, Scope::Hidden,
false,
true);
85 G->allocActions().push_back(
87 PlatformBootstrap, ELFNixHeaderAddr)),
92 G->allocActions().push_back(
95 RegisterJITDylib, PlatformJDName, ELFNixHeaderAddr)),
97 DeregisterJITDylib, ELFNixHeaderAddr))});
100 for (
auto &[Fn, CallDatas] : DeferredAAsMap) {
101 for (
auto &CallData : CallDatas) {
102 G->allocActions().push_back(
130 createDSOHandleSectionInterface(ENP, DSOHandleSymbol)),
135 void materialize(std::unique_ptr<MaterializationResponsibility> R)
override {
141 switch (ES.getTargetTriple().getArch()) {
162 auto G = std::make_unique<jitlink::LinkGraph>(
163 "<DSOHandleMU>", ES.getSymbolStringPool(), ES.getTargetTriple(),
165 auto &DSOHandleSection =
166 G->createSection(
".data.__dso_handle", MemProt::Read);
167 auto &DSOHandleBlock =
G->createContentBlock(
168 DSOHandleSection, getDSOHandleContent(
G->getPointerSize()),
170 auto &DSOHandleSymbol =
G->addDefinedSymbol(
171 DSOHandleBlock, 0, *R->getInitializerSymbol(), DSOHandleBlock.getSize(),
172 jitlink::Linkage::Strong, jitlink::Scope::Default,
false,
true);
173 DSOHandleBlock.addEdge(EdgeKind, 0, DSOHandleSymbol, 0);
191 static const char Content[8] = {0};
207 std::unique_ptr<DefinitionGenerator> OrcRuntime,
208 std::optional<SymbolAliasMap> RuntimeAliases) {
214 return make_error<StringError>(
"Unsupported ELFNixPlatform triple: " +
221 if (!RuntimeAliases) {
223 if (!StandardRuntimeAliases)
224 return StandardRuntimeAliases.takeError();
225 RuntimeAliases = std::move(*StandardRuntimeAliases);
230 return std::move(Err);
233 if (
auto Err = PlatformJD.
define(
235 {EPC.getJITDispatchInfo().JITDispatchFunction,
237 {ES.
intern(
"__orc_rt_jit_dispatch_ctx"),
238 {EPC.getJITDispatchInfo().JITDispatchContext,
240 return std::move(Err);
245 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
247 return std::move(Err);
253 JITDylib &PlatformJD,
const char *OrcRuntimePath,
254 std::optional<SymbolAliasMap> RuntimeAliases) {
257 auto OrcRuntimeArchiveGenerator =
259 if (!OrcRuntimeArchiveGenerator)
260 return OrcRuntimeArchiveGenerator.takeError();
262 return Create(ObjLinkingLayer, PlatformJD,
263 std::move(*OrcRuntimeArchiveGenerator),
264 std::move(RuntimeAliases));
268 if (
auto Err = JD.
define(std::make_unique<DSOHandleMaterializationUnit>(
269 *
this, DSOHandleSymbol)))
272 return ES.
lookup({&JD}, DSOHandleSymbol).takeError();
276 std::lock_guard<std::mutex> Lock(PlatformMutex);
277 auto I = JITDylibToHandleAddr.find(&JD);
278 if (
I != JITDylibToHandleAddr.end()) {
279 assert(HandleAddrToJITDylib.count(
I->second) &&
280 "HandleAddrToJITDylib missing entry");
281 HandleAddrToJITDylib.erase(
I->second);
282 JITDylibToHandleAddr.erase(
I);
295 RegisteredInitSymbols[&JD].add(InitSym,
298 dbgs() <<
"ELFNixPlatform: Registered init symbol " << *InitSym
299 <<
" for MU " << MU.
getName() <<
"\n";
309 ArrayRef<std::pair<const char *, const char *>> AL) {
310 for (
auto &KV : AL) {
311 auto AliasName = ES.
intern(KV.first);
312 assert(!Aliases.
count(AliasName) &&
"Duplicate symbol name in alias map");
313 Aliases[std::move(AliasName)] = {ES.
intern(KV.second),
330 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
331 {
"__cxa_atexit",
"__orc_rt_elfnix_cxa_atexit"},
332 {
"atexit",
"__orc_rt_elfnix_atexit"}};
339 static const std::pair<const char *, const char *>
340 StandardRuntimeUtilityAliases[] = {
341 {
"__orc_rt_run_program",
"__orc_rt_elfnix_run_program"},
342 {
"__orc_rt_jit_dlerror",
"__orc_rt_elfnix_jit_dlerror"},
343 {
"__orc_rt_jit_dlopen",
"__orc_rt_elfnix_jit_dlopen"},
344 {
"__orc_rt_jit_dlupdate",
"__orc_rt_elfnix_jit_dlupdate"},
345 {
"__orc_rt_jit_dlclose",
"__orc_rt_elfnix_jit_dlclose"},
346 {
"__orc_rt_jit_dlsym",
"__orc_rt_elfnix_jit_dlsym"},
347 {
"__orc_rt_log_error",
"__orc_rt_log_error_to_stderr"}};
350 StandardRuntimeUtilityAliases);
355 static const std::pair<const char *, const char *>
356 StandardLazyCompilationAliases[] = {
357 {
"__orc_rt_reenter",
"__orc_rt_sysv_reenter"}};
360 StandardLazyCompilationAliases);
363bool ELFNixPlatform::supportedTarget(
const Triple &TT) {
364 switch (TT.getArch()) {
377ELFNixPlatform::ELFNixPlatform(
379 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator,
Error &Err)
380 : ES(ObjLinkingLayer.getExecutionSession()), PlatformJD(PlatformJD),
381 ObjLinkingLayer(ObjLinkingLayer),
382 DSOHandleSymbol(ES.intern(
"__dso_handle")) {
384 ObjLinkingLayer.
addPlugin(std::make_unique<ELFNixPlatformPlugin>(*
this));
386 PlatformJD.
addGenerator(std::move(OrcRuntimeGenerator));
403 {PlatformBootstrap.
Name, PlatformShutdown.
Name,
404 RegisterJITDylib.
Name, DeregisterJITDylib.
Name,
405 RegisterInitSections.
Name, DeregisterInitSections.
Name,
406 RegisterObjectSections.
Name,
407 DeregisterObjectSections.
Name, CreatePThreadKey.
Name}))
413 std::unique_lock<std::mutex> Lock(BI.Mutex);
414 BI.CV.wait(Lock, [&]() {
return BI.ActiveGraphs == 0; });
419 auto BootstrapCompleteSymbol =
420 ES.
intern(
"__orc_rt_elfnix_complete_bootstrap");
421 if ((Err = PlatformJD.
define(
422 std::make_unique<ELFNixPlatformCompleteBootstrapMaterializationUnit>(
423 *
this, PlatformJD.
getName(), BootstrapCompleteSymbol,
424 std::move(BI.DeferredRTFnMap), BI.ELFNixHeaderAddr,
425 PlatformBootstrap.
Addr, PlatformShutdown.
Addr,
426 RegisterJITDylib.
Addr, DeregisterJITDylib.
Addr))))
430 std::move(BootstrapCompleteSymbol))
435 if (
auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
441Error ELFNixPlatform::associateRuntimeSupportFunctions(
JITDylib &PlatformJD) {
444 using RecordInitializersSPSSig =
446 WFs[ES.
intern(
"__orc_rt_elfnix_push_initializers_tag")] =
448 this, &ELFNixPlatform::rt_recordInitializers);
450 using LookupSymbolSPSSig =
452 WFs[ES.
intern(
"__orc_rt_elfnix_symbol_lookup_tag")] =
454 &ELFNixPlatform::rt_lookupSymbol);
459void ELFNixPlatform::pushInitializersLoop(
460 PushInitializersSendResultFn SendResult,
JITDylibSP JD) {
466 while (!Worklist.empty()) {
469 auto DepJD = Worklist.back();
473 if (JDDepMap.count(DepJD))
477 auto &DM = JDDepMap[DepJD];
478 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
480 if (KV.first == DepJD)
482 DM.push_back(KV.first);
483 Worklist.push_back(KV.first);
488 auto RISItr = RegisteredInitSymbols.find(DepJD);
489 if (RISItr != RegisteredInitSymbols.end()) {
490 NewInitSymbols[DepJD] = std::move(RISItr->second);
491 RegisteredInitSymbols.erase(RISItr);
498 if (NewInitSymbols.
empty()) {
507 std::lock_guard<std::mutex> Lock(PlatformMutex);
508 for (
auto &KV : JDDepMap) {
509 auto I = JITDylibToHandleAddr.find(KV.first);
510 if (
I != JITDylibToHandleAddr.end())
511 HeaderAddrs[KV.first] =
I->second;
517 DIM.reserve(JDDepMap.size());
518 for (
auto &KV : JDDepMap) {
519 auto HI = HeaderAddrs.
find(KV.first);
521 if (HI == HeaderAddrs.
end())
525 for (
auto &Dep : KV.second) {
526 auto HJ = HeaderAddrs.
find(Dep);
527 if (HJ != HeaderAddrs.
end())
528 DepInfo.push_back(HJ->second);
530 DIM.push_back(std::make_pair(
H, std::move(DepInfo)));
537 lookupInitSymbolsAsync(
538 [
this, SendResult = std::move(SendResult), JD](
Error Err)
mutable {
540 SendResult(std::move(Err));
542 pushInitializersLoop(std::move(SendResult), JD);
544 ES, std::move(NewInitSymbols));
547void ELFNixPlatform::rt_recordInitializers(
548 PushInitializersSendResultFn SendResult,
ExecutorAddr JDHeaderAddr) {
551 std::lock_guard<std::mutex> Lock(PlatformMutex);
552 auto I = HandleAddrToJITDylib.find(JDHeaderAddr);
553 if (
I != HandleAddrToJITDylib.end())
558 dbgs() <<
"ELFNixPlatform::rt_recordInitializers(" << JDHeaderAddr <<
") ";
560 dbgs() <<
"pushing initializers for " << JD->
getName() <<
"\n";
562 dbgs() <<
"No JITDylib for header address.\n";
566 SendResult(make_error<StringError>(
"No JITDylib with header addr " +
567 formatv(
"{0:x}", JDHeaderAddr),
572 pushInitializersLoop(std::move(SendResult), JD);
575void ELFNixPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
579 dbgs() <<
"ELFNixPlatform::rt_lookupSymbol(\"" << Handle <<
"\")\n";
585 std::lock_guard<std::mutex> Lock(PlatformMutex);
586 auto I = HandleAddrToJITDylib.find(Handle);
587 if (
I != HandleAddrToJITDylib.end())
592 LLVM_DEBUG(
dbgs() <<
" No JITDylib for handle " << Handle <<
"\n");
593 SendResult(make_error<StringError>(
"No JITDylib associated with handle " +
600 class RtLookupNotifyComplete {
602 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
603 : SendResult(
std::
move(SendResult)) {}
606 assert(
Result->size() == 1 &&
"Unexpected result map count");
607 SendResult(
Result->begin()->second.getAddress());
609 SendResult(
Result.takeError());
614 SendSymbolAddressFn SendResult;
618 LookupKind::DLSym, {{JD, JITDylibLookupFlags::MatchExportedSymbolsOnly}},
623Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineStart(
626 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
627 ++MP.Bootstrap.load()->ActiveGraphs;
631Error ELFNixPlatform::ELFNixPlatformPlugin::
634 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
635 {*MP.DSOHandleSymbol, &MP.Bootstrap.load()->ELFNixHeaderAddr},
636 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
637 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
638 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
639 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
640 {*MP.RegisterObjectSections.Name, &MP.RegisterObjectSections.Addr},
641 {*MP.DeregisterObjectSections.Name, &MP.DeregisterObjectSections.Addr},
642 {*MP.RegisterInitSections.Name, &MP.RegisterInitSections.Addr},
643 {*MP.DeregisterInitSections.Name, &MP.DeregisterInitSections.Addr},
644 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr}};
646 bool RegisterELFNixHeader =
false;
648 for (
auto *
Sym :
G.defined_symbols()) {
649 for (
auto &RTSym : RuntimeSymbols) {
650 if (
Sym->hasName() && *
Sym->getName() == RTSym.first) {
652 return make_error<StringError>(
653 "Duplicate " + RTSym.first +
654 " detected during ELFNixPlatform bootstrap",
657 if (*
Sym->getName() == *MP.DSOHandleSymbol)
658 RegisterELFNixHeader =
true;
660 *RTSym.second =
Sym->getAddress();
665 if (RegisterELFNixHeader) {
668 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
669 MP.JITDylibToHandleAddr[&MP.PlatformJD] =
670 MP.Bootstrap.load()->ELFNixHeaderAddr;
671 MP.HandleAddrToJITDylib[MP.Bootstrap.load()->ELFNixHeaderAddr] =
678Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineEnd(
680 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
681 assert(MP.Bootstrap &&
"DeferredAAs reset before bootstrap completed");
682 --MP.Bootstrap.load()->ActiveGraphs;
685 if (MP.Bootstrap.load()->ActiveGraphs == 0)
686 MP.Bootstrap.load()->CV.notify_all();
690Error ELFNixPlatform::registerPerObjectSections(
692 bool IsBootstrapping) {
693 using SPSRegisterPerObjSectionsArgs =
697 Bootstrap.load()->addArgumentsToRTFnMap(
698 &RegisterObjectSections, &DeregisterObjectSections,
699 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR),
700 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR));
704 G.allocActions().push_back(
705 {
cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
706 RegisterObjectSections.Addr, POSR)),
707 cantFail(WrapperFunctionCall::Create<SPSRegisterPerObjSectionsArgs>(
708 DeregisterObjectSections.Addr, POSR))});
714 if (!CreatePThreadKey.Addr)
715 return make_error<StringError>(
716 "Attempting to create pthread key in target, but runtime support has "
717 "not been loaded yet",
722 CreatePThreadKey.Addr,
Result))
723 return std::move(Err);
727void ELFNixPlatform::ELFNixPlatformPlugin::modifyPassConfig(
730 using namespace jitlink;
732 bool InBootstrapPhase =
736 if (InBootstrapPhase) {
737 Config.PrePrunePasses.push_back(
738 [
this](LinkGraph &
G) {
return bootstrapPipelineStart(
G); });
739 Config.PostAllocationPasses.push_back([
this](LinkGraph &
G) {
740 return bootstrapPipelineRecordRuntimeFunctions(
G);
747 if (InitSymbol == MP.DSOHandleSymbol && !InBootstrapPhase) {
748 addDSOHandleSupportPasses(MR,
Config);
755 Config.PrePrunePasses.push_back(
757 if (
auto Err = preserveInitSections(
G, MR))
764 addEHAndTLVSupportPasses(MR,
Config, InBootstrapPhase);
769 return registerInitSections(G, JD, InBootstrapPhase);
774 if (InBootstrapPhase)
775 Config.PostFixupPasses.push_back(
776 [
this](LinkGraph &
G) {
return bootstrapPipelineEnd(
G); });
779void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
784 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
785 return Sym->getName() == MP.DSOHandleSymbol;
787 assert(
I !=
G.defined_symbols().end() &&
"Missing DSO handle symbol");
789 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
790 auto HandleAddr = (*I)->getAddress();
791 MP.HandleAddrToJITDylib[HandleAddr] = &JD;
792 MP.JITDylibToHandleAddr[&JD] = HandleAddr;
794 G.allocActions().push_back(
797 MP.RegisterJITDylib.Addr, JD.getName(), HandleAddr)),
799 MP.DeregisterJITDylib.Addr, HandleAddr))});
805void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
807 bool IsBootstrapping) {
814 Config.PostPrunePasses.push_back(
816 return fixTLVSectionsAndEdges(G, JD);
821 Config.PostFixupPasses.push_back([
this, IsBootstrapping](
826 jitlink::SectionRange R(*EHFrameSection);
828 POSR.EHFrameSection = R.getRange();
841 if (ThreadDataSection)
842 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
844 ThreadDataSection = ThreadBSSSection;
849 if (ThreadDataSection) {
856 if (
auto Err = MP.registerPerObjectSections(
G, POSR, IsBootstrapping))
864Error ELFNixPlatform::ELFNixPlatformPlugin::preserveInitSections(
871 for (
auto &InitSection :
G.sections()) {
880 auto &
B = **InitSection.blocks().begin();
881 InitSym = &
G.addDefinedSymbol(
882 B, 0, *InitSymName,
B.getSize(), jitlink::Linkage::Strong,
883 jitlink::Scope::SideEffectsOnly,
false,
true);
887 for (
auto *
B : InitSection.blocks()) {
891 auto &S =
G.addAnonymousSymbol(*
B, 0,
B->getSize(),
false,
true);
900Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
906 for (
auto &Sec :
G.sections())
916 if (RHS->getName().starts_with(
".init_array")) {
917 StringRef LHSPrioStr(LHS->getName());
918 StringRef RHSPrioStr(RHS->getName());
919 uint64_t LHSPriority;
920 bool LHSHasPriority = LHSPrioStr.consume_front(
".init_array.") &&
921 !LHSPrioStr.getAsInteger(10, LHSPriority);
922 uint64_t RHSPriority;
923 bool RHSHasPriority = RHSPrioStr.consume_front(
".init_array.") &&
924 !RHSPrioStr.getAsInteger(10, RHSPriority);
926 return RHSHasPriority ? LHSPriority < RHSPriority : true;
927 else if (RHSHasPriority)
939 for (
auto &Sec : OrderedInitSections)
944 dbgs() <<
"ELFNixPlatform: Scraped " <<
G.getName() <<
" init sections:\n";
945 for (
auto &Sec :
G.sections()) {
947 dbgs() <<
" " << Sec.getName() <<
": " <<
R.getRange() <<
"\n";
953 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
954 auto I = MP.JITDylibToHandleAddr.find(&JD);
955 assert(
I != MP.JITDylibToHandleAddr.end() &&
"No header registered for JD");
956 assert(
I->second &&
"Null header registered for JD");
957 HeaderAddr =
I->second;
960 using SPSRegisterInitSectionsArgs =
964 MP.Bootstrap.load()->addArgumentsToRTFnMap(
965 &MP.RegisterInitSections, &MP.DeregisterInitSections,
966 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
968 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
969 ELFNixPlatformSecs));
973 G.allocActions().push_back(
974 {
cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
975 MP.RegisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs)),
976 cantFail(WrapperFunctionCall::Create<SPSRegisterInitSectionsArgs>(
977 MP.DeregisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs))});
982Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
984 auto TLSGetAddrSymbolName =
G.intern(
"__tls_get_addr");
985 auto TLSDescResolveSymbolName =
G.intern(
"__tlsdesc_resolver");
986 for (
auto *
Sym :
G.external_symbols()) {
987 if (
Sym->getName() == TLSGetAddrSymbolName) {
989 MP.getExecutionSession().intern(
"___orc_rt_elfnix_tls_get_addr");
990 Sym->setName(std::move(TLSGetAddr));
991 }
else if (
Sym->getName() == TLSDescResolveSymbolName) {
993 MP.getExecutionSession().intern(
"___orc_rt_elfnix_tlsdesc_resolver");
994 Sym->setName(std::move(TLSGetAddr));
998 auto *TLSInfoEntrySection =
G.findSectionByName(
"$__TLSINFO");
1000 if (TLSInfoEntrySection) {
1001 std::optional<uint64_t>
Key;
1003 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1004 auto I = MP.JITDylibToPThreadKey.find(&JD);
1005 if (
I != MP.JITDylibToPThreadKey.end())
1009 if (
auto KeyOrErr = MP.createPThreadKey())
1012 return KeyOrErr.takeError();
1018 for (
auto *
B : TLSInfoEntrySection->blocks()) {
1021 assert(
B->getSize() == (
G.getPointerSize() * 2) &&
1022 "TLS descriptor must be 2 words length");
1023 auto TLSInfoEntryContent =
B->getMutableContent(
G);
1024 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.
@ 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