LLVM 22.0.0git
ELFNixPlatform.cpp
Go to the documentation of this file.
1//===----- ELFNixPlatform.cpp - Utilities for executing ELFNix in Orc -----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
19#include "llvm/Support/Debug.h"
20#include <optional>
21
22#define DEBUG_TYPE "orc"
23
24using namespace llvm;
25using namespace llvm::orc;
26using namespace llvm::orc::shared;
27
28namespace {
29
30template <typename SPSSerializer, typename... ArgTs>
32getArgDataBufferType(const ArgTs &...Args) {
34 ArgData.resize(SPSSerializer::size(Args...));
35 SPSOutputBuffer OB(ArgData.empty() ? nullptr : ArgData.data(),
36 ArgData.size());
37 if (SPSSerializer::serialize(OB, Args...))
38 return ArgData;
39 return {};
40}
41
42std::unique_ptr<jitlink::LinkGraph> createPlatformGraph(ELFNixPlatform &MOP,
43 std::string Name) {
44 auto &ES = MOP.getExecutionSession();
45 return std::make_unique<jitlink::LinkGraph>(
46 std::move(Name), ES.getSymbolStringPool(), ES.getTargetTriple(),
48}
49
50// Creates a Bootstrap-Complete LinkGraph to run deferred actions.
51class ELFNixPlatformCompleteBootstrapMaterializationUnit
52 : public MaterializationUnit {
53public:
54 ELFNixPlatformCompleteBootstrapMaterializationUnit(
55 ELFNixPlatform &MOP, StringRef PlatformJDName,
56 SymbolStringPtr CompleteBootstrapSymbol, DeferredRuntimeFnMap DeferredAAs,
57 ExecutorAddr ELFNixHeaderAddr, ExecutorAddr PlatformBootstrap,
58 ExecutorAddr PlatformShutdown, ExecutorAddr RegisterJITDylib,
59 ExecutorAddr DeregisterJITDylib)
61 {{{CompleteBootstrapSymbol, JITSymbolFlags::None}}, nullptr}),
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) {}
69
70 StringRef getName() const override {
71 return "ELFNixPlatformCompleteBootstrap";
72 }
73
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);
83
84 // 1. Bootstrap the platform support code.
85 G->allocActions().push_back(
87 PlatformBootstrap, ELFNixHeaderAddr)),
89 WrapperFunctionCall::Create<SPSArgList<>>(PlatformShutdown))});
90
91 // 2. Register the platform JITDylib.
92 G->allocActions().push_back(
95 RegisterJITDylib, PlatformJDName, ELFNixHeaderAddr)),
97 DeregisterJITDylib, ELFNixHeaderAddr))});
98
99 // 4. Add the deferred actions to the graph.
100 for (auto &[Fn, CallDatas] : DeferredAAsMap) {
101 for (auto &CallData : CallDatas) {
102 G->allocActions().push_back(
103 {WrapperFunctionCall(Fn.first->Addr, std::move(CallData.first)),
104 WrapperFunctionCall(Fn.second->Addr, std::move(CallData.second))});
105 }
106 }
107
108 MOP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
109 }
110
111 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
112
113private:
114 ELFNixPlatform &MOP;
115 StringRef PlatformJDName;
116 SymbolStringPtr CompleteBootstrapSymbol;
117 DeferredRuntimeFnMap DeferredAAsMap;
118 ExecutorAddr ELFNixHeaderAddr;
119 ExecutorAddr PlatformBootstrap;
120 ExecutorAddr PlatformShutdown;
121 ExecutorAddr RegisterJITDylib;
122 ExecutorAddr DeregisterJITDylib;
123};
124
125class DSOHandleMaterializationUnit : public MaterializationUnit {
126public:
127 DSOHandleMaterializationUnit(ELFNixPlatform &ENP,
128 const SymbolStringPtr &DSOHandleSymbol)
130 createDSOHandleSectionInterface(ENP, DSOHandleSymbol)),
131 ENP(ENP) {}
132
133 StringRef getName() const override { return "DSOHandleMU"; }
134
135 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
136
137 auto &ES = ENP.getExecutionSession();
138
139 jitlink::Edge::Kind EdgeKind;
140
141 switch (ES.getTargetTriple().getArch()) {
142 case Triple::x86_64:
144 break;
145 case Triple::aarch64:
147 break;
148 case Triple::ppc64:
149 EdgeKind = jitlink::ppc64::Pointer64;
150 break;
151 case Triple::ppc64le:
152 EdgeKind = jitlink::ppc64::Pointer64;
153 break;
156 break;
157 case Triple::systemz:
159 break;
160 default:
161 llvm_unreachable("Unrecognized architecture");
162 }
163
164 // void *__dso_handle = &__dso_handle;
165 auto G = std::make_unique<jitlink::LinkGraph>(
166 "<DSOHandleMU>", ES.getSymbolStringPool(), ES.getTargetTriple(),
168 auto &DSOHandleSection =
169 G->createSection(".data.__dso_handle", MemProt::Read);
170 auto &DSOHandleBlock = G->createContentBlock(
171 DSOHandleSection, getDSOHandleContent(G->getPointerSize()),
172 orc::ExecutorAddr(), 8, 0);
173 auto &DSOHandleSymbol = G->addDefinedSymbol(
174 DSOHandleBlock, 0, *R->getInitializerSymbol(), DSOHandleBlock.getSize(),
176 DSOHandleBlock.addEdge(EdgeKind, 0, DSOHandleSymbol, 0);
177
178 ENP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
179 }
180
181 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
182
183private:
185 createDSOHandleSectionInterface(ELFNixPlatform &ENP,
186 const SymbolStringPtr &DSOHandleSymbol) {
187 SymbolFlagsMap SymbolFlags;
188 SymbolFlags[DSOHandleSymbol] = JITSymbolFlags::Exported;
189 return MaterializationUnit::Interface(std::move(SymbolFlags),
190 DSOHandleSymbol);
191 }
192
193 ArrayRef<char> getDSOHandleContent(size_t PointerSize) {
194 static const char Content[8] = {0};
195 assert(PointerSize <= sizeof Content);
196 return {Content, PointerSize};
197 }
198
199 ELFNixPlatform &ENP;
200};
201
202} // end anonymous namespace
203
204namespace llvm {
205namespace orc {
206
207Expected<std::unique_ptr<ELFNixPlatform>>
209 JITDylib &PlatformJD,
210 std::unique_ptr<DefinitionGenerator> OrcRuntime,
211 std::optional<SymbolAliasMap> RuntimeAliases) {
212
213 auto &ES = ObjLinkingLayer.getExecutionSession();
214
215 // If the target is not supported then bail out immediately.
216 if (!supportedTarget(ES.getTargetTriple()))
217 return make_error<StringError>("Unsupported ELFNixPlatform triple: " +
218 ES.getTargetTriple().str(),
220
221 auto &EPC = ES.getExecutorProcessControl();
222
223 // Create default aliases if the caller didn't supply any.
224 if (!RuntimeAliases) {
225 auto StandardRuntimeAliases = standardPlatformAliases(ES, PlatformJD);
226 if (!StandardRuntimeAliases)
227 return StandardRuntimeAliases.takeError();
228 RuntimeAliases = std::move(*StandardRuntimeAliases);
229 }
230
231 // Define the aliases.
232 if (auto Err = PlatformJD.define(symbolAliases(std::move(*RuntimeAliases))))
233 return std::move(Err);
234
235 // Add JIT-dispatch function support symbols.
236 if (auto Err = PlatformJD.define(
237 absoluteSymbols({{ES.intern("__orc_rt_jit_dispatch"),
238 {EPC.getJITDispatchInfo().JITDispatchFunction,
240 {ES.intern("__orc_rt_jit_dispatch_ctx"),
241 {EPC.getJITDispatchInfo().JITDispatchContext,
243 return std::move(Err);
244
245 // Create the instance.
246 Error Err = Error::success();
247 auto P = std::unique_ptr<ELFNixPlatform>(new ELFNixPlatform(
248 ObjLinkingLayer, PlatformJD, std::move(OrcRuntime), Err));
249 if (Err)
250 return std::move(Err);
251 return std::move(P);
252}
253
256 JITDylib &PlatformJD, const char *OrcRuntimePath,
257 std::optional<SymbolAliasMap> RuntimeAliases) {
258
259 // Create a generator for the ORC runtime archive.
260 auto OrcRuntimeArchiveGenerator =
261 StaticLibraryDefinitionGenerator::Load(ObjLinkingLayer, OrcRuntimePath);
262 if (!OrcRuntimeArchiveGenerator)
263 return OrcRuntimeArchiveGenerator.takeError();
264
265 return Create(ObjLinkingLayer, PlatformJD,
266 std::move(*OrcRuntimeArchiveGenerator),
267 std::move(RuntimeAliases));
268}
269
271 if (auto Err = JD.define(std::make_unique<DSOHandleMaterializationUnit>(
272 *this, DSOHandleSymbol)))
273 return Err;
274
275 return ES.lookup({&JD}, DSOHandleSymbol).takeError();
276}
277
279 std::lock_guard<std::mutex> Lock(PlatformMutex);
280 auto I = JITDylibToHandleAddr.find(&JD);
281 if (I != JITDylibToHandleAddr.end()) {
282 assert(HandleAddrToJITDylib.count(I->second) &&
283 "HandleAddrToJITDylib missing entry");
284 HandleAddrToJITDylib.erase(I->second);
285 JITDylibToHandleAddr.erase(I);
286 }
287 return Error::success();
288}
289
291 const MaterializationUnit &MU) {
292
293 auto &JD = RT.getJITDylib();
294 const auto &InitSym = MU.getInitializerSymbol();
295 if (!InitSym)
296 return Error::success();
297
298 RegisteredInitSymbols[&JD].add(InitSym,
300 LLVM_DEBUG({
301 dbgs() << "ELFNixPlatform: Registered init symbol " << *InitSym
302 << " for MU " << MU.getName() << "\n";
303 });
304 return Error::success();
305}
306
310
312 ArrayRef<std::pair<const char *, const char *>> AL) {
313 for (auto &KV : AL) {
314 auto AliasName = ES.intern(KV.first);
315 assert(!Aliases.count(AliasName) && "Duplicate symbol name in alias map");
316 Aliases[std::move(AliasName)] = {ES.intern(KV.second),
318 }
319}
320
323 JITDylib &PlatformJD) {
324 SymbolAliasMap Aliases;
325 addAliases(ES, Aliases, requiredCXXAliases());
328 return Aliases;
329}
330
333 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
334 {"__cxa_atexit", "__orc_rt_elfnix_cxa_atexit"},
335 {"atexit", "__orc_rt_elfnix_atexit"}};
336
337 return ArrayRef<std::pair<const char *, const char *>>(RequiredCXXAliases);
338}
339
342 static const std::pair<const char *, const char *>
343 StandardRuntimeUtilityAliases[] = {
344 {"__orc_rt_run_program", "__orc_rt_elfnix_run_program"},
345 {"__orc_rt_jit_dlerror", "__orc_rt_elfnix_jit_dlerror"},
346 {"__orc_rt_jit_dlopen", "__orc_rt_elfnix_jit_dlopen"},
347 {"__orc_rt_jit_dlupdate", "__orc_rt_elfnix_jit_dlupdate"},
348 {"__orc_rt_jit_dlclose", "__orc_rt_elfnix_jit_dlclose"},
349 {"__orc_rt_jit_dlsym", "__orc_rt_elfnix_jit_dlsym"},
350 {"__orc_rt_log_error", "__orc_rt_log_error_to_stderr"}};
351
353 StandardRuntimeUtilityAliases);
354}
355
358 static const std::pair<const char *, const char *>
359 StandardLazyCompilationAliases[] = {
360 {"__orc_rt_reenter", "__orc_rt_sysv_reenter"}};
361
363 StandardLazyCompilationAliases);
364}
365
366bool ELFNixPlatform::supportedTarget(const Triple &TT) {
367 switch (TT.getArch()) {
368 case Triple::x86_64:
369 case Triple::aarch64:
370 // FIXME: jitlink for ppc64 hasn't been well tested, leave it unsupported
371 // right now.
372 case Triple::ppc64le:
374 case Triple::systemz:
375 return true;
376 default:
377 return false;
378 }
379}
380
381ELFNixPlatform::ELFNixPlatform(
382 ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
383 std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator, Error &Err)
384 : ES(ObjLinkingLayer.getExecutionSession()), PlatformJD(PlatformJD),
385 ObjLinkingLayer(ObjLinkingLayer),
386 DSOHandleSymbol(ES.intern("__dso_handle")) {
388 ObjLinkingLayer.addPlugin(std::make_unique<ELFNixPlatformPlugin>(*this));
389
390 PlatformJD.addGenerator(std::move(OrcRuntimeGenerator));
391
392 BootstrapInfo BI;
393 Bootstrap = &BI;
394
395 // PlatformJD hasn't been 'set-up' by the platform yet (since we're creating
396 // the platform now), so set it up.
397 if (auto E2 = setupJITDylib(PlatformJD)) {
398 Err = std::move(E2);
399 return;
400 }
401
402 // Step (2) Request runtime registration functions to trigger
403 // materialization..
404 if ((Err = ES.lookup(
405 makeJITDylibSearchOrder(&PlatformJD),
406 SymbolLookupSet(
407 {PlatformBootstrap.Name, PlatformShutdown.Name,
408 RegisterJITDylib.Name, DeregisterJITDylib.Name,
409 RegisterInitSections.Name, DeregisterInitSections.Name,
410 RegisterObjectSections.Name,
411 DeregisterObjectSections.Name, CreatePThreadKey.Name}))
412 .takeError()))
413 return;
414
415 // Step (3) Wait for any incidental linker work to complete.
416 {
417 std::unique_lock<std::mutex> Lock(BI.Mutex);
418 BI.CV.wait(Lock, [&]() { return BI.ActiveGraphs == 0; });
419 Bootstrap = nullptr;
420 }
421
422 // Step (4) Add complete-bootstrap materialization unit and request.
423 auto BootstrapCompleteSymbol =
424 ES.intern("__orc_rt_elfnix_complete_bootstrap");
425 if ((Err = PlatformJD.define(
426 std::make_unique<ELFNixPlatformCompleteBootstrapMaterializationUnit>(
427 *this, PlatformJD.getName(), BootstrapCompleteSymbol,
428 std::move(BI.DeferredRTFnMap), BI.ELFNixHeaderAddr,
429 PlatformBootstrap.Addr, PlatformShutdown.Addr,
430 RegisterJITDylib.Addr, DeregisterJITDylib.Addr))))
431 return;
432 if ((Err = ES.lookup(makeJITDylibSearchOrder(
434 std::move(BootstrapCompleteSymbol))
435 .takeError()))
436 return;
437
438 // Associate wrapper function tags with JIT-side function implementations.
439 if (auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
440 Err = std::move(E2);
441 return;
442 }
443}
444
445Error ELFNixPlatform::associateRuntimeSupportFunctions(JITDylib &PlatformJD) {
447
448 using RecordInitializersSPSSig =
449 SPSExpected<SPSELFNixJITDylibDepInfoMap>(SPSExecutorAddr);
450 WFs[ES.intern("__orc_rt_elfnix_push_initializers_tag")] =
451 ES.wrapAsyncWithSPS<RecordInitializersSPSSig>(
452 this, &ELFNixPlatform::rt_recordInitializers);
453
454 using LookupSymbolSPSSig =
455 SPSExpected<SPSExecutorAddr>(SPSExecutorAddr, SPSString);
456 WFs[ES.intern("__orc_rt_elfnix_symbol_lookup_tag")] =
457 ES.wrapAsyncWithSPS<LookupSymbolSPSSig>(this,
458 &ELFNixPlatform::rt_lookupSymbol);
459
460 return ES.registerJITDispatchHandlers(PlatformJD, std::move(WFs));
461}
462
463void ELFNixPlatform::pushInitializersLoop(
464 PushInitializersSendResultFn SendResult, JITDylibSP JD) {
465 DenseMap<JITDylib *, SymbolLookupSet> NewInitSymbols;
466 DenseMap<JITDylib *, SmallVector<JITDylib *>> JDDepMap;
467 SmallVector<JITDylib *, 16> Worklist({JD.get()});
468
469 ES.runSessionLocked([&]() {
470 while (!Worklist.empty()) {
471 // FIXME: Check for defunct dylibs.
472
473 auto DepJD = Worklist.back();
474 Worklist.pop_back();
475
476 // If we've already visited this JITDylib on this iteration then continue.
477 auto [It, Inserted] = JDDepMap.try_emplace(DepJD);
478 if (!Inserted)
479 continue;
480
481 // Add dep info.
482 auto &DM = It->second;
483 DepJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
484 for (auto &KV : O) {
485 if (KV.first == DepJD)
486 continue;
487 DM.push_back(KV.first);
488 Worklist.push_back(KV.first);
489 }
490 });
491
492 // Add any registered init symbols.
493 auto RISItr = RegisteredInitSymbols.find(DepJD);
494 if (RISItr != RegisteredInitSymbols.end()) {
495 NewInitSymbols[DepJD] = std::move(RISItr->second);
496 RegisteredInitSymbols.erase(RISItr);
497 }
498 }
499 });
500
501 // If there are no further init symbols to look up then send the link order
502 // (as a list of header addresses) to the caller.
503 if (NewInitSymbols.empty()) {
504
505 // To make the list intelligible to the runtime we need to convert all
506 // JITDylib pointers to their header addresses. Only include JITDylibs
507 // that appear in the JITDylibToHandleAddr map (i.e. those that have been
508 // through setupJITDylib) -- bare JITDylibs aren't managed by the platform.
509 DenseMap<JITDylib *, ExecutorAddr> HeaderAddrs;
510 HeaderAddrs.reserve(JDDepMap.size());
511 {
512 std::lock_guard<std::mutex> Lock(PlatformMutex);
513 for (auto &KV : JDDepMap) {
514 auto I = JITDylibToHandleAddr.find(KV.first);
515 if (I != JITDylibToHandleAddr.end())
516 HeaderAddrs[KV.first] = I->second;
517 }
518 }
519
520 // Build the dep info map to return.
522 DIM.reserve(JDDepMap.size());
523 for (auto &KV : JDDepMap) {
524 auto HI = HeaderAddrs.find(KV.first);
525 // Skip unmanaged JITDylibs.
526 if (HI == HeaderAddrs.end())
527 continue;
528 auto H = HI->second;
529 ELFNixJITDylibDepInfo DepInfo;
530 for (auto &Dep : KV.second) {
531 auto HJ = HeaderAddrs.find(Dep);
532 if (HJ != HeaderAddrs.end())
533 DepInfo.push_back(HJ->second);
534 }
535 DIM.push_back(std::make_pair(H, std::move(DepInfo)));
536 }
537 SendResult(DIM);
538 return;
539 }
540
541 // Otherwise issue a lookup and re-run this phase when it completes.
543 [this, SendResult = std::move(SendResult), JD](Error Err) mutable {
544 if (Err)
545 SendResult(std::move(Err));
546 else
547 pushInitializersLoop(std::move(SendResult), JD);
548 },
549 ES, std::move(NewInitSymbols));
550}
551
552void ELFNixPlatform::rt_recordInitializers(
553 PushInitializersSendResultFn SendResult, ExecutorAddr JDHeaderAddr) {
554 JITDylibSP JD;
555 {
556 std::lock_guard<std::mutex> Lock(PlatformMutex);
557 auto I = HandleAddrToJITDylib.find(JDHeaderAddr);
558 if (I != HandleAddrToJITDylib.end())
559 JD = I->second;
560 }
561
562 LLVM_DEBUG({
563 dbgs() << "ELFNixPlatform::rt_recordInitializers(" << JDHeaderAddr << ") ";
564 if (JD)
565 dbgs() << "pushing initializers for " << JD->getName() << "\n";
566 else
567 dbgs() << "No JITDylib for header address.\n";
568 });
569
570 if (!JD) {
571 SendResult(make_error<StringError>("No JITDylib with header addr " +
572 formatv("{0:x}", JDHeaderAddr),
574 return;
575 }
576
577 pushInitializersLoop(std::move(SendResult), JD);
578}
579
580void ELFNixPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
581 ExecutorAddr Handle,
582 StringRef SymbolName) {
583 LLVM_DEBUG({
584 dbgs() << "ELFNixPlatform::rt_lookupSymbol(\"" << Handle << "\")\n";
585 });
586
587 JITDylib *JD = nullptr;
588
589 {
590 std::lock_guard<std::mutex> Lock(PlatformMutex);
591 auto I = HandleAddrToJITDylib.find(Handle);
592 if (I != HandleAddrToJITDylib.end())
593 JD = I->second;
594 }
595
596 if (!JD) {
597 LLVM_DEBUG(dbgs() << " No JITDylib for handle " << Handle << "\n");
598 SendResult(make_error<StringError>("No JITDylib associated with handle " +
599 formatv("{0:x}", Handle),
601 return;
602 }
603
604 // Use functor class to work around XL build compiler issue on AIX.
605 class RtLookupNotifyComplete {
606 public:
607 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
608 : SendResult(std::move(SendResult)) {}
609 void operator()(Expected<SymbolMap> Result) {
610 if (Result) {
611 assert(Result->size() == 1 && "Unexpected result map count");
612 SendResult(Result->begin()->second.getAddress());
613 } else {
614 SendResult(Result.takeError());
615 }
616 }
617
618 private:
619 SendSymbolAddressFn SendResult;
620 };
621
622 ES.lookup(
624 SymbolLookupSet(ES.intern(SymbolName)), SymbolState::Ready,
625 RtLookupNotifyComplete(std::move(SendResult)), NoDependenciesToRegister);
626}
627
628Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineStart(
629 jitlink::LinkGraph &G) {
630 // Increment the active graphs count in BootstrapInfo.
631 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
632 ++MP.Bootstrap.load()->ActiveGraphs;
633 return Error::success();
634}
635
636Error ELFNixPlatform::ELFNixPlatformPlugin::
637 bootstrapPipelineRecordRuntimeFunctions(jitlink::LinkGraph &G) {
638 // Record bootstrap function names.
639 std::pair<StringRef, ExecutorAddr *> RuntimeSymbols[] = {
640 {*MP.DSOHandleSymbol, &MP.Bootstrap.load()->ELFNixHeaderAddr},
641 {*MP.PlatformBootstrap.Name, &MP.PlatformBootstrap.Addr},
642 {*MP.PlatformShutdown.Name, &MP.PlatformShutdown.Addr},
643 {*MP.RegisterJITDylib.Name, &MP.RegisterJITDylib.Addr},
644 {*MP.DeregisterJITDylib.Name, &MP.DeregisterJITDylib.Addr},
645 {*MP.RegisterObjectSections.Name, &MP.RegisterObjectSections.Addr},
646 {*MP.DeregisterObjectSections.Name, &MP.DeregisterObjectSections.Addr},
647 {*MP.RegisterInitSections.Name, &MP.RegisterInitSections.Addr},
648 {*MP.DeregisterInitSections.Name, &MP.DeregisterInitSections.Addr},
649 {*MP.CreatePThreadKey.Name, &MP.CreatePThreadKey.Addr}};
650
651 bool RegisterELFNixHeader = false;
652
653 for (auto *Sym : G.defined_symbols()) {
654 for (auto &RTSym : RuntimeSymbols) {
655 if (Sym->hasName() && *Sym->getName() == RTSym.first) {
656 if (*RTSym.second)
658 "Duplicate " + RTSym.first +
659 " detected during ELFNixPlatform bootstrap",
661
662 if (*Sym->getName() == *MP.DSOHandleSymbol)
663 RegisterELFNixHeader = true;
664
665 *RTSym.second = Sym->getAddress();
666 }
667 }
668 }
669
670 if (RegisterELFNixHeader) {
671 // If this graph defines the elfnix header symbol then create the internal
672 // mapping between it and PlatformJD.
673 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
674 MP.JITDylibToHandleAddr[&MP.PlatformJD] =
675 MP.Bootstrap.load()->ELFNixHeaderAddr;
676 MP.HandleAddrToJITDylib[MP.Bootstrap.load()->ELFNixHeaderAddr] =
677 &MP.PlatformJD;
678 }
679
680 return Error::success();
681}
682
683Error ELFNixPlatform::ELFNixPlatformPlugin::bootstrapPipelineEnd(
684 jitlink::LinkGraph &G) {
685 std::lock_guard<std::mutex> Lock(MP.Bootstrap.load()->Mutex);
686 assert(MP.Bootstrap && "DeferredAAs reset before bootstrap completed");
687 --MP.Bootstrap.load()->ActiveGraphs;
688 // Notify Bootstrap->CV while holding the mutex because the mutex is
689 // also keeping Bootstrap->CV alive.
690 if (MP.Bootstrap.load()->ActiveGraphs == 0)
691 MP.Bootstrap.load()->CV.notify_all();
692 return Error::success();
693}
694
695Error ELFNixPlatform::registerPerObjectSections(
696 jitlink::LinkGraph &G, const ELFPerObjectSectionsToRegister &POSR,
697 bool IsBootstrapping) {
698 using SPSRegisterPerObjSectionsArgs =
699 SPSArgList<SPSELFPerObjectSectionsToRegister>;
700
701 if (LLVM_UNLIKELY(IsBootstrapping)) {
702 Bootstrap.load()->addArgumentsToRTFnMap(
703 &RegisterObjectSections, &DeregisterObjectSections,
704 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR),
705 getArgDataBufferType<SPSRegisterPerObjSectionsArgs>(POSR));
706 return Error::success();
707 }
708
709 G.allocActions().push_back(
711 RegisterObjectSections.Addr, POSR)),
713 DeregisterObjectSections.Addr, POSR))});
714
715 return Error::success();
716}
717
718Expected<uint64_t> ELFNixPlatform::createPThreadKey() {
719 if (!CreatePThreadKey.Addr)
721 "Attempting to create pthread key in target, but runtime support has "
722 "not been loaded yet",
724
725 Expected<uint64_t> Result(0);
726 if (auto Err = ES.callSPSWrapper<SPSExpected<uint64_t>(void)>(
727 CreatePThreadKey.Addr, Result))
728 return std::move(Err);
729 return Result;
730}
731
732void ELFNixPlatform::ELFNixPlatformPlugin::modifyPassConfig(
733 MaterializationResponsibility &MR, jitlink::LinkGraph &LG,
734 jitlink::PassConfiguration &Config) {
735 using namespace jitlink;
736
737 bool InBootstrapPhase =
738 &MR.getTargetJITDylib() == &MP.PlatformJD && MP.Bootstrap;
739
740 // If we're in the bootstrap phase then increment the active graphs.
741 if (InBootstrapPhase) {
742 Config.PrePrunePasses.push_back(
743 [this](LinkGraph &G) { return bootstrapPipelineStart(G); });
744 Config.PostAllocationPasses.push_back([this](LinkGraph &G) {
745 return bootstrapPipelineRecordRuntimeFunctions(G);
746 });
747 }
748
749 // If the initializer symbol is the __dso_handle symbol then just add
750 // the DSO handle support passes.
751 if (auto InitSymbol = MR.getInitializerSymbol()) {
752 if (InitSymbol == MP.DSOHandleSymbol && !InBootstrapPhase) {
753 addDSOHandleSupportPasses(MR, Config);
754 // The DSOHandle materialization unit doesn't require any other
755 // support, so we can bail out early.
756 return;
757 }
758
759 /// Preserve init sections.
760 Config.PrePrunePasses.push_back(
761 [this, &MR](jitlink::LinkGraph &G) -> Error {
762 if (auto Err = preserveInitSections(G, MR))
763 return Err;
764 return Error::success();
765 });
766 }
767
768 // Add passes for eh-frame and TLV support.
769 addEHAndTLVSupportPasses(MR, Config, InBootstrapPhase);
770
771 // If the object contains initializers then add passes to record them.
772 Config.PostFixupPasses.push_back([this, &JD = MR.getTargetJITDylib(),
773 InBootstrapPhase](jitlink::LinkGraph &G) {
774 return registerInitSections(G, JD, InBootstrapPhase);
775 });
776
777 // If we're in the bootstrap phase then steal allocation actions and then
778 // decrement the active graphs.
779 if (InBootstrapPhase)
780 Config.PostFixupPasses.push_back(
781 [this](LinkGraph &G) { return bootstrapPipelineEnd(G); });
782}
783
784void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
785 MaterializationResponsibility &MR, jitlink::PassConfiguration &Config) {
786
787 Config.PostAllocationPasses.push_back([this, &JD = MR.getTargetJITDylib()](
788 jitlink::LinkGraph &G) -> Error {
789 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
790 return Sym->getName() == MP.DSOHandleSymbol;
791 });
792 assert(I != G.defined_symbols().end() && "Missing DSO handle symbol");
793 {
794 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
795 auto HandleAddr = (*I)->getAddress();
796 MP.HandleAddrToJITDylib[HandleAddr] = &JD;
797 MP.JITDylibToHandleAddr[&JD] = HandleAddr;
798
799 G.allocActions().push_back(
801 SPSArgList<SPSString, SPSExecutorAddr>>(
802 MP.RegisterJITDylib.Addr, JD.getName(), HandleAddr)),
803 cantFail(WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddr>>(
804 MP.DeregisterJITDylib.Addr, HandleAddr))});
805 }
806 return Error::success();
807 });
808}
809
810void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
811 MaterializationResponsibility &MR, jitlink::PassConfiguration &Config,
812 bool IsBootstrapping) {
813
814 // Insert TLV lowering at the start of the PostPrunePasses, since we want
815 // it to run before GOT/PLT lowering.
816
817 // TODO: Check that before the fixTLVSectionsAndEdges pass, the GOT/PLT build
818 // pass has done. Because the TLS descriptor need to be allocate in GOT.
819 Config.PostPrunePasses.push_back(
820 [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
821 return fixTLVSectionsAndEdges(G, JD);
822 });
823
824 // Add a pass to register the final addresses of the eh-frame and TLV sections
825 // with the runtime.
826 Config.PostFixupPasses.push_back([this, IsBootstrapping](
827 jitlink::LinkGraph &G) -> Error {
828 ELFPerObjectSectionsToRegister POSR;
829
830 if (auto *EHFrameSection = G.findSectionByName(ELFEHFrameSectionName)) {
831 jitlink::SectionRange R(*EHFrameSection);
832 if (!R.empty())
833 POSR.EHFrameSection = R.getRange();
834 }
835
836 // Get a pointer to the thread data section if there is one. It will be used
837 // below.
838 jitlink::Section *ThreadDataSection =
839 G.findSectionByName(ELFThreadDataSectionName);
840
841 // Handle thread BSS section if there is one.
842 if (auto *ThreadBSSSection = G.findSectionByName(ELFThreadBSSSectionName)) {
843 // If there's already a thread data section in this graph then merge the
844 // thread BSS section content into it, otherwise just treat the thread
845 // BSS section as the thread data section.
846 if (ThreadDataSection)
847 G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
848 else
849 ThreadDataSection = ThreadBSSSection;
850 }
851
852 // Having merged thread BSS (if present) and thread data (if present),
853 // record the resulting section range.
854 if (ThreadDataSection) {
855 jitlink::SectionRange R(*ThreadDataSection);
856 if (!R.empty())
857 POSR.ThreadDataSection = R.getRange();
858 }
859
860 if (POSR.EHFrameSection.Start || POSR.ThreadDataSection.Start) {
861 if (auto Err = MP.registerPerObjectSections(G, POSR, IsBootstrapping))
862 return Err;
863 }
864
865 return Error::success();
866 });
867}
868
869Error ELFNixPlatform::ELFNixPlatformPlugin::preserveInitSections(
870 jitlink::LinkGraph &G, MaterializationResponsibility &MR) {
871
872 if (const auto &InitSymName = MR.getInitializerSymbol()) {
873
874 jitlink::Symbol *InitSym = nullptr;
875
876 for (auto &InitSection : G.sections()) {
877 // Skip non-init sections.
878 if (!isELFInitializerSection(InitSection.getName()) ||
879 InitSection.empty())
880 continue;
881
882 // Create the init symbol if it has not been created already and attach it
883 // to the first block.
884 if (!InitSym) {
885 auto &B = **InitSection.blocks().begin();
886 InitSym = &G.addDefinedSymbol(
887 B, 0, *InitSymName, B.getSize(), jitlink::Linkage::Strong,
889 }
890
891 // Add keep-alive edges to anonymous symbols in all other init blocks.
892 for (auto *B : InitSection.blocks()) {
893 if (B == &InitSym->getBlock())
894 continue;
895
896 auto &S = G.addAnonymousSymbol(*B, 0, B->getSize(), false, true);
897 InitSym->getBlock().addEdge(jitlink::Edge::KeepAlive, 0, S, 0);
898 }
899 }
900 }
901
902 return Error::success();
903}
904
905Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
906 jitlink::LinkGraph &G, JITDylib &JD, bool IsBootstrapping) {
907 SmallVector<ExecutorAddrRange> ELFNixPlatformSecs;
908 LLVM_DEBUG(dbgs() << "ELFNixPlatform::registerInitSections\n");
909
910 SmallVector<jitlink::Section *> OrderedInitSections;
911 for (auto &Sec : G.sections())
912 if (isELFInitializerSection(Sec.getName()))
913 OrderedInitSections.push_back(&Sec);
914
915 // FIXME: This handles priority order within the current graph, but we'll need
916 // to include priority information in the initializer allocation
917 // actions in order to respect the ordering across multiple graphs.
918 llvm::sort(OrderedInitSections, [](const jitlink::Section *LHS,
919 const jitlink::Section *RHS) {
920 if (LHS->getName().starts_with(".init_array")) {
921 if (RHS->getName().starts_with(".init_array")) {
922 StringRef LHSPrioStr(LHS->getName());
923 StringRef RHSPrioStr(RHS->getName());
924 uint64_t LHSPriority;
925 bool LHSHasPriority = LHSPrioStr.consume_front(".init_array.") &&
926 !LHSPrioStr.getAsInteger(10, LHSPriority);
927 uint64_t RHSPriority;
928 bool RHSHasPriority = RHSPrioStr.consume_front(".init_array.") &&
929 !RHSPrioStr.getAsInteger(10, RHSPriority);
930 if (LHSHasPriority)
931 return RHSHasPriority ? LHSPriority < RHSPriority : true;
932 else if (RHSHasPriority)
933 return false;
934 // If we get here we'll fall through to the
935 // LHS->getName() < RHS->getName() test below.
936 } else {
937 // .init_array[.N] comes before any non-.init_array[.N] section.
938 return true;
939 }
940 }
941 return LHS->getName() < RHS->getName();
942 });
943
944 for (auto &Sec : OrderedInitSections)
945 ELFNixPlatformSecs.push_back(jitlink::SectionRange(*Sec).getRange());
946
947 // Dump the scraped inits.
948 LLVM_DEBUG({
949 dbgs() << "ELFNixPlatform: Scraped " << G.getName() << " init sections:\n";
950 for (auto &Sec : G.sections()) {
951 jitlink::SectionRange R(Sec);
952 dbgs() << " " << Sec.getName() << ": " << R.getRange() << "\n";
953 }
954 });
955
956 ExecutorAddr HeaderAddr;
957 {
958 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
959 auto I = MP.JITDylibToHandleAddr.find(&JD);
960 assert(I != MP.JITDylibToHandleAddr.end() && "No header registered for JD");
961 assert(I->second && "Null header registered for JD");
962 HeaderAddr = I->second;
963 }
964
965 using SPSRegisterInitSectionsArgs =
966 SPSArgList<SPSExecutorAddr, SPSSequence<SPSExecutorAddrRange>>;
967
968 if (LLVM_UNLIKELY(IsBootstrapping)) {
969 MP.Bootstrap.load()->addArgumentsToRTFnMap(
970 &MP.RegisterInitSections, &MP.DeregisterInitSections,
971 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
972 ELFNixPlatformSecs),
973 getArgDataBufferType<SPSRegisterInitSectionsArgs>(HeaderAddr,
974 ELFNixPlatformSecs));
975 return Error::success();
976 }
977
978 G.allocActions().push_back(
980 MP.RegisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs)),
982 MP.DeregisterInitSections.Addr, HeaderAddr, ELFNixPlatformSecs))});
983
984 return Error::success();
985}
986
987Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
988 jitlink::LinkGraph &G, JITDylib &JD) {
989 auto TLSGetAddrSymbolName = G.intern("__tls_get_addr");
990 auto TLSDescResolveSymbolName = G.intern("__tlsdesc_resolver");
991 for (auto *Sym : G.external_symbols()) {
992 if (Sym->getName() == TLSGetAddrSymbolName) {
993 auto TLSGetAddr =
994 MP.getExecutionSession().intern("___orc_rt_elfnix_tls_get_addr");
995 Sym->setName(std::move(TLSGetAddr));
996 } else if (Sym->getName() == TLSDescResolveSymbolName) {
997 auto TLSGetAddr =
998 MP.getExecutionSession().intern("___orc_rt_elfnix_tlsdesc_resolver");
999 Sym->setName(std::move(TLSGetAddr));
1000 }
1001 }
1002
1003 auto *TLSInfoEntrySection = G.findSectionByName("$__TLSINFO");
1004
1005 if (TLSInfoEntrySection) {
1006 std::optional<uint64_t> Key;
1007 {
1008 std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
1009 auto I = MP.JITDylibToPThreadKey.find(&JD);
1010 if (I != MP.JITDylibToPThreadKey.end())
1011 Key = I->second;
1012 }
1013 if (!Key) {
1014 if (auto KeyOrErr = MP.createPThreadKey())
1015 Key = *KeyOrErr;
1016 else
1017 return KeyOrErr.takeError();
1018 }
1019
1020 uint64_t PlatformKeyBits =
1021 support::endian::byte_swap(*Key, G.getEndianness());
1022
1023 for (auto *B : TLSInfoEntrySection->blocks()) {
1024 // FIXME: The TLS descriptor byte length may different with different
1025 // ISA
1026 assert(B->getSize() == (G.getPointerSize() * 2) &&
1027 "TLS descriptor must be 2 words length");
1028 auto TLSInfoEntryContent = B->getMutableContent(G);
1029 memcpy(TLSInfoEntryContent.data(), &PlatformKeyBits, G.getPointerSize());
1030 }
1031 }
1032
1033 return Error::success();
1034}
1035
1036} // End namespace orc.
1037} // End namespace llvm.
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_UNLIKELY(EXPR)
Definition Compiler.h:336
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
#define _
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define H(x, y, z)
Definition MD5.cpp:56
#define P(N)
static StringRef getName(Value *V)
#define LLVM_DEBUG(...)
Definition Debug.h:114
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:178
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition DenseMap.h:256
unsigned size() const
Definition DenseMap.h:110
bool empty() const
Definition DenseMap.h:109
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition DenseMap.h:174
iterator end()
Definition DenseMap.h:81
void reserve(size_type NumEntries)
Grow the densemap so that it can contain at least NumEntries items before resizing again.
Definition DenseMap.h:114
Helper for Errors used as out-parameters.
Definition Error.h:1144
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
void resize(size_type N)
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.
Definition StringRef.h:55
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:261
Manages the enabling and disabling of subtarget specific features.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
@ loongarch64
Definition Triple.h:65
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:322
Mediates between ELFNix initialization and ExecutionSession state.
ObjectLinkingLayer & getObjectLinkingLayer() const
static Expected< SymbolAliasMap > standardPlatformAliases(ExecutionSession &ES, JITDylib &PlatformJD)
Returns an AliasMap containing the default aliases for the ELFNixPlatform.
Error notifyAdding(ResourceTracker &RT, const MaterializationUnit &MU) override
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added t...
Error notifyRemoving(ResourceTracker &RT) override
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
Error setupJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is created (unless it is cre...
ExecutionSession & getExecutionSession() const
static ArrayRef< std::pair< const char *, const char * > > standardRuntimeUtilityAliases()
Returns the array of standard runtime utility aliases for ELF.
static Expected< std::unique_ptr< ELFNixPlatform > > Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< DefinitionGenerator > OrcRuntime, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
Try to create a ELFNixPlatform instance, adding the ORC runtime to the given JITDylib.
static ArrayRef< std::pair< const char *, const char * > > standardLazyCompilationAliases()
Returns a list of aliases required to enable lazy compilation via the ORC runtime.
static ArrayRef< std::pair< const char *, const char * > > requiredCXXAliases()
Returns the array of required CXX aliases.
Error teardownJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is removed to allow the Plat...
An ExecutionSession represents a running JIT program.
Definition Core.h:1342
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition Core.h:1396
DenseMap< SymbolStringPtr, JITDispatchHandlerFunction > JITDispatchHandlerAssociationMap
A map associating tag names with asynchronous wrapper function implementations in the JIT.
Definition Core.h:1365
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Definition Core.h:906
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
Definition Core.h:1866
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition Core.h:1849
LinkGraphLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition Core.h:580
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
Definition Core.h:619
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition Core.h:605
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.
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.
static void lookupInitSymbolsAsync(unique_function< void(Error)> OnComplete, ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
Performs an async lookup for the given symbols in each of the given JITDylibs, calling the given hand...
Definition Core.cpp:1504
API to remove / transfer ownership of JIT resources.
Definition Core.h:82
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
Definition Core.h:97
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.
Pointer to a pooled string representing a symbol name.
A utility class for serializing to a blob from a variadic list.
Output char buffer with overflow check.
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.
SPSSequence< char > SPSString
SPS tag type for strings, which are equivalent to sequences of chars.
LLVM_ABI 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...
Definition Core.h:182
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
Definition Core.h:177
IntrusiveRefCntPtr< JITDylib > JITDylibSP
Definition Core.h:57
std::vector< std::pair< ExecutorAddr, ELFNixJITDylibDepInfo > > ELFNixJITDylibDepInfoMap
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition Core.h:754
std::vector< ExecutorAddr > ELFNixJITDylibDepInfo
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
LLVM_ABI StringRef ELFEHFrameSectionName
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * > > AL)
std::unordered_map< std::pair< RuntimeFunction *, RuntimeFunction * >, SmallVector< std::pair< shared::WrapperFunctionCall::ArgDataBufferType, shared::WrapperFunctionCall::ArgDataBufferType > >, FunctionPairKeyHash, FunctionPairKeyEqual > DeferredRuntimeFnMap
LLVM_ABI StringRef ELFThreadDataSectionName
LLVM_ABI RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition Core.cpp:38
@ Ready
Emitted to memory, but waiting on transitive dependencies.
Definition Core.h:782
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
Definition Core.h:417
LLVM_ABI bool isELFInitializerSection(StringRef SecName)
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
value_type byte_swap(value_type value, endianness endian)
Definition Endian.h:44
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:98
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
Definition STLExtras.h:1634
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1879