LLVM 24.0.0git
LazyReexports.cpp
Go to the documentation of this file.
1//===---------- LazyReexports.cpp - Utilities for lazy reexports ----------===//
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
17
18#define DEBUG_TYPE "orc"
19
20namespace llvm {
21namespace orc {
22
24 ExecutorAddr ErrorHandlerAddr,
26 : ES(ES), ErrorHandlerAddr(ErrorHandlerAddr), TP(TP) {}
27
29 JITDylib &SourceJD, SymbolStringPtr SymbolName,
30 NotifyResolvedFunction NotifyResolved) {
31 assert(TP && "TrampolinePool not set");
32
33 std::lock_guard<std::mutex> Lock(LCTMMutex);
34 auto Trampoline = TP->getTrampoline();
35
36 if (!Trampoline)
37 return Trampoline.takeError();
38
39 Reexports[*Trampoline] = ReexportsEntry{&SourceJD, std::move(SymbolName)};
40 Notifiers[*Trampoline] = std::move(NotifyResolved);
41 return *Trampoline;
42}
43
45 ES.reportError(std::move(Err));
46 return ErrorHandlerAddr;
47}
48
51 std::lock_guard<std::mutex> Lock(LCTMMutex);
52 auto I = Reexports.find(TrampolineAddr);
53 if (I == Reexports.end())
55 "Missing reexport for trampoline address %p" +
56 formatv("{0:x}", TrampolineAddr));
57 return I->second;
58}
59
61 ExecutorAddr ResolvedAddr) {
62 NotifyResolvedFunction NotifyResolved;
63 {
64 std::lock_guard<std::mutex> Lock(LCTMMutex);
65 auto I = Notifiers.find(TrampolineAddr);
66 if (I != Notifiers.end()) {
67 NotifyResolved = std::move(I->second);
68 Notifiers.erase(I);
69 }
70 }
71
72 return NotifyResolved ? NotifyResolved(ResolvedAddr) : Error::success();
73}
74
76 ExecutorAddr TrampolineAddr,
77 NotifyLandingResolvedFunction NotifyLandingResolved) {
78
79 auto Entry = findReexport(TrampolineAddr);
80 if (!Entry)
81 return NotifyLandingResolved(reportCallThroughError(Entry.takeError()));
82
83 // Declaring SLS and the callback outside of the call to ES.lookup is a
84 // workaround to fix build failures on AIX and on z/OS platforms.
85 SymbolLookupSet SLS({Entry->SymbolName});
86 auto Callback = [this, TrampolineAddr, SymbolName = Entry->SymbolName,
87 NotifyLandingResolved = std::move(NotifyLandingResolved)](
89 if (Result) {
90 assert(Result->size() == 1 && "Unexpected result size");
91 assert(Result->count(SymbolName) && "Unexpected result value");
92 ExecutorAddr LandingAddr = (*Result)[SymbolName].getAddress();
93
94 if (auto Err = notifyResolved(TrampolineAddr, LandingAddr))
95 NotifyLandingResolved(reportCallThroughError(std::move(Err)));
96 else
97 NotifyLandingResolved(LandingAddr);
98 } else {
99 NotifyLandingResolved(reportCallThroughError(Result.takeError()));
100 }
101 };
102
103 ES.lookup(LookupKind::Static,
104 makeJITDylibSearchOrder(Entry->SourceJD,
106 std::move(SLS), SymbolState::Ready, std::move(Callback),
108}
109
112 ExecutorAddr ErrorHandlerAddr) {
113 switch (T.getArch()) {
114 default:
116 std::string("No callback manager available for ") + T.str(),
118
119 case Triple::aarch64:
122 ErrorHandlerAddr);
123
124 case Triple::x86:
125 return LocalLazyCallThroughManager::Create<OrcI386>(ES, ErrorHandlerAddr);
126
129 ES, ErrorHandlerAddr);
130
131 case Triple::mips:
133 ErrorHandlerAddr);
134
135 case Triple::mipsel:
137 ErrorHandlerAddr);
138
139 case Triple::mips64:
140 case Triple::mips64el:
141 return LocalLazyCallThroughManager::Create<OrcMips64>(ES, ErrorHandlerAddr);
142
143 case Triple::riscv64:
145 ErrorHandlerAddr);
146
147 case Triple::x86_64:
148 if (T.getOS() == Triple::OSType::Win32)
150 ES, ErrorHandlerAddr);
151 else
153 ES, ErrorHandlerAddr);
154 }
155}
156
159 JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc)
160 : MaterializationUnit(extractFlags(CallableAliases)),
161 LCTManager(LCTManager), RSManager(RSManager), SourceJD(SourceJD),
162 CallableAliases(std::move(CallableAliases)), AliaseeTable(SrcJDLoc) {}
163
165 return "<Lazy Reexports>";
166}
167
168void LazyReexportsMaterializationUnit::materialize(
169 std::unique_ptr<MaterializationResponsibility> R) {
170 auto RequestedSymbols = R->getRequestedSymbols();
171
172 SymbolAliasMap RequestedAliases;
173 for (auto &RequestedSymbol : RequestedSymbols) {
174 auto I = CallableAliases.find(RequestedSymbol);
175 assert(I != CallableAliases.end() && "Symbol not found in alias map?");
176 RequestedAliases[I->first] = std::move(I->second);
177 CallableAliases.erase(I);
178 }
179
180 if (!CallableAliases.empty())
181 if (auto Err = R->replace(lazyReexports(LCTManager, RSManager, SourceJD,
182 std::move(CallableAliases),
183 AliaseeTable))) {
184 R->getExecutionSession().reportError(std::move(Err));
185 R->failMaterialization();
186 return;
187 }
188
189 SymbolMap Inits;
190 for (auto &Alias : RequestedAliases) {
191 auto CallThroughTrampoline = LCTManager.getCallThroughTrampoline(
192 SourceJD, Alias.second.Aliasee,
193 [&TargetJD = R->getTargetJITDylib(), &RSManager = this->RSManager,
194 StubSym = Alias.first](ExecutorAddr ResolvedAddr) -> Error {
195 return RSManager.redirect(TargetJD, StubSym,
196 ExecutorSymbolDef(ResolvedAddr, {}));
197 });
198
199 if (!CallThroughTrampoline) {
200 R->getExecutionSession().reportError(CallThroughTrampoline.takeError());
201 R->failMaterialization();
202 return;
203 }
204
205 Inits[Alias.first] = {*CallThroughTrampoline, Alias.second.AliasFlags};
206 }
207
208 if (AliaseeTable != nullptr && !RequestedAliases.empty())
209 AliaseeTable->trackImpls(RequestedAliases, &SourceJD);
210
211 if (auto Err = R->replace(std::make_unique<RedirectableMaterializationUnit>(
212 RSManager, std::move(Inits)))) {
213 R->getExecutionSession().reportError(std::move(Err));
214 return R->failMaterialization();
215 }
216}
217
218void LazyReexportsMaterializationUnit::discard(const JITDylib &JD,
219 const SymbolStringPtr &Name) {
220 assert(CallableAliases.count(Name) &&
221 "Symbol not covered by this MaterializationUnit");
222 CallableAliases.erase(Name);
223}
224
225MaterializationUnit::Interface
226LazyReexportsMaterializationUnit::extractFlags(const SymbolAliasMap &Aliases) {
228 for (auto &KV : Aliases) {
229 assert(KV.second.AliasFlags.isCallable() &&
230 "Lazy re-exports must be callable symbols");
231 SymbolFlags[KV.first] = KV.second.AliasFlags;
232 }
233 return MaterializationUnit::Interface(std::move(SymbolFlags), nullptr);
234}
235
237public:
239 : MaterializationUnit(getInterface(Reexports)), LRMgr(LRMgr),
240 Reexports(std::move(Reexports)) {}
241
242private:
243 Interface getInterface(const SymbolAliasMap &Reexports) {
245 for (auto &[Alias, AI] : Reexports)
246 SF[Alias] = AI.AliasFlags;
247 return {std::move(SF), nullptr};
248 }
249
250 StringRef getName() const override { return "LazyReexportsManager::MU"; }
251
252 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
253 LRMgr.emitReentryTrampolines(std::move(R), std::move(Reexports));
254 }
255
256 void discard(const JITDylib &JD, const SymbolStringPtr &Name) override {
257 Reexports.erase(Name);
258 }
259
260 LazyReexportsManager &LRMgr;
261 SymbolAliasMap Reexports;
262};
263
281
283
287 JITDylib &PlatformJD, Listener *L) {
288 Error Err = Error::success();
289 std::unique_ptr<LazyReexportsManager> LRM(new LazyReexportsManager(
290 std::move(EmitTrampolines), RSMgr, PlatformJD, L, Err));
291 if (Err)
292 return std::move(Err);
293 return std::move(LRM);
294}
295
297 return JD.getExecutionSession().runSessionLocked([&]() -> Error {
298 auto I = KeyToReentryAddrs.find(K);
299 if (I == KeyToReentryAddrs.end())
300 return Error::success();
301
302 auto &ReentryAddrs = I->second;
303 for (auto &ReentryAddr : ReentryAddrs) {
304 assert(CallThroughs.count(ReentryAddr) && "CallTrhough missing");
305 CallThroughs.erase(ReentryAddr);
306 }
307 KeyToReentryAddrs.erase(I);
308 return L ? L->onLazyReexportsRemoved(JD, K) : Error::success();
309 });
310}
311
313 ResourceKey DstK,
314 ResourceKey SrcK) {
315 auto I = KeyToReentryAddrs.find(SrcK);
316 if (I != KeyToReentryAddrs.end()) {
317 auto J = KeyToReentryAddrs.find(DstK);
318 if (J == KeyToReentryAddrs.end()) {
319 auto Tmp = std::move(I->second);
320 KeyToReentryAddrs.erase(I);
321 KeyToReentryAddrs[DstK] = std::move(Tmp);
322 } else {
323 auto &SrcAddrs = I->second;
324 auto &DstAddrs = J->second;
325 llvm::append_range(DstAddrs, SrcAddrs);
326 KeyToReentryAddrs.erase(I);
327 }
328 if (L)
329 L->onLazyReexportsTransfered(JD, DstK, SrcK);
330 }
331}
332
333// Spec for the call-controller handler that the ORC runtime calls to
334// resolve lazy reexports.
337 : sps::HandlerSpec<shared::SPSExpected<shared::SPSExecutorSymbolDef>(
338 shared::SPSExecutorAddr)> {
339 static constexpr SymbolNameSpec Name =
340 SymbolNameSpec::c("__orc_rt_resolve_tag");
341};
342} // namespace lazy_reexports_sps_handlers
343
344LazyReexportsManager::LazyReexportsManager(EmitTrampolinesFn EmitTrampolines,
346 JITDylib &PlatformJD, Listener *L,
347 Error &Err)
348 : ES(PlatformJD.getExecutionSession()),
349 EmitTrampolines(std::move(EmitTrampolines)), RSMgr(RSMgr), L(L) {
350
351 using namespace shared;
353 Err = ES.registerCallControllerHandlers(
354 PlatformJD,
356 this, &LazyReexportsManager::resolve));
357}
358
359std::unique_ptr<MaterializationUnit>
360LazyReexportsManager::createLazyReexports(SymbolAliasMap Reexports) {
361 return std::make_unique<MU>(*this, std::move(Reexports));
362}
363
364void LazyReexportsManager::emitReentryTrampolines(
365 std::unique_ptr<MaterializationResponsibility> MR,
366 SymbolAliasMap Reexports) {
367 size_t NumTrampolines = Reexports.size();
368 auto RT = MR->getResourceTracker();
369 EmitTrampolines(
370 std::move(RT), NumTrampolines,
371 [this, MR = std::move(MR), Reexports = std::move(Reexports)](
372 Expected<std::vector<ExecutorSymbolDef>> ReentryPoints) mutable {
373 emitRedirectableSymbols(std::move(MR), std::move(Reexports),
374 std::move(ReentryPoints));
375 });
376}
377
378void LazyReexportsManager::emitRedirectableSymbols(
379 std::unique_ptr<MaterializationResponsibility> MR, SymbolAliasMap Reexports,
380 Expected<std::vector<ExecutorSymbolDef>> ReentryPoints) {
381
382 if (!ReentryPoints) {
383 MR->getExecutionSession().reportError(ReentryPoints.takeError());
384 MR->failMaterialization();
385 return;
386 }
387
388 assert(Reexports.size() == ReentryPoints->size() &&
389 "Number of reentry points doesn't match number of reexports");
390
391 // Bind entry points to names.
392 SymbolMap Redirs;
393 size_t I = 0;
394 for (auto &[Name, AI] : Reexports)
395 Redirs[Name] = {(*ReentryPoints)[I++].getAddress(), AI.AliasFlags};
396
397 I = 0;
398 if (!Reexports.empty()) {
399 if (auto Err = MR->withResourceKeyDo([&](ResourceKey K) {
400 auto &JD = MR->getTargetJITDylib();
401 auto &ReentryAddrsForK = KeyToReentryAddrs[K];
402 for (auto &[Name, AI] : Reexports) {
403 const auto &ReentryPoint = (*ReentryPoints)[I++];
404 CallThroughs[ReentryPoint.getAddress()] = {&JD, Name, AI.Aliasee};
405 ReentryAddrsForK.push_back(ReentryPoint.getAddress());
406 }
407 if (L)
408 L->onLazyReexportsCreated(JD, K, Reexports);
409 })) {
410 MR->getExecutionSession().reportError(std::move(Err));
411 MR->failMaterialization();
412 return;
413 }
414 }
415
416 RSMgr.emitRedirectableSymbols(std::move(MR), std::move(Redirs));
417}
418
419void LazyReexportsManager::resolve(ResolveSendResultFn SendResult,
420 ExecutorAddr ReentryStubAddr) {
421
422 CallThroughInfo LandingInfo;
423
424 ES.runSessionLocked([&]() {
425 auto I = CallThroughs.find(ReentryStubAddr);
426 if (I == CallThroughs.end())
427 return SendResult(make_error<StringError>(
428 "Reentry address " + formatv("{0:x}", ReentryStubAddr) +
429 " not registered",
431 LandingInfo = I->second;
432 });
433
434 if (L)
435 L->onLazyReexportCalled(LandingInfo);
436
437 ES.lookup(
439 {{LandingInfo.JD.get(), JITDylibLookupFlags::MatchAllSymbols}},
440 SymbolLookupSet(std::move(LandingInfo.BodyName)), SymbolState::Ready,
441 [this, JD = std::move(LandingInfo.JD),
442 ReentryName = std::move(LandingInfo.Name),
443 SendResult = std::move(SendResult)](Expected<SymbolMap> Result) mutable {
444 if (!Result)
445 return SendResult(Result.takeError());
446
447 assert(Result->size() == 1 && "Unexpected number of results");
448 auto BodySym = Result->begin()->second;
449 if (auto Err = RSMgr.redirect(*JD, ReentryName, BodySym))
450 SendResult(std::move(Err));
451 SendResult(BodySym);
452 },
454}
455
457public:
458 SpeculateTask(std::weak_ptr<SimpleLazyReexportsSpeculator> Speculator)
459 : Speculator(std::move(Speculator)) {}
460
461 void printDescription(raw_ostream &OS) override {
462 OS << "Speculative Lookup Task";
463 }
464
465 void run() override {
466 if (auto S = Speculator.lock())
467 S->doNextSpeculativeLookup();
468 }
469
470private:
471 std::weak_ptr<SimpleLazyReexportsSpeculator> Speculator;
472};
473
475 for (auto &[JD, _] : LazyReexports)
476 JITDylibSP(JD)->Release();
477}
478
480 JITDylib &JD, ResourceKey K, const SymbolAliasMap &Reexports) {
481 if (!LazyReexports.count(&JD))
482 JD.Retain();
483 auto &BodiesVec = LazyReexports[&JD][K];
484 for (auto &[Name, AI] : Reexports)
485 BodiesVec.push_back(AI.Aliasee);
486 if (!SpeculateTaskActive) {
487 SpeculateTaskActive = true;
488 ES.dispatchTask(std::make_unique<SpeculateTask>(WeakThis));
489 }
490}
491
493 JITDylib &JD, ResourceKey DstK, ResourceKey SrcK) {
494
495 auto I = LazyReexports.find(&JD);
496 if (I == LazyReexports.end())
497 return;
498
499 auto &MapForJD = I->second;
500 auto J = MapForJD.find(SrcK);
501 if (J == MapForJD.end())
502 return;
503
504 // We have something to transfer.
505 auto K = MapForJD.find(DstK);
506 if (K == MapForJD.end()) {
507 auto Tmp = std::move(J->second);
508 MapForJD.erase(J);
509 MapForJD[DstK] = std::move(Tmp);
510 } else {
511 auto &SrcNames = J->second;
512 auto &DstNames = K->second;
513 llvm::append_range(DstNames, SrcNames);
514 MapForJD.erase(J);
515 }
516}
517
519 ResourceKey K) {
520
521 auto I = LazyReexports.find(&JD);
522 if (I == LazyReexports.end())
523 return Error::success();
524
525 auto &MapForJD = I->second;
526 MapForJD.erase(K);
527
528 if (MapForJD.empty()) {
529 LazyReexports.erase(I);
530 JD.Release();
531 }
532
533 return Error::success();
534}
535
537 const CallThroughInfo &CTI) {
538 if (RecordExec)
539 RecordExec(CTI);
540}
541
543 std::vector<std::pair<std::string, SymbolStringPtr>> NewSuggestions) {
544 ES.runSessionLocked([&]() {
545 for (auto &[JDName, SymbolName] : NewSuggestions)
546 SpeculateSuggestions.push_back(
547 {std::move(JDName), std::move(SymbolName)});
548 });
549}
550
551bool SimpleLazyReexportsSpeculator::doNextSpeculativeLookup() {
552 // Use existing speculation queue if available, otherwise take the next
553 // element from LazyReexports.
554 JITDylibSP SpeculateJD = nullptr;
555 SymbolStringPtr SpeculateFn;
556
557 auto SpeculateAgain = ES.runSessionLocked([&]() {
558 while (!SpeculateSuggestions.empty()) {
559 auto [JDName, SymbolName] = std::move(SpeculateSuggestions.front());
560 SpeculateSuggestions.pop_front();
561
562 if (auto *JD = ES.getJITDylibByName(JDName)) {
563 SpeculateJD = JD;
564 SpeculateFn = std::move(SymbolName);
565 break;
566 }
567 }
568
569 if (!SpeculateJD) {
570 assert(!LazyReexports.empty() && "LazyReexports map is empty");
571 auto LRItr =
572 std::next(LazyReexports.begin(), rand() % LazyReexports.size());
573 auto &[JD, KeyToFnBodies] = *LRItr;
574
575 assert(!KeyToFnBodies.empty() && "Key to function bodies map empty");
576 auto KeyToFnBodiesItr =
577 std::next(KeyToFnBodies.begin(), rand() % KeyToFnBodies.size());
578 auto &[Key, FnBodies] = *KeyToFnBodiesItr;
579
580 assert(!FnBodies.empty() && "Function bodies list empty");
581 auto FnBodyItr = std::next(FnBodies.begin(), rand() % FnBodies.size());
582
583 SpeculateJD = JITDylibSP(JD);
584 SpeculateFn = std::move(*FnBodyItr);
585
586 FnBodies.erase(FnBodyItr);
587 if (FnBodies.empty()) {
588 KeyToFnBodies.erase(KeyToFnBodiesItr);
589 if (KeyToFnBodies.empty()) {
590 LRItr->first->Release();
591 LazyReexports.erase(LRItr);
592 }
593 }
594 }
595
596 SpeculateTaskActive =
597 !SpeculateSuggestions.empty() || !LazyReexports.empty();
598 return SpeculateTaskActive;
599 });
600
601 LLVM_DEBUG({
602 dbgs() << "Issuing speculative lookup for ( " << SpeculateJD->getName()
603 << ", " << SpeculateFn << " )...\n";
604 });
605
606 ES.lookup(
608 {{std::move(SpeculateFn), SymbolLookupFlags::WeaklyReferencedSymbol}},
610 [](Expected<SymbolMap> Result) { consumeError(Result.takeError()); },
612
613 if (SpeculateAgain)
614 ES.dispatchTask(std::make_unique<SpeculateTask>(WeakThis));
615
616 return false;
617}
618
619} // End namespace orc.
620} // End namespace llvm.
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define _
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define T
if(PassOpts->AAPipeline)
static StringRef getName(Value *V)
#define LLVM_DEBUG(...)
Definition Debug.h:119
bool empty() const
Definition DenseMap.h:716
iterator find(const_arg_type_t< KeyT > Val)
Definition DenseMap.h:766
iterator end()
Definition DenseMap.h:686
bool erase(const KeyT &Val)
Definition DenseMap.h:930
Helper for Errors used as out-parameters.
Definition Error.h:1160
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
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
@ loongarch64
Definition Triple.h:66
An ExecutionSession represents a running JIT program.
Definition Core.h:1096
LLVM_ABI JITDylib * getJITDylibByName(StringRef Name)
Return a pointer to the "name" JITDylib.
Definition Core.cpp:1636
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Definition Core.h:1203
Represents an address in the executor process.
IdleTask can be used as the basis for low-priority tasks, e.g.
Represents a JIT'd dynamic library.
Definition Core.h:668
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
Definition Core.h:687
Manages a set of 'lazy call-through' trampolines.
LLVM_ABI ExecutorAddr reportCallThroughError(Error Err)
TrampolinePool::NotifyLandingResolvedFunction NotifyLandingResolvedFunction
LLVM_ABI Expected< ReexportsEntry > findReexport(ExecutorAddr TrampolineAddr)
LLVM_ABI Error notifyResolved(ExecutorAddr TrampolineAddr, ExecutorAddr ResolvedAddr)
LLVM_ABI void resolveTrampolineLandingAddress(ExecutorAddr TrampolineAddr, TrampolinePool::NotifyLandingResolvedFunction NotifyLandingResolved)
unique_function< Error(ExecutorAddr ResolvedAddr)> NotifyResolvedFunction
LLVM_ABI LazyCallThroughManager(ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr, TrampolinePool *TP)
LLVM_ABI Expected< ExecutorAddr > getCallThroughTrampoline(JITDylib &SourceJD, SymbolStringPtr SymbolName, NotifyResolvedFunction NotifyResolved)
LazyReexportsManager::CallThroughInfo CallThroughInfo
MU(LazyReexportsManager &LRMgr, SymbolAliasMap Reexports)
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &Config) override
void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, ResourceKey SrcKey) override
Error notifyFailed(MaterializationResponsibility &MR) override
Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override
void handleTransferResources(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK) override
This function will be called inside the session lock.
Error handleRemoveResources(JITDylib &JD, ResourceKey K) override
This function will be called outside the session lock.
unique_function< void(ResourceTrackerSP RT, size_t NumTrampolines, OnTrampolinesReadyFn OnTrampolinesReady)> EmitTrampolinesFn
LazyReexportsManager(LazyReexportsManager &&)=delete
static Expected< std::unique_ptr< LazyReexportsManager > > Create(EmitTrampolinesFn EmitTrampolines, RedirectableSymbolManager &RSMgr, JITDylib &PlatformJD, Listener *L=nullptr)
Create a LazyReexportsManager that uses the ORC runtime for reentry.
LazyReexportsMaterializationUnit(LazyCallThroughManager &LCTManager, RedirectableSymbolManager &RSManager, JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc)
StringRef getName() const override
Return the name of this materialization unit.
Plugin instances can be added to the ObjectLinkingLayer to receive callbacks when code is loaded or e...
static Expected< std::unique_ptr< LocalLazyCallThroughManager > > Create(ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)
Create a LocalLazyCallThroughManager using the given ABI.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition Core.h:343
Base class for managing redirectable symbols in which a call gets redirected to another symbol in run...
virtual void emitRedirectableSymbols(std::unique_ptr< MaterializationResponsibility > MR, SymbolMap InitialDests)=0
Emit redirectable symbol.
SpeculateTask(std::weak_ptr< SimpleLazyReexportsSpeculator > Speculator)
Error onLazyReexportsRemoved(JITDylib &JD, ResourceKey K) override
Called under the session lock when lazy reexports are removed.
void onLazyReexportsCreated(JITDylib &JD, ResourceKey K, const SymbolAliasMap &Reexports) override
Called under the session lock when new lazy reexports are created.
void onLazyReexportCalled(const CallThroughInfo &CTI) override
Called outside the session lock when a lazy reexport is called.
void onLazyReexportsTransfered(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK) override
Called under the session lock when lazy reexports have their ownership transferred to a new ResourceK...
void addSpeculationSuggestions(std::vector< std::pair< std::string, SymbolStringPtr > > NewSuggestions)
A set of symbols to look up, each associated with a SymbolLookupFlags value.
A symbol name together with the naming level (SymbolNameKind) it is expressed in, so that a Mangler /...
static constexpr SymbolNameSpec c(StringRef Name)
Pointer to a pooled string representing a symbol name.
Base class for pools of compiler re-entry trampolines.
Base class for specs that bind handlers for calls with the SPS signature SPSSigT.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
SymbolFlags
Symbol flags.
Definition Symbol.h:25
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:147
IntrusiveRefCntPtr< JITDylib > JITDylibSP
Definition Core.h:60
ExecutionSession::CallControllerHandlerBinding bindCallControllerHandler(HandlerT &&H, SymbolLookupFlags LF=SymbolLookupFlags::RequiredSymbol)
Bind H, using the given spec, to the tag with the spec's default name.
uintptr_t ResourceKey
Definition Core.h:62
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
LLVM_ABI Expected< std::unique_ptr< LazyCallThroughManager > > createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)
Create a LocalLazyCallThroughManager from the given triple and execution session.
std::unique_ptr< LazyReexportsMaterializationUnit > lazyReexports(LazyCallThroughManager &LCTManager, RedirectableSymbolManager &RSManager, JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc=nullptr)
Define lazy-reexports based on the given SymbolAliasMap.
LLVM_ABI RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition Core.cpp:42
@ Ready
Emitted to memory, but waiting on transitive dependencies.
Definition Core.h:545
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
Definition Core.h:167
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
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:94
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Definition STLExtras.h:2229
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition Error.h:1321
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
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
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:1933
void consumeError(Error Err)
Consume a Error without doing anything.
Definition Error.h:1106
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:879