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::systemz:
149 ErrorHandlerAddr);
150
151 case Triple::x86_64:
152 if (T.getOS() == Triple::OSType::Win32)
154 ES, ErrorHandlerAddr);
155 else
157 ES, ErrorHandlerAddr);
158 }
159}
160
163 JITDylib &SourceJD, SymbolAliasMap CallableAliases, ImplSymbolMap *SrcJDLoc)
164 : MaterializationUnit(extractFlags(CallableAliases)),
165 LCTManager(LCTManager), RSManager(RSManager), SourceJD(SourceJD),
166 CallableAliases(std::move(CallableAliases)), AliaseeTable(SrcJDLoc) {}
167
169 return "<Lazy Reexports>";
170}
171
172void LazyReexportsMaterializationUnit::materialize(
173 std::unique_ptr<MaterializationResponsibility> R) {
174 auto RequestedSymbols = R->getRequestedSymbols();
175
176 SymbolAliasMap RequestedAliases;
177 for (auto &RequestedSymbol : RequestedSymbols) {
178 auto I = CallableAliases.find(RequestedSymbol);
179 assert(I != CallableAliases.end() && "Symbol not found in alias map?");
180 RequestedAliases[I->first] = std::move(I->second);
181 CallableAliases.erase(I);
182 }
183
184 if (!CallableAliases.empty())
185 if (auto Err = R->replace(lazyReexports(LCTManager, RSManager, SourceJD,
186 std::move(CallableAliases),
187 AliaseeTable))) {
188 R->getExecutionSession().reportError(std::move(Err));
189 R->failMaterialization();
190 return;
191 }
192
193 SymbolMap Inits;
194 for (auto &Alias : RequestedAliases) {
195 auto CallThroughTrampoline = LCTManager.getCallThroughTrampoline(
196 SourceJD, Alias.second.Aliasee,
197 [&TargetJD = R->getTargetJITDylib(), &RSManager = this->RSManager,
198 StubSym = Alias.first](ExecutorAddr ResolvedAddr) -> Error {
199 return RSManager.redirect(TargetJD, StubSym,
200 ExecutorSymbolDef(ResolvedAddr, {}));
201 });
202
203 if (!CallThroughTrampoline) {
204 R->getExecutionSession().reportError(CallThroughTrampoline.takeError());
205 R->failMaterialization();
206 return;
207 }
208
209 Inits[Alias.first] = {*CallThroughTrampoline, Alias.second.AliasFlags};
210 }
211
212 if (AliaseeTable != nullptr && !RequestedAliases.empty())
213 AliaseeTable->trackImpls(RequestedAliases, &SourceJD);
214
215 if (auto Err = R->replace(std::make_unique<RedirectableMaterializationUnit>(
216 RSManager, std::move(Inits)))) {
217 R->getExecutionSession().reportError(std::move(Err));
218 return R->failMaterialization();
219 }
220}
221
222void LazyReexportsMaterializationUnit::discard(const JITDylib &JD,
223 const SymbolStringPtr &Name) {
224 assert(CallableAliases.count(Name) &&
225 "Symbol not covered by this MaterializationUnit");
226 CallableAliases.erase(Name);
227}
228
229MaterializationUnit::Interface
230LazyReexportsMaterializationUnit::extractFlags(const SymbolAliasMap &Aliases) {
232 for (auto &KV : Aliases) {
233 assert(KV.second.AliasFlags.isCallable() &&
234 "Lazy re-exports must be callable symbols");
235 SymbolFlags[KV.first] = KV.second.AliasFlags;
236 }
237 return MaterializationUnit::Interface(std::move(SymbolFlags), nullptr);
238}
239
241public:
243 : MaterializationUnit(getInterface(Reexports)), LRMgr(LRMgr),
244 Reexports(std::move(Reexports)) {}
245
246private:
247 Interface getInterface(const SymbolAliasMap &Reexports) {
249 for (auto &[Alias, AI] : Reexports)
250 SF[Alias] = AI.AliasFlags;
251 return {std::move(SF), nullptr};
252 }
253
254 StringRef getName() const override { return "LazyReexportsManager::MU"; }
255
256 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
257 LRMgr.emitReentryTrampolines(std::move(R), std::move(Reexports));
258 }
259
260 void discard(const JITDylib &JD, const SymbolStringPtr &Name) override {
261 Reexports.erase(Name);
262 }
263
264 LazyReexportsManager &LRMgr;
265 SymbolAliasMap Reexports;
266};
267
285
287
291 JITDylib &PlatformJD, Listener *L) {
292 Error Err = Error::success();
293 std::unique_ptr<LazyReexportsManager> LRM(new LazyReexportsManager(
294 std::move(EmitTrampolines), RSMgr, PlatformJD, L, Err));
295 if (Err)
296 return std::move(Err);
297 return std::move(LRM);
298}
299
301 return JD.getExecutionSession().runSessionLocked([&]() -> Error {
302 auto I = KeyToReentryAddrs.find(K);
303 if (I == KeyToReentryAddrs.end())
304 return Error::success();
305
306 auto &ReentryAddrs = I->second;
307 for (auto &ReentryAddr : ReentryAddrs) {
308 assert(CallThroughs.count(ReentryAddr) && "CallTrhough missing");
309 CallThroughs.erase(ReentryAddr);
310 }
311 KeyToReentryAddrs.erase(I);
312 return L ? L->onLazyReexportsRemoved(JD, K) : Error::success();
313 });
314}
315
317 ResourceKey DstK,
318 ResourceKey SrcK) {
319 auto I = KeyToReentryAddrs.find(SrcK);
320 if (I != KeyToReentryAddrs.end()) {
321 auto J = KeyToReentryAddrs.find(DstK);
322 if (J == KeyToReentryAddrs.end()) {
323 auto Tmp = std::move(I->second);
324 KeyToReentryAddrs.erase(I);
325 KeyToReentryAddrs[DstK] = std::move(Tmp);
326 } else {
327 auto &SrcAddrs = I->second;
328 auto &DstAddrs = J->second;
329 llvm::append_range(DstAddrs, SrcAddrs);
330 KeyToReentryAddrs.erase(I);
331 }
332 if (L)
333 L->onLazyReexportsTransfered(JD, DstK, SrcK);
334 }
335}
336
337// Spec for the call-controller handler that the ORC runtime calls to
338// resolve lazy reexports.
341 : sps::HandlerSpec<shared::SPSExpected<shared::SPSExecutorSymbolDef>(
342 shared::SPSExecutorAddr)> {
343 static constexpr SymbolNameSpec Name =
344 SymbolNameSpec::c("__orc_rt_resolve_tag");
345};
346} // namespace lazy_reexports_sps_handlers
347
348LazyReexportsManager::LazyReexportsManager(EmitTrampolinesFn EmitTrampolines,
350 JITDylib &PlatformJD, Listener *L,
351 Error &Err)
352 : ES(PlatformJD.getExecutionSession()),
353 EmitTrampolines(std::move(EmitTrampolines)), RSMgr(RSMgr), L(L) {
354
355 using namespace shared;
357 Err = ES.registerCallControllerHandlers(
358 PlatformJD,
360 this, &LazyReexportsManager::resolve));
361}
362
363std::unique_ptr<MaterializationUnit>
364LazyReexportsManager::createLazyReexports(SymbolAliasMap Reexports) {
365 return std::make_unique<MU>(*this, std::move(Reexports));
366}
367
368void LazyReexportsManager::emitReentryTrampolines(
369 std::unique_ptr<MaterializationResponsibility> MR,
370 SymbolAliasMap Reexports) {
371 size_t NumTrampolines = Reexports.size();
372 auto RT = MR->getResourceTracker();
373 EmitTrampolines(
374 std::move(RT), NumTrampolines,
375 [this, MR = std::move(MR), Reexports = std::move(Reexports)](
376 Expected<std::vector<ExecutorSymbolDef>> ReentryPoints) mutable {
377 emitRedirectableSymbols(std::move(MR), std::move(Reexports),
378 std::move(ReentryPoints));
379 });
380}
381
382void LazyReexportsManager::emitRedirectableSymbols(
383 std::unique_ptr<MaterializationResponsibility> MR, SymbolAliasMap Reexports,
384 Expected<std::vector<ExecutorSymbolDef>> ReentryPoints) {
385
386 if (!ReentryPoints) {
387 MR->getExecutionSession().reportError(ReentryPoints.takeError());
388 MR->failMaterialization();
389 return;
390 }
391
392 assert(Reexports.size() == ReentryPoints->size() &&
393 "Number of reentry points doesn't match number of reexports");
394
395 // Bind entry points to names.
396 SymbolMap Redirs;
397 size_t I = 0;
398 for (auto &[Name, AI] : Reexports)
399 Redirs[Name] = {(*ReentryPoints)[I++].getAddress(), AI.AliasFlags};
400
401 I = 0;
402 if (!Reexports.empty()) {
403 if (auto Err = MR->withResourceKeyDo([&](ResourceKey K) {
404 auto &JD = MR->getTargetJITDylib();
405 auto &ReentryAddrsForK = KeyToReentryAddrs[K];
406 for (auto &[Name, AI] : Reexports) {
407 const auto &ReentryPoint = (*ReentryPoints)[I++];
408 CallThroughs[ReentryPoint.getAddress()] = {&JD, Name, AI.Aliasee};
409 ReentryAddrsForK.push_back(ReentryPoint.getAddress());
410 }
411 if (L)
412 L->onLazyReexportsCreated(JD, K, Reexports);
413 })) {
414 MR->getExecutionSession().reportError(std::move(Err));
415 MR->failMaterialization();
416 return;
417 }
418 }
419
420 RSMgr.emitRedirectableSymbols(std::move(MR), std::move(Redirs));
421}
422
423void LazyReexportsManager::resolve(ResolveSendResultFn SendResult,
424 ExecutorAddr ReentryStubAddr) {
425
426 CallThroughInfo LandingInfo;
427
428 ES.runSessionLocked([&]() {
429 auto I = CallThroughs.find(ReentryStubAddr);
430 if (I == CallThroughs.end())
431 return SendResult(make_error<StringError>(
432 "Reentry address " + formatv("{0:x}", ReentryStubAddr) +
433 " not registered",
435 LandingInfo = I->second;
436 });
437
438 if (L)
439 L->onLazyReexportCalled(LandingInfo);
440
441 ES.lookup(
443 {{LandingInfo.JD.get(), JITDylibLookupFlags::MatchAllSymbols}},
444 SymbolLookupSet(std::move(LandingInfo.BodyName)), SymbolState::Ready,
445 [this, JD = std::move(LandingInfo.JD),
446 ReentryName = std::move(LandingInfo.Name),
447 SendResult = std::move(SendResult)](Expected<SymbolMap> Result) mutable {
448 if (!Result)
449 return SendResult(Result.takeError());
450
451 assert(Result->size() == 1 && "Unexpected number of results");
452 auto BodySym = Result->begin()->second;
453 if (auto Err = RSMgr.redirect(*JD, ReentryName, BodySym))
454 SendResult(std::move(Err));
455 SendResult(BodySym);
456 },
458}
459
461public:
462 SpeculateTask(std::weak_ptr<SimpleLazyReexportsSpeculator> Speculator)
463 : Speculator(std::move(Speculator)) {}
464
465 void printDescription(raw_ostream &OS) override {
466 OS << "Speculative Lookup Task";
467 }
468
469 void run() override {
470 if (auto S = Speculator.lock())
471 S->doNextSpeculativeLookup();
472 }
473
474private:
475 std::weak_ptr<SimpleLazyReexportsSpeculator> Speculator;
476};
477
479 for (auto &[JD, _] : LazyReexports)
480 JITDylibSP(JD)->Release();
481}
482
484 JITDylib &JD, ResourceKey K, const SymbolAliasMap &Reexports) {
485 if (!LazyReexports.count(&JD))
486 JD.Retain();
487 auto &BodiesVec = LazyReexports[&JD][K];
488 for (auto &[Name, AI] : Reexports)
489 BodiesVec.push_back(AI.Aliasee);
490 if (!SpeculateTaskActive) {
491 SpeculateTaskActive = true;
492 ES.dispatchTask(std::make_unique<SpeculateTask>(WeakThis));
493 }
494}
495
497 JITDylib &JD, ResourceKey DstK, ResourceKey SrcK) {
498
499 auto I = LazyReexports.find(&JD);
500 if (I == LazyReexports.end())
501 return;
502
503 auto &MapForJD = I->second;
504 auto J = MapForJD.find(SrcK);
505 if (J == MapForJD.end())
506 return;
507
508 // We have something to transfer.
509 auto K = MapForJD.find(DstK);
510 if (K == MapForJD.end()) {
511 auto Tmp = std::move(J->second);
512 MapForJD.erase(J);
513 MapForJD[DstK] = std::move(Tmp);
514 } else {
515 auto &SrcNames = J->second;
516 auto &DstNames = K->second;
517 llvm::append_range(DstNames, SrcNames);
518 MapForJD.erase(J);
519 }
520}
521
523 ResourceKey K) {
524
525 auto I = LazyReexports.find(&JD);
526 if (I == LazyReexports.end())
527 return Error::success();
528
529 auto &MapForJD = I->second;
530 MapForJD.erase(K);
531
532 if (MapForJD.empty()) {
533 LazyReexports.erase(I);
534 JD.Release();
535 }
536
537 return Error::success();
538}
539
541 const CallThroughInfo &CTI) {
542 if (RecordExec)
543 RecordExec(CTI);
544}
545
547 std::vector<std::pair<std::string, SymbolStringPtr>> NewSuggestions) {
548 ES.runSessionLocked([&]() {
549 for (auto &[JDName, SymbolName] : NewSuggestions)
550 SpeculateSuggestions.push_back(
551 {std::move(JDName), std::move(SymbolName)});
552 });
553}
554
555bool SimpleLazyReexportsSpeculator::doNextSpeculativeLookup() {
556 // Use existing speculation queue if available, otherwise take the next
557 // element from LazyReexports.
558 JITDylibSP SpeculateJD = nullptr;
559 SymbolStringPtr SpeculateFn;
560
561 auto SpeculateAgain = ES.runSessionLocked([&]() {
562 while (!SpeculateSuggestions.empty()) {
563 auto [JDName, SymbolName] = std::move(SpeculateSuggestions.front());
564 SpeculateSuggestions.pop_front();
565
566 if (auto *JD = ES.getJITDylibByName(JDName)) {
567 SpeculateJD = JD;
568 SpeculateFn = std::move(SymbolName);
569 break;
570 }
571 }
572
573 if (!SpeculateJD) {
574 assert(!LazyReexports.empty() && "LazyReexports map is empty");
575 auto LRItr =
576 std::next(LazyReexports.begin(), rand() % LazyReexports.size());
577 auto &[JD, KeyToFnBodies] = *LRItr;
578
579 assert(!KeyToFnBodies.empty() && "Key to function bodies map empty");
580 auto KeyToFnBodiesItr =
581 std::next(KeyToFnBodies.begin(), rand() % KeyToFnBodies.size());
582 auto &[Key, FnBodies] = *KeyToFnBodiesItr;
583
584 assert(!FnBodies.empty() && "Function bodies list empty");
585 auto FnBodyItr = std::next(FnBodies.begin(), rand() % FnBodies.size());
586
587 SpeculateJD = JITDylibSP(JD);
588 SpeculateFn = std::move(*FnBodyItr);
589
590 FnBodies.erase(FnBodyItr);
591 if (FnBodies.empty()) {
592 KeyToFnBodies.erase(KeyToFnBodiesItr);
593 if (KeyToFnBodies.empty()) {
594 LRItr->first->Release();
595 LazyReexports.erase(LRItr);
596 }
597 }
598 }
599
600 SpeculateTaskActive =
601 !SpeculateSuggestions.empty() || !LazyReexports.empty();
602 return SpeculateTaskActive;
603 });
604
605 LLVM_DEBUG({
606 dbgs() << "Issuing speculative lookup for ( " << SpeculateJD->getName()
607 << ", " << SpeculateFn << " )...\n";
608 });
609
610 ES.lookup(
612 {{std::move(SpeculateFn), SymbolLookupFlags::WeaklyReferencedSymbol}},
614 [](Expected<SymbolMap> Result) { consumeError(Result.takeError()); },
616
617 if (SpeculateAgain)
618 ES.dispatchTask(std::make_unique<SpeculateTask>(WeakThis));
619
620 return false;
621}
622
623} // End namespace orc.
624} // End namespace llvm.
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define _
if(!TBB||Cond.size()< 1) return false
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define T
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