LLVM 23.0.0git
Core.h
Go to the documentation of this file.
1//===------ Core.h -- Core ORC APIs (Layer, JITDylib, etc.) -----*- C++ -*-===//
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//
9// Contains core ORC APIs.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_CORE_H
14#define LLVM_EXECUTIONENGINE_ORC_CORE_H
15
17#include "llvm/ADT/DenseSet.h"
32#include "llvm/Support/Debug.h"
34
35#include <atomic>
36#include <deque>
37#include <future>
38#include <memory>
39#include <vector>
40
41namespace llvm {
42namespace orc {
43
44// Forward declare some classes.
48class JITDylib;
49class ResourceTracker;
51
52enum class SymbolState : uint8_t;
53
56
59
60/// A definition of a Symbol within a JITDylib.
62public:
65
67 : JD(std::move(JD)), Name(std::move(Name)) {}
68
69 const JITDylib &getJITDylib() const { return *JD; }
70 const SymbolStringPtr &getName() const { return Name; }
71
73 LLVM_ABI void lookupAsync(LookupAsyncOnCompleteFn OnComplete) const;
74
75private:
76 JITDylibSP JD;
77 SymbolStringPtr Name;
78};
79
80using ResourceKey = uintptr_t;
81
82/// API to remove / transfer ownership of JIT resources.
83class ResourceTracker : public ThreadSafeRefCountedBase<ResourceTracker> {
84private:
85 friend class ExecutionSession;
86 friend class JITDylib;
88
89public:
94
96
97 /// Return the JITDylib targeted by this tracker.
99 return *reinterpret_cast<JITDylib *>(JDAndFlag.load() &
100 ~static_cast<uintptr_t>(1));
101 }
102
103 /// Runs the given callback under the session lock, passing in the associated
104 /// ResourceKey. This is the safe way to associate resources with trackers.
105 template <typename Func> Error withResourceKeyDo(Func &&F);
106
107 /// Remove all resources associated with this key.
109
110 /// Transfer all resources associated with this key to the given
111 /// tracker, which must target the same JITDylib as this one.
113
114 /// Return true if this tracker has become defunct.
115 bool isDefunct() const { return JDAndFlag.load() & 0x1; }
116
117 /// Returns the key associated with this tracker.
118 /// This method should not be used except for debug logging: there is no
119 /// guarantee that the returned value will remain valid.
120 ResourceKey getKeyUnsafe() const { return reinterpret_cast<uintptr_t>(this); }
121
122private:
124
125 void makeDefunct();
126
127 std::atomic_uintptr_t JDAndFlag;
128};
129
130/// Listens for ResourceTracker operations.
132public:
134
135 /// This function will be called *outside* the session lock. ResourceManagers
136 /// should perform book-keeping under the session lock, and any expensive
137 /// cleanup outside the session lock.
139
140 /// This function will be called *inside* the session lock. ResourceManagers
141 /// DO NOT need to re-lock the session.
143 ResourceKey SrcK) = 0;
144};
145
146/// Lookup flags that apply to each dylib in the search order for a lookup.
147///
148/// If MatchHiddenSymbolsOnly is used (the default) for a given dylib, then
149/// only symbols in that Dylib's interface will be searched. If
150/// MatchHiddenSymbols is used then symbols with hidden visibility will match
151/// as well.
153
154/// Describes the kind of lookup being performed. The lookup kind is passed to
155/// symbol generators (if they're invoked) to help them determine what
156/// definitions to generate.
157///
158/// Static -- Lookup is being performed as-if at static link time (e.g.
159/// generators representing static archives should pull in new
160/// definitions).
161///
162/// DLSym -- Lookup is being performed as-if at runtime (e.g. generators
163/// representing static archives should not pull in new definitions).
164enum class LookupKind { Static, DLSym };
165
166/// A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search
167/// order during symbol lookup.
169 std::vector<std::pair<JITDylib *, JITDylibLookupFlags>>;
170
171/// Convenience function for creating a search order from an ArrayRef of
172/// JITDylib*, all with the same flags.
177 O.reserve(JDs.size());
178 for (auto *JD : JDs)
179 O.push_back(std::make_pair(JD, Flags));
180 return O;
181}
182
191
192/// A map of Symbols to (Symbol, Flags) pairs.
194
195/// Callback to notify client that symbols have been resolved.
197
198/// Callback to register the dependencies for a given query.
200 std::function<void(const SymbolDependenceMap &)>;
201
202/// This can be used as the value for a RegisterDependenciesFunction if there
203/// are no dependants to register with.
205
207 : public ErrorInfo<ResourceTrackerDefunct> {
208public:
209 static char ID;
210
212 std::error_code convertToErrorCode() const override;
213 void log(raw_ostream &OS) const override;
214
215private:
217};
218
219/// Returned by operations that fail because a JITDylib has been closed.
220class LLVM_ABI JITDylibDefunct : public ErrorInfo<JITDylibDefunct> {
221public:
222 static char ID;
223
225 std::error_code convertToErrorCode() const override;
226 void log(raw_ostream &OS) const override;
227
228private:
229 JITDylibSP JD;
230};
231
232/// Used to notify a JITDylib that the given set of symbols failed to
233/// materialize.
234class LLVM_ABI FailedToMaterialize : public ErrorInfo<FailedToMaterialize> {
235public:
236 static char ID;
237
238 FailedToMaterialize(std::shared_ptr<SymbolStringPool> SSP,
239 std::shared_ptr<SymbolDependenceMap> Symbols);
240 ~FailedToMaterialize() override;
241 std::error_code convertToErrorCode() const override;
242 void log(raw_ostream &OS) const override;
243 const SymbolDependenceMap &getSymbols() const { return *Symbols; }
244
245private:
246 std::shared_ptr<SymbolStringPool> SSP;
247 std::shared_ptr<SymbolDependenceMap> Symbols;
248};
249
250/// Used to report failure due to unsatisfiable symbol dependencies.
252 : public ErrorInfo<UnsatisfiedSymbolDependencies> {
253public:
254 static char ID;
255
256 UnsatisfiedSymbolDependencies(std::shared_ptr<SymbolStringPool> SSP,
257 JITDylibSP JD, SymbolNameSet FailedSymbols,
258 SymbolDependenceMap BadDeps,
259 std::string Explanation);
260 std::error_code convertToErrorCode() const override;
261 void log(raw_ostream &OS) const override;
262
263private:
264 std::shared_ptr<SymbolStringPool> SSP;
265 JITDylibSP JD;
266 SymbolNameSet FailedSymbols;
267 SymbolDependenceMap BadDeps;
268 std::string Explanation;
269};
270
271/// Used to notify clients when symbols can not be found during a lookup.
272class LLVM_ABI SymbolsNotFound : public ErrorInfo<SymbolsNotFound> {
273public:
274 static char ID;
275
276 SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP, SymbolNameSet Symbols);
277 SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP,
278 SymbolNameVector Symbols);
279 std::error_code convertToErrorCode() const override;
280 void log(raw_ostream &OS) const override;
281 std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
282 const SymbolNameVector &getSymbols() const { return Symbols; }
283
284private:
285 std::shared_ptr<SymbolStringPool> SSP;
286 SymbolNameVector Symbols;
287};
288
289/// Used to notify clients that a set of symbols could not be removed.
291 : public ErrorInfo<SymbolsCouldNotBeRemoved> {
292public:
293 static char ID;
294
295 SymbolsCouldNotBeRemoved(std::shared_ptr<SymbolStringPool> SSP,
296 SymbolNameSet Symbols);
297 std::error_code convertToErrorCode() const override;
298 void log(raw_ostream &OS) const override;
299 std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
300 const SymbolNameSet &getSymbols() const { return Symbols; }
301
302private:
303 std::shared_ptr<SymbolStringPool> SSP;
304 SymbolNameSet Symbols;
305};
306
307/// Errors of this type should be returned if a module fails to include
308/// definitions that are claimed by the module's associated
309/// MaterializationResponsibility. If this error is returned it is indicative of
310/// a broken transformation / compiler / object cache.
312 : public ErrorInfo<MissingSymbolDefinitions> {
313public:
314 static char ID;
315
316 MissingSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
317 std::string ModuleName, SymbolNameVector Symbols)
318 : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
319 Symbols(std::move(Symbols)) {}
320 std::error_code convertToErrorCode() const override;
321 void log(raw_ostream &OS) const override;
322 std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
323 const std::string &getModuleName() const { return ModuleName; }
324 const SymbolNameVector &getSymbols() const { return Symbols; }
325private:
326 std::shared_ptr<SymbolStringPool> SSP;
327 std::string ModuleName;
328 SymbolNameVector Symbols;
329};
330
331/// Errors of this type should be returned if a module contains definitions for
332/// symbols that are not claimed by the module's associated
333/// MaterializationResponsibility. If this error is returned it is indicative of
334/// a broken transformation / compiler / object cache.
336 : public ErrorInfo<UnexpectedSymbolDefinitions> {
337public:
338 static char ID;
339
340 UnexpectedSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
341 std::string ModuleName, SymbolNameVector Symbols)
342 : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
343 Symbols(std::move(Symbols)) {}
344 std::error_code convertToErrorCode() const override;
345 void log(raw_ostream &OS) const override;
346 std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
347 const std::string &getModuleName() const { return ModuleName; }
348 const SymbolNameVector &getSymbols() const { return Symbols; }
349private:
350 std::shared_ptr<SymbolStringPool> SSP;
351 std::string ModuleName;
352 SymbolNameVector Symbols;
353};
354
355/// A set of symbols and the their dependencies. Used to describe dependencies
356/// for the MaterializationResponsibility::notifyEmitted operation.
361
362/// Tracks responsibility for materialization, and mediates interactions between
363/// MaterializationUnits and JDs.
364///
365/// An instance of this class is passed to MaterializationUnits when their
366/// materialize method is called. It allows MaterializationUnits to resolve and
367/// emit symbols, or abandon materialization by notifying any unmaterialized
368/// symbols of an error.
370 friend class ExecutionSession;
371 friend class JITDylib;
372
373public:
377
378 /// Destruct a MaterializationResponsibility instance. In debug mode
379 /// this asserts that all symbols being tracked have been either
380 /// emitted or notified of an error.
382
383 /// Return the ResourceTracker associated with this instance.
384 const ResourceTrackerSP &getResourceTracker() const { return RT; }
385
386 /// Runs the given callback under the session lock, passing in the associated
387 /// ResourceKey. This is the safe way to associate resources with trackers.
388 template <typename Func> Error withResourceKeyDo(Func &&F) const {
389 return RT->withResourceKeyDo(std::forward<Func>(F));
390 }
391
392 /// Returns the target JITDylib that these symbols are being materialized
393 /// into.
394 JITDylib &getTargetJITDylib() const { return JD; }
395
396 /// Returns the ExecutionSession for this instance.
398
399 /// Returns the symbol flags map for this responsibility instance.
400 /// Note: The returned flags may have transient flags (Lazy, Materializing)
401 /// set. These should be stripped with JITSymbolFlags::stripTransientFlags
402 /// before using.
403 const SymbolFlagsMap &getSymbols() const { return SymbolFlags; }
404
405 /// Returns the initialization pseudo-symbol, if any. This symbol will also
406 /// be present in the SymbolFlagsMap for this MaterializationResponsibility
407 /// object.
408 const SymbolStringPtr &getInitializerSymbol() const { return InitSymbol; }
409
410 /// Returns the names of any symbols covered by this
411 /// MaterializationResponsibility object that have queries pending. This
412 /// information can be used to return responsibility for unrequested symbols
413 /// back to the JITDylib via the delegate method.
415
416 /// Notifies the target JITDylib that the given symbols have been resolved.
417 /// This will update the given symbols' addresses in the JITDylib, and notify
418 /// any pending queries on the given symbols of their resolution. The given
419 /// symbols must be ones covered by this MaterializationResponsibility
420 /// instance. Individual calls to this method may resolve a subset of the
421 /// symbols, but all symbols must have been resolved prior to calling emit.
422 ///
423 /// This method will return an error if any symbols being resolved have been
424 /// moved to the error state due to the failure of a dependency. If this
425 /// method returns an error then clients should log it and call
426 /// failMaterialize. If no dependencies have been registered for the
427 /// symbols covered by this MaterializationResponsibility then this method
428 /// is guaranteed to return Error::success() and can be wrapped with cantFail.
429 Error notifyResolved(const SymbolMap &Symbols);
430
431 /// Notifies the target JITDylib (and any pending queries on that JITDylib)
432 /// that all symbols covered by this MaterializationResponsibility instance
433 /// have been emitted.
434 ///
435 /// The DepGroups array describes the dependencies of symbols being emitted on
436 /// symbols that are outside this MaterializationResponsibility object. Each
437 /// group consists of a pair of a set of symbols and a SymbolDependenceMap
438 /// that describes the dependencies for the symbols in the first set. The
439 /// elements of DepGroups must be non-overlapping (no symbol should appear in
440 /// more than one of hte symbol sets), but do not have to be exhaustive. Any
441 /// symbol in this MaterializationResponsibility object that is not covered
442 /// by an entry will be treated as having no dependencies.
443 ///
444 /// This method will return an error if any symbols being resolved have been
445 /// moved to the error state due to the failure of a dependency. If this
446 /// method returns an error then clients should log it and call
447 /// failMaterialize. If no dependencies have been registered for the
448 /// symbols covered by this MaterializationResponsibility then this method
449 /// is guaranteed to return Error::success() and can be wrapped with cantFail.
451
452 /// Attempt to claim responsibility for new definitions. This method can be
453 /// used to claim responsibility for symbols that are added to a
454 /// materialization unit during the compilation process (e.g. literal pool
455 /// symbols). Symbol linkage rules are the same as for symbols that are
456 /// defined up front: duplicate strong definitions will result in errors.
457 /// Duplicate weak definitions will be discarded (in which case they will
458 /// not be added to this responsibility instance).
459 ///
460 /// This method can be used by materialization units that want to add
461 /// additional symbols at materialization time (e.g. stubs, compile
462 /// callbacks, metadata).
464
465 /// Notify all not-yet-emitted covered by this MaterializationResponsibility
466 /// instance that an error has occurred.
467 /// This will remove all symbols covered by this MaterializationResponsibility
468 /// from the target JITDylib, and send an error to any queries waiting on
469 /// these symbols.
470 void failMaterialization();
471
472 /// Transfers responsibility to the given MaterializationUnit for all
473 /// symbols defined by that MaterializationUnit. This allows
474 /// materializers to break up work based on run-time information (e.g.
475 /// by introspecting which symbols have actually been looked up and
476 /// materializing only those).
477 Error replace(std::unique_ptr<MaterializationUnit> MU);
478
479 /// Delegates responsibility for the given symbols to the returned
480 /// materialization responsibility. Useful for breaking up work between
481 /// threads, or different kinds of materialization processes.
483 delegate(const SymbolNameSet &Symbols);
484
485private:
486 /// Create a MaterializationResponsibility for the given JITDylib and
487 /// initial symbols.
489 SymbolFlagsMap SymbolFlags,
490 SymbolStringPtr InitSymbol)
491 : JD(RT->getJITDylib()), RT(std::move(RT)),
492 SymbolFlags(std::move(SymbolFlags)), InitSymbol(std::move(InitSymbol)) {
493 assert(!this->SymbolFlags.empty() && "Materializing nothing?");
494 }
495
496 JITDylib &JD;
498 SymbolFlagsMap SymbolFlags;
499 SymbolStringPtr InitSymbol;
500};
501
502/// A materialization unit for symbol aliases. Allows existing symbols to be
503/// aliased with alternate flags.
505public:
506 /// SourceJD is allowed to be nullptr, in which case the source JITDylib is
507 /// taken to be whatever JITDylib these definitions are materialized in (and
508 /// MatchNonExported has no effect). This is useful for defining aliases
509 /// within a JITDylib.
510 ///
511 /// Note: Care must be taken that no sets of aliases form a cycle, as such
512 /// a cycle will result in a deadlock when any symbol in the cycle is
513 /// resolved.
515 JITDylibLookupFlags SourceJDLookupFlags,
516 SymbolAliasMap Aliases);
517
518 StringRef getName() const override;
519
520private:
521 void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
522 void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
524 extractFlags(const SymbolAliasMap &Aliases);
525
526 JITDylib *SourceJD = nullptr;
527 JITDylibLookupFlags SourceJDLookupFlags;
528 SymbolAliasMap Aliases;
529};
530
531/// Create a ReExportsMaterializationUnit with the given aliases.
532/// Useful for defining symbol aliases.: E.g., given a JITDylib JD containing
533/// symbols "foo" and "bar", we can define aliases "baz" (for "foo") and "qux"
534/// (for "bar") with: \code{.cpp}
535/// SymbolStringPtr Baz = ...;
536/// SymbolStringPtr Qux = ...;
537/// if (auto Err = JD.define(symbolAliases({
538/// {Baz, { Foo, JITSymbolFlags::Exported }},
539/// {Qux, { Bar, JITSymbolFlags::Weak }}}))
540/// return Err;
541/// \endcode
542inline std::unique_ptr<ReExportsMaterializationUnit>
544 return std::make_unique<ReExportsMaterializationUnit>(
545 nullptr, JITDylibLookupFlags::MatchAllSymbols, std::move(Aliases));
546}
547
548/// Create a materialization unit for re-exporting symbols from another JITDylib
549/// with alternative names/flags.
550/// SourceJD will be searched using the given JITDylibLookupFlags.
551inline std::unique_ptr<ReExportsMaterializationUnit>
553 JITDylibLookupFlags SourceJDLookupFlags =
555 return std::make_unique<ReExportsMaterializationUnit>(
556 &SourceJD, SourceJDLookupFlags, std::move(Aliases));
557}
558
559/// Build a SymbolAliasMap for the common case where you want to re-export
560/// symbols from another JITDylib with the same linkage/flags.
563
564/// Represents the state that a symbol has reached during materialization.
565enum class SymbolState : uint8_t {
566 Invalid, /// No symbol should be in this state.
567 NeverSearched, /// Added to the symbol table, never queried.
568 Materializing, /// Queried, materialization begun.
569 Resolved, /// Assigned address, still materializing.
570 Emitted, /// Emitted to memory, but waiting on transitive dependencies.
571 Ready = 0x3f /// Ready and safe for clients to access.
572};
573
574/// A symbol query that returns results via a callback when results are
575/// ready.
576///
577/// makes a callback when all symbols are available.
579 friend class ExecutionSession;
581 friend class JITDylib;
584
585public:
586 /// Create a query for the given symbols. The NotifyComplete
587 /// callback will be called once all queried symbols reach the given
588 /// minimum state.
590 SymbolState RequiredState,
591 SymbolsResolvedCallback NotifyComplete);
592
593 /// Notify the query that a requested symbol has reached the required state.
596
597 /// Returns true if all symbols covered by this query have been
598 /// resolved.
599 bool isComplete() const { return OutstandingSymbolsCount == 0; }
600
601
602private:
603 void handleComplete(ExecutionSession &ES);
604
605 SymbolState getRequiredState() { return RequiredState; }
606
607 void addQueryDependence(JITDylib &JD, SymbolStringPtr Name);
608
609 void removeQueryDependence(JITDylib &JD, const SymbolStringPtr &Name);
610
611 void dropSymbol(const SymbolStringPtr &Name);
612
613 void handleFailed(Error Err);
614
615 void detach();
616
617 SymbolsResolvedCallback NotifyComplete;
618 SymbolDependenceMap QueryRegistrations;
619 SymbolMap ResolvedSymbols;
620 size_t OutstandingSymbolsCount;
621 SymbolState RequiredState;
622};
623
624/// Wraps state for a lookup-in-progress.
625/// DefinitionGenerators can optionally take ownership of a LookupState object
626/// to suspend a lookup-in-progress while they search for definitions.
628 friend class OrcV2CAPIHelper;
629 friend class ExecutionSession;
630
631public:
636
637 /// Continue the lookup. This can be called by DefinitionGenerators
638 /// to re-start a captured query-application operation.
639 LLVM_ABI void continueLookup(Error Err);
640
641private:
642 LookupState(std::unique_ptr<InProgressLookupState> IPLS);
643
644 // For C API.
645 void reset(InProgressLookupState *IPLS);
646
647 std::unique_ptr<InProgressLookupState> IPLS;
648};
649
650/// Definition generators can be attached to JITDylibs to generate new
651/// definitions for otherwise unresolved symbols during lookup.
653 friend class ExecutionSession;
654
655public:
656 virtual ~DefinitionGenerator();
657
658 /// DefinitionGenerators should override this method to insert new
659 /// definitions into the parent JITDylib. K specifies the kind of this
660 /// lookup. JD specifies the target JITDylib being searched, and
661 /// JDLookupFlags specifies whether the search should match against
662 /// hidden symbols. Finally, Symbols describes the set of unresolved
663 /// symbols and their associated lookup flags.
665 JITDylibLookupFlags JDLookupFlags,
666 const SymbolLookupSet &LookupSet) = 0;
667
668private:
669 std::mutex M;
670 bool InUse = false;
671 std::deque<LookupState> PendingLookups;
672};
673
674/// Represents a JIT'd dynamic library.
675///
676/// This class aims to mimic the behavior of a regular dylib or shared object,
677/// but without requiring the contained program representations to be compiled
678/// up-front. The JITDylib's content is defined by adding MaterializationUnits,
679/// and contained MaterializationUnits will typically rely on the JITDylib's
680/// links-against order to resolve external references (similar to a regular
681/// dylib).
682///
683/// The JITDylib object is a thin wrapper that references state held by the
684/// ExecutionSession. JITDylibs can be removed, clearing this underlying state
685/// and leaving the JITDylib object in a defunct state. In this state the
686/// JITDylib's name is guaranteed to remain accessible. If the ExecutionSession
687/// is still alive then other operations are callable but will return an Error
688/// or null result (depending on the API). It is illegal to call any operation
689/// other than getName on a JITDylib after the ExecutionSession has been torn
690/// down.
691///
692/// JITDylibs cannot be moved or copied. Their address is stable, and useful as
693/// a key in some JIT data structures.
694class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
695 public jitlink::JITLinkDylib {
697 friend class ExecutionSession;
698 friend class Platform;
700public:
701
702 JITDylib(const JITDylib &) = delete;
703 JITDylib &operator=(const JITDylib &) = delete;
704 JITDylib(JITDylib &&) = delete;
707
708 /// Get a reference to the ExecutionSession for this JITDylib.
709 ///
710 /// It is legal to call this method on a defunct JITDylib, however the result
711 /// will only usable if the ExecutionSession is still alive. If this JITDylib
712 /// is held by an error that may have torn down the JIT then the result
713 /// should not be used.
714 ExecutionSession &getExecutionSession() const { return ES; }
715
716 /// Dump current JITDylib state to OS.
717 ///
718 /// It is legal to call this method on a defunct JITDylib.
719 LLVM_ABI void dump(raw_ostream &OS);
720
721 /// Calls remove on all trackers currently associated with this JITDylib.
722 /// Does not run static deinits.
723 ///
724 /// Note that removal happens outside the session lock, so new code may be
725 /// added concurrently while the clear is underway, and the newly added
726 /// code will *not* be cleared. Adding new code concurrently with a clear
727 /// is usually a bug and should be avoided.
728 ///
729 /// It is illegal to call this method on a defunct JITDylib and the client
730 /// is responsible for ensuring that they do not do so.
732
733 /// Get the default resource tracker for this JITDylib.
734 ///
735 /// It is illegal to call this method on a defunct JITDylib and the client
736 /// is responsible for ensuring that they do not do so.
738
739 /// Create a resource tracker for this JITDylib.
740 ///
741 /// It is illegal to call this method on a defunct JITDylib and the client
742 /// is responsible for ensuring that they do not do so.
744
745 /// Adds a definition generator to this JITDylib and returns a referenece to
746 /// it.
747 ///
748 /// When JITDylibs are searched during lookup, if no existing definition of
749 /// a symbol is found, then any generators that have been added are run (in
750 /// the order that they were added) to potentially generate a definition.
751 ///
752 /// It is illegal to call this method on a defunct JITDylib and the client
753 /// is responsible for ensuring that they do not do so.
754 template <typename GeneratorT>
755 GeneratorT &addGenerator(std::unique_ptr<GeneratorT> DefGenerator);
756
757 /// Remove a definition generator from this JITDylib.
758 ///
759 /// The given generator must exist in this JITDylib's generators list (i.e.
760 /// have been added and not yet removed).
761 ///
762 /// It is illegal to call this method on a defunct JITDylib and the client
763 /// is responsible for ensuring that they do not do so.
765
766 /// Set the link order to be used when fixing up definitions in JITDylib.
767 /// This will replace the previous link order, and apply to any symbol
768 /// resolutions made for definitions in this JITDylib after the call to
769 /// setLinkOrder (even if the definition itself was added before the
770 /// call).
771 ///
772 /// If LinkAgainstThisJITDylibFirst is true (the default) then this JITDylib
773 /// will add itself to the beginning of the LinkOrder (Clients should not
774 /// put this JITDylib in the list in this case, to avoid redundant lookups).
775 ///
776 /// If LinkAgainstThisJITDylibFirst is false then the link order will be used
777 /// as-is. The primary motivation for this feature is to support deliberate
778 /// shadowing of symbols in this JITDylib by a facade JITDylib. For example,
779 /// the facade may resolve function names to stubs, and the stubs may compile
780 /// lazily by looking up symbols in this dylib. Adding the facade dylib
781 /// as the first in the link order (instead of this dylib) ensures that
782 /// definitions within this dylib resolve to the lazy-compiling stubs,
783 /// rather than immediately materializing the definitions in this dylib.
784 ///
785 /// It is illegal to call this method on a defunct JITDylib and the client
786 /// is responsible for ensuring that they do not do so.
787 LLVM_ABI void setLinkOrder(JITDylibSearchOrder NewSearchOrder,
788 bool LinkAgainstThisJITDylibFirst = true);
789
790 /// Append the given JITDylibSearchOrder to the link order for this
791 /// JITDylib (discarding any elements already present in this JITDylib's
792 /// link order).
793 LLVM_ABI void addToLinkOrder(const JITDylibSearchOrder &NewLinks);
794
795 /// Add the given JITDylib to the link order for definitions in this
796 /// JITDylib.
797 ///
798 /// It is illegal to call this method on a defunct JITDylib and the client
799 /// is responsible for ensuring that they do not do so.
800 LLVM_ABI void
802 JITDylibLookupFlags JDLookupFlags =
804
805 /// Replace OldJD with NewJD in the link order if OldJD is present.
806 /// Otherwise this operation is a no-op.
807 ///
808 /// It is illegal to call this method on a defunct JITDylib and the client
809 /// is responsible for ensuring that they do not do so.
810 LLVM_ABI void
811 replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD,
812 JITDylibLookupFlags JDLookupFlags =
814
815 /// Remove the given JITDylib from the link order for this JITDylib if it is
816 /// present. Otherwise this operation is a no-op.
817 ///
818 /// It is illegal to call this method on a defunct JITDylib and the client
819 /// is responsible for ensuring that they do not do so.
821
822 /// Do something with the link order (run under the session lock).
823 ///
824 /// It is illegal to call this method on a defunct JITDylib and the client
825 /// is responsible for ensuring that they do not do so.
826 template <typename Func>
827 auto withLinkOrderDo(Func &&F)
828 -> decltype(F(std::declval<const JITDylibSearchOrder &>()));
829
830 /// Define all symbols provided by the materialization unit to be part of this
831 /// JITDylib.
832 ///
833 /// If RT is not specified then the default resource tracker will be used.
834 ///
835 /// This overload always takes ownership of the MaterializationUnit. If any
836 /// errors occur, the MaterializationUnit consumed.
837 ///
838 /// It is illegal to call this method on a defunct JITDylib and the client
839 /// is responsible for ensuring that they do not do so.
840 template <typename MaterializationUnitType>
841 Error define(std::unique_ptr<MaterializationUnitType> &&MU,
842 ResourceTrackerSP RT = nullptr);
843
844 /// Define all symbols provided by the materialization unit to be part of this
845 /// JITDylib.
846 ///
847 /// This overload only takes ownership of the MaterializationUnit no error is
848 /// generated. If an error occurs, ownership remains with the caller. This
849 /// may allow the caller to modify the MaterializationUnit to correct the
850 /// issue, then re-call define.
851 ///
852 /// It is illegal to call this method on a defunct JITDylib and the client
853 /// is responsible for ensuring that they do not do so.
854 template <typename MaterializationUnitType>
855 Error define(std::unique_ptr<MaterializationUnitType> &MU,
856 ResourceTrackerSP RT = nullptr);
857
858 /// Tries to remove the given symbols.
859 ///
860 /// If any symbols are not defined in this JITDylib this method will return
861 /// a SymbolsNotFound error covering the missing symbols.
862 ///
863 /// If all symbols are found but some symbols are in the process of being
864 /// materialized this method will return a SymbolsCouldNotBeRemoved error.
865 ///
866 /// On success, all symbols are removed. On failure, the JITDylib state is
867 /// left unmodified (no symbols are removed).
868 ///
869 /// It is illegal to call this method on a defunct JITDylib and the client
870 /// is responsible for ensuring that they do not do so.
871 LLVM_ABI Error remove(const SymbolNameSet &Names);
872
873 /// Returns the given JITDylibs and all of their transitive dependencies in
874 /// DFS order (based on linkage relationships). Each JITDylib will appear
875 /// only once.
876 ///
877 /// If any JITDylib in the order is defunct then this method will return an
878 /// error, otherwise returns the order.
881
882 /// Returns the given JITDylibs and all of their transitive dependencies in
883 /// reverse DFS order (based on linkage relationships). Each JITDylib will
884 /// appear only once.
885 ///
886 /// If any JITDylib in the order is defunct then this method will return an
887 /// error, otherwise returns the order.
890
891 /// Return this JITDylib and its transitive dependencies in DFS order
892 /// based on linkage relationships.
893 ///
894 /// If any JITDylib in the order is defunct then this method will return an
895 /// error, otherwise returns the order.
897
898 /// Rteurn this JITDylib and its transitive dependencies in reverse DFS order
899 /// based on linkage relationships.
900 ///
901 /// If any JITDylib in the order is defunct then this method will return an
902 /// error, otherwise returns the order.
904
905private:
906 using AsynchronousSymbolQuerySet =
907 std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
908
909 using AsynchronousSymbolQueryList =
910 std::vector<std::shared_ptr<AsynchronousSymbolQuery>>;
911
912 struct UnmaterializedInfo {
913 UnmaterializedInfo(std::unique_ptr<MaterializationUnit> MU,
914 ResourceTracker *RT)
915 : MU(std::move(MU)), RT(RT) {}
916
917 std::unique_ptr<MaterializationUnit> MU;
918 ResourceTracker *RT;
919 };
920
921 using UnmaterializedInfosMap =
922 DenseMap<SymbolStringPtr, std::shared_ptr<UnmaterializedInfo>>;
923
924 using UnmaterializedInfosList =
925 std::vector<std::shared_ptr<UnmaterializedInfo>>;
926
927 // Information about not-yet-ready symbol.
928 // * DefiningEDU will point to the EmissionDepUnit that defines the symbol.
929 // * DependantEDUs will hold pointers to any EmissionDepUnits currently
930 // waiting on this symbol.
931 // * Pending queries holds any not-yet-completed queries that include this
932 // symbol.
933 struct MaterializingInfo {
934 friend class ExecutionSession;
935
936 LLVM_ABI void addQuery(std::shared_ptr<AsynchronousSymbolQuery> Q);
937 LLVM_ABI void removeQuery(const AsynchronousSymbolQuery &Q);
938 LLVM_ABI AsynchronousSymbolQueryList
939 takeQueriesMeeting(SymbolState RequiredState);
940 AsynchronousSymbolQueryList takeAllPendingQueries() {
941 return std::move(PendingQueries);
942 }
943 bool hasQueriesPending() const { return !PendingQueries.empty(); }
944 const AsynchronousSymbolQueryList &pendingQueries() const {
945 return PendingQueries;
946 }
947 private:
948 AsynchronousSymbolQueryList PendingQueries;
949 };
950
951 using MaterializingInfosMap = DenseMap<SymbolStringPtr, MaterializingInfo>;
952
953 class SymbolTableEntry {
954 public:
955 SymbolTableEntry() = default;
956 SymbolTableEntry(JITSymbolFlags Flags)
957 : Flags(Flags), State(static_cast<uint8_t>(SymbolState::NeverSearched)),
958 MaterializerAttached(false) {}
959
960 ExecutorAddr getAddress() const { return Addr; }
961 JITSymbolFlags getFlags() const { return Flags; }
962 SymbolState getState() const { return static_cast<SymbolState>(State); }
963
964 bool hasMaterializerAttached() const { return MaterializerAttached; }
965
966 void setAddress(ExecutorAddr Addr) { this->Addr = Addr; }
967 void setFlags(JITSymbolFlags Flags) { this->Flags = Flags; }
968 void setState(SymbolState State) {
969 assert(static_cast<uint8_t>(State) < (1 << 6) &&
970 "State does not fit in bitfield");
971 this->State = static_cast<uint8_t>(State);
972 }
973
974 void setMaterializerAttached(bool MaterializerAttached) {
975 this->MaterializerAttached = MaterializerAttached;
976 }
977
978 ExecutorSymbolDef getSymbol() const { return {Addr, Flags}; }
979
980 private:
981 ExecutorAddr Addr;
982 JITSymbolFlags Flags;
983 uint8_t State : 7;
984 uint8_t MaterializerAttached : 1;
985 };
986
987 using SymbolTable = DenseMap<SymbolStringPtr, SymbolTableEntry>;
988
989 JITDylib(ExecutionSession &ES, std::string Name);
990
991 struct RemoveTrackerResult {
992 AsynchronousSymbolQuerySet QueriesToFail;
993 std::shared_ptr<SymbolDependenceMap> FailedSymbols;
994 std::vector<std::unique_ptr<MaterializationUnit>> DefunctMUs;
995 };
996
997 RemoveTrackerResult IL_removeTracker(ResourceTracker &RT);
998
999 void transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
1000
1001 LLVM_ABI Error defineImpl(MaterializationUnit &MU);
1002
1003 LLVM_ABI void
1004 installMaterializationUnit(std::unique_ptr<MaterializationUnit> MU,
1005 ResourceTracker &RT);
1006
1007 void detachQueryHelper(AsynchronousSymbolQuery &Q,
1008 const SymbolNameSet &QuerySymbols);
1009
1010 void transferEmittedNodeDependencies(MaterializingInfo &DependantMI,
1011 const SymbolStringPtr &DependantName,
1012 MaterializingInfo &EmittedMI);
1013
1014 Expected<SymbolFlagsMap>
1015 defineMaterializing(MaterializationResponsibility &FromMR,
1016 SymbolFlagsMap SymbolFlags);
1017
1018 Error replace(MaterializationResponsibility &FromMR,
1019 std::unique_ptr<MaterializationUnit> MU);
1020
1021 Expected<std::unique_ptr<MaterializationResponsibility>>
1022 delegate(MaterializationResponsibility &FromMR, SymbolFlagsMap SymbolFlags,
1023 SymbolStringPtr InitSymbol);
1024
1025 SymbolNameSet getRequestedSymbols(const SymbolFlagsMap &SymbolFlags) const;
1026
1027 void addDependencies(const SymbolStringPtr &Name,
1028 const SymbolDependenceMap &Dependants);
1029
1031
1032 void unlinkMaterializationResponsibility(MaterializationResponsibility &MR);
1033
1034 /// Attempt to reduce memory usage from empty \c UnmaterializedInfos and
1035 /// \c MaterializingInfos tables.
1036 void shrinkMaterializationInfoMemory();
1037
1038 ExecutionSession &ES;
1039 enum { Open, Closing, Closed } State = Open;
1040 std::mutex GeneratorsMutex;
1041 SymbolTable Symbols;
1042 UnmaterializedInfosMap UnmaterializedInfos;
1043 MaterializingInfosMap MaterializingInfos;
1044 std::vector<std::shared_ptr<DefinitionGenerator>> DefGenerators;
1045 JITDylibSearchOrder LinkOrder;
1046 ResourceTrackerSP DefaultTracker;
1047
1048 // Map trackers to sets of symbols tracked.
1049 DenseMap<ResourceTracker *, SymbolNameVector> TrackerSymbols;
1050 DenseMap<ResourceTracker *, DenseSet<MaterializationResponsibility *>>
1051 TrackerMRs;
1052};
1053
1054/// Platforms set up standard symbols and mediate interactions between dynamic
1055/// initializers (e.g. C++ static constructors) and ExecutionSession state.
1056/// Note that Platforms do not automatically run initializers: clients are still
1057/// responsible for doing this.
1059public:
1060 virtual ~Platform();
1061
1062 /// This method will be called outside the session lock each time a JITDylib
1063 /// is created (unless it is created with EmptyJITDylib set) to allow the
1064 /// Platform to install any JITDylib specific standard symbols (e.g
1065 /// __dso_handle).
1066 virtual Error setupJITDylib(JITDylib &JD) = 0;
1067
1068 /// This method will be called outside the session lock each time a JITDylib
1069 /// is removed to allow the Platform to remove any JITDylib-specific data.
1071
1072 /// This method will be called under the ExecutionSession lock each time a
1073 /// MaterializationUnit is added to a JITDylib.
1075 const MaterializationUnit &MU) = 0;
1076
1077 /// This method will be called under the ExecutionSession lock when a
1078 /// ResourceTracker is removed.
1080
1081 /// A utility function for looking up initializer symbols. Performs a blocking
1082 /// lookup for the given symbols in each of the given JITDylibs.
1083 ///
1084 /// Note: This function is deprecated and will be removed in the near future.
1088
1089 /// Performs an async lookup for the given symbols in each of the given
1090 /// JITDylibs, calling the given handler once all lookups have completed.
1091 static void
1093 ExecutionSession &ES,
1095};
1096
1097/// A materialization task.
1099 : public RTTIExtends<MaterializationTask, Task> {
1100public:
1101 static char ID;
1102
1103 MaterializationTask(std::unique_ptr<MaterializationUnit> MU,
1104 std::unique_ptr<MaterializationResponsibility> MR)
1105 : MU(std::move(MU)), MR(std::move(MR)) {}
1106 ~MaterializationTask() override;
1107 void printDescription(raw_ostream &OS) override;
1108 void run() override;
1109
1110private:
1111 std::unique_ptr<MaterializationUnit> MU;
1112 std::unique_ptr<MaterializationResponsibility> MR;
1113};
1114
1115/// Lookups are usually run on the current thread, but in some cases they may
1116/// be run as tasks, e.g. if the lookup has been continued from a suspended
1117/// state.
1118class LLVM_ABI LookupTask : public RTTIExtends<LookupTask, Task> {
1119public:
1120 static char ID;
1121
1122 LookupTask(LookupState LS) : LS(std::move(LS)) {}
1123 void printDescription(raw_ostream &OS) override;
1124 void run() override;
1125
1126private:
1127 LookupState LS;
1128};
1129
1130/// An ExecutionSession represents a running JIT program.
1134 friend class JITDylib;
1135 friend class LookupState;
1137 friend class ResourceTracker;
1138
1139public:
1140 /// For reporting errors.
1142
1143 /// Send a result to the remote.
1145
1146 /// An asynchronous wrapper-function callable from the executor via
1147 /// jit-dispatch.
1149 SendResultFunction SendResult,
1150 const char *ArgData, size_t ArgSize)>;
1151
1152 /// A map associating tag names with asynchronous wrapper function
1153 /// implementations in the JIT.
1156
1157 /// Construct an ExecutionSession with the given ExecutorProcessControl
1158 /// object.
1159 LLVM_ABI ExecutionSession(std::unique_ptr<ExecutorProcessControl> EPC);
1160
1161 /// Destroy an ExecutionSession. Verifies that endSession was called prior to
1162 /// destruction.
1164
1165 /// End the session. Closes all JITDylibs and disconnects from the
1166 /// executor. Clients must call this method before destroying the session.
1168
1169 /// Get the ExecutorProcessControl object associated with this
1170 /// ExecutionSession.
1172
1173 /// Return the triple for the executor.
1174 const Triple &getTargetTriple() const { return EPC->getTargetTriple(); }
1175
1176 // Return the page size for the executor.
1177 size_t getPageSize() const { return EPC->getPageSize(); }
1178
1179 /// Get the SymbolStringPool for this instance.
1180 std::shared_ptr<SymbolStringPool> getSymbolStringPool() {
1181 return EPC->getSymbolStringPool();
1182 }
1183
1184 /// Add a symbol name to the SymbolStringPool and return a pointer to it.
1185 SymbolStringPtr intern(StringRef SymName) { return EPC->intern(SymName); }
1186
1187 /// Returns a reference to the bootstrap JITDylib.
1188 ///
1189 /// This is a bare JITDylib that is created for each ExecutionSession and
1190 /// populated with the bootstrap symbol definitions provided by the
1191 /// ExecutorProcessControl object.
1192 JITDylib &getBootstrapJITDylib() { return BootstrapJD; }
1193
1194 /// Set a WaitingOnGraph::Recorder to capture WaitingOnGraph operations.
1195 ///
1196 /// This method can be called at most once. If called, it should be called
1197 /// before any symbols are materialized.
1198 void setWaitingOnGraphOpRecorder(WaitingOnGraph::OpRecorder &R) {
1199 assert(!GOpRecorder && "WaitingOnGraph recorder already set");
1200 GOpRecorder = &R;
1201 }
1202
1203 /// Set the Platform for this ExecutionSession.
1204 void setPlatform(std::unique_ptr<Platform> P) { this->P = std::move(P); }
1205
1206 /// Get the Platform for this session.
1207 /// Will return null if no Platform has been set for this ExecutionSession.
1208 Platform *getPlatform() { return P.get(); }
1209
1210 /// Run the given lambda with the session mutex locked.
1211 template <typename Func> decltype(auto) runSessionLocked(Func &&F) {
1212 std::lock_guard<std::recursive_mutex> Lock(SessionMutex);
1213 return F();
1214 }
1215
1216 /// Register the given ResourceManager with this ExecutionSession.
1217 /// Managers will be notified of events in reverse order of registration.
1219
1220 /// Deregister the given ResourceManager with this ExecutionSession.
1221 /// Manager must have been previously registered.
1223
1224 /// Return a pointer to the "name" JITDylib.
1225 /// Ownership of JITDylib remains within Execution Session
1227
1228 /// Add a new bare JITDylib to this ExecutionSession.
1229 ///
1230 /// The JITDylib Name is required to be unique. Clients should verify that
1231 /// names are not being re-used (E.g. by calling getJITDylibByName) if names
1232 /// are based on user input.
1233 ///
1234 /// This call does not install any library code or symbols into the newly
1235 /// created JITDylib. The client is responsible for all configuration.
1236 LLVM_ABI JITDylib &createBareJITDylib(std::string Name);
1237
1238 /// Add a new JITDylib to this ExecutionSession.
1239 ///
1240 /// The JITDylib Name is required to be unique. Clients should verify that
1241 /// names are not being re-used (e.g. by calling getJITDylibByName) if names
1242 /// are based on user input.
1243 ///
1244 /// If a Platform is attached then Platform::setupJITDylib will be called to
1245 /// install standard platform symbols (e.g. standard library interposes).
1246 /// If no Platform is attached this call is equivalent to createBareJITDylib.
1248
1249 /// Removes the given JITDylibs from the ExecutionSession.
1250 ///
1251 /// This method clears all resources held for the JITDylibs, puts them in the
1252 /// closed state, and clears all references to them that are held by the
1253 /// ExecutionSession or other JITDylibs. No further code can be added to the
1254 /// removed JITDylibs, and the JITDylib objects will be freed once any
1255 /// remaining JITDylibSPs pointing to them are destroyed.
1256 ///
1257 /// This method does *not* run static destructors for code contained in the
1258 /// JITDylibs, and each JITDylib can only be removed once.
1259 ///
1260 /// JITDylibs will be removed in the order given. Teardown is usually
1261 /// independent for each JITDylib, but not always. In particular, where the
1262 /// ORC runtime is used it is expected that teardown off all JITDylibs will
1263 /// depend on it, so the JITDylib containing the ORC runtime must be removed
1264 /// last. If the client has introduced any other dependencies they should be
1265 /// accounted for in the removal order too.
1266 LLVM_ABI Error removeJITDylibs(std::vector<JITDylibSP> JDsToRemove);
1267
1268 /// Calls removeJTIDylibs on the gives JITDylib.
1270 return removeJITDylibs(std::vector<JITDylibSP>({&JD}));
1271 }
1272
1273 /// Set the error reporter function.
1275 this->ReportError = std::move(ReportError);
1276 return *this;
1277 }
1278
1279 /// Report a error for this execution session.
1280 ///
1281 /// Unhandled errors can be sent here to log them.
1282 void reportError(Error Err) { ReportError(std::move(Err)); }
1283
1284 /// Search the given JITDylibs to find the flags associated with each of the
1285 /// given symbols.
1286 LLVM_ABI void
1288 SymbolLookupSet Symbols,
1289 unique_function<void(Expected<SymbolFlagsMap>)> OnComplete);
1290
1291 /// Blocking version of lookupFlags.
1293 JITDylibSearchOrder SearchOrder,
1294 SymbolLookupSet Symbols);
1295
1296 /// Search the given JITDylibs for the given symbols.
1297 ///
1298 /// SearchOrder lists the JITDylibs to search. For each dylib, the associated
1299 /// boolean indicates whether the search should match against non-exported
1300 /// (hidden visibility) symbols in that dylib (true means match against
1301 /// non-exported symbols, false means do not match).
1302 ///
1303 /// The NotifyComplete callback will be called once all requested symbols
1304 /// reach the required state.
1305 ///
1306 /// If all symbols are found, the RegisterDependencies function will be called
1307 /// while the session lock is held. This gives clients a chance to register
1308 /// dependencies for on the queried symbols for any symbols they are
1309 /// materializing (if a MaterializationResponsibility instance is present,
1310 /// this can be implemented by calling
1311 /// MaterializationResponsibility::addDependencies). If there are no
1312 /// dependenant symbols for this query (e.g. it is being made by a top level
1313 /// client to get an address to call) then the value NoDependenciesToRegister
1314 /// can be used.
1315 LLVM_ABI void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder,
1316 SymbolLookupSet Symbols, SymbolState RequiredState,
1317 SymbolsResolvedCallback NotifyComplete,
1318 RegisterDependenciesFunction RegisterDependencies);
1319
1320 /// Blocking version of lookup above. Returns the resolved symbol map.
1321 /// If WaitUntilReady is true (the default), will not return until all
1322 /// requested symbols are ready (or an error occurs). If WaitUntilReady is
1323 /// false, will return as soon as all requested symbols are resolved,
1324 /// or an error occurs. If WaitUntilReady is false and an error occurs
1325 /// after resolution, the function will return a success value, but the
1326 /// error will be reported via reportErrors.
1328 lookup(const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols,
1330 SymbolState RequiredState = SymbolState::Ready,
1331 RegisterDependenciesFunction RegisterDependencies =
1333
1334 /// Convenience version of blocking lookup.
1335 /// Searches each of the JITDylibs in the search order in turn for the given
1336 /// symbol.
1338 lookup(const JITDylibSearchOrder &SearchOrder, SymbolStringPtr Symbol,
1339 SymbolState RequiredState = SymbolState::Ready);
1340
1341 /// Convenience version of blocking lookup.
1342 /// Searches each of the JITDylibs in the search order in turn for the given
1343 /// symbol. The search will not find non-exported symbols.
1345 lookup(ArrayRef<JITDylib *> SearchOrder, SymbolStringPtr Symbol,
1346 SymbolState RequiredState = SymbolState::Ready);
1347
1348 /// Convenience version of blocking lookup.
1349 /// Searches each of the JITDylibs in the search order in turn for the given
1350 /// symbol. The search will not find non-exported symbols.
1352 lookup(ArrayRef<JITDylib *> SearchOrder, StringRef Symbol,
1353 SymbolState RequiredState = SymbolState::Ready);
1354
1355 /// Materialize the given unit.
1356 void dispatchTask(std::unique_ptr<Task> T) {
1357 assert(T && "T must be non-null");
1358 DEBUG_WITH_TYPE("orc", dumpDispatchInfo(*T));
1359 EPC->getDispatcher().dispatch(std::move(T));
1360 }
1361
1362 /// Returns the bootstrap map.
1364 return EPC->getBootstrapMap();
1365 }
1366
1367 /// Look up and SPS-deserialize a bootstrap map value.
1368 template <typename T, typename SPSTagT>
1369 Error getBootstrapMapValue(StringRef Key, std::optional<T> &Val) const {
1370 return EPC->getBootstrapMapValue<T, SPSTagT>(Key, Val);
1371 }
1372
1373 /// Returns the bootstrap symbol map.
1375 return EPC->getBootstrapSymbolsMap();
1376 }
1377
1378 /// For each (ExecutorAddr&, StringRef) pair, looks up the string in the
1379 /// bootstrap symbols map and writes its address to the ExecutorAddr if
1380 /// found. If any symbol is not found then the function returns an error.
1382 ArrayRef<std::pair<ExecutorAddr &, StringRef>> Pairs) const {
1383 return EPC->getBootstrapSymbols(Pairs);
1384 }
1385
1386 /// Run a wrapper function in the executor. The given WFRHandler will be
1387 /// called on the result when it is returned.
1388 ///
1389 /// The wrapper function should be callable as:
1390 ///
1391 /// \code{.cpp}
1392 /// CWrapperFunctionBuffer fn(uint8_t *Data, uint64_t Size);
1393 /// \endcode{.cpp}
1394 void callWrapperAsync(ExecutorAddr WrapperFnAddr,
1396 ArrayRef<char> ArgBuffer) {
1397 EPC->callWrapperAsync(WrapperFnAddr, std::move(OnComplete), ArgBuffer);
1398 }
1399
1400 /// Run a wrapper function in the executor using the given Runner to dispatch
1401 /// OnComplete when the result is ready.
1402 template <typename RunPolicyT, typename FnT>
1403 void callWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr,
1404 FnT &&OnComplete, ArrayRef<char> ArgBuffer) {
1405 EPC->callWrapperAsync(std::forward<RunPolicyT>(Runner), WrapperFnAddr,
1406 std::forward<FnT>(OnComplete), ArgBuffer);
1407 }
1408
1409 /// Run a wrapper function in the executor. OnComplete will be dispatched
1410 /// as a GenericNamedTask using this instance's TaskDispatch object.
1411 template <typename FnT>
1412 void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete,
1413 ArrayRef<char> ArgBuffer) {
1414 EPC->callWrapperAsync(WrapperFnAddr, std::forward<FnT>(OnComplete),
1415 ArgBuffer);
1416 }
1417
1418 /// Run a wrapper function in the executor. The wrapper function should be
1419 /// callable as:
1420 ///
1421 /// \code{.cpp}
1422 /// CWrapperFunctionBuffer fn(uint8_t *Data, uint64_t Size);
1423 /// \endcode{.cpp}
1425 ArrayRef<char> ArgBuffer) {
1426 return EPC->callWrapper(WrapperFnAddr, ArgBuffer);
1427 }
1428
1429 /// Run a wrapper function using SPS to serialize the arguments and
1430 /// deserialize the results.
1431 template <typename SPSSignature, typename SendResultT, typename... ArgTs>
1432 void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
1433 const ArgTs &...Args) {
1434 EPC->callSPSWrapperAsync<SPSSignature, SendResultT, ArgTs...>(
1435 WrapperFnAddr, std::forward<SendResultT>(SendResult), Args...);
1436 }
1437
1438 /// Run a wrapper function using SPS to serialize the arguments and
1439 /// deserialize the results.
1440 ///
1441 /// If SPSSignature is a non-void function signature then the second argument
1442 /// (the first in the Args list) should be a reference to a return value.
1443 template <typename SPSSignature, typename... WrapperCallArgTs>
1445 WrapperCallArgTs &&...WrapperCallArgs) {
1446 return EPC->callSPSWrapper<SPSSignature, WrapperCallArgTs...>(
1447 WrapperFnAddr, std::forward<WrapperCallArgTs>(WrapperCallArgs)...);
1448 }
1449
1450 /// Wrap a handler that takes concrete argument types (and a sender for a
1451 /// concrete return type) to produce an AsyncHandlerWrapperFunction. Uses SPS
1452 /// to unpack the arguments and pack the result.
1453 ///
1454 /// This function is intended to support easy construction of
1455 /// AsyncHandlerWrapperFunctions that can be associated with a tag
1456 /// (using registerJITDispatchHandler) and called from the executor.
1457 template <typename SPSSignature, typename HandlerT>
1459 return [H = std::forward<HandlerT>(H)](SendResultFunction SendResult,
1460 const char *ArgData,
1461 size_t ArgSize) mutable {
1463 ArgData, ArgSize, std::move(SendResult), H);
1464 };
1465 }
1466
1467 /// Wrap a class method that takes concrete argument types (and a sender for
1468 /// a concrete return type) to produce an AsyncHandlerWrapperFunction. Uses
1469 /// SPS to unpack the arguments and pack the result.
1470 ///
1471 /// This function is intended to support easy construction of
1472 /// AsyncHandlerWrapperFunctions that can be associated with a tag
1473 /// (using registerJITDispatchHandler) and called from the executor.
1474 template <typename SPSSignature, typename ClassT, typename... MethodArgTs>
1476 wrapAsyncWithSPS(ClassT *Instance, void (ClassT::*Method)(MethodArgTs...)) {
1478 [Instance, Method](MethodArgTs &&...MethodArgs) {
1479 (Instance->*Method)(std::forward<MethodArgTs>(MethodArgs)...);
1480 });
1481 }
1482
1483 /// For each tag symbol name, associate the corresponding
1484 /// AsyncHandlerWrapperFunction with the address of that symbol. The
1485 /// handler becomes callable from the executor using the ORC runtime
1486 /// __orc_rt_jit_dispatch function and the given tag.
1487 ///
1488 /// Tag symbols will be looked up in JD using LookupKind::Static,
1489 /// JITDylibLookupFlags::MatchAllSymbols (hidden tags will be found), and
1490 /// LookupFlags::WeaklyReferencedSymbol. Missing tag definitions will not
1491 /// cause an error, the handler will simply be dropped.
1494
1495 /// Run a registered jit-side wrapper function.
1496 /// This should be called by the ExecutorProcessControl instance in response
1497 /// to incoming jit-dispatch requests from the executor.
1499 ExecutorAddr HandlerFnTagAddr,
1501
1502 /// Dump the state of all the JITDylibs in this session.
1503 LLVM_ABI void dump(raw_ostream &OS);
1504
1505 /// Check the internal consistency of ExecutionSession data structures.
1506#ifdef EXPENSIVE_CHECKS
1507 bool verifySessionState(Twine Phase);
1508#endif
1509
1510private:
1511 static void logErrorsToStdErr(Error Err) {
1512 logAllUnhandledErrors(std::move(Err), errs(), "JIT session error: ");
1513 }
1514
1515 void dispatchOutstandingMUs();
1516
1517 static std::unique_ptr<MaterializationResponsibility>
1518 createMaterializationResponsibility(ResourceTracker &RT,
1519 SymbolFlagsMap Symbols,
1520 SymbolStringPtr InitSymbol) {
1521 auto &JD = RT.getJITDylib();
1522 std::unique_ptr<MaterializationResponsibility> MR(
1523 new MaterializationResponsibility(&RT, std::move(Symbols),
1524 std::move(InitSymbol)));
1525 JD.TrackerMRs[&RT].insert(MR.get());
1526 return MR;
1527 }
1528
1529 Error removeResourceTracker(ResourceTracker &RT);
1530 void transferResourceTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
1531 void destroyResourceTracker(ResourceTracker &RT);
1532
1533 // State machine functions for query application..
1534
1535 /// IL_updateCandidatesFor is called to remove already-defined symbols that
1536 /// match a given query from the set of candidate symbols to generate
1537 /// definitions for (no need to generate a definition if one already exists).
1538 Error IL_updateCandidatesFor(JITDylib &JD, JITDylibLookupFlags JDLookupFlags,
1539 SymbolLookupSet &Candidates,
1540 SymbolLookupSet *NonCandidates);
1541
1542 /// Handle resumption of a lookup after entering a generator.
1543 void OL_resumeLookupAfterGeneration(InProgressLookupState &IPLS);
1544
1545 /// OL_applyQueryPhase1 is an optionally re-startable loop for triggering
1546 /// definition generation. It is called when a lookup is performed, and again
1547 /// each time that LookupState::continueLookup is called.
1548 void OL_applyQueryPhase1(std::unique_ptr<InProgressLookupState> IPLS,
1549 Error Err);
1550
1551 /// OL_completeLookup is run once phase 1 successfully completes for a lookup
1552 /// call. It attempts to attach the symbol to all symbol table entries and
1553 /// collect all MaterializationUnits to dispatch. If this method fails then
1554 /// all MaterializationUnits will be left un-materialized.
1555 void OL_completeLookup(std::unique_ptr<InProgressLookupState> IPLS,
1556 std::shared_ptr<AsynchronousSymbolQuery> Q,
1557 RegisterDependenciesFunction RegisterDependencies);
1558
1559 /// OL_completeLookupFlags is run once phase 1 successfully completes for a
1560 /// lookupFlags call.
1561 void OL_completeLookupFlags(
1562 std::unique_ptr<InProgressLookupState> IPLS,
1563 unique_function<void(Expected<SymbolFlagsMap>)> OnComplete);
1564
1565 // State machine functions for MaterializationResponsibility.
1566 LLVM_ABI void
1567 OL_destroyMaterializationResponsibility(MaterializationResponsibility &MR);
1569 OL_getRequestedSymbols(const MaterializationResponsibility &MR);
1570 LLVM_ABI Error OL_notifyResolved(MaterializationResponsibility &MR,
1571 const SymbolMap &Symbols);
1572
1573 // FIXME: We should be able to derive FailedSymsForQuery from each query once
1574 // we fix how the detach operation works.
1575 struct EmitQueries {
1576 JITDylib::AsynchronousSymbolQuerySet Completed;
1577 JITDylib::AsynchronousSymbolQuerySet Failed;
1578 DenseMap<AsynchronousSymbolQuery *, std::shared_ptr<SymbolDependenceMap>>
1579 FailedSymsForQuery;
1580 };
1581
1583 IL_getSymbolState(JITDylib *JD, NonOwningSymbolStringPtr Name);
1584
1585 template <typename UpdateSymbolFn, typename UpdateQueryFn>
1586 void IL_collectQueries(JITDylib::AsynchronousSymbolQuerySet &Qs,
1587 WaitingOnGraph::ContainerElementsMap &QualifiedSymbols,
1588 UpdateSymbolFn &&UpdateSymbol,
1589 UpdateQueryFn &&UpdateQuery);
1590
1591 Expected<EmitQueries> IL_emit(MaterializationResponsibility &MR,
1592 WaitingOnGraph::SimplifyResult SR);
1593 LLVM_ABI Error OL_notifyEmitted(MaterializationResponsibility &MR,
1595
1596 LLVM_ABI Error OL_defineMaterializing(MaterializationResponsibility &MR,
1597 SymbolFlagsMap SymbolFlags);
1598
1599 std::pair<JITDylib::AsynchronousSymbolQuerySet,
1600 std::shared_ptr<SymbolDependenceMap>>
1601 IL_failSymbols(JITDylib &JD, const SymbolNameVector &SymbolsToFail);
1602 LLVM_ABI void OL_notifyFailed(MaterializationResponsibility &MR);
1604 std::unique_ptr<MaterializationUnit> MU);
1605 LLVM_ABI Expected<std::unique_ptr<MaterializationResponsibility>>
1606 OL_delegate(MaterializationResponsibility &MR, const SymbolNameSet &Symbols);
1607
1608#ifndef NDEBUG
1609 void dumpDispatchInfo(Task &T);
1610#endif // NDEBUG
1611
1612 mutable std::recursive_mutex SessionMutex;
1613 bool SessionOpen = true;
1614 std::unique_ptr<ExecutorProcessControl> EPC;
1615 std::unique_ptr<Platform> P;
1616 ErrorReporter ReportError = logErrorsToStdErr;
1617
1618 std::vector<ResourceManager *> ResourceManagers;
1619
1620 std::vector<JITDylibSP> JDs;
1621 JITDylib &BootstrapJD;
1623 WaitingOnGraph::OpRecorder *GOpRecorder = nullptr;
1624
1625 // FIXME: Remove this (and runOutstandingMUs) once the linking layer works
1626 // with callbacks from asynchronous queries.
1627 mutable std::recursive_mutex OutstandingMUsMutex;
1628 std::vector<std::pair<std::unique_ptr<MaterializationUnit>,
1629 std::unique_ptr<MaterializationResponsibility>>>
1630 OutstandingMUs;
1631
1632 mutable std::mutex JITDispatchHandlersMutex;
1633 DenseMap<ExecutorAddr, std::shared_ptr<JITDispatchHandlerFunction>>
1634 JITDispatchHandlers;
1635};
1636
1638 return JD->getExecutionSession().lookup({JD.get()}, Name);
1639}
1640
1641template <typename Func> Error ResourceTracker::withResourceKeyDo(Func &&F) {
1643 if (isDefunct())
1645 F(getKeyUnsafe());
1646 return Error::success();
1647 });
1648}
1649
1650inline ExecutionSession &
1652 return JD.getExecutionSession();
1653}
1654
1655template <typename GeneratorT>
1656GeneratorT &JITDylib::addGenerator(std::unique_ptr<GeneratorT> DefGenerator) {
1657 auto &G = *DefGenerator;
1658 ES.runSessionLocked([&] {
1659 assert(State == Open && "Cannot add generator to closed JITDylib");
1660 DefGenerators.push_back(std::move(DefGenerator));
1661 });
1662 return G;
1663}
1664
1665template <typename Func>
1667 -> decltype(F(std::declval<const JITDylibSearchOrder &>())) {
1668 assert(State == Open && "Cannot use link order of closed JITDylib");
1669 return ES.runSessionLocked([&]() { return F(LinkOrder); });
1670}
1671
1672template <typename MaterializationUnitType>
1673Error JITDylib::define(std::unique_ptr<MaterializationUnitType> &&MU,
1674 ResourceTrackerSP RT) {
1675 assert(MU && "Can not define with a null MU");
1676
1677 if (MU->getSymbols().empty()) {
1678 // Empty MUs are allowable but pathological, so issue a warning.
1679 DEBUG_WITH_TYPE("orc", {
1680 dbgs() << "Warning: Discarding empty MU " << MU->getName() << " for "
1681 << getName() << "\n";
1682 });
1683 return Error::success();
1684 } else
1685 DEBUG_WITH_TYPE("orc", {
1686 dbgs() << "Defining MU " << MU->getName() << " for " << getName()
1687 << " (tracker: ";
1688 if (RT == getDefaultResourceTracker())
1689 dbgs() << "default)";
1690 else if (RT)
1691 dbgs() << RT.get() << ")\n";
1692 else
1693 dbgs() << "0x0, default will be used)\n";
1694 });
1695
1696 return ES.runSessionLocked([&, this]() -> Error {
1697 if (State != Open)
1698 return make_error<JITDylibDefunct>(this);
1699
1700 if (auto Err = defineImpl(*MU))
1701 return Err;
1702
1703 if (!RT)
1705
1706 if (auto *P = ES.getPlatform()) {
1707 if (auto Err = P->notifyAdding(*RT, *MU))
1708 return Err;
1709 }
1710
1711 installMaterializationUnit(std::move(MU), *RT);
1712 return Error::success();
1713 });
1714}
1715
1716template <typename MaterializationUnitType>
1717Error JITDylib::define(std::unique_ptr<MaterializationUnitType> &MU,
1718 ResourceTrackerSP RT) {
1719 assert(MU && "Can not define with a null MU");
1720
1721 if (MU->getSymbols().empty()) {
1722 // Empty MUs are allowable but pathological, so issue a warning.
1723 DEBUG_WITH_TYPE("orc", {
1724 dbgs() << "Warning: Discarding empty MU " << MU->getName() << getName()
1725 << "\n";
1726 });
1727 return Error::success();
1728 } else
1729 DEBUG_WITH_TYPE("orc", {
1730 dbgs() << "Defining MU " << MU->getName() << " for " << getName()
1731 << " (tracker: ";
1732 if (RT == getDefaultResourceTracker())
1733 dbgs() << "default)";
1734 else if (RT)
1735 dbgs() << RT.get() << ")\n";
1736 else
1737 dbgs() << "0x0, default will be used)\n";
1738 });
1739
1740 return ES.runSessionLocked([&, this]() -> Error {
1741 assert(State == Open && "JD is defunct");
1742
1743 if (auto Err = defineImpl(*MU))
1744 return Err;
1745
1746 if (!RT)
1748
1749 if (auto *P = ES.getPlatform()) {
1750 if (auto Err = P->notifyAdding(*RT, *MU))
1751 return Err;
1752 }
1753
1754 installMaterializationUnit(std::move(MU), *RT);
1755 return Error::success();
1756 });
1757}
1758
1759/// ReexportsGenerator can be used with JITDylib::addGenerator to automatically
1760/// re-export a subset of the source JITDylib's symbols in the target.
1762public:
1763 using SymbolPredicate = std::function<bool(SymbolStringPtr)>;
1764
1765 /// Create a reexports generator. If an Allow predicate is passed, only
1766 /// symbols for which the predicate returns true will be reexported. If no
1767 /// Allow predicate is passed, all symbols will be exported.
1768 ReexportsGenerator(JITDylib &SourceJD,
1769 JITDylibLookupFlags SourceJDLookupFlags,
1771
1773 JITDylibLookupFlags JDLookupFlags,
1774 const SymbolLookupSet &LookupSet) override;
1775
1776private:
1777 JITDylib &SourceJD;
1778 JITDylibLookupFlags SourceJDLookupFlags;
1779 SymbolPredicate Allow;
1780};
1781
1782// --------------- IMPLEMENTATION --------------
1783// Implementations for inline functions/methods.
1784// ---------------------------------------------
1785
1787 getExecutionSession().OL_destroyMaterializationResponsibility(*this);
1788}
1789
1791 return getExecutionSession().OL_getRequestedSymbols(*this);
1792}
1793
1795 const SymbolMap &Symbols) {
1796 return getExecutionSession().OL_notifyResolved(*this, Symbols);
1797}
1798
1800 ArrayRef<SymbolDependenceGroup> EmittedDeps) {
1801 return getExecutionSession().OL_notifyEmitted(*this, EmittedDeps);
1802}
1803
1805 SymbolFlagsMap SymbolFlags) {
1806 return getExecutionSession().OL_defineMaterializing(*this,
1807 std::move(SymbolFlags));
1808}
1809
1811 getExecutionSession().OL_notifyFailed(*this);
1812}
1813
1815 std::unique_ptr<MaterializationUnit> MU) {
1816 return getExecutionSession().OL_replace(*this, std::move(MU));
1817}
1818
1821 return getExecutionSession().OL_delegate(*this, Symbols);
1822}
1823
1824} // End namespace orc
1825} // End namespace llvm
1826
1827#endif // LLVM_EXECUTIONENGINE_ORC_CORE_H
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Function Alias Analysis false
#define LLVM_ABI
Definition Compiler.h:213
This file defines the DenseSet and SmallDenseSet classes.
This file provides a collection of function (or more generally, callable) type erasure utilities supp...
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
#define F(x, y, z)
Definition MD5.cpp:54
#define G(x, y, z)
Definition MD5.cpp:55
#define H(x, y, z)
Definition MD5.cpp:56
#define T
#define P(N)
static StringRef getName(Value *V)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Definition Debug.h:72
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
bool empty() const
Definition DenseMap.h:173
Base class for user error types.
Definition Error.h:354
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
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
Flags for symbols in the JIT.
Definition JITSymbol.h:75
Inheritance utility for extensible RTTI.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
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:47
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
A symbol query that returns results via a callback when results are ready.
Definition Core.h:578
LLVM_ABI AsynchronousSymbolQuery(const SymbolLookupSet &Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete)
Create a query for the given symbols.
Definition Core.cpp:212
bool isComplete() const
Returns true if all symbols covered by this query have been resolved.
Definition Core.h:599
friend class InProgressFullLookupState
Definition Core.h:580
LLVM_ABI void notifySymbolMetRequiredState(const SymbolStringPtr &Name, ExecutorSymbolDef Sym)
Notify the query that a requested symbol has reached the required state.
Definition Core.cpp:226
friend class JITSymbolResolverAdapter
Definition Core.h:582
friend class MaterializationResponsibility
Definition Core.h:583
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
Definition Core.h:652
virtual Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet)=0
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
friend class ExecutionSession
Definition Core.h:653
An ExecutionSession represents a running JIT program.
Definition Core.h:1131
LLVM_ABI void runJITDispatchHandler(SendResultFunction SendResult, ExecutorAddr HandlerFnTagAddr, shared::WrapperFunctionBuffer ArgBytes)
Run a registered jit-side wrapper function.
Definition Core.cpp:1919
LLVM_ABI Error endSession()
End the session.
Definition Core.cpp:1593
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition Core.h:1171
shared::WrapperFunctionBuffer callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Definition Core.h:1424
void reportError(Error Err)
Report a error for this execution session.
Definition Core.h:1282
void callWrapperAsync(ExecutorAddr WrapperFnAddr, ExecutorProcessControl::IncomingWFRHandler OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Definition Core.h:1394
friend class JITDylib
Definition Core.h:1134
friend class InProgressLookupFlagsState
Definition Core.h:1132
const StringMap< ExecutorAddr > & getBootstrapSymbolsMap() const
Returns the bootstrap symbol map.
Definition Core.h:1374
void setPlatform(std::unique_ptr< Platform > P)
Set the Platform for this ExecutionSession.
Definition Core.h:1204
const Triple & getTargetTriple() const
Return the triple for the executor.
Definition Core.h:1174
Platform * getPlatform()
Get the Platform for this session.
Definition Core.h:1208
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition Core.h:1444
LLVM_ABI void lookupFlags(LookupKind K, JITDylibSearchOrder SearchOrder, SymbolLookupSet Symbols, unique_function< void(Expected< SymbolFlagsMap >)> OnComplete)
Search the given JITDylibs to find the flags associated with each of the given symbols.
Definition Core.cpp:1759
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition Core.h:1185
LLVM_ABI JITDylib * getJITDylibByName(StringRef Name)
Return a pointer to the "name" JITDylib.
Definition Core.cpp:1638
static JITDispatchHandlerFunction wrapAsyncWithSPS(ClassT *Instance, void(ClassT::*Method)(MethodArgTs...))
Wrap a class method that takes concrete argument types (and a sender for a concrete return type) to p...
Definition Core.h:1476
friend class LookupState
Definition Core.h:1135
void callWrapperAsync(RunPolicyT &&Runner, ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor using the given Runner to dispatch OnComplete when the result ...
Definition Core.h:1403
LLVM_ABI JITDylib & createBareJITDylib(std::string Name)
Add a new bare JITDylib to this ExecutionSession.
Definition Core.cpp:1647
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H)
Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produc...
Definition Core.h:1458
void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult, const ArgTs &...Args)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition Core.h:1432
JITDylib & getBootstrapJITDylib()
Returns a reference to the bootstrap JITDylib.
Definition Core.h:1192
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Get the SymbolStringPool for this instance.
Definition Core.h:1180
Error getBootstrapMapValue(StringRef Key, std::optional< T > &Val) const
Look up and SPS-deserialize a bootstrap map value.
Definition Core.h:1369
friend class InProgressFullLookupState
Definition Core.h:1133
Error getBootstrapSymbols(ArrayRef< std::pair< ExecutorAddr &, StringRef > > Pairs) const
For each (ExecutorAddr&, StringRef) pair, looks up the string in the bootstrap symbols map and writes...
Definition Core.h:1381
const StringMap< std::vector< char > > & getBootstrapMap() const
Returns the bootstrap map.
Definition Core.h:1363
LLVM_ABI void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
Definition Core.cpp:1785
LLVM_ABI Error registerJITDispatchHandlers(JITDylib &JD, JITDispatchHandlerAssociationMap WFs)
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of...
Definition Core.cpp:1880
friend class MaterializationResponsibility
Definition Core.h:1136
LLVM_ABI void registerResourceManager(ResourceManager &RM)
Register the given ResourceManager with this ExecutionSession.
Definition Core.cpp:1621
LLVM_ABI ~ExecutionSession()
Destroy an ExecutionSession.
Definition Core.cpp:1587
void setWaitingOnGraphOpRecorder(WaitingOnGraph::OpRecorder &R)
Set a WaitingOnGraph::Recorder to capture WaitingOnGraph operations.
Definition Core.h:1198
LLVM_ABI void deregisterResourceManager(ResourceManager &RM)
Deregister the given ResourceManager with this ExecutionSession.
Definition Core.cpp:1625
LLVM_ABI ExecutionSession(std::unique_ptr< ExecutorProcessControl > EPC)
Construct an ExecutionSession with the given ExecutorProcessControl object.
Definition Core.cpp:1574
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Definition Core.h:1211
unique_function< void( SendResultFunction SendResult, const char *ArgData, size_t ArgSize)> JITDispatchHandlerFunction
An asynchronous wrapper-function callable from the executor via jit-dispatch.
Definition Core.h:1148
LLVM_ABI void dump(raw_ostream &OS)
Dump the state of all the JITDylibs in this session.
Definition Core.cpp:1940
unique_function< void(shared::WrapperFunctionBuffer)> SendResultFunction
Send a result to the remote.
Definition Core.h:1144
friend class ResourceTracker
Definition Core.h:1137
ExecutionSession & setErrorReporter(ErrorReporter ReportError)
Set the error reporter function.
Definition Core.h:1274
LLVM_ABI Error removeJITDylibs(std::vector< JITDylibSP > JDsToRemove)
Removes the given JITDylibs from the ExecutionSession.
Definition Core.cpp:1664
size_t getPageSize() const
Definition Core.h:1177
LLVM_ABI Expected< JITDylib & > createJITDylib(std::string Name)
Add a new JITDylib to this ExecutionSession.
Definition Core.cpp:1656
void dispatchTask(std::unique_ptr< Task > T)
Materialize the given unit.
Definition Core.h:1356
unique_function< void(Error)> ErrorReporter
For reporting errors.
Definition Core.h:1141
Error removeJITDylib(JITDylib &JD)
Calls removeJTIDylibs on the gives JITDylib.
Definition Core.h:1269
void callWrapperAsync(ExecutorAddr WrapperFnAddr, FnT &&OnComplete, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Definition Core.h:1412
DenseMap< SymbolStringPtr, JITDispatchHandlerFunction > JITDispatchHandlerAssociationMap
A map associating tag names with asynchronous wrapper function implementations in the JIT.
Definition Core.h:1154
Represents an address in the executor process.
A handler or incoming WrapperFunctionBuffers – either return values from callWrapper* calls,...
ExecutorProcessControl supports interaction with a JIT target process.
Represents a defining location for a JIT symbol.
FailedToMaterialize(std::shared_ptr< SymbolStringPool > SSP, std::shared_ptr< SymbolDependenceMap > Symbols)
Definition Core.cpp:93
const SymbolDependenceMap & getSymbols() const
Definition Core.h:243
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition Core.cpp:111
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition Core.cpp:115
JITDylibDefunct(JITDylibSP JD)
Definition Core.h:224
Represents a JIT'd dynamic library.
Definition Core.h:695
LLVM_ABI ~JITDylib()
Definition Core.cpp:663
LLVM_ABI Error remove(const SymbolNameSet &Names)
Tries to remove the given symbols.
Definition Core.cpp:1065
LLVM_ABI Error clear()
Calls remove on all trackers currently associated with this JITDylib.
Definition Core.cpp:667
JITDylib & operator=(JITDylib &&)=delete
LLVM_ABI void dump(raw_ostream &OS)
Dump current JITDylib state to OS.
Definition Core.cpp:1121
friend class AsynchronousSymbolQuery
Definition Core.h:696
LLVM_ABI void replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Replace OldJD with NewJD in the link order if OldJD is present.
Definition Core.cpp:1041
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:1673
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
Definition Core.h:714
LLVM_ABI void addToLinkOrder(const JITDylibSearchOrder &NewLinks)
Append the given JITDylibSearchOrder to the link order for this JITDylib (discarding any elements alr...
Definition Core.cpp:1025
LLVM_ABI ResourceTrackerSP createResourceTracker()
Create a resource tracker for this JITDylib.
Definition Core.cpp:691
auto withLinkOrderDo(Func &&F) -> decltype(F(std::declval< const JITDylibSearchOrder & >()))
Do something with the link order (run under the session lock).
Definition Core.h:1666
friend class MaterializationResponsibility
Definition Core.h:699
friend class Platform
Definition Core.h:698
LLVM_ABI void removeFromLinkOrder(JITDylib &JD)
Remove the given JITDylib from the link order for this JITDylib if it is present.
Definition Core.cpp:1053
LLVM_ABI void setLinkOrder(JITDylibSearchOrder NewSearchOrder, bool LinkAgainstThisJITDylibFirst=true)
Set the link order to be used when fixing up definitions in JITDylib.
Definition Core.cpp:1010
LLVM_ABI Expected< std::vector< JITDylibSP > > getReverseDFSLinkOrder()
Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationsh...
Definition Core.cpp:1755
friend class ExecutionSession
Definition Core.h:697
LLVM_ABI ResourceTrackerSP getDefaultResourceTracker()
Get the default resource tracker for this JITDylib.
Definition Core.cpp:682
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition Core.h:1656
JITDylib(const JITDylib &)=delete
JITDylib & operator=(const JITDylib &)=delete
JITDylib(JITDylib &&)=delete
LLVM_ABI void removeGenerator(DefinitionGenerator &G)
Remove a definition generator from this JITDylib.
Definition Core.cpp:699
LLVM_ABI Expected< std::vector< JITDylibSP > > getDFSLinkOrder()
Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships.
Definition Core.cpp:1751
Wraps state for a lookup-in-progress.
Definition Core.h:627
LLVM_ABI void continueLookup(Error Err)
Continue the lookup.
Definition Core.cpp:643
LLVM_ABI LookupState & operator=(LookupState &&)
friend class ExecutionSession
Definition Core.h:629
friend class OrcV2CAPIHelper
Definition Core.h:628
LLVM_ABI LookupState(LookupState &&)
LookupTask(LookupState LS)
Definition Core.h:1122
static char ID
Definition Core.h:1120
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition Core.h:369
MaterializationResponsibility & operator=(MaterializationResponsibility &&)=delete
ExecutionSession & getExecutionSession() const
Returns the ExecutionSession for this instance.
Definition Core.h:1651
Error notifyResolved(const SymbolMap &Symbols)
Notifies the target JITDylib that the given symbols have been resolved.
Definition Core.h:1794
~MaterializationResponsibility()
Destruct a MaterializationResponsibility instance.
Definition Core.h:1786
Error replace(std::unique_ptr< MaterializationUnit > MU)
Transfers responsibility to the given MaterializationUnit for all symbols defined by that Materializa...
Definition Core.h:1814
Error withResourceKeyDo(Func &&F) const
Runs the given callback under the session lock, passing in the associated ResourceKey.
Definition Core.h:388
Error defineMaterializing(SymbolFlagsMap SymbolFlags)
Attempt to claim responsibility for new definitions.
Definition Core.h:1804
SymbolNameSet getRequestedSymbols() const
Returns the names of any symbols covered by this MaterializationResponsibility object that have queri...
Definition Core.h:1790
Expected< std::unique_ptr< MaterializationResponsibility > > delegate(const SymbolNameSet &Symbols)
Delegates responsibility for the given symbols to the returned materialization responsibility.
Definition Core.h:1820
const ResourceTrackerSP & getResourceTracker() const
Return the ResourceTracker associated with this instance.
Definition Core.h:384
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
Definition Core.h:408
MaterializationResponsibility(MaterializationResponsibility &&)=delete
Error notifyEmitted(ArrayRef< SymbolDependenceGroup > DepGroups)
Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by t...
Definition Core.h:1799
void failMaterialization()
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has o...
Definition Core.h:1810
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition Core.h:394
const SymbolFlagsMap & getSymbols() const
Returns the symbol flags map for this responsibility instance.
Definition Core.h:403
A materialization task.
Definition Core.h:1099
MaterializationTask(std::unique_ptr< MaterializationUnit > MU, std::unique_ptr< MaterializationResponsibility > MR)
Definition Core.h:1103
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
const SymbolNameVector & getSymbols() const
Definition Core.h:324
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition Core.h:322
MissingSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
Definition Core.h:316
const std::string & getModuleName() const
Definition Core.h:323
Platforms set up standard symbols and mediate interactions between dynamic initializers (e....
Definition Core.h:1058
virtual Error teardownJITDylib(JITDylib &JD)=0
This method will be called outside the session lock each time a JITDylib is removed to allow the Plat...
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:1510
virtual Error notifyRemoving(ResourceTracker &RT)=0
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
static Expected< DenseMap< JITDylib *, SymbolMap > > lookupInitSymbols(ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
A utility function for looking up initializer symbols.
Definition Core.cpp:1461
virtual Error notifyAdding(ResourceTracker &RT, const MaterializationUnit &MU)=0
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added t...
virtual Error setupJITDylib(JITDylib &JD)=0
This method will be called outside the session lock each time a JITDylib is created (unless it is cre...
ReExportsMaterializationUnit(JITDylib *SourceJD, JITDylibLookupFlags SourceJDLookupFlags, SymbolAliasMap Aliases)
SourceJD is allowed to be nullptr, in which case the source JITDylib is taken to be whatever JITDylib...
Definition Core.cpp:311
std::function< bool(SymbolStringPtr)> SymbolPredicate
Definition Core.h:1763
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
Definition Core.cpp:608
ReexportsGenerator(JITDylib &SourceJD, JITDylibLookupFlags SourceJDLookupFlags, SymbolPredicate Allow=SymbolPredicate())
Create a reexports generator.
Definition Core.cpp:602
Listens for ResourceTracker operations.
Definition Core.h:131
virtual Error handleRemoveResources(JITDylib &JD, ResourceKey K)=0
This function will be called outside the session lock.
virtual void handleTransferResources(JITDylib &JD, ResourceKey DstK, ResourceKey SrcK)=0
This function will be called inside the session lock.
ResourceTrackerDefunct(ResourceTrackerSP RT)
Definition Core.cpp:73
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition Core.cpp:80
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition Core.cpp:76
API to remove / transfer ownership of JIT resources.
Definition Core.h:83
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
Definition Core.h:98
friend class JITDylib
Definition Core.h:86
ResourceTracker & operator=(const ResourceTracker &)=delete
ResourceKey getKeyUnsafe() const
Returns the key associated with this tracker.
Definition Core.h:120
LLVM_ABI void transferTo(ResourceTracker &DstRT)
Transfer all resources associated with this key to the given tracker, which must target the same JITD...
Definition Core.cpp:61
ResourceTracker & operator=(ResourceTracker &&)=delete
LLVM_ABI ~ResourceTracker()
Definition Core.cpp:52
ResourceTracker(const ResourceTracker &)=delete
friend class MaterializationResponsibility
Definition Core.h:87
bool isDefunct() const
Return true if this tracker has become defunct.
Definition Core.h:115
ResourceTracker(ResourceTracker &&)=delete
Error withResourceKeyDo(Func &&F)
Runs the given callback under the session lock, passing in the associated ResourceKey.
Definition Core.h:1641
friend class ExecutionSession
Definition Core.h:85
LLVM_ABI Error remove()
Remove all resources associated with this key.
Definition Core.cpp:57
Expected< ExecutorSymbolDef > lookup() const
Definition Core.h:1637
SymbolInstance(JITDylibSP JD, SymbolStringPtr Name)
Definition Core.h:66
LLVM_ABI void lookupAsync(LookupAsyncOnCompleteFn OnComplete) const
Definition Core.cpp:191
unique_function< void(Expected< ExecutorSymbolDef >)> LookupAsyncOnCompleteFn
Definition Core.h:63
const JITDylib & getJITDylib() const
Definition Core.h:69
const SymbolStringPtr & getName() const
Definition Core.h:70
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Pointer to a pooled string representing a symbol name.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition Core.cpp:165
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition Core.cpp:169
const SymbolNameSet & getSymbols() const
Definition Core.h:300
SymbolsCouldNotBeRemoved(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
Definition Core.cpp:159
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition Core.h:299
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition Core.cpp:155
SymbolsNotFound(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
Definition Core.cpp:138
const SymbolNameVector & getSymbols() const
Definition Core.h:282
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition Core.cpp:151
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition Core.h:281
UnexpectedSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
Definition Core.h:340
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition Core.h:346
const std::string & getModuleName() const
Definition Core.h:347
const SymbolNameVector & getSymbols() const
Definition Core.h:348
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition Core.cpp:131
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition Core.cpp:127
UnsatisfiedSymbolDependencies(std::shared_ptr< SymbolStringPool > SSP, JITDylibSP JD, SymbolNameSet FailedSymbols, SymbolDependenceMap BadDeps, std::string Explanation)
Definition Core.cpp:119
WaitingOnGraph class template.
C++ wrapper function buffer: Same as CWrapperFunctionBuffer but auto-releases memory.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
unique_function is a type-erasing functor similar to std::function.
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:173
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:168
IntrusiveRefCntPtr< JITDylib > JITDylibSP
Definition Core.h:58
IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
Definition Core.h:57
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition Core.h:543
std::function< void(const SymbolDependenceMap &)> RegisterDependenciesFunction
Callback to register the dependencies for a given query.
Definition Core.h:199
uintptr_t ResourceKey
Definition Core.h:80
std::unique_ptr< ReExportsMaterializationUnit > reexports(JITDylib &SourceJD, SymbolAliasMap Aliases, JITDylibLookupFlags SourceJDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Create a materialization unit for re-exporting symbols from another JITDylib with alternative names/f...
Definition Core.h:552
LLVM_ABI Expected< SymbolAliasMap > buildSimpleReexportsAliasMap(JITDylib &SourceJD, const SymbolNameSet &Symbols)
Build a SymbolAliasMap for the common case where you want to re-export symbols from another JITDylib ...
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition Core.h:152
detail::WaitingOnGraph< JITDylib *, NonOwningSymbolStringPtr > WaitingOnGraph
Definition Core.h:54
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
static std::unique_ptr< UnwindInfoManager > Instance
LookupKind
Describes the kind of lookup being performed.
Definition Core.h:164
LLVM_ABI RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition Core.cpp:40
std::vector< SymbolStringPtr > SymbolNameVector
A vector of symbol names.
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
SymbolState
Represents the state that a symbol has reached during materialization.
Definition Core.h:565
@ Materializing
Added to the symbol table, never queried.
Definition Core.h:568
@ NeverSearched
No symbol should be in this state.
Definition Core.h:567
@ Ready
Emitted to memory, but waiting on transitive dependencies.
Definition Core.h:571
@ Emitted
Assigned address, still materializing.
Definition Core.h:570
@ Resolved
Queried, materialization begun.
Definition Core.h:569
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
Definition Core.h:193
unique_function< void(Expected< SymbolMap >)> SymbolsResolvedCallback
Callback to notify client that symbols have been resolved.
Definition Core.h:196
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 void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
Definition Error.cpp:61
testing::Matcher< const detail::ErrorHolder & > Failed()
Definition Error.h:198
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
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
ArrayRef(const T &OneElt) -> ArrayRef< T >
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:1916
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:861
JITSymbolFlags AliasFlags
Definition Core.h:189
SymbolAliasMapEntry(SymbolStringPtr Aliasee, JITSymbolFlags AliasFlags)
Definition Core.h:185
SymbolStringPtr Aliasee
Definition Core.h:188
A set of symbols and the their dependencies.
Definition Core.h:357
SymbolDependenceMap Dependencies
Definition Core.h:359