LLVM  14.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 
16 #include "llvm/ADT/BitmaskEnum.h"
17 #include "llvm/ADT/DenseSet.h"
25 #include "llvm/Support/Debug.h"
27 
28 #include <atomic>
29 #include <future>
30 #include <memory>
31 #include <vector>
32 
33 namespace llvm {
34 namespace orc {
35 
36 // Forward declare some classes.
37 class AsynchronousSymbolQuery;
38 class ExecutionSession;
39 class MaterializationUnit;
40 class MaterializationResponsibility;
41 class JITDylib;
42 class ResourceTracker;
43 class InProgressLookupState;
44 
45 enum class SymbolState : uint8_t;
46 
47 using ResourceTrackerSP = IntrusiveRefCntPtr<ResourceTracker>;
48 using JITDylibSP = IntrusiveRefCntPtr<JITDylib>;
49 
50 using ResourceKey = uintptr_t;
51 
52 /// API to remove / transfer ownership of JIT resources.
53 class ResourceTracker : public ThreadSafeRefCountedBase<ResourceTracker> {
54 private:
55  friend class ExecutionSession;
56  friend class JITDylib;
58 
59 public:
60  ResourceTracker(const ResourceTracker &) = delete;
61  ResourceTracker &operator=(const ResourceTracker &) = delete;
62  ResourceTracker(ResourceTracker &&) = delete;
63  ResourceTracker &operator=(ResourceTracker &&) = delete;
64 
65  ~ResourceTracker();
66 
67  /// Return the JITDylib targeted by this tracker.
68  JITDylib &getJITDylib() const {
69  return *reinterpret_cast<JITDylib *>(JDAndFlag.load() &
70  ~static_cast<uintptr_t>(1));
71  }
72 
73  /// Remove all resources associated with this key.
74  Error remove();
75 
76  /// Transfer all resources associated with this key to the given
77  /// tracker, which must target the same JITDylib as this one.
78  void transferTo(ResourceTracker &DstRT);
79 
80  /// Return true if this tracker has become defunct.
81  bool isDefunct() const { return JDAndFlag.load() & 0x1; }
82 
83  /// Returns the key associated with this tracker.
84  /// This method should not be used except for debug logging: there is no
85  /// guarantee that the returned value will remain valid.
86  ResourceKey getKeyUnsafe() const { return reinterpret_cast<uintptr_t>(this); }
87 
88 private:
90 
91  void makeDefunct();
92 
93  std::atomic_uintptr_t JDAndFlag;
94 };
95 
96 /// Listens for ResourceTracker operations.
98 public:
99  virtual ~ResourceManager();
100  virtual Error handleRemoveResources(ResourceKey K) = 0;
101  virtual void handleTransferResources(ResourceKey DstK, ResourceKey SrcK) = 0;
102 };
103 
104 /// A set of symbol names (represented by SymbolStringPtrs for
105 // efficiency).
107 
108 /// A vector of symbol names.
109 using SymbolNameVector = std::vector<SymbolStringPtr>;
110 
111 /// A map from symbol names (as SymbolStringPtrs) to JITSymbols
112 /// (address/flags pairs).
114 
115 /// A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
117 
118 /// A map from JITDylibs to sets of symbols.
120 
121 /// Lookup flags that apply to each dylib in the search order for a lookup.
122 ///
123 /// If MatchHiddenSymbolsOnly is used (the default) for a given dylib, then
124 /// only symbols in that Dylib's interface will be searched. If
125 /// MatchHiddenSymbols is used then symbols with hidden visibility will match
126 /// as well.
128 
129 /// Lookup flags that apply to each symbol in a lookup.
130 ///
131 /// If RequiredSymbol is used (the default) for a given symbol then that symbol
132 /// must be found during the lookup or the lookup will fail returning a
133 /// SymbolNotFound error. If WeaklyReferencedSymbol is used and the given
134 /// symbol is not found then the query will continue, and no result for the
135 /// missing symbol will be present in the result (assuming the rest of the
136 /// lookup succeeds).
138 
139 /// Describes the kind of lookup being performed. The lookup kind is passed to
140 /// symbol generators (if they're invoked) to help them determine what
141 /// definitions to generate.
142 ///
143 /// Static -- Lookup is being performed as-if at static link time (e.g.
144 /// generators representing static archives should pull in new
145 /// definitions).
146 ///
147 /// DLSym -- Lookup is being performed as-if at runtime (e.g. generators
148 /// representing static archives should not pull in new definitions).
149 enum class LookupKind { Static, DLSym };
150 
151 /// A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search
152 /// order during symbol lookup.
153 using JITDylibSearchOrder =
154  std::vector<std::pair<JITDylib *, JITDylibLookupFlags>>;
155 
156 /// Convenience function for creating a search order from an ArrayRef of
157 /// JITDylib*, all with the same flags.
162  O.reserve(JDs.size());
163  for (auto *JD : JDs)
164  O.push_back(std::make_pair(JD, Flags));
165  return O;
166 }
167 
168 /// A set of symbols to look up, each associated with a SymbolLookupFlags
169 /// value.
170 ///
171 /// This class is backed by a vector and optimized for fast insertion,
172 /// deletion and iteration. It does not guarantee a stable order between
173 /// operations, and will not automatically detect duplicate elements (they
174 /// can be manually checked by calling the validate method).
176 public:
177  using value_type = std::pair<SymbolStringPtr, SymbolLookupFlags>;
178  using UnderlyingVector = std::vector<value_type>;
179  using iterator = UnderlyingVector::iterator;
180  using const_iterator = UnderlyingVector::const_iterator;
181 
182  SymbolLookupSet() = default;
183 
184  explicit SymbolLookupSet(
187  add(std::move(Name), Flags);
188  }
189 
190  /// Construct a SymbolLookupSet from an initializer list of SymbolStringPtrs.
191  explicit SymbolLookupSet(
192  std::initializer_list<SymbolStringPtr> Names,
194  Symbols.reserve(Names.size());
195  for (auto &Name : Names)
196  add(std::move(Name), Flags);
197  }
198 
199  /// Construct a SymbolLookupSet from a SymbolNameSet with the given
200  /// Flags used for each value.
201  explicit SymbolLookupSet(
202  const SymbolNameSet &Names,
204  Symbols.reserve(Names.size());
205  for (const auto &Name : Names)
206  add(Name, Flags);
207  }
208 
209  /// Construct a SymbolLookupSet from a vector of symbols with the given Flags
210  /// used for each value.
211  /// If the ArrayRef contains duplicates it is up to the client to remove these
212  /// before using this instance for lookup.
213  explicit SymbolLookupSet(
216  Symbols.reserve(Names.size());
217  for (const auto &Name : Names)
218  add(Name, Flags);
219  }
220 
221  /// Construct a SymbolLookupSet from DenseMap keys.
222  template <typename KeyT>
223  static SymbolLookupSet
226  SymbolLookupSet Result;
227  Result.Symbols.reserve(M.size());
228  for (const auto &KV : M)
229  Result.add(KV.first, Flags);
230  return Result;
231  }
232 
233  /// Add an element to the set. The client is responsible for checking that
234  /// duplicates are not added.
238  Symbols.push_back(std::make_pair(std::move(Name), Flags));
239  return *this;
240  }
241 
242  /// Quickly append one lookup set to another.
244  Symbols.reserve(Symbols.size() + Other.size());
245  for (auto &KV : Other)
246  Symbols.push_back(std::move(KV));
247  return *this;
248  }
249 
250  bool empty() const { return Symbols.empty(); }
251  UnderlyingVector::size_type size() const { return Symbols.size(); }
252  iterator begin() { return Symbols.begin(); }
253  iterator end() { return Symbols.end(); }
254  const_iterator begin() const { return Symbols.begin(); }
255  const_iterator end() const { return Symbols.end(); }
256 
257  /// Removes the Ith element of the vector, replacing it with the last element.
258  void remove(UnderlyingVector::size_type I) {
259  std::swap(Symbols[I], Symbols.back());
260  Symbols.pop_back();
261  }
262 
263  /// Removes the element pointed to by the given iterator. This iterator and
264  /// all subsequent ones (including end()) are invalidated.
265  void remove(iterator I) { remove(I - begin()); }
266 
267  /// Removes all elements matching the given predicate, which must be callable
268  /// as bool(const SymbolStringPtr &, SymbolLookupFlags Flags).
269  template <typename PredFn> void remove_if(PredFn &&Pred) {
270  UnderlyingVector::size_type I = 0;
271  while (I != Symbols.size()) {
272  const auto &Name = Symbols[I].first;
273  auto Flags = Symbols[I].second;
274  if (Pred(Name, Flags))
275  remove(I);
276  else
277  ++I;
278  }
279  }
280 
281  /// Loop over the elements of this SymbolLookupSet, applying the Body function
282  /// to each one. Body must be callable as
283  /// bool(const SymbolStringPtr &, SymbolLookupFlags).
284  /// If Body returns true then the element just passed in is removed from the
285  /// set. If Body returns false then the element is retained.
286  template <typename BodyFn>
287  auto forEachWithRemoval(BodyFn &&Body) -> std::enable_if_t<
288  std::is_same<decltype(Body(std::declval<const SymbolStringPtr &>(),
289  std::declval<SymbolLookupFlags>())),
290  bool>::value> {
291  UnderlyingVector::size_type I = 0;
292  while (I != Symbols.size()) {
293  const auto &Name = Symbols[I].first;
294  auto Flags = Symbols[I].second;
295  if (Body(Name, Flags))
296  remove(I);
297  else
298  ++I;
299  }
300  }
301 
302  /// Loop over the elements of this SymbolLookupSet, applying the Body function
303  /// to each one. Body must be callable as
304  /// Expected<bool>(const SymbolStringPtr &, SymbolLookupFlags).
305  /// If Body returns a failure value, the loop exits immediately. If Body
306  /// returns true then the element just passed in is removed from the set. If
307  /// Body returns false then the element is retained.
308  template <typename BodyFn>
309  auto forEachWithRemoval(BodyFn &&Body) -> std::enable_if_t<
310  std::is_same<decltype(Body(std::declval<const SymbolStringPtr &>(),
311  std::declval<SymbolLookupFlags>())),
312  Expected<bool>>::value,
313  Error> {
314  UnderlyingVector::size_type I = 0;
315  while (I != Symbols.size()) {
316  const auto &Name = Symbols[I].first;
317  auto Flags = Symbols[I].second;
318  auto Remove = Body(Name, Flags);
319  if (!Remove)
320  return Remove.takeError();
321  if (*Remove)
322  remove(I);
323  else
324  ++I;
325  }
326  return Error::success();
327  }
328 
329  /// Construct a SymbolNameVector from this instance by dropping the Flags
330  /// values.
332  SymbolNameVector Names;
333  Names.reserve(Symbols.size());
334  for (auto &KV : Symbols)
335  Names.push_back(KV.first);
336  return Names;
337  }
338 
339  /// Sort the lookup set by pointer value. This sort is fast but sensitive to
340  /// allocation order and so should not be used where a consistent order is
341  /// required.
342  void sortByAddress() {
343  llvm::sort(Symbols, [](const value_type &LHS, const value_type &RHS) {
344  return LHS.first < RHS.first;
345  });
346  }
347 
348  /// Sort the lookup set lexicographically. This sort is slow but the order
349  /// is unaffected by allocation order.
350  void sortByName() {
351  llvm::sort(Symbols, [](const value_type &LHS, const value_type &RHS) {
352  return *LHS.first < *RHS.first;
353  });
354  }
355 
356  /// Remove any duplicate elements. If a SymbolLookupSet is not duplicate-free
357  /// by construction, this method can be used to turn it into a proper set.
359  sortByAddress();
360  auto LastI = std::unique(Symbols.begin(), Symbols.end());
361  Symbols.erase(LastI, Symbols.end());
362  }
363 
364 #ifndef NDEBUG
365  /// Returns true if this set contains any duplicates. This should only be used
366  /// in assertions.
368  if (Symbols.size() < 2)
369  return false;
370  sortByAddress();
371  for (UnderlyingVector::size_type I = 1; I != Symbols.size(); ++I)
372  if (Symbols[I].first == Symbols[I - 1].first)
373  return true;
374  return false;
375  }
376 #endif
377 
378 private:
379  UnderlyingVector Symbols;
380 };
381 
383  SymbolAliasMapEntry() = default;
386 
389 };
390 
391 /// A map of Symbols to (Symbol, Flags) pairs.
393 
394 /// Callback to notify client that symbols have been resolved.
396 
397 /// Callback to register the dependencies for a given query.
400 
401 /// This can be used as the value for a RegisterDependenciesFunction if there
402 /// are no dependants to register with.
404 
405 class ResourceTrackerDefunct : public ErrorInfo<ResourceTrackerDefunct> {
406 public:
407  static char ID;
408 
410  std::error_code convertToErrorCode() const override;
411  void log(raw_ostream &OS) const override;
412 
413 private:
415 };
416 
417 /// Used to notify a JITDylib that the given set of symbols failed to
418 /// materialize.
419 class FailedToMaterialize : public ErrorInfo<FailedToMaterialize> {
420 public:
421  static char ID;
422 
423  FailedToMaterialize(std::shared_ptr<SymbolDependenceMap> Symbols);
424  std::error_code convertToErrorCode() const override;
425  void log(raw_ostream &OS) const override;
426  const SymbolDependenceMap &getSymbols() const { return *Symbols; }
427 
428 private:
429  std::shared_ptr<SymbolDependenceMap> Symbols;
430 };
431 
432 /// Used to notify clients when symbols can not be found during a lookup.
433 class SymbolsNotFound : public ErrorInfo<SymbolsNotFound> {
434 public:
435  static char ID;
436 
437  SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP, SymbolNameSet Symbols);
438  SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP,
439  SymbolNameVector Symbols);
440  std::error_code convertToErrorCode() const override;
441  void log(raw_ostream &OS) const override;
442  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
443  const SymbolNameVector &getSymbols() const { return Symbols; }
444 
445 private:
446  std::shared_ptr<SymbolStringPool> SSP;
447  SymbolNameVector Symbols;
448 };
449 
450 /// Used to notify clients that a set of symbols could not be removed.
451 class SymbolsCouldNotBeRemoved : public ErrorInfo<SymbolsCouldNotBeRemoved> {
452 public:
453  static char ID;
454 
455  SymbolsCouldNotBeRemoved(std::shared_ptr<SymbolStringPool> SSP,
456  SymbolNameSet Symbols);
457  std::error_code convertToErrorCode() const override;
458  void log(raw_ostream &OS) const override;
459  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
460  const SymbolNameSet &getSymbols() const { return Symbols; }
461 
462 private:
463  std::shared_ptr<SymbolStringPool> SSP;
464  SymbolNameSet Symbols;
465 };
466 
467 /// Errors of this type should be returned if a module fails to include
468 /// definitions that are claimed by the module's associated
469 /// MaterializationResponsibility. If this error is returned it is indicative of
470 /// a broken transformation / compiler / object cache.
471 class MissingSymbolDefinitions : public ErrorInfo<MissingSymbolDefinitions> {
472 public:
473  static char ID;
474 
475  MissingSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
476  std::string ModuleName, SymbolNameVector Symbols)
477  : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
478  Symbols(std::move(Symbols)) {}
479  std::error_code convertToErrorCode() const override;
480  void log(raw_ostream &OS) const override;
481  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
482  const std::string &getModuleName() const { return ModuleName; }
483  const SymbolNameVector &getSymbols() const { return Symbols; }
484 private:
485  std::shared_ptr<SymbolStringPool> SSP;
486  std::string ModuleName;
487  SymbolNameVector Symbols;
488 };
489 
490 /// Errors of this type should be returned if a module contains definitions for
491 /// symbols that are not claimed by the module's associated
492 /// MaterializationResponsibility. If this error is returned it is indicative of
493 /// a broken transformation / compiler / object cache.
494 class UnexpectedSymbolDefinitions : public ErrorInfo<UnexpectedSymbolDefinitions> {
495 public:
496  static char ID;
497 
498  UnexpectedSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
499  std::string ModuleName, SymbolNameVector Symbols)
500  : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
501  Symbols(std::move(Symbols)) {}
502  std::error_code convertToErrorCode() const override;
503  void log(raw_ostream &OS) const override;
504  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
505  const std::string &getModuleName() const { return ModuleName; }
506  const SymbolNameVector &getSymbols() const { return Symbols; }
507 private:
508  std::shared_ptr<SymbolStringPool> SSP;
509  std::string ModuleName;
510  SymbolNameVector Symbols;
511 };
512 
513 /// Tracks responsibility for materialization, and mediates interactions between
514 /// MaterializationUnits and JDs.
515 ///
516 /// An instance of this class is passed to MaterializationUnits when their
517 /// materialize method is called. It allows MaterializationUnits to resolve and
518 /// emit symbols, or abandon materialization by notifying any unmaterialized
519 /// symbols of an error.
521  friend class ExecutionSession;
522  friend class JITDylib;
523 
524 public:
528 
529  /// Destruct a MaterializationResponsibility instance. In debug mode
530  /// this asserts that all symbols being tracked have been either
531  /// emitted or notified of an error.
533 
534  /// Returns the ResourceTracker for this instance.
535  template <typename Func> Error withResourceKeyDo(Func &&F) const;
536 
537  /// Returns the target JITDylib that these symbols are being materialized
538  /// into.
539  JITDylib &getTargetJITDylib() const { return JD; }
540 
541  /// Returns the ExecutionSession for this instance.
543 
544  /// Returns the symbol flags map for this responsibility instance.
545  /// Note: The returned flags may have transient flags (Lazy, Materializing)
546  /// set. These should be stripped with JITSymbolFlags::stripTransientFlags
547  /// before using.
548  const SymbolFlagsMap &getSymbols() const { return SymbolFlags; }
549 
550  /// Returns the initialization pseudo-symbol, if any. This symbol will also
551  /// be present in the SymbolFlagsMap for this MaterializationResponsibility
552  /// object.
553  const SymbolStringPtr &getInitializerSymbol() const { return InitSymbol; }
554 
555  /// Returns the names of any symbols covered by this
556  /// MaterializationResponsibility object that have queries pending. This
557  /// information can be used to return responsibility for unrequested symbols
558  /// back to the JITDylib via the delegate method.
560 
561  /// Notifies the target JITDylib that the given symbols have been resolved.
562  /// This will update the given symbols' addresses in the JITDylib, and notify
563  /// any pending queries on the given symbols of their resolution. The given
564  /// symbols must be ones covered by this MaterializationResponsibility
565  /// instance. Individual calls to this method may resolve a subset of the
566  /// symbols, but all symbols must have been resolved prior to calling emit.
567  ///
568  /// This method will return an error if any symbols being resolved have been
569  /// moved to the error state due to the failure of a dependency. If this
570  /// method returns an error then clients should log it and call
571  /// failMaterialize. If no dependencies have been registered for the
572  /// symbols covered by this MaterializationResponsibiility then this method
573  /// is guaranteed to return Error::success() and can be wrapped with cantFail.
574  Error notifyResolved(const SymbolMap &Symbols);
575 
576  /// Notifies the target JITDylib (and any pending queries on that JITDylib)
577  /// that all symbols covered by this MaterializationResponsibility instance
578  /// have been emitted.
579  ///
580  /// This method will return an error if any symbols being resolved have been
581  /// moved to the error state due to the failure of a dependency. If this
582  /// method returns an error then clients should log it and call
583  /// failMaterialize. If no dependencies have been registered for the
584  /// symbols covered by this MaterializationResponsibiility then this method
585  /// is guaranteed to return Error::success() and can be wrapped with cantFail.
587 
588  /// Attempt to claim responsibility for new definitions. This method can be
589  /// used to claim responsibility for symbols that are added to a
590  /// materialization unit during the compilation process (e.g. literal pool
591  /// symbols). Symbol linkage rules are the same as for symbols that are
592  /// defined up front: duplicate strong definitions will result in errors.
593  /// Duplicate weak definitions will be discarded (in which case they will
594  /// not be added to this responsibility instance).
595  ///
596  /// This method can be used by materialization units that want to add
597  /// additional symbols at materialization time (e.g. stubs, compile
598  /// callbacks, metadata).
600 
601  /// Define the given symbols as non-existent, removing it from the symbol
602  /// table and notifying any pending queries. Queries that lookup up the
603  /// symbol using the SymbolLookupFlags::WeaklyReferencedSymbol flag will
604  /// behave as if the symbol had not been matched in the first place. Queries
605  /// that required this symbol will fail with a missing symbol definition
606  /// error.
607  ///
608  /// This method is intended to support cleanup of special symbols like
609  /// initializer symbols: Queries using
610  /// SymbolLookupFlags::WeaklyReferencedSymbol can be used to trigger their
611  /// emission, and this method can be used to remove them from the JITDylib
612  /// once materialization is complete.
614 
615  /// Notify all not-yet-emitted covered by this MaterializationResponsibility
616  /// instance that an error has occurred.
617  /// This will remove all symbols covered by this MaterializationResponsibilty
618  /// from the target JITDylib, and send an error to any queries waiting on
619  /// these symbols.
620  void failMaterialization();
621 
622  /// Transfers responsibility to the given MaterializationUnit for all
623  /// symbols defined by that MaterializationUnit. This allows
624  /// materializers to break up work based on run-time information (e.g.
625  /// by introspecting which symbols have actually been looked up and
626  /// materializing only those).
627  Error replace(std::unique_ptr<MaterializationUnit> MU);
628 
629  /// Delegates responsibility for the given symbols to the returned
630  /// materialization responsibility. Useful for breaking up work between
631  /// threads, or different kinds of materialization processes.
633  delegate(const SymbolNameSet &Symbols);
634 
636  const SymbolDependenceMap &Dependencies);
637 
638  /// Add dependencies that apply to all symbols covered by this instance.
639  void addDependenciesForAll(const SymbolDependenceMap &Dependencies);
640 
641 private:
642  /// Create a MaterializationResponsibility for the given JITDylib and
643  /// initial symbols.
646  SymbolStringPtr InitSymbol)
647  : JD(RT->getJITDylib()), RT(std::move(RT)),
648  SymbolFlags(std::move(SymbolFlags)), InitSymbol(std::move(InitSymbol)) {
649  assert(!this->SymbolFlags.empty() && "Materializing nothing?");
650  }
651 
652  JITDylib &JD;
655  SymbolStringPtr InitSymbol;
656 };
657 
658 /// A MaterializationUnit represents a set of symbol definitions that can
659 /// be materialized as a group, or individually discarded (when
660 /// overriding definitions are encountered).
661 ///
662 /// MaterializationUnits are used when providing lazy definitions of symbols to
663 /// JITDylibs. The JITDylib will call materialize when the address of a symbol
664 /// is requested via the lookup method. The JITDylib will call discard if a
665 /// stronger definition is added or already present.
667  friend class ExecutionSession;
668  friend class JITDylib;
669 
670 public:
671  static char ID;
672 
673  struct Interface {
674  Interface() = default;
676  : SymbolFlags(std::move(InitalSymbolFlags)),
678  assert((!this->InitSymbol || this->SymbolFlags.count(this->InitSymbol)) &&
679  "If set, InitSymbol should appear in InitialSymbolFlags map");
680  }
681 
684  };
685 
689  virtual ~MaterializationUnit() {}
690 
691  /// Return the name of this materialization unit. Useful for debugging
692  /// output.
693  virtual StringRef getName() const = 0;
694 
695  /// Return the set of symbols that this source provides.
696  const SymbolFlagsMap &getSymbols() const { return SymbolFlags; }
697 
698  /// Returns the initialization symbol for this MaterializationUnit (if any).
700 
701  /// Implementations of this method should materialize all symbols
702  /// in the materialzation unit, except for those that have been
703  /// previously discarded.
704  virtual void
705  materialize(std::unique_ptr<MaterializationResponsibility> R) = 0;
706 
707  /// Called by JITDylibs to notify MaterializationUnits that the given symbol
708  /// has been overridden.
709  void doDiscard(const JITDylib &JD, const SymbolStringPtr &Name) {
711  discard(JD, std::move(Name));
712  }
713 
714 protected:
717 
718 private:
719  virtual void anchor();
720 
721  /// Implementations of this method should discard the given symbol
722  /// from the source (e.g. if the source is an LLVM IR Module and the
723  /// symbol is a function, delete the function body or mark it available
724  /// externally).
725  virtual void discard(const JITDylib &JD, const SymbolStringPtr &Name) = 0;
726 };
727 
728 /// A MaterializationUnit implementation for pre-existing absolute symbols.
729 ///
730 /// All symbols will be resolved and marked ready as soon as the unit is
731 /// materialized.
733 public:
735 
736  StringRef getName() const override;
737 
738 private:
739  void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
740  void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
741  static MaterializationUnit::Interface extractFlags(const SymbolMap &Symbols);
742 
743  SymbolMap Symbols;
744 };
745 
746 /// Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
747 /// Useful for inserting absolute symbols into a JITDylib. E.g.:
748 /// \code{.cpp}
749 /// JITDylib &JD = ...;
750 /// SymbolStringPtr Foo = ...;
751 /// JITEvaluatedSymbol FooSym = ...;
752 /// if (auto Err = JD.define(absoluteSymbols({{Foo, FooSym}})))
753 /// return Err;
754 /// \endcode
755 ///
756 inline std::unique_ptr<AbsoluteSymbolsMaterializationUnit>
758  return std::make_unique<AbsoluteSymbolsMaterializationUnit>(
759  std::move(Symbols));
760 }
761 
762 /// A materialization unit for symbol aliases. Allows existing symbols to be
763 /// aliased with alternate flags.
765 public:
766  /// SourceJD is allowed to be nullptr, in which case the source JITDylib is
767  /// taken to be whatever JITDylib these definitions are materialized in (and
768  /// MatchNonExported has no effect). This is useful for defining aliases
769  /// within a JITDylib.
770  ///
771  /// Note: Care must be taken that no sets of aliases form a cycle, as such
772  /// a cycle will result in a deadlock when any symbol in the cycle is
773  /// resolved.
775  JITDylibLookupFlags SourceJDLookupFlags,
776  SymbolAliasMap Aliases);
777 
778  StringRef getName() const override;
779 
780 private:
781  void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
782  void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
784  extractFlags(const SymbolAliasMap &Aliases);
785 
786  JITDylib *SourceJD = nullptr;
787  JITDylibLookupFlags SourceJDLookupFlags;
788  SymbolAliasMap Aliases;
789 };
790 
791 /// Create a ReExportsMaterializationUnit with the given aliases.
792 /// Useful for defining symbol aliases.: E.g., given a JITDylib JD containing
793 /// symbols "foo" and "bar", we can define aliases "baz" (for "foo") and "qux"
794 /// (for "bar") with: \code{.cpp}
795 /// SymbolStringPtr Baz = ...;
796 /// SymbolStringPtr Qux = ...;
797 /// if (auto Err = JD.define(symbolAliases({
798 /// {Baz, { Foo, JITSymbolFlags::Exported }},
799 /// {Qux, { Bar, JITSymbolFlags::Weak }}}))
800 /// return Err;
801 /// \endcode
802 inline std::unique_ptr<ReExportsMaterializationUnit>
804  return std::make_unique<ReExportsMaterializationUnit>(
806 }
807 
808 /// Create a materialization unit for re-exporting symbols from another JITDylib
809 /// with alternative names/flags.
810 /// SourceJD will be searched using the given JITDylibLookupFlags.
811 inline std::unique_ptr<ReExportsMaterializationUnit>
812 reexports(JITDylib &SourceJD, SymbolAliasMap Aliases,
813  JITDylibLookupFlags SourceJDLookupFlags =
815  return std::make_unique<ReExportsMaterializationUnit>(
816  &SourceJD, SourceJDLookupFlags, std::move(Aliases));
817 }
818 
819 /// Build a SymbolAliasMap for the common case where you want to re-export
820 /// symbols from another JITDylib with the same linkage/flags.
822 buildSimpleReexportsAliasMap(JITDylib &SourceJD, const SymbolNameSet &Symbols);
823 
824 /// Represents the state that a symbol has reached during materialization.
825 enum class SymbolState : uint8_t {
826  Invalid, /// No symbol should be in this state.
827  NeverSearched, /// Added to the symbol table, never queried.
828  Materializing, /// Queried, materialization begun.
829  Resolved, /// Assigned address, still materializing.
830  Emitted, /// Emitted to memory, but waiting on transitive dependencies.
831  Ready = 0x3f /// Ready and safe for clients to access.
832 };
833 
834 /// A symbol query that returns results via a callback when results are
835 /// ready.
836 ///
837 /// makes a callback when all symbols are available.
839  friend class ExecutionSession;
841  friend class JITDylib;
844 
845 public:
846  /// Create a query for the given symbols. The NotifyComplete
847  /// callback will be called once all queried symbols reach the given
848  /// minimum state.
850  SymbolState RequiredState,
851  SymbolsResolvedCallback NotifyComplete);
852 
853  /// Notify the query that a requested symbol has reached the required state.
855  JITEvaluatedSymbol Sym);
856 
857  /// Returns true if all symbols covered by this query have been
858  /// resolved.
859  bool isComplete() const { return OutstandingSymbolsCount == 0; }
860 
861 
862 private:
863  void handleComplete(ExecutionSession &ES);
864 
865  SymbolState getRequiredState() { return RequiredState; }
866 
867  void addQueryDependence(JITDylib &JD, SymbolStringPtr Name);
868 
869  void removeQueryDependence(JITDylib &JD, const SymbolStringPtr &Name);
870 
871  void dropSymbol(const SymbolStringPtr &Name);
872 
873  void handleFailed(Error Err);
874 
875  void detach();
876 
877  SymbolsResolvedCallback NotifyComplete;
878  SymbolDependenceMap QueryRegistrations;
879  SymbolMap ResolvedSymbols;
880  size_t OutstandingSymbolsCount;
881  SymbolState RequiredState;
882 };
883 
884 /// Wraps state for a lookup-in-progress.
885 /// DefinitionGenerators can optionally take ownership of a LookupState object
886 /// to suspend a lookup-in-progress while they search for definitions.
887 class LookupState {
888  friend class OrcV2CAPIHelper;
889  friend class ExecutionSession;
890 
891 public:
892  LookupState();
895  ~LookupState();
896 
897  /// Continue the lookup. This can be called by DefinitionGenerators
898  /// to re-start a captured query-application operation.
899  void continueLookup(Error Err);
900 
901 private:
902  LookupState(std::unique_ptr<InProgressLookupState> IPLS);
903 
904  // For C API.
905  void reset(InProgressLookupState *IPLS);
906 
907  std::unique_ptr<InProgressLookupState> IPLS;
908 };
909 
910 /// Definition generators can be attached to JITDylibs to generate new
911 /// definitions for otherwise unresolved symbols during lookup.
913 public:
914  virtual ~DefinitionGenerator();
915 
916  /// DefinitionGenerators should override this method to insert new
917  /// definitions into the parent JITDylib. K specifies the kind of this
918  /// lookup. JD specifies the target JITDylib being searched, and
919  /// JDLookupFlags specifies whether the search should match against
920  /// hidden symbols. Finally, Symbols describes the set of unresolved
921  /// symbols and their associated lookup flags.
923  JITDylibLookupFlags JDLookupFlags,
924  const SymbolLookupSet &LookupSet) = 0;
925 };
926 
927 /// Represents a JIT'd dynamic library.
928 ///
929 /// This class aims to mimic the behavior of a regular dylib or shared object,
930 /// but without requiring the contained program representations to be compiled
931 /// up-front. The JITDylib's content is defined by adding MaterializationUnits,
932 /// and contained MaterializationUnits will typically rely on the JITDylib's
933 /// links-against order to resolve external references (similar to a regular
934 /// dylib).
935 ///
936 /// The JITDylib object is a thin wrapper that references state held by the
937 /// ExecutionSession. JITDylibs can be removed, clearing this underlying state
938 /// and leaving the JITDylib object in a defunct state. In this state the
939 /// JITDylib's name is guaranteed to remain accessible. If the ExecutionSession
940 /// is still alive then other operations are callable but will return an Error
941 /// or null result (depending on the API). It is illegal to call any operation
942 /// other than getName on a JITDylib after the ExecutionSession has been torn
943 /// down.
944 ///
945 /// JITDylibs cannot be moved or copied. Their address is stable, and useful as
946 /// a key in some JIT data structures.
947 class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
948  public jitlink::JITLinkDylib {
950  friend class ExecutionSession;
951  friend class Platform;
953 public:
954 
955  JITDylib(const JITDylib &) = delete;
956  JITDylib &operator=(const JITDylib &) = delete;
957  JITDylib(JITDylib &&) = delete;
958  JITDylib &operator=(JITDylib &&) = delete;
959  ~JITDylib();
960 
961  /// Get a reference to the ExecutionSession for this JITDylib.
962  ///
963  /// It is legal to call this method on a defunct JITDylib, however the result
964  /// will only usable if the ExecutionSession is still alive. If this JITDylib
965  /// is held by an error that may have torn down the JIT then the result
966  /// should not be used.
967  ExecutionSession &getExecutionSession() const { return ES; }
968 
969  /// Dump current JITDylib state to OS.
970  ///
971  /// It is legal to call this method on a defunct JITDylib.
972  void dump(raw_ostream &OS);
973 
974  /// Calls remove on all trackers currently associated with this JITDylib.
975  /// Does not run static deinits.
976  ///
977  /// Note that removal happens outside the session lock, so new code may be
978  /// added concurrently while the clear is underway, and the newly added
979  /// code will *not* be cleared. Adding new code concurrently with a clear
980  /// is usually a bug and should be avoided.
981  ///
982  /// It is illegal to call this method on a defunct JITDylib and the client
983  /// is responsible for ensuring that they do not do so.
984  Error clear();
985 
986  /// Get the default resource tracker for this JITDylib.
987  ///
988  /// It is illegal to call this method on a defunct JITDylib and the client
989  /// is responsible for ensuring that they do not do so.
991 
992  /// Create a resource tracker for this JITDylib.
993  ///
994  /// It is illegal to call this method on a defunct JITDylib and the client
995  /// is responsible for ensuring that they do not do so.
997 
998  /// Adds a definition generator to this JITDylib and returns a referenece to
999  /// it.
1000  ///
1001  /// When JITDylibs are searched during lookup, if no existing definition of
1002  /// a symbol is found, then any generators that have been added are run (in
1003  /// the order that they were added) to potentially generate a definition.
1004  ///
1005  /// It is illegal to call this method on a defunct JITDylib and the client
1006  /// is responsible for ensuring that they do not do so.
1007  template <typename GeneratorT>
1008  GeneratorT &addGenerator(std::unique_ptr<GeneratorT> DefGenerator);
1009 
1010  /// Remove a definition generator from this JITDylib.
1011  ///
1012  /// The given generator must exist in this JITDylib's generators list (i.e.
1013  /// have been added and not yet removed).
1014  ///
1015  /// It is illegal to call this method on a defunct JITDylib and the client
1016  /// is responsible for ensuring that they do not do so.
1018 
1019  /// Set the link order to be used when fixing up definitions in JITDylib.
1020  /// This will replace the previous link order, and apply to any symbol
1021  /// resolutions made for definitions in this JITDylib after the call to
1022  /// setLinkOrder (even if the definition itself was added before the
1023  /// call).
1024  ///
1025  /// If LinkAgainstThisJITDylibFirst is true (the default) then this JITDylib
1026  /// will add itself to the beginning of the LinkOrder (Clients should not
1027  /// put this JITDylib in the list in this case, to avoid redundant lookups).
1028  ///
1029  /// If LinkAgainstThisJITDylibFirst is false then the link order will be used
1030  /// as-is. The primary motivation for this feature is to support deliberate
1031  /// shadowing of symbols in this JITDylib by a facade JITDylib. For example,
1032  /// the facade may resolve function names to stubs, and the stubs may compile
1033  /// lazily by looking up symbols in this dylib. Adding the facade dylib
1034  /// as the first in the link order (instead of this dylib) ensures that
1035  /// definitions within this dylib resolve to the lazy-compiling stubs,
1036  /// rather than immediately materializing the definitions in this dylib.
1037  ///
1038  /// It is illegal to call this method on a defunct JITDylib and the client
1039  /// is responsible for ensuring that they do not do so.
1040  void setLinkOrder(JITDylibSearchOrder NewSearchOrder,
1041  bool LinkAgainstThisJITDylibFirst = true);
1042 
1043  /// Add the given JITDylib to the link order for definitions in this
1044  /// JITDylib.
1045  ///
1046  /// It is illegal to call this method on a defunct JITDylib and the client
1047  /// is responsible for ensuring that they do not do so.
1048  void addToLinkOrder(JITDylib &JD,
1049  JITDylibLookupFlags JDLookupFlags =
1051 
1052  /// Replace OldJD with NewJD in the link order if OldJD is present.
1053  /// Otherwise this operation is a no-op.
1054  ///
1055  /// It is illegal to call this method on a defunct JITDylib and the client
1056  /// is responsible for ensuring that they do not do so.
1057  void replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD,
1058  JITDylibLookupFlags JDLookupFlags =
1060 
1061  /// Remove the given JITDylib from the link order for this JITDylib if it is
1062  /// present. Otherwise this operation is a no-op.
1063  ///
1064  /// It is illegal to call this method on a defunct JITDylib and the client
1065  /// is responsible for ensuring that they do not do so.
1066  void removeFromLinkOrder(JITDylib &JD);
1067 
1068  /// Do something with the link order (run under the session lock).
1069  ///
1070  /// It is illegal to call this method on a defunct JITDylib and the client
1071  /// is responsible for ensuring that they do not do so.
1072  template <typename Func>
1073  auto withLinkOrderDo(Func &&F)
1074  -> decltype(F(std::declval<const JITDylibSearchOrder &>()));
1075 
1076  /// Define all symbols provided by the materialization unit to be part of this
1077  /// JITDylib.
1078  ///
1079  /// If RT is not specified then the default resource tracker will be used.
1080  ///
1081  /// This overload always takes ownership of the MaterializationUnit. If any
1082  /// errors occur, the MaterializationUnit consumed.
1083  ///
1084  /// It is illegal to call this method on a defunct JITDylib and the client
1085  /// is responsible for ensuring that they do not do so.
1086  template <typename MaterializationUnitType>
1087  Error define(std::unique_ptr<MaterializationUnitType> &&MU,
1088  ResourceTrackerSP RT = nullptr);
1089 
1090  /// Define all symbols provided by the materialization unit to be part of this
1091  /// JITDylib.
1092  ///
1093  /// This overload only takes ownership of the MaterializationUnit no error is
1094  /// generated. If an error occurs, ownership remains with the caller. This
1095  /// may allow the caller to modify the MaterializationUnit to correct the
1096  /// issue, then re-call define.
1097  ///
1098  /// It is illegal to call this method on a defunct JITDylib and the client
1099  /// is responsible for ensuring that they do not do so.
1100  template <typename MaterializationUnitType>
1101  Error define(std::unique_ptr<MaterializationUnitType> &MU,
1102  ResourceTrackerSP RT = nullptr);
1103 
1104  /// Tries to remove the given symbols.
1105  ///
1106  /// If any symbols are not defined in this JITDylib this method will return
1107  /// a SymbolsNotFound error covering the missing symbols.
1108  ///
1109  /// If all symbols are found but some symbols are in the process of being
1110  /// materialized this method will return a SymbolsCouldNotBeRemoved error.
1111  ///
1112  /// On success, all symbols are removed. On failure, the JITDylib state is
1113  /// left unmodified (no symbols are removed).
1114  ///
1115  /// It is illegal to call this method on a defunct JITDylib and the client
1116  /// is responsible for ensuring that they do not do so.
1117  Error remove(const SymbolNameSet &Names);
1118 
1119  /// Returns the given JITDylibs and all of their transitive dependencies in
1120  /// DFS order (based on linkage relationships). Each JITDylib will appear
1121  /// only once.
1122  ///
1123  /// It is illegal to call this method on a defunct JITDylib and the client
1124  /// is responsible for ensuring that they do not do so.
1125  static std::vector<JITDylibSP> getDFSLinkOrder(ArrayRef<JITDylibSP> JDs);
1126 
1127  /// Returns the given JITDylibs and all of their transitive dependencies in
1128  /// reverse DFS order (based on linkage relationships). Each JITDylib will
1129  /// appear only once.
1130  ///
1131  /// It is illegal to call this method on a defunct JITDylib and the client
1132  /// is responsible for ensuring that they do not do so.
1133  static std::vector<JITDylibSP>
1135 
1136  /// Return this JITDylib and its transitive dependencies in DFS order
1137  /// based on linkage relationships.
1138  ///
1139  /// It is illegal to call this method on a defunct JITDylib and the client
1140  /// is responsible for ensuring that they do not do so.
1141  std::vector<JITDylibSP> getDFSLinkOrder();
1142 
1143  /// Rteurn this JITDylib and its transitive dependencies in reverse DFS order
1144  /// based on linkage relationships.
1145  ///
1146  /// It is illegal to call this method on a defunct JITDylib and the client
1147  /// is responsible for ensuring that they do not do so.
1148  std::vector<JITDylibSP> getReverseDFSLinkOrder();
1149 
1150 private:
1151  using AsynchronousSymbolQuerySet =
1152  std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
1153 
1154  using AsynchronousSymbolQueryList =
1155  std::vector<std::shared_ptr<AsynchronousSymbolQuery>>;
1156 
1157  struct UnmaterializedInfo {
1158  UnmaterializedInfo(std::unique_ptr<MaterializationUnit> MU,
1159  ResourceTracker *RT)
1160  : MU(std::move(MU)), RT(RT) {}
1161 
1162  std::unique_ptr<MaterializationUnit> MU;
1163  ResourceTracker *RT;
1164  };
1165 
1166  using UnmaterializedInfosMap =
1167  DenseMap<SymbolStringPtr, std::shared_ptr<UnmaterializedInfo>>;
1168 
1169  using UnmaterializedInfosList =
1170  std::vector<std::shared_ptr<UnmaterializedInfo>>;
1171 
1172  struct MaterializingInfo {
1173  SymbolDependenceMap Dependants;
1174  SymbolDependenceMap UnemittedDependencies;
1175 
1176  void addQuery(std::shared_ptr<AsynchronousSymbolQuery> Q);
1177  void removeQuery(const AsynchronousSymbolQuery &Q);
1178  AsynchronousSymbolQueryList takeQueriesMeeting(SymbolState RequiredState);
1179  AsynchronousSymbolQueryList takeAllPendingQueries() {
1180  return std::move(PendingQueries);
1181  }
1182  bool hasQueriesPending() const { return !PendingQueries.empty(); }
1183  const AsynchronousSymbolQueryList &pendingQueries() const {
1184  return PendingQueries;
1185  }
1186  private:
1187  AsynchronousSymbolQueryList PendingQueries;
1188  };
1189 
1190  using MaterializingInfosMap = DenseMap<SymbolStringPtr, MaterializingInfo>;
1191 
1192  class SymbolTableEntry {
1193  public:
1194  SymbolTableEntry() = default;
1195  SymbolTableEntry(JITSymbolFlags Flags)
1196  : Flags(Flags), State(static_cast<uint8_t>(SymbolState::NeverSearched)),
1197  MaterializerAttached(false), PendingRemoval(false) {}
1198 
1199  JITTargetAddress getAddress() const { return Addr; }
1200  JITSymbolFlags getFlags() const { return Flags; }
1201  SymbolState getState() const { return static_cast<SymbolState>(State); }
1202 
1203  bool hasMaterializerAttached() const { return MaterializerAttached; }
1204  bool isPendingRemoval() const { return PendingRemoval; }
1205 
1206  void setAddress(JITTargetAddress Addr) { this->Addr = Addr; }
1207  void setFlags(JITSymbolFlags Flags) { this->Flags = Flags; }
1208  void setState(SymbolState State) {
1209  assert(static_cast<uint8_t>(State) < (1 << 6) &&
1210  "State does not fit in bitfield");
1211  this->State = static_cast<uint8_t>(State);
1212  }
1213 
1214  void setMaterializerAttached(bool MaterializerAttached) {
1215  this->MaterializerAttached = MaterializerAttached;
1216  }
1217 
1218  void setPendingRemoval(bool PendingRemoval) {
1219  this->PendingRemoval = PendingRemoval;
1220  }
1221 
1222  JITEvaluatedSymbol getSymbol() const {
1223  return JITEvaluatedSymbol(Addr, Flags);
1224  }
1225 
1226  private:
1227  JITTargetAddress Addr = 0;
1228  JITSymbolFlags Flags;
1229  uint8_t State : 6;
1230  uint8_t MaterializerAttached : 1;
1231  uint8_t PendingRemoval : 1;
1232  };
1233 
1234  using SymbolTable = DenseMap<SymbolStringPtr, SymbolTableEntry>;
1235 
1236  JITDylib(ExecutionSession &ES, std::string Name);
1237 
1238  std::pair<AsynchronousSymbolQuerySet, std::shared_ptr<SymbolDependenceMap>>
1239  removeTracker(ResourceTracker &RT);
1240 
1241  void transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
1242 
1243  Error defineImpl(MaterializationUnit &MU);
1244 
1245  void installMaterializationUnit(std::unique_ptr<MaterializationUnit> MU,
1246  ResourceTracker &RT);
1247 
1248  void detachQueryHelper(AsynchronousSymbolQuery &Q,
1249  const SymbolNameSet &QuerySymbols);
1250 
1251  void transferEmittedNodeDependencies(MaterializingInfo &DependantMI,
1252  const SymbolStringPtr &DependantName,
1253  MaterializingInfo &EmittedMI);
1254 
1255  Expected<SymbolFlagsMap> defineMaterializing(SymbolFlagsMap SymbolFlags);
1256 
1257  Error replace(MaterializationResponsibility &FromMR,
1258  std::unique_ptr<MaterializationUnit> MU);
1259 
1260  Expected<std::unique_ptr<MaterializationResponsibility>>
1262  SymbolStringPtr InitSymbol);
1263 
1264  SymbolNameSet getRequestedSymbols(const SymbolFlagsMap &SymbolFlags) const;
1265 
1266  void addDependencies(const SymbolStringPtr &Name,
1267  const SymbolDependenceMap &Dependants);
1268 
1269  Error resolve(MaterializationResponsibility &MR, const SymbolMap &Resolved);
1270 
1271  Error emit(MaterializationResponsibility &MR, const SymbolFlagsMap &Emitted);
1272 
1273  void unlinkMaterializationResponsibility(MaterializationResponsibility &MR);
1274 
1275  using FailedSymbolsWorklist =
1276  std::vector<std::pair<JITDylib *, SymbolStringPtr>>;
1277 
1278  static std::pair<AsynchronousSymbolQuerySet,
1279  std::shared_ptr<SymbolDependenceMap>>
1280  failSymbols(FailedSymbolsWorklist);
1281 
1282  ExecutionSession &ES;
1283  enum { Open, Closing, Closed } State = Open;
1284  std::mutex GeneratorsMutex;
1285  SymbolTable Symbols;
1286  UnmaterializedInfosMap UnmaterializedInfos;
1287  MaterializingInfosMap MaterializingInfos;
1288  std::vector<std::shared_ptr<DefinitionGenerator>> DefGenerators;
1289  JITDylibSearchOrder LinkOrder;
1290  ResourceTrackerSP DefaultTracker;
1291 
1292  // Map trackers to sets of symbols tracked.
1293  DenseMap<ResourceTracker *, SymbolNameVector> TrackerSymbols;
1294  DenseMap<ResourceTracker *, DenseSet<MaterializationResponsibility *>>
1295  TrackerMRs;
1296 };
1297 
1298 /// Platforms set up standard symbols and mediate interactions between dynamic
1299 /// initializers (e.g. C++ static constructors) and ExecutionSession state.
1300 /// Note that Platforms do not automatically run initializers: clients are still
1301 /// responsible for doing this.
1302 class Platform {
1303 public:
1304  virtual ~Platform();
1305 
1306  /// This method will be called outside the session lock each time a JITDylib
1307  /// is created (unless it is created with EmptyJITDylib set) to allow the
1308  /// Platform to install any JITDylib specific standard symbols (e.g
1309  /// __dso_handle).
1310  virtual Error setupJITDylib(JITDylib &JD) = 0;
1311 
1312  /// This method will be called outside the session lock each time a JITDylib
1313  /// is removed to allow the Platform to remove any JITDylib-specific data.
1314  virtual Error teardownJITDylib(JITDylib &JD) = 0;
1315 
1316  /// This method will be called under the ExecutionSession lock each time a
1317  /// MaterializationUnit is added to a JITDylib.
1318  virtual Error notifyAdding(ResourceTracker &RT,
1319  const MaterializationUnit &MU) = 0;
1320 
1321  /// This method will be called under the ExecutionSession lock when a
1322  /// ResourceTracker is removed.
1323  virtual Error notifyRemoving(ResourceTracker &RT) = 0;
1324 
1325  /// A utility function for looking up initializer symbols. Performs a blocking
1326  /// lookup for the given symbols in each of the given JITDylibs.
1327  ///
1328  /// Note: This function is deprecated and will be removed in the near future.
1331  const DenseMap<JITDylib *, SymbolLookupSet> &InitSyms);
1332 
1333  /// Performs an async lookup for the the given symbols in each of the given
1334  /// JITDylibs, calling the given handler once all lookups have completed.
1335  static void
1336  lookupInitSymbolsAsync(unique_function<void(Error)> OnComplete,
1337  ExecutionSession &ES,
1338  const DenseMap<JITDylib *, SymbolLookupSet> &InitSyms);
1339 };
1340 
1341 /// A materialization task.
1342 class MaterializationTask : public RTTIExtends<MaterializationTask, Task> {
1343 public:
1344  static char ID;
1345 
1346  MaterializationTask(std::unique_ptr<MaterializationUnit> MU,
1347  std::unique_ptr<MaterializationResponsibility> MR)
1348  : MU(std::move(MU)), MR(std::move(MR)) {}
1349  void printDescription(raw_ostream &OS) override;
1350  void run() override;
1351 
1352 private:
1353  std::unique_ptr<MaterializationUnit> MU;
1354  std::unique_ptr<MaterializationResponsibility> MR;
1355 };
1356 
1357 /// An ExecutionSession represents a running JIT program.
1361  friend class JITDylib;
1362  friend class LookupState;
1364  friend class ResourceTracker;
1365 
1366 public:
1367  /// For reporting errors.
1369 
1370  /// Send a result to the remote.
1372 
1373  /// For dispatching ORC tasks (typically materialization tasks).
1374  using DispatchTaskFunction = unique_function<void(std::unique_ptr<Task> T)>;
1375 
1376  /// An asynchronous wrapper-function callable from the executor via
1377  /// jit-dispatch.
1379  SendResultFunction SendResult,
1380  const char *ArgData, size_t ArgSize)>;
1381 
1382  /// A map associating tag names with asynchronous wrapper function
1383  /// implementations in the JIT.
1386 
1387  /// Construct an ExecutionSession with the given ExecutorProcessControl
1388  /// object.
1389  ExecutionSession(std::unique_ptr<ExecutorProcessControl> EPC);
1390 
1391  /// End the session. Closes all JITDylibs and disconnects from the
1392  /// executor.
1393  Error endSession();
1394 
1395  /// Get the ExecutorProcessControl object associated with this
1396  /// ExecutionSession.
1398 
1399  /// Get the SymbolStringPool for this instance.
1400  std::shared_ptr<SymbolStringPool> getSymbolStringPool() {
1401  return EPC->getSymbolStringPool();
1402  }
1403 
1404  /// Add a symbol name to the SymbolStringPool and return a pointer to it.
1405  SymbolStringPtr intern(StringRef SymName) { return EPC->intern(SymName); }
1406 
1407  /// Set the Platform for this ExecutionSession.
1408  void setPlatform(std::unique_ptr<Platform> P) { this->P = std::move(P); }
1409 
1410  /// Get the Platform for this session.
1411  /// Will return null if no Platform has been set for this ExecutionSession.
1412  Platform *getPlatform() { return P.get(); }
1413 
1414  /// Run the given lambda with the session mutex locked.
1415  template <typename Func> decltype(auto) runSessionLocked(Func &&F) {
1416  std::lock_guard<std::recursive_mutex> Lock(SessionMutex);
1417  return F();
1418  }
1419 
1420  /// Register the given ResourceManager with this ExecutionSession.
1421  /// Managers will be notified of events in reverse order of registration.
1423 
1424  /// Deregister the given ResourceManager with this ExecutionSession.
1425  /// Manager must have been previously registered.
1427 
1428  /// Return a pointer to the "name" JITDylib.
1429  /// Ownership of JITDylib remains within Execution Session
1431 
1432  /// Add a new bare JITDylib to this ExecutionSession.
1433  ///
1434  /// The JITDylib Name is required to be unique. Clients should verify that
1435  /// names are not being re-used (E.g. by calling getJITDylibByName) if names
1436  /// are based on user input.
1437  ///
1438  /// This call does not install any library code or symbols into the newly
1439  /// created JITDylib. The client is responsible for all configuration.
1440  JITDylib &createBareJITDylib(std::string Name);
1441 
1442  /// Add a new JITDylib to this ExecutionSession.
1443  ///
1444  /// The JITDylib Name is required to be unique. Clients should verify that
1445  /// names are not being re-used (e.g. by calling getJITDylibByName) if names
1446  /// are based on user input.
1447  ///
1448  /// If a Platform is attached then Platform::setupJITDylib will be called to
1449  /// install standard platform symbols (e.g. standard library interposes).
1450  /// If no Platform is attached this call is equivalent to createBareJITDylib.
1452 
1453  /// Closes the given JITDylib.
1454  ///
1455  /// This method clears all resources held for the JITDylib, puts it in the
1456  /// closed state, and clears all references held by the ExecutionSession and
1457  /// other JITDylibs. No further code can be added to the JITDylib, and the
1458  /// object will be freed once any remaining JITDylibSPs to it are destroyed.
1459  ///
1460  /// This method does *not* run static destructors.
1461  ///
1462  /// This method can only be called once for each JITDylib.
1464 
1465  /// Set the error reporter function.
1467  this->ReportError = std::move(ReportError);
1468  return *this;
1469  }
1470 
1471  /// Report a error for this execution session.
1472  ///
1473  /// Unhandled errors can be sent here to log them.
1474  void reportError(Error Err) { ReportError(std::move(Err)); }
1475 
1476  /// Set the task dispatch function.
1478  this->DispatchTask = std::move(DispatchTask);
1479  return *this;
1480  }
1481 
1482  /// Search the given JITDylibs to find the flags associated with each of the
1483  /// given symbols.
1484  void lookupFlags(LookupKind K, JITDylibSearchOrder SearchOrder,
1485  SymbolLookupSet Symbols,
1486  unique_function<void(Expected<SymbolFlagsMap>)> OnComplete);
1487 
1488  /// Blocking version of lookupFlags.
1490  JITDylibSearchOrder SearchOrder,
1491  SymbolLookupSet Symbols);
1492 
1493  /// Search the given JITDylibs for the given symbols.
1494  ///
1495  /// SearchOrder lists the JITDylibs to search. For each dylib, the associated
1496  /// boolean indicates whether the search should match against non-exported
1497  /// (hidden visibility) symbols in that dylib (true means match against
1498  /// non-exported symbols, false means do not match).
1499  ///
1500  /// The NotifyComplete callback will be called once all requested symbols
1501  /// reach the required state.
1502  ///
1503  /// If all symbols are found, the RegisterDependencies function will be called
1504  /// while the session lock is held. This gives clients a chance to register
1505  /// dependencies for on the queried symbols for any symbols they are
1506  /// materializing (if a MaterializationResponsibility instance is present,
1507  /// this can be implemented by calling
1508  /// MaterializationResponsibility::addDependencies). If there are no
1509  /// dependenant symbols for this query (e.g. it is being made by a top level
1510  /// client to get an address to call) then the value NoDependenciesToRegister
1511  /// can be used.
1512  void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder,
1513  SymbolLookupSet Symbols, SymbolState RequiredState,
1514  SymbolsResolvedCallback NotifyComplete,
1515  RegisterDependenciesFunction RegisterDependencies);
1516 
1517  /// Blocking version of lookup above. Returns the resolved symbol map.
1518  /// If WaitUntilReady is true (the default), will not return until all
1519  /// requested symbols are ready (or an error occurs). If WaitUntilReady is
1520  /// false, will return as soon as all requested symbols are resolved,
1521  /// or an error occurs. If WaitUntilReady is false and an error occurs
1522  /// after resolution, the function will return a success value, but the
1523  /// error will be reported via reportErrors.
1524  Expected<SymbolMap> lookup(const JITDylibSearchOrder &SearchOrder,
1525  const SymbolLookupSet &Symbols,
1527  SymbolState RequiredState = SymbolState::Ready,
1528  RegisterDependenciesFunction RegisterDependencies =
1530 
1531  /// Convenience version of blocking lookup.
1532  /// Searches each of the JITDylibs in the search order in turn for the given
1533  /// symbol.
1535  lookup(const JITDylibSearchOrder &SearchOrder, SymbolStringPtr Symbol,
1536  SymbolState RequiredState = SymbolState::Ready);
1537 
1538  /// Convenience version of blocking lookup.
1539  /// Searches each of the JITDylibs in the search order in turn for the given
1540  /// symbol. The search will not find non-exported symbols.
1543  SymbolState RequiredState = SymbolState::Ready);
1544 
1545  /// Convenience version of blocking lookup.
1546  /// Searches each of the JITDylibs in the search order in turn for the given
1547  /// symbol. The search will not find non-exported symbols.
1550  SymbolState RequiredState = SymbolState::Ready);
1551 
1552  /// Materialize the given unit.
1553  void dispatchTask(std::unique_ptr<Task> T) {
1554  assert(T && "T must be non-null");
1555  DEBUG_WITH_TYPE("orc", dumpDispatchInfo(*T));
1556  DispatchTask(std::move(T));
1557  }
1558 
1559  /// Run a wrapper function in the executor.
1560  ///
1561  /// The wrapper function should be callable as:
1562  ///
1563  /// \code{.cpp}
1564  /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
1565  /// \endcode{.cpp}
1566  ///
1567  /// The given OnComplete function will be called to return the result.
1568  template <typename... ArgTs>
1569  void callWrapperAsync(ArgTs &&... Args) {
1570  EPC->callWrapperAsync(std::forward<ArgTs>(Args)...);
1571  }
1572 
1573  /// Run a wrapper function in the executor. The wrapper function should be
1574  /// callable as:
1575  ///
1576  /// \code{.cpp}
1577  /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
1578  /// \endcode{.cpp}
1580  ArrayRef<char> ArgBuffer) {
1581  return EPC->callWrapper(WrapperFnAddr, ArgBuffer);
1582  }
1583 
1584  /// Run a wrapper function using SPS to serialize the arguments and
1585  /// deserialize the results.
1586  template <typename SPSSignature, typename SendResultT, typename... ArgTs>
1587  void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
1588  const ArgTs &...Args) {
1589  EPC->callSPSWrapperAsync<SPSSignature, SendResultT, ArgTs...>(
1590  WrapperFnAddr, std::forward<SendResultT>(SendResult), Args...);
1591  }
1592 
1593  /// Run a wrapper function using SPS to serialize the arguments and
1594  /// deserialize the results.
1595  ///
1596  /// If SPSSignature is a non-void function signature then the second argument
1597  /// (the first in the Args list) should be a reference to a return value.
1598  template <typename SPSSignature, typename... WrapperCallArgTs>
1600  WrapperCallArgTs &&...WrapperCallArgs) {
1601  return EPC->callSPSWrapper<SPSSignature, WrapperCallArgTs...>(
1602  WrapperFnAddr, std::forward<WrapperCallArgTs>(WrapperCallArgs)...);
1603  }
1604 
1605  /// Wrap a handler that takes concrete argument types (and a sender for a
1606  /// concrete return type) to produce an AsyncHandlerWrapperFunction. Uses SPS
1607  /// to unpack the arguments and pack the result.
1608  ///
1609  /// This function is intended to support easy construction of
1610  /// AsyncHandlerWrapperFunctions that can be associated with a tag
1611  /// (using registerJITDispatchHandler) and called from the executor.
1612  template <typename SPSSignature, typename HandlerT>
1614  return [H = std::forward<HandlerT>(H)](
1615  SendResultFunction SendResult,
1616  const char *ArgData, size_t ArgSize) mutable {
1618  std::move(SendResult));
1619  };
1620  }
1621 
1622  /// Wrap a class method that takes concrete argument types (and a sender for
1623  /// a concrete return type) to produce an AsyncHandlerWrapperFunction. Uses
1624  /// SPS to unpack teh arguments and pack the result.
1625  ///
1626  /// This function is intended to support easy construction of
1627  /// AsyncHandlerWrapperFunctions that can be associated with a tag
1628  /// (using registerJITDispatchHandler) and called from the executor.
1629  template <typename SPSSignature, typename ClassT, typename... MethodArgTs>
1631  wrapAsyncWithSPS(ClassT *Instance, void (ClassT::*Method)(MethodArgTs...)) {
1632  return wrapAsyncWithSPS<SPSSignature>(
1633  [Instance, Method](MethodArgTs &&...MethodArgs) {
1634  (Instance->*Method)(std::forward<MethodArgTs>(MethodArgs)...);
1635  });
1636  }
1637 
1638  /// For each tag symbol name, associate the corresponding
1639  /// AsyncHandlerWrapperFunction with the address of that symbol. The
1640  /// handler becomes callable from the executor using the ORC runtime
1641  /// __orc_rt_jit_dispatch function and the given tag.
1642  ///
1643  /// Tag symbols will be looked up in JD using LookupKind::Static,
1644  /// JITDylibLookupFlags::MatchAllSymbols (hidden tags will be found), and
1645  /// LookupFlags::WeaklyReferencedSymbol. Missing tag definitions will not
1646  /// cause an error, the handler will simply be dropped.
1649 
1650  /// Run a registered jit-side wrapper function.
1651  /// This should be called by the ExecutorProcessControl instance in response
1652  /// to incoming jit-dispatch requests from the executor.
1653  void
1655  JITTargetAddress HandlerFnTagAddr,
1656  ArrayRef<char> ArgBuffer);
1657 
1658  /// Dump the state of all the JITDylibs in this session.
1659  void dump(raw_ostream &OS);
1660 
1661 private:
1662  static void logErrorsToStdErr(Error Err) {
1663  logAllUnhandledErrors(std::move(Err), errs(), "JIT session error: ");
1664  }
1665 
1666  static void runOnCurrentThread(std::unique_ptr<Task> T) { T->run(); }
1667 
1668  void dispatchOutstandingMUs();
1669 
1670  static std::unique_ptr<MaterializationResponsibility>
1671  createMaterializationResponsibility(ResourceTracker &RT,
1672  SymbolFlagsMap Symbols,
1673  SymbolStringPtr InitSymbol) {
1674  auto &JD = RT.getJITDylib();
1675  std::unique_ptr<MaterializationResponsibility> MR(
1676  new MaterializationResponsibility(&RT, std::move(Symbols),
1677  std::move(InitSymbol)));
1678  JD.TrackerMRs[&RT].insert(MR.get());
1679  return MR;
1680  }
1681 
1682  Error removeResourceTracker(ResourceTracker &RT);
1683  void transferResourceTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
1684  void destroyResourceTracker(ResourceTracker &RT);
1685 
1686  // State machine functions for query application..
1687 
1688  /// IL_updateCandidatesFor is called to remove already-defined symbols that
1689  /// match a given query from the set of candidate symbols to generate
1690  /// definitions for (no need to generate a definition if one already exists).
1691  Error IL_updateCandidatesFor(JITDylib &JD, JITDylibLookupFlags JDLookupFlags,
1692  SymbolLookupSet &Candidates,
1693  SymbolLookupSet *NonCandidates);
1694 
1695  /// OL_applyQueryPhase1 is an optionally re-startable loop for triggering
1696  /// definition generation. It is called when a lookup is performed, and again
1697  /// each time that LookupState::continueLookup is called.
1698  void OL_applyQueryPhase1(std::unique_ptr<InProgressLookupState> IPLS,
1699  Error Err);
1700 
1701  /// OL_completeLookup is run once phase 1 successfully completes for a lookup
1702  /// call. It attempts to attach the symbol to all symbol table entries and
1703  /// collect all MaterializationUnits to dispatch. If this method fails then
1704  /// all MaterializationUnits will be left un-materialized.
1705  void OL_completeLookup(std::unique_ptr<InProgressLookupState> IPLS,
1706  std::shared_ptr<AsynchronousSymbolQuery> Q,
1707  RegisterDependenciesFunction RegisterDependencies);
1708 
1709  /// OL_completeLookupFlags is run once phase 1 successfully completes for a
1710  /// lookupFlags call.
1711  void OL_completeLookupFlags(
1712  std::unique_ptr<InProgressLookupState> IPLS,
1713  unique_function<void(Expected<SymbolFlagsMap>)> OnComplete);
1714 
1715  // State machine functions for MaterializationResponsibility.
1716  void OL_destroyMaterializationResponsibility(
1718  SymbolNameSet OL_getRequestedSymbols(const MaterializationResponsibility &MR);
1719  Error OL_notifyResolved(MaterializationResponsibility &MR,
1720  const SymbolMap &Symbols);
1721  Error OL_notifyEmitted(MaterializationResponsibility &MR);
1722  Error OL_defineMaterializing(MaterializationResponsibility &MR,
1724  void OL_notifyFailed(MaterializationResponsibility &MR);
1725  Error OL_replace(MaterializationResponsibility &MR,
1726  std::unique_ptr<MaterializationUnit> MU);
1727  Expected<std::unique_ptr<MaterializationResponsibility>>
1728  OL_delegate(MaterializationResponsibility &MR, const SymbolNameSet &Symbols);
1729  void OL_addDependencies(MaterializationResponsibility &MR,
1730  const SymbolStringPtr &Name,
1731  const SymbolDependenceMap &Dependencies);
1732  void OL_addDependenciesForAll(MaterializationResponsibility &MR,
1733  const SymbolDependenceMap &Dependencies);
1734 
1735 #ifndef NDEBUG
1736  void dumpDispatchInfo(Task &T);
1737 #endif // NDEBUG
1738 
1739  mutable std::recursive_mutex SessionMutex;
1740  bool SessionOpen = true;
1741  std::unique_ptr<ExecutorProcessControl> EPC;
1742  std::unique_ptr<Platform> P;
1743  ErrorReporter ReportError = logErrorsToStdErr;
1744  DispatchTaskFunction DispatchTask = runOnCurrentThread;
1745 
1746  std::vector<ResourceManager *> ResourceManagers;
1747 
1748  std::vector<JITDylibSP> JDs;
1749 
1750  // FIXME: Remove this (and runOutstandingMUs) once the linking layer works
1751  // with callbacks from asynchronous queries.
1752  mutable std::recursive_mutex OutstandingMUsMutex;
1753  std::vector<std::pair<std::unique_ptr<MaterializationUnit>,
1754  std::unique_ptr<MaterializationResponsibility>>>
1755  OutstandingMUs;
1756 
1757  mutable std::mutex JITDispatchHandlersMutex;
1758  DenseMap<JITTargetAddress, std::shared_ptr<JITDispatchHandlerFunction>>
1759  JITDispatchHandlers;
1760 };
1761 
1762 inline ExecutionSession &
1764  return JD.getExecutionSession();
1765 }
1766 
1767 template <typename Func>
1769  return JD.getExecutionSession().runSessionLocked([&]() -> Error {
1770  if (RT->isDefunct())
1771  return make_error<ResourceTrackerDefunct>(RT);
1772  F(RT->getKeyUnsafe());
1773  return Error::success();
1774  });
1775 }
1776 
1777 template <typename GeneratorT>
1778 GeneratorT &JITDylib::addGenerator(std::unique_ptr<GeneratorT> DefGenerator) {
1779  auto &G = *DefGenerator;
1780  ES.runSessionLocked([&] {
1781  assert(State == Open && "Cannot add generator to closed JITDylib");
1782  DefGenerators.push_back(std::move(DefGenerator));
1783  });
1784  return G;
1785 }
1786 
1787 template <typename Func>
1789  -> decltype(F(std::declval<const JITDylibSearchOrder &>())) {
1790  assert(State == Open && "Cannot use link order of closed JITDylib");
1791  return ES.runSessionLocked([&]() { return F(LinkOrder); });
1792 }
1793 
1794 template <typename MaterializationUnitType>
1795 Error JITDylib::define(std::unique_ptr<MaterializationUnitType> &&MU,
1796  ResourceTrackerSP RT) {
1797  assert(MU && "Can not define with a null MU");
1798 
1799  if (MU->getSymbols().empty()) {
1800  // Empty MUs are allowable but pathological, so issue a warning.
1801  DEBUG_WITH_TYPE("orc", {
1802  dbgs() << "Warning: Discarding empty MU " << MU->getName() << " for "
1803  << getName() << "\n";
1804  });
1805  return Error::success();
1806  } else
1807  DEBUG_WITH_TYPE("orc", {
1808  dbgs() << "Defining MU " << MU->getName() << " for " << getName()
1809  << " (tracker: ";
1810  if (RT == getDefaultResourceTracker())
1811  dbgs() << "default)";
1812  else if (RT)
1813  dbgs() << RT.get() << ")\n";
1814  else
1815  dbgs() << "0x0, default will be used)\n";
1816  });
1817 
1818  return ES.runSessionLocked([&, this]() -> Error {
1819  assert(State == Open && "JD is defunct");
1820 
1821  if (auto Err = defineImpl(*MU))
1822  return Err;
1823 
1824  if (!RT)
1826 
1827  if (auto *P = ES.getPlatform()) {
1828  if (auto Err = P->notifyAdding(*RT, *MU))
1829  return Err;
1830  }
1831 
1832  installMaterializationUnit(std::move(MU), *RT);
1833  return Error::success();
1834  });
1835 }
1836 
1837 template <typename MaterializationUnitType>
1838 Error JITDylib::define(std::unique_ptr<MaterializationUnitType> &MU,
1839  ResourceTrackerSP RT) {
1840  assert(MU && "Can not define with a null MU");
1841 
1842  if (MU->getSymbols().empty()) {
1843  // Empty MUs are allowable but pathological, so issue a warning.
1844  DEBUG_WITH_TYPE("orc", {
1845  dbgs() << "Warning: Discarding empty MU " << MU->getName() << getName()
1846  << "\n";
1847  });
1848  return Error::success();
1849  } else
1850  DEBUG_WITH_TYPE("orc", {
1851  dbgs() << "Defining MU " << MU->getName() << " for " << getName()
1852  << " (tracker: ";
1853  if (RT == getDefaultResourceTracker())
1854  dbgs() << "default)";
1855  else if (RT)
1856  dbgs() << RT.get() << ")\n";
1857  else
1858  dbgs() << "0x0, default will be used)\n";
1859  });
1860 
1861  return ES.runSessionLocked([&, this]() -> Error {
1862  assert(State == Open && "JD is defunct");
1863 
1864  if (auto Err = defineImpl(*MU))
1865  return Err;
1866 
1867  if (!RT)
1869 
1870  if (auto *P = ES.getPlatform()) {
1871  if (auto Err = P->notifyAdding(*RT, *MU))
1872  return Err;
1873  }
1874 
1875  installMaterializationUnit(std::move(MU), *RT);
1876  return Error::success();
1877  });
1878 }
1879 
1880 /// ReexportsGenerator can be used with JITDylib::addGenerator to automatically
1881 /// re-export a subset of the source JITDylib's symbols in the target.
1883 public:
1885 
1886  /// Create a reexports generator. If an Allow predicate is passed, only
1887  /// symbols for which the predicate returns true will be reexported. If no
1888  /// Allow predicate is passed, all symbols will be exported.
1889  ReexportsGenerator(JITDylib &SourceJD,
1890  JITDylibLookupFlags SourceJDLookupFlags,
1891  SymbolPredicate Allow = SymbolPredicate());
1892 
1894  JITDylibLookupFlags JDLookupFlags,
1895  const SymbolLookupSet &LookupSet) override;
1896 
1897 private:
1898  JITDylib &SourceJD;
1899  JITDylibLookupFlags SourceJDLookupFlags;
1900  SymbolPredicate Allow;
1901 };
1902 
1903 // --------------- IMPLEMENTATION --------------
1904 // Implementations for inline functions/methods.
1905 // ---------------------------------------------
1906 
1908  getExecutionSession().OL_destroyMaterializationResponsibility(*this);
1909 }
1910 
1912  return getExecutionSession().OL_getRequestedSymbols(*this);
1913 }
1914 
1916  const SymbolMap &Symbols) {
1917  return getExecutionSession().OL_notifyResolved(*this, Symbols);
1918 }
1919 
1921  return getExecutionSession().OL_notifyEmitted(*this);
1922 }
1923 
1926  return getExecutionSession().OL_defineMaterializing(*this,
1927  std::move(SymbolFlags));
1928 }
1929 
1931  getExecutionSession().OL_notifyFailed(*this);
1932 }
1933 
1935  std::unique_ptr<MaterializationUnit> MU) {
1936  return getExecutionSession().OL_replace(*this, std::move(MU));
1937 }
1938 
1941  return getExecutionSession().OL_delegate(*this, Symbols);
1942 }
1943 
1945  const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies) {
1946  getExecutionSession().OL_addDependencies(*this, Name, Dependencies);
1947 }
1948 
1950  const SymbolDependenceMap &Dependencies) {
1951  getExecutionSession().OL_addDependenciesForAll(*this, Dependencies);
1952 }
1953 
1954 } // End namespace orc
1955 } // End namespace llvm
1956 
1957 #endif // LLVM_EXECUTIONENGINE_ORC_CORE_H
llvm::orc::ExecutorAddr
Represents an address in the executor process.
Definition: ExecutorAddress.h:30
llvm::orc::ResourceKey
uintptr_t ResourceKey
Definition: Core.h:50
llvm::orc::MaterializationResponsibility::replace
Error replace(std::unique_ptr< MaterializationUnit > MU)
Transfers responsibility to the given MaterializationUnit for all symbols defined by that Materializa...
Definition: Core.h:1934
llvm::orc::SymbolLookupSet::fromMapKeys
static SymbolLookupSet fromMapKeys(const DenseMap< SymbolStringPtr, KeyT > &M, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Construct a SymbolLookupSet from DenseMap keys.
Definition: Core.h:224
llvm::orc::MaterializationTask
A materialization task.
Definition: Core.h:1342
llvm::orc::MaterializationResponsibility
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:520
llvm::orc::MaterializationTask::MaterializationTask
MaterializationTask(std::unique_ptr< MaterializationUnit > MU, std::unique_ptr< MaterializationResponsibility > MR)
Definition: Core.h:1346
llvm::orc::JITDylib::withLinkOrderDo
auto withLinkOrderDo(Func &&F) -> decltype(F(std::declval< const JITDylibSearchOrder & >()))
Do something with the link order (run under the session lock).
Definition: Core.h:1788
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::orc::SymbolsNotFound::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:110
llvm::orc::JITDylib
Represents a JIT'd dynamic library.
Definition: Core.h:947
llvm::orc::ReexportsGenerator::tryToGenerate
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:571
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
JITSymbol.h
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
FunctionExtras.h
llvm::orc::SymbolLookupSet::remove_if
void remove_if(PredFn &&Pred)
Removes all elements matching the given predicate, which must be callable as bool(const SymbolStringP...
Definition: Core.h:269
llvm::orc::AsynchronousSymbolQuery::notifySymbolMetRequiredState
void notifySymbolMetRequiredState(const SymbolStringPtr &Name, JITEvaluatedSymbol Sym)
Notify the query that a requested symbol has reached the required state.
Definition: Core.cpp:160
llvm::orc::SymbolLookupSet::UnderlyingVector
std::vector< value_type > UnderlyingVector
Definition: Core.h:178
llvm::orc::SymbolState::Materializing
@ Materializing
Added to the symbol table, never queried.
llvm::orc::JITDylib::setLinkOrder
void setLinkOrder(JITDylibSearchOrder NewSearchOrder, bool LinkAgainstThisJITDylibFirst=true)
Set the link order to be used when fixing up definitions in JITDylib.
Definition: Core.cpp:1287
llvm::orc::ExecutionSession::callSPSWrapperAsync
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:1587
llvm::orc::DefinitionGenerator::~DefinitionGenerator
virtual ~DefinitionGenerator()
Definition: Core.cpp:612
llvm::orc::ExecutionSession::reportError
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:1474
llvm::orc::InProgressLookupState
Definition: Core.cpp:486
llvm::orc::ExecutionSession::callWrapperAsync
void callWrapperAsync(ArgTs &&... Args)
Run a wrapper function in the executor.
Definition: Core.h:1569
llvm::unique_function< void(Expected< SymbolMap >)>
llvm::orc::ExecutionSession::DispatchTaskFunction
unique_function< void(std::unique_ptr< Task > T)> DispatchTaskFunction
For dispatching ORC tasks (typically materialization tasks).
Definition: Core.h:1374
llvm::orc::MaterializationUnit::materialize
virtual void materialize(std::unique_ptr< MaterializationResponsibility > R)=0
Implementations of this method should materialize all symbols in the materialzation unit,...
llvm::orc::SymbolsCouldNotBeRemoved::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:120
llvm::orc::ResourceTrackerDefunct
Definition: Core.h:405
llvm::orc::JITDylib::addToLinkOrder
void addToLinkOrder(JITDylib &JD, JITDylibLookupFlags JDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Add the given JITDylib to the link order for definitions in this JITDylib.
Definition: Core.cpp:1302
llvm::orc::ExecutionSession::getJITDylibByName
JITDylib * getJITDylibByName(StringRef Name)
Return a pointer to the "name" JITDylib.
Definition: Core.cpp:1897
llvm::orc::LookupState::operator=
LookupState & operator=(LookupState &&)
llvm::orc::ResourceTrackerDefunct::ID
static char ID
Definition: Core.h:407
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::orc::JITDylib::dump
void dump(raw_ostream &OS)
Dump current JITDylib state to OS.
Definition: Core.cpp:1389
llvm::orc::JITDylib::getDefaultResourceTracker
ResourceTrackerSP getDefaultResourceTracker()
Get the default resource tracker for this JITDylib.
Definition: Core.cpp:633
llvm::orc::JITDylib::ExecutionSession
friend class ExecutionSession
Definition: Core.h:950
llvm::orc::AbsoluteSymbolsMaterializationUnit
A MaterializationUnit implementation for pre-existing absolute symbols.
Definition: Core.h:732
llvm::orc::ResourceTrackerDefunct::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:74
llvm::orc::SymbolAliasMapEntry::SymbolAliasMapEntry
SymbolAliasMapEntry(SymbolStringPtr Aliasee, JITSymbolFlags AliasFlags)
Definition: Core.h:384
llvm::orc::MaterializationResponsibility::notifyResolved
Error notifyResolved(const SymbolMap &Symbols)
Notifies the target JITDylib that the given symbols have been resolved.
Definition: Core.h:1915
llvm::orc::MaterializationUnit::doDiscard
void doDiscard(const JITDylib &JD, const SymbolStringPtr &Name)
Called by JITDylibs to notify MaterializationUnits that the given symbol has been overridden.
Definition: Core.h:709
llvm::orc::ExecutionSession::removeJITDylib
Error removeJITDylib(JITDylib &JD)
Closes the given JITDylib.
Definition: Core.cpp:1922
llvm::orc::SymbolLookupSet
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:175
llvm::orc::Platform::~Platform
virtual ~Platform()
Definition: Core.cpp:1754
llvm::orc::LookupKind::Static
@ Static
llvm::orc::SymbolsCouldNotBeRemoved::getSymbols
const SymbolNameSet & getSymbols() const
Definition: Core.h:460
llvm::orc::SymbolStringPtr
Pointer to a pooled string representing a symbol name.
Definition: SymbolStringPool.h:50
llvm::orc::ReExportsMaterializationUnit::getName
StringRef getName() const override
Return the name of this materialization unit.
Definition: Core.cpp:279
llvm::orc::MaterializationResponsibility::defineNonExistent
void defineNonExistent(ArrayRef< SymbolStringPtr > Symbols)
Define the given symbols as non-existent, removing it from the symbol table and notifying any pending...
llvm::orc::shared::WrapperFunction
Definition: WrapperFunctionUtils.h:434
llvm::orc::ResourceManager::~ResourceManager
virtual ~ResourceManager()
Definition: Core.cpp:65
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::orc::JITDylib::clear
Error clear()
Calls remove on all trackers currently associated with this JITDylib.
Definition: Core.cpp:618
llvm::orc::ExecutionSession::ResourceTracker
friend class ResourceTracker
Definition: Core.h:1364
llvm::orc::UnexpectedSymbolDefinitions::UnexpectedSymbolDefinitions
UnexpectedSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
Definition: Core.h:498
llvm::orc::ReExportsMaterializationUnit
A materialization unit for symbol aliases.
Definition: Core.h:764
llvm::DenseMapBase::erase
bool erase(const KeyT &Val)
Definition: DenseMap.h:302
llvm::orc::SymbolsCouldNotBeRemoved
Used to notify clients that a set of symbols could not be removed.
Definition: Core.h:451
WrapperFunctionUtils.h
llvm::orc::FailedToMaterialize::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:84
llvm::orc::SymbolsNotFound::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:442
llvm::orc::LookupState::~LookupState
~LookupState()
llvm::orc::ExecutorProcessControl
ExecutorProcessControl supports interaction with a JIT target process.
Definition: ExecutorProcessControl.h:38
llvm::orc::SymbolState::Invalid
@ Invalid
llvm::orc::ResourceTracker
API to remove / transfer ownership of JIT resources.
Definition: Core.h:53
llvm::orc::JITDylib::~JITDylib
~JITDylib()
Definition: Core.cpp:614
llvm::orc::SymbolLookupSet::end
const_iterator end() const
Definition: Core.h:255
llvm::orc::MaterializationResponsibility::defineMaterializing
Error defineMaterializing(SymbolFlagsMap SymbolFlags)
Attempt to claim responsibility for new definitions.
Definition: Core.h:1924
llvm::orc::ExecutionSession::registerResourceManager
void registerResourceManager(ResourceManager &RM)
Register the given ResourceManager with this ExecutionSession.
Definition: Core.cpp:1880
llvm::orc::MaterializationTask::run
void run() override
Definition: Core.cpp:1853
llvm::DenseMapBase::count
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:145
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::orc::MaterializationUnit::Interface::InitSymbol
SymbolStringPtr InitSymbol
Definition: Core.h:683
llvm::orc::SymbolsCouldNotBeRemoved::SymbolsCouldNotBeRemoved
SymbolsCouldNotBeRemoved(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
Definition: Core.cpp:114
llvm::orc::FailedToMaterialize::getSymbols
const SymbolDependenceMap & getSymbols() const
Definition: Core.h:426
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:894
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::orc::LookupState::continueLookup
void continueLookup(Error Err)
Continue the lookup.
Definition: Core.cpp:606
llvm::orc::UnexpectedSymbolDefinitions::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:504
llvm::orc::Platform::lookupInitSymbolsAsync
static void lookupInitSymbolsAsync(unique_function< void(Error)> OnComplete, ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
Performs an async lookup for the the given symbols in each of the given JITDylibs,...
Definition: Core.cpp:1805
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::orc::UnexpectedSymbolDefinitions
Errors of this type should be returned if a module contains definitions for symbols that are not clai...
Definition: Core.h:494
llvm::orc::SymbolsNotFound::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:106
llvm::orc::SymbolsCouldNotBeRemoved::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:459
IntrusiveRefCntPtr.h
llvm::orc::LookupKind
LookupKind
Describes the kind of lookup being performed.
Definition: Core.h:149
ExtensibleRTTI.h
llvm::JITSymbolFlags
Flags for symbols in the JIT.
Definition: JITSymbol.h:74
llvm::MachO::SymbolFlags
SymbolFlags
Symbol flags.
Definition: Symbol.h:25
llvm::orc::MaterializationUnit
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Definition: Core.h:666
llvm::orc::ExecutionSession::runJITDispatchHandler
void runJITDispatchHandler(SendResultFunction SendResult, JITTargetAddress HandlerFnTagAddr, ArrayRef< char > ArgBuffer)
Run a registered jit-side wrapper function.
Definition: Core.cpp:2179
llvm::orc::ExecutionSession::dispatchTask
void dispatchTask(std::unique_ptr< Task > T)
Materialize the given unit.
Definition: Core.h:1553
llvm::orc::ExecutionSession::JITDylib
friend class JITDylib
Definition: Core.h:1361
llvm::orc::SymbolLookupSet::sortByName
void sortByName()
Sort the lookup set lexicographically.
Definition: Core.h:350
llvm::orc::MissingSymbolDefinitions::getModuleName
const std::string & getModuleName() const
Definition: Core.h:482
llvm::JITEvaluatedSymbol
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:229
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::orc::JITDylib::createResourceTracker
ResourceTrackerSP createResourceTracker()
Create a resource tracker for this JITDylib.
Definition: Core.cpp:642
llvm::orc::buildSimpleReexportsAliasMap
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 ...
llvm::orc::FailedToMaterialize::ID
static char ID
Definition: Core.h:421
llvm::orc::MaterializationUnit::getName
virtual StringRef getName() const =0
Return the name of this materialization unit.
llvm::orc::Platform::notifyRemoving
virtual Error notifyRemoving(ResourceTracker &RT)=0
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::Lock
static sys::Mutex Lock
Definition: NVPTXUtilities.cpp:39
llvm::orc::RegisterDependenciesFunction
std::function< void(const SymbolDependenceMap &)> RegisterDependenciesFunction
Callback to register the dependencies for a given query.
Definition: Core.h:399
llvm::orc::JITDylib::replaceInLinkOrder
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:1306
llvm::orc::JITDylib::JITDylib
JITDylib(const JITDylib &)=delete
llvm::orc::ExecutionSession::SendResultFunction
unique_function< void(shared::WrapperFunctionResult)> SendResultFunction
Send a result to the remote.
Definition: Core.h:1371
llvm::orc::ResourceTracker::getJITDylib
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
Definition: Core.h:68
llvm::orc::ExecutionSession::dump
void dump(raw_ostream &OS)
Dump the state of all the JITDylibs in this session.
Definition: Core.cpp:2200
LHS
Value * LHS
Definition: X86PartialReduction.cpp:73
llvm::orc::ExecutionSession::registerJITDispatchHandlers
Error registerJITDispatchHandlers(JITDylib &JD, JITDispatchHandlerAssociationMap WFs)
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of...
Definition: Core.cpp:2148
llvm::orc::SymbolLookupSet::SymbolLookupSet
SymbolLookupSet(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Definition: Core.h:184
llvm::orc::SymbolState
SymbolState
Represents the state that a symbol has reached during materialization.
Definition: Core.h:825
DEBUG_WITH_TYPE
#define DEBUG_WITH_TYPE(TYPE, X)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
Definition: Debug.h:64
llvm::orc::SymbolLookupSet::SymbolLookupSet
SymbolLookupSet(std::initializer_list< SymbolStringPtr > Names, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Construct a SymbolLookupSet from an initializer list of SymbolStringPtrs.
Definition: Core.h:191
llvm::orc::MissingSymbolDefinitions::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:132
llvm::orc::SymbolLookupFlags
SymbolLookupFlags
Lookup flags that apply to each symbol in a lookup.
Definition: Core.h:137
llvm::orc::MaterializationResponsibility::getSymbols
const SymbolFlagsMap & getSymbols() const
Returns the symbol flags map for this responsibility instance.
Definition: Core.h:548
llvm::orc::SymbolLookupSet::forEachWithRemoval
auto forEachWithRemoval(BodyFn &&Body) -> std::enable_if_t< std::is_same< decltype(Body(std::declval< const SymbolStringPtr & >(), std::declval< SymbolLookupFlags >())), bool >::value >
Loop over the elements of this SymbolLookupSet, applying the Body function to each one.
Definition: Core.h:287
llvm::orc::UnexpectedSymbolDefinitions::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:141
llvm::orc::UnexpectedSymbolDefinitions::getModuleName
const std::string & getModuleName() const
Definition: Core.h:505
llvm::orc::Platform::setupJITDylib
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...
llvm::orc::SymbolLookupSet::end
iterator end()
Definition: Core.h:253
llvm::orc::Platform::lookupInitSymbols
static Expected< DenseMap< JITDylib *, SymbolMap > > lookupInitSymbols(ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
A utility function for looking up initializer symbols.
Definition: Core.cpp:1756
llvm::orc::SymbolLookupSet::containsDuplicates
bool containsDuplicates()
Returns true if this set contains any duplicates.
Definition: Core.h:367
llvm::orc::SymbolsNotFound
Used to notify clients when symbols can not be found during a lookup.
Definition: Core.h:433
llvm::orc::Platform::notifyAdding
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...
llvm::orc::UnexpectedSymbolDefinitions::ID
static char ID
Definition: Core.h:496
llvm::orc::SymbolLookupSet::remove
void remove(iterator I)
Removes the element pointed to by the given iterator.
Definition: Core.h:265
llvm::orc::SymbolLookupSet::SymbolLookupSet
SymbolLookupSet(ArrayRef< SymbolStringPtr > Names, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Construct a SymbolLookupSet from a vector of symbols with the given Flags used for each value.
Definition: Core.h:213
llvm::orc::NoDependenciesToRegister
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition: Core.cpp:34
llvm::orc::AsynchronousSymbolQuery::JITSymbolResolverAdapter
friend class JITSymbolResolverAdapter
Definition: Core.h:842
llvm::orc::MaterializationResponsibility::notifyEmitted
Error notifyEmitted()
Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by t...
Definition: Core.h:1920
DenseSet.h
false
Definition: StackSlotColoring.cpp:142
llvm::orc::SymbolMap
DenseMap< SymbolStringPtr, JITEvaluatedSymbol > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
Definition: Core.h:113
llvm::orc::MaterializationResponsibility::addDependenciesForAll
void addDependenciesForAll(const SymbolDependenceMap &Dependencies)
Add dependencies that apply to all symbols covered by this instance.
Definition: Core.h:1949
llvm::orc::SymbolLookupSet::SymbolLookupSet
SymbolLookupSet(const SymbolNameSet &Names, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Construct a SymbolLookupSet from a SymbolNameSet with the given Flags used for each value.
Definition: Core.h:201
llvm::orc::ExecutionSession::intern
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition: Core.h:1405
llvm::detail::DenseSetImpl::size
size_type size() const
Definition: DenseSet.h:81
llvm::ThreadSafeRefCountedBase
A thread-safe version of RefCountedBase.
Definition: IntrusiveRefCntPtr.h:101
llvm::orc::MaterializationUnit::~MaterializationUnit
virtual ~MaterializationUnit()
Definition: Core.h:689
llvm::orc::JITDylib::addGenerator
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition: Core.h:1778
llvm::orc::AsynchronousSymbolQuery
A symbol query that returns results via a callback when results are ready.
Definition: Core.h:838
llvm::orc::ExecutionSession::runSessionLocked
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Definition: Core.h:1415
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::orc::LookupKind::DLSym
@ DLSym
llvm::orc::MaterializationUnit::Interface
Definition: Core.h:673
llvm::orc::SymbolLookupSet::add
SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Add an element to the set.
Definition: Core.h:236
llvm::orc::AbsoluteSymbolsMaterializationUnit::getName
StringRef getName() const override
Return the name of this materialization unit.
Definition: Core.cpp:248
llvm::orc::MaterializationResponsibility::operator=
MaterializationResponsibility & operator=(MaterializationResponsibility &&)=delete
llvm::orc::FailedToMaterialize::FailedToMaterialize
FailedToMaterialize(std::shared_ptr< SymbolDependenceMap > Symbols)
Definition: Core.cpp:78
llvm::orc::SymbolsNotFound::ID
static char ID
Definition: Core.h:435
llvm::RTTIExtends
Inheritance utility for extensible RTTI.
Definition: ExtensibleRTTI.h:65
llvm::orc::ExecutionSession::setPlatform
void setPlatform(std::unique_ptr< Platform > P)
Set the Platform for this ExecutionSession.
Definition: Core.h:1408
llvm::orc::SymbolLookupFlags::WeaklyReferencedSymbol
@ WeaklyReferencedSymbol
llvm::orc::SymbolsNotFound::SymbolsNotFound
SymbolsNotFound(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
Definition: Core.cpp:92
llvm::orc::SymbolLookupSet::remove
void remove(UnderlyingVector::size_type I)
Removes the Ith element of the vector, replacing it with the last element.
Definition: Core.h:258
llvm::orc::MaterializationResponsibility::getRequestedSymbols
SymbolNameSet getRequestedSymbols() const
Returns the names of any symbols covered by this MaterializationResponsibility object that have queri...
Definition: Core.h:1911
llvm::orc::UnexpectedSymbolDefinitions::getSymbols
const SymbolNameVector & getSymbols() const
Definition: Core.h:506
llvm::orc::ExecutionSession::createBareJITDylib
JITDylib & createBareJITDylib(std::string Name)
Add a new bare JITDylib to this ExecutionSession.
Definition: Core.cpp:1906
llvm::orc::ExecutionSession::endSession
Error endSession()
End the session.
Definition: Core.cpp:1861
llvm::orc::SymbolLookupSet::size
UnderlyingVector::size_type size() const
Definition: Core.h:251
llvm::orc::MaterializationResponsibility::getInitializerSymbol
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
Definition: Core.h:553
llvm::orc::MaterializationResponsibility::withResourceKeyDo
Error withResourceKeyDo(Func &&F) const
Returns the ResourceTracker for this instance.
Definition: Core.h:1768
llvm::orc::MaterializationTask::printDescription
void printDescription(raw_ostream &OS) override
Definition: Core.cpp:1848
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::DenseSet< SymbolStringPtr >
llvm::orc::InProgressLookupFlagsState
Definition: Core.cpp:511
llvm::orc::ExecutionSession::callWrapper
shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Definition: Core.h:1579
llvm::orc::shared::WrapperFunctionResult
C++ wrapper function result: Same as CWrapperFunctionResult but auto-releases memory.
Definition: WrapperFunctionUtils.h:40
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:206
llvm::orc::ExecutionSession::JITDispatchHandlerAssociationMap
DenseMap< SymbolStringPtr, JITDispatchHandlerFunction > JITDispatchHandlerAssociationMap
A map associating tag names with asynchronous wrapper function implementations in the JIT.
Definition: Core.h:1385
llvm::orc::MissingSymbolDefinitions
Errors of this type should be returned if a module fails to include definitions that are claimed by t...
Definition: Core.h:471
llvm::orc::JITDylib::MaterializationResponsibility
friend class MaterializationResponsibility
Definition: Core.h:952
llvm::orc::MaterializationResponsibility::getTargetJITDylib
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition: Core.h:539
llvm::orc::SymbolLookupSet::value_type
std::pair< SymbolStringPtr, SymbolLookupFlags > value_type
Definition: Core.h:177
llvm::orc::ExecutionSession::setDispatchTask
ExecutionSession & setDispatchTask(DispatchTaskFunction DispatchTask)
Set the task dispatch function.
Definition: Core.h:1477
llvm::orc::MissingSymbolDefinitions::MissingSymbolDefinitions
MissingSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
Definition: Core.h:475
llvm::orc::SymbolLookupSet::append
SymbolLookupSet & append(SymbolLookupSet Other)
Quickly append one lookup set to another.
Definition: Core.h:243
llvm::orc::MaterializationUnit::getInitializerSymbol
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
Definition: Core.h:699
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
llvm::orc::ExecutionSession::lookupFlags
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:2013
llvm::orc::ResourceTracker::isDefunct
bool isDefunct() const
Return true if this tracker has become defunct.
Definition: Core.h:81
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::DenseMap< SymbolStringPtr, JITEvaluatedSymbol >
llvm::orc::ExecutionSession::wrapAsyncWithSPS
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:1631
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::orc::MaterializationUnit::getSymbols
const SymbolFlagsMap & getSymbols() const
Return the set of symbols that this source provides.
Definition: Core.h:696
llvm::orc::SymbolLookupSet::forEachWithRemoval
auto forEachWithRemoval(BodyFn &&Body) -> std::enable_if_t< std::is_same< decltype(Body(std::declval< const SymbolStringPtr & >(), std::declval< SymbolLookupFlags >())), Expected< bool >>::value, Error >
Loop over the elements of this SymbolLookupSet, applying the Body function to each one.
Definition: Core.h:309
llvm::orc::MaterializationResponsibility::addDependencies
void addDependencies(const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies)
Definition: Core.h:1944
llvm::orc::SymbolState::NeverSearched
@ NeverSearched
No symbol should be in this state.
llvm::orc::ResourceTrackerSP
uint8_t IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
Definition: Core.h:47
llvm::orc::ExecutionSession::JITDispatchHandlerFunction
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:1380
llvm::orc::ReexportsGenerator::ReexportsGenerator
ReexportsGenerator(JITDylib &SourceJD, JITDylibLookupFlags SourceJDLookupFlags, SymbolPredicate Allow=SymbolPredicate())
Create a reexports generator.
Definition: Core.cpp:565
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::orc::AbsoluteSymbolsMaterializationUnit::AbsoluteSymbolsMaterializationUnit
AbsoluteSymbolsMaterializationUnit(SymbolMap Symbols)
Definition: Core.cpp:244
llvm::move
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:1707
llvm::orc::ResourceTracker::getKeyUnsafe
ResourceKey getKeyUnsafe() const
Returns the key associated with this tracker.
Definition: Core.h:86
llvm::orc::JITDylib::AsynchronousSymbolQuery
friend class AsynchronousSymbolQuery
Definition: Core.h:949
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:840
llvm::orc::ExecutionSession::ExecutionSession
ExecutionSession(std::unique_ptr< ExecutorProcessControl > EPC)
Construct an ExecutionSession with the given ExecutorProcessControl object.
Definition: Core.cpp:1855
llvm::orc::MaterializationUnit::MaterializationUnit
MaterializationUnit(Interface I)
Definition: Core.h:686
llvm::orc::SymbolAliasMapEntry::SymbolAliasMapEntry
SymbolAliasMapEntry()=default
llvm::orc::ExecutionSession::callSPSWrapper
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: Core.h:1599
llvm::orc::JITDylib::remove
Error remove(const SymbolNameSet &Names)
Tries to remove the given symbols.
Definition: Core.cpp:1330
llvm::orc::SymbolLookupSet::begin
const_iterator begin() const
Definition: Core.h:254
llvm::orc::MaterializationResponsibility::JITDylib
friend class JITDylib
Definition: Core.h:522
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::orc::MaterializationUnit::Interface::Interface
Interface(SymbolFlagsMap InitalSymbolFlags, SymbolStringPtr InitSymbol)
Definition: Core.h:675
llvm::orc::SymbolLookupSet::empty
bool empty() const
Definition: Core.h:250
llvm::orc::JITDylibSearchOrder
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:154
llvm::orc::ResourceManager::handleRemoveResources
virtual Error handleRemoveResources(ResourceKey K)=0
llvm::orc::JITDylib::getReverseDFSLinkOrder
std::vector< JITDylibSP > getReverseDFSLinkOrder()
Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationsh...
Definition: Core.cpp:2009
llvm::orc::DefinitionGenerator
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
Definition: Core.h:912
llvm::orc::ExecutionSession::getExecutorProcessControl
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1397
llvm::ErrorInfo
Base class for user error types.
Definition: Error.h:349
llvm::orc::JITDylib::operator=
JITDylib & operator=(const JITDylib &)=delete
llvm::orc::MaterializationResponsibility::getExecutionSession
ExecutionSession & getExecutionSession() const
Returns the ExecutionSession for this instance.
Definition: Core.h:1763
llvm::orc::SymbolAliasMapEntry::Aliasee
SymbolStringPtr Aliasee
Definition: Core.h:387
llvm::orc::MaterializationUnit::Interface::Interface
Interface()=default
llvm::orc::reexports
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:812
llvm::orc::ExecutionSession::deregisterResourceManager
void deregisterResourceManager(ResourceManager &RM)
Deregister the given ResourceManager with this ExecutionSession.
Definition: Core.cpp:1884
llvm::orc::ResourceManager::handleTransferResources
virtual void handleTransferResources(ResourceKey DstK, ResourceKey SrcK)=0
llvm::sys::fs::remove
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
llvm::AArch64::RM
@ RM
Definition: AArch64ISelLowering.h:480
llvm::orc::SymbolLookupSet::SymbolLookupSet
SymbolLookupSet()=default
llvm::orc::MaterializationResponsibility::~MaterializationResponsibility
~MaterializationResponsibility()
Destruct a MaterializationResponsibility instance.
Definition: Core.h:1907
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::orc::ExecutionSession::MaterializationResponsibility
friend class MaterializationResponsibility
Definition: Core.h:1363
llvm::orc::ReexportsGenerator::SymbolPredicate
std::function< bool(SymbolStringPtr)> SymbolPredicate
Definition: Core.h:1884
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::orc::Platform
Platforms set up standard symbols and mediate interactions between dynamic initializers (e....
Definition: Core.h:1302
llvm::orc::SymbolState::Ready
@ Ready
Emitted to memory, but waiting on transitive dependencies.
BitmaskEnum.h
llvm::orc::SymbolLookupSet::begin
iterator begin()
Definition: Core.h:252
llvm::orc::Platform::teardownJITDylib
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...
llvm::orc::MaterializationResponsibility::MaterializationResponsibility
MaterializationResponsibility(MaterializationResponsibility &&)=delete
llvm::orc::LookupState
Wraps state for a lookup-in-progress.
Definition: Core.h:887
llvm::orc::JITDylib::getDFSLinkOrder
std::vector< JITDylibSP > getDFSLinkOrder()
Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships.
Definition: Core.cpp:2005
llvm::orc::SymbolLookupSet::iterator
UnderlyingVector::iterator iterator
Definition: Core.h:179
llvm::orc::MaterializationUnit::ID
static char ID
Definition: Core.h:671
llvm::orc::SymbolLookupSet::getSymbolNames
SymbolNameVector getSymbolNames() const
Construct a SymbolNameVector from this instance by dropping the Flags values.
Definition: Core.h:331
llvm::orc::SymbolLookupSet::sortByAddress
void sortByAddress()
Sort the lookup set by pointer value.
Definition: Core.h:342
llvm::orc::SymbolAliasMapEntry
Definition: Core.h:382
llvm::orc::InProgressFullLookupState
Definition: Core.cpp:535
llvm::orc::ExecutionSession::createJITDylib
Expected< JITDylib & > createJITDylib(std::string Name)
Add a new JITDylib to this ExecutionSession.
Definition: Core.cpp:1914
llvm::orc::SymbolDependenceMap
DenseMap< JITDylib *, SymbolNameSet > SymbolDependenceMap
A map from JITDylibs to sets of symbols.
Definition: Core.h:119
llvm::orc::ResourceTrackerDefunct::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:70
llvm::orc::SymbolFlagsMap
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
Definition: Core.h:116
llvm::DenseMapBase::empty
LLVM_NODISCARD bool empty() const
Definition: DenseMap.h:97
llvm::logAllUnhandledErrors
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
Definition: Error.cpp:61
llvm::orc::AsynchronousSymbolQuery::AsynchronousSymbolQuery
AsynchronousSymbolQuery(const SymbolLookupSet &Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete)
Create a query for the given symbols.
Definition: Core.cpp:146
llvm::orc::ResourceManager
Listens for ResourceTracker operations.
Definition: Core.h:97
llvm::orc::ExecutionSession::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Get the SymbolStringPool for this instance.
Definition: Core.h:1400
llvm::orc::MaterializationResponsibility::failMaterialization
void failMaterialization()
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has o...
Definition: Core.h:1930
llvm::orc::ReexportsGenerator
ReexportsGenerator can be used with JITDylib::addGenerator to automatically re-export a subset of the...
Definition: Core.h:1882
llvm::orc::ExecutionSession::getPlatform
Platform * getPlatform()
Get the Platform for this session.
Definition: Core.h:1412
llvm::orc::ExecutionSession::ErrorReporter
std::function< void(Error)> ErrorReporter
For reporting errors.
Definition: Core.h:1368
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
H
#define H(x, y, z)
Definition: MD5.cpp:57
llvm::orc::SymbolLookupSet::const_iterator
UnderlyingVector::const_iterator const_iterator
Definition: Core.h:180
llvm::orc::JITDylib::removeFromLinkOrder
void removeFromLinkOrder(JITDylib &JD)
Remove the given JITDylib from the link order for this JITDylib if it is present.
Definition: Core.cpp:1318
getFlags
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:23
llvm::orc::OrcV2CAPIHelper
Definition: OrcV2CBindings.cpp:28
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::orc::MissingSymbolDefinitions::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:481
llvm::orc::DefinitionGenerator::tryToGenerate
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.
llvm::orc::SymbolLookupSet::removeDuplicates
void removeDuplicates()
Remove any duplicate elements.
Definition: Core.h:358
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1358
llvm::orc::JITDylibLookupFlags::MatchExportedSymbolsOnly
@ MatchExportedSymbolsOnly
llvm::AArch64CC::LS
@ LS
Definition: AArch64BaseInfo.h:264
llvm::orc::FailedToMaterialize
Used to notify a JITDylib that the given set of symbols failed to materialize.
Definition: Core.h:419
llvm::orc::MissingSymbolDefinitions::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:128
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1590
llvm::orc::symbolAliases
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition: Core.h:803
llvm::unique
auto unique(Range &&R, Predicate P)
Definition: STLExtras.h:1802
llvm::orc::absoluteSymbols
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
Definition: Core.h:757
llvm::orc::FailedToMaterialize::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:88
llvm::JITTargetAddress
uint64_t JITTargetAddress
Represents an address in the target process's address space.
Definition: JITSymbol.h:42
llvm::orc::SymbolsNotFound::getSymbols
const SymbolNameVector & getSymbols() const
Definition: Core.h:443
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:83
llvm::orc::ResourceTrackerDefunct::ResourceTrackerDefunct
ResourceTrackerDefunct(ResourceTrackerSP RT)
Definition: Core.cpp:67
llvm::orc::MaterializationResponsibility::delegate
Expected< std::unique_ptr< MaterializationResponsibility > > delegate(const SymbolNameSet &Symbols)
Delegates responsibility for the given symbols to the returned materialization responsibility.
Definition: Core.h:1940
JITLinkDylib.h
llvm::orc::JITDylib::define
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:1795
llvm::orc::SymbolAliasMapEntry::AliasFlags
JITSymbolFlags AliasFlags
Definition: Core.h:388
llvm::orc::ExecutionSession::lookup
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:2039
llvm::orc::AsynchronousSymbolQuery::JITDylib
friend class JITDylib
Definition: Core.h:841
llvm::orc::JITDylib::getExecutionSession
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
Definition: Core.h:967
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:163
TaskDispatch.h
llvm::orc::MissingSymbolDefinitions::getSymbols
const SymbolNameVector & getSymbols() const
Definition: Core.h:483
llvm::orc::MissingSymbolDefinitions::ID
static char ID
Definition: Core.h:473
llvm::orc::MaterializationUnit::Interface::SymbolFlags
SymbolFlagsMap SymbolFlags
Definition: Core.h:682
llvm::orc::SymbolState::Emitted
@ Emitted
Assigned address, still materializing.
ExecutorProcessControl.h
llvm::orc::SymbolNameSet
DenseSet< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
Definition: Core.h:106
llvm::orc::JITDylibLookupFlags
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition: Core.h:127
llvm::orc::SymbolState::Resolved
@ Resolved
Queried, materialization begun.
llvm::orc::ExecutionSession::wrapAsyncWithSPS
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:1613
llvm::orc::MaterializationTask::ID
static char ID
Definition: Core.h:1344
llvm::orc::ReExportsMaterializationUnit::ReExportsMaterializationUnit
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:273
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::orc::MaterializationUnit::SymbolFlags
SymbolFlagsMap SymbolFlags
Definition: Core.h:715
llvm::orc::UnexpectedSymbolDefinitions::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:137
llvm::orc::LookupState::LookupState
LookupState()
llvm::orc::JITDylibLookupFlags::MatchAllSymbols
@ MatchAllSymbols
llvm::orc::SymbolLookupFlags::RequiredSymbol
@ RequiredSymbol
llvm::orc::SymbolsResolvedCallback
unique_function< void(Expected< SymbolMap >)> SymbolsResolvedCallback
Callback to notify client that symbols have been resolved.
Definition: Core.h:395
llvm::orc::SymbolNameVector
std::vector< SymbolStringPtr > SymbolNameVector
A vector of symbol names.
Definition: Core.h:109
Debug.h
llvm::orc::ExecutionSession::setErrorReporter
ExecutionSession & setErrorReporter(ErrorReporter ReportError)
Set the error reporter function.
Definition: Core.h:1466
llvm::IntrusiveRefCntPtr
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
Definition: IntrusiveRefCntPtr.h:163
llvm::orc::makeJITDylibSearchOrder
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:158
llvm::orc::SymbolsCouldNotBeRemoved::ID
static char ID
Definition: Core.h:453
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1198
llvm::orc::AsynchronousSymbolQuery::isComplete
bool isComplete() const
Returns true if all symbols covered by this query have been resolved.
Definition: Core.h:859
llvm::orc::SymbolsCouldNotBeRemoved::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:124
llvm::orc::MaterializationUnit::InitSymbol
SymbolStringPtr InitSymbol
Definition: Core.h:716
llvm::orc::JITDylib::removeGenerator
void removeGenerator(DefinitionGenerator &G)
Remove a definition generator from this JITDylib.
Definition: Core.cpp:650