LLVM  16.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(
185  SymbolStringPtr Name,
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 (const 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 (const 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() { llvm::sort(Symbols, llvm::less_first()); }
343 
344  /// Sort the lookup set lexicographically. This sort is slow but the order
345  /// is unaffected by allocation order.
346  void sortByName() {
347  llvm::sort(Symbols, [](const value_type &LHS, const value_type &RHS) {
348  return *LHS.first < *RHS.first;
349  });
350  }
351 
352  /// Remove any duplicate elements. If a SymbolLookupSet is not duplicate-free
353  /// by construction, this method can be used to turn it into a proper set.
355  sortByAddress();
356  auto LastI = std::unique(Symbols.begin(), Symbols.end());
357  Symbols.erase(LastI, Symbols.end());
358  }
359 
360 #ifndef NDEBUG
361  /// Returns true if this set contains any duplicates. This should only be used
362  /// in assertions.
364  if (Symbols.size() < 2)
365  return false;
366  sortByAddress();
367  for (UnderlyingVector::size_type I = 1; I != Symbols.size(); ++I)
368  if (Symbols[I].first == Symbols[I - 1].first)
369  return true;
370  return false;
371  }
372 #endif
373 
374 private:
375  UnderlyingVector Symbols;
376 };
377 
379  SymbolAliasMapEntry() = default;
382 
385 };
386 
387 /// A map of Symbols to (Symbol, Flags) pairs.
389 
390 /// Callback to notify client that symbols have been resolved.
392 
393 /// Callback to register the dependencies for a given query.
396 
397 /// This can be used as the value for a RegisterDependenciesFunction if there
398 /// are no dependants to register with.
400 
401 class ResourceTrackerDefunct : public ErrorInfo<ResourceTrackerDefunct> {
402 public:
403  static char ID;
404 
406  std::error_code convertToErrorCode() const override;
407  void log(raw_ostream &OS) const override;
408 
409 private:
411 };
412 
413 /// Used to notify a JITDylib that the given set of symbols failed to
414 /// materialize.
415 class FailedToMaterialize : public ErrorInfo<FailedToMaterialize> {
416 public:
417  static char ID;
418 
419  FailedToMaterialize(std::shared_ptr<SymbolStringPool> SSP,
420  std::shared_ptr<SymbolDependenceMap> Symbols);
422  std::error_code convertToErrorCode() const override;
423  void log(raw_ostream &OS) const override;
424  const SymbolDependenceMap &getSymbols() const { return *Symbols; }
425 
426 private:
427  std::shared_ptr<SymbolStringPool> SSP;
428  std::shared_ptr<SymbolDependenceMap> Symbols;
429 };
430 
431 /// Used to notify clients when symbols can not be found during a lookup.
432 class SymbolsNotFound : public ErrorInfo<SymbolsNotFound> {
433 public:
434  static char ID;
435 
436  SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP, SymbolNameSet Symbols);
437  SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP,
438  SymbolNameVector Symbols);
439  std::error_code convertToErrorCode() const override;
440  void log(raw_ostream &OS) const override;
441  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
442  const SymbolNameVector &getSymbols() const { return Symbols; }
443 
444 private:
445  std::shared_ptr<SymbolStringPool> SSP;
446  SymbolNameVector Symbols;
447 };
448 
449 /// Used to notify clients that a set of symbols could not be removed.
450 class SymbolsCouldNotBeRemoved : public ErrorInfo<SymbolsCouldNotBeRemoved> {
451 public:
452  static char ID;
453 
454  SymbolsCouldNotBeRemoved(std::shared_ptr<SymbolStringPool> SSP,
455  SymbolNameSet Symbols);
456  std::error_code convertToErrorCode() const override;
457  void log(raw_ostream &OS) const override;
458  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
459  const SymbolNameSet &getSymbols() const { return Symbols; }
460 
461 private:
462  std::shared_ptr<SymbolStringPool> SSP;
463  SymbolNameSet Symbols;
464 };
465 
466 /// Errors of this type should be returned if a module fails to include
467 /// definitions that are claimed by the module's associated
468 /// MaterializationResponsibility. If this error is returned it is indicative of
469 /// a broken transformation / compiler / object cache.
470 class MissingSymbolDefinitions : public ErrorInfo<MissingSymbolDefinitions> {
471 public:
472  static char ID;
473 
474  MissingSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
475  std::string ModuleName, SymbolNameVector Symbols)
476  : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
477  Symbols(std::move(Symbols)) {}
478  std::error_code convertToErrorCode() const override;
479  void log(raw_ostream &OS) const override;
480  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
481  const std::string &getModuleName() const { return ModuleName; }
482  const SymbolNameVector &getSymbols() const { return Symbols; }
483 private:
484  std::shared_ptr<SymbolStringPool> SSP;
485  std::string ModuleName;
486  SymbolNameVector Symbols;
487 };
488 
489 /// Errors of this type should be returned if a module contains definitions for
490 /// symbols that are not claimed by the module's associated
491 /// MaterializationResponsibility. If this error is returned it is indicative of
492 /// a broken transformation / compiler / object cache.
493 class UnexpectedSymbolDefinitions : public ErrorInfo<UnexpectedSymbolDefinitions> {
494 public:
495  static char ID;
496 
497  UnexpectedSymbolDefinitions(std::shared_ptr<SymbolStringPool> SSP,
498  std::string ModuleName, SymbolNameVector Symbols)
499  : SSP(std::move(SSP)), ModuleName(std::move(ModuleName)),
500  Symbols(std::move(Symbols)) {}
501  std::error_code convertToErrorCode() const override;
502  void log(raw_ostream &OS) const override;
503  std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
504  const std::string &getModuleName() const { return ModuleName; }
505  const SymbolNameVector &getSymbols() const { return Symbols; }
506 private:
507  std::shared_ptr<SymbolStringPool> SSP;
508  std::string ModuleName;
509  SymbolNameVector Symbols;
510 };
511 
512 /// Tracks responsibility for materialization, and mediates interactions between
513 /// MaterializationUnits and JDs.
514 ///
515 /// An instance of this class is passed to MaterializationUnits when their
516 /// materialize method is called. It allows MaterializationUnits to resolve and
517 /// emit symbols, or abandon materialization by notifying any unmaterialized
518 /// symbols of an error.
520  friend class ExecutionSession;
521  friend class JITDylib;
522 
523 public:
527 
528  /// Destruct a MaterializationResponsibility instance. In debug mode
529  /// this asserts that all symbols being tracked have been either
530  /// emitted or notified of an error.
532 
533  /// Returns the ResourceTracker for this instance.
534  template <typename Func> Error withResourceKeyDo(Func &&F) const;
535 
536  /// Returns the target JITDylib that these symbols are being materialized
537  /// into.
538  JITDylib &getTargetJITDylib() const { return JD; }
539 
540  /// Returns the ExecutionSession for this instance.
542 
543  /// Returns the symbol flags map for this responsibility instance.
544  /// Note: The returned flags may have transient flags (Lazy, Materializing)
545  /// set. These should be stripped with JITSymbolFlags::stripTransientFlags
546  /// before using.
547  const SymbolFlagsMap &getSymbols() const { return SymbolFlags; }
548 
549  /// Returns the initialization pseudo-symbol, if any. This symbol will also
550  /// be present in the SymbolFlagsMap for this MaterializationResponsibility
551  /// object.
552  const SymbolStringPtr &getInitializerSymbol() const { return InitSymbol; }
553 
554  /// Returns the names of any symbols covered by this
555  /// MaterializationResponsibility object that have queries pending. This
556  /// information can be used to return responsibility for unrequested symbols
557  /// back to the JITDylib via the delegate method.
559 
560  /// Notifies the target JITDylib that the given symbols have been resolved.
561  /// This will update the given symbols' addresses in the JITDylib, and notify
562  /// any pending queries on the given symbols of their resolution. The given
563  /// symbols must be ones covered by this MaterializationResponsibility
564  /// instance. Individual calls to this method may resolve a subset of the
565  /// symbols, but all symbols must have been resolved prior to calling emit.
566  ///
567  /// This method will return an error if any symbols being resolved have been
568  /// moved to the error state due to the failure of a dependency. If this
569  /// method returns an error then clients should log it and call
570  /// failMaterialize. If no dependencies have been registered for the
571  /// symbols covered by this MaterializationResponsibiility then this method
572  /// is guaranteed to return Error::success() and can be wrapped with cantFail.
573  Error notifyResolved(const SymbolMap &Symbols);
574 
575  /// Notifies the target JITDylib (and any pending queries on that JITDylib)
576  /// that all symbols covered by this MaterializationResponsibility instance
577  /// have been emitted.
578  ///
579  /// This method will return an error if any symbols being resolved have been
580  /// moved to the error state due to the failure of a dependency. If this
581  /// method returns an error then clients should log it and call
582  /// failMaterialize. If no dependencies have been registered for the
583  /// symbols covered by this MaterializationResponsibiility then this method
584  /// is guaranteed to return Error::success() and can be wrapped with cantFail.
586 
587  /// Attempt to claim responsibility for new definitions. This method can be
588  /// used to claim responsibility for symbols that are added to a
589  /// materialization unit during the compilation process (e.g. literal pool
590  /// symbols). Symbol linkage rules are the same as for symbols that are
591  /// defined up front: duplicate strong definitions will result in errors.
592  /// Duplicate weak definitions will be discarded (in which case they will
593  /// not be added to this responsibility instance).
594  ///
595  /// This method can be used by materialization units that want to add
596  /// additional symbols at materialization time (e.g. stubs, compile
597  /// callbacks, metadata).
599 
600  /// Define the given symbols as non-existent, removing it from the symbol
601  /// table and notifying any pending queries. Queries that lookup up the
602  /// symbol using the SymbolLookupFlags::WeaklyReferencedSymbol flag will
603  /// behave as if the symbol had not been matched in the first place. Queries
604  /// that required this symbol will fail with a missing symbol definition
605  /// error.
606  ///
607  /// This method is intended to support cleanup of special symbols like
608  /// initializer symbols: Queries using
609  /// SymbolLookupFlags::WeaklyReferencedSymbol can be used to trigger their
610  /// emission, and this method can be used to remove them from the JITDylib
611  /// once materialization is complete.
613 
614  /// Notify all not-yet-emitted covered by this MaterializationResponsibility
615  /// instance that an error has occurred.
616  /// This will remove all symbols covered by this MaterializationResponsibilty
617  /// from the target JITDylib, and send an error to any queries waiting on
618  /// these symbols.
619  void failMaterialization();
620 
621  /// Transfers responsibility to the given MaterializationUnit for all
622  /// symbols defined by that MaterializationUnit. This allows
623  /// materializers to break up work based on run-time information (e.g.
624  /// by introspecting which symbols have actually been looked up and
625  /// materializing only those).
626  Error replace(std::unique_ptr<MaterializationUnit> MU);
627 
628  /// Delegates responsibility for the given symbols to the returned
629  /// materialization responsibility. Useful for breaking up work between
630  /// threads, or different kinds of materialization processes.
632  delegate(const SymbolNameSet &Symbols);
633 
635  const SymbolDependenceMap &Dependencies);
636 
637  /// Add dependencies that apply to all symbols covered by this instance.
638  void addDependenciesForAll(const SymbolDependenceMap &Dependencies);
639 
640 private:
641  /// Create a MaterializationResponsibility for the given JITDylib and
642  /// initial symbols.
645  SymbolStringPtr InitSymbol)
646  : JD(RT->getJITDylib()), RT(std::move(RT)),
647  SymbolFlags(std::move(SymbolFlags)), InitSymbol(std::move(InitSymbol)) {
648  assert(!this->SymbolFlags.empty() && "Materializing nothing?");
649  }
650 
651  JITDylib &JD;
654  SymbolStringPtr InitSymbol;
655 };
656 
657 /// A MaterializationUnit represents a set of symbol definitions that can
658 /// be materialized as a group, or individually discarded (when
659 /// overriding definitions are encountered).
660 ///
661 /// MaterializationUnits are used when providing lazy definitions of symbols to
662 /// JITDylibs. The JITDylib will call materialize when the address of a symbol
663 /// is requested via the lookup method. The JITDylib will call discard if a
664 /// stronger definition is added or already present.
666  friend class ExecutionSession;
667  friend class JITDylib;
668 
669 public:
670  static char ID;
671 
672  struct Interface {
673  Interface() = default;
675  : SymbolFlags(std::move(InitalSymbolFlags)),
677  assert((!this->InitSymbol || this->SymbolFlags.count(this->InitSymbol)) &&
678  "If set, InitSymbol should appear in InitialSymbolFlags map");
679  }
680 
683  };
684 
688  virtual ~MaterializationUnit() = default;
689 
690  /// Return the name of this materialization unit. Useful for debugging
691  /// output.
692  virtual StringRef getName() const = 0;
693 
694  /// Return the set of symbols that this source provides.
695  const SymbolFlagsMap &getSymbols() const { return SymbolFlags; }
696 
697  /// Returns the initialization symbol for this MaterializationUnit (if any).
699 
700  /// Implementations of this method should materialize all symbols
701  /// in the materialzation unit, except for those that have been
702  /// previously discarded.
703  virtual void
704  materialize(std::unique_ptr<MaterializationResponsibility> R) = 0;
705 
706  /// Called by JITDylibs to notify MaterializationUnits that the given symbol
707  /// has been overridden.
708  void doDiscard(const JITDylib &JD, const SymbolStringPtr &Name) {
709  SymbolFlags.erase(Name);
710  if (InitSymbol == Name) {
711  DEBUG_WITH_TYPE("orc", {
712  dbgs() << "In " << getName() << ": discarding init symbol \""
713  << *Name << "\"\n";
714  });
715  InitSymbol = nullptr;
716  }
717  discard(JD, std::move(Name));
718  }
719 
720 protected:
723 
724 private:
725  virtual void anchor();
726 
727  /// Implementations of this method should discard the given symbol
728  /// from the source (e.g. if the source is an LLVM IR Module and the
729  /// symbol is a function, delete the function body or mark it available
730  /// externally).
731  virtual void discard(const JITDylib &JD, const SymbolStringPtr &Name) = 0;
732 };
733 
734 /// A MaterializationUnit implementation for pre-existing absolute symbols.
735 ///
736 /// All symbols will be resolved and marked ready as soon as the unit is
737 /// materialized.
739 public:
741 
742  StringRef getName() const override;
743 
744 private:
745  void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
746  void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
747  static MaterializationUnit::Interface extractFlags(const SymbolMap &Symbols);
748 
749  SymbolMap Symbols;
750 };
751 
752 /// Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
753 /// Useful for inserting absolute symbols into a JITDylib. E.g.:
754 /// \code{.cpp}
755 /// JITDylib &JD = ...;
756 /// SymbolStringPtr Foo = ...;
757 /// JITEvaluatedSymbol FooSym = ...;
758 /// if (auto Err = JD.define(absoluteSymbols({{Foo, FooSym}})))
759 /// return Err;
760 /// \endcode
761 ///
762 inline std::unique_ptr<AbsoluteSymbolsMaterializationUnit>
764  return std::make_unique<AbsoluteSymbolsMaterializationUnit>(
765  std::move(Symbols));
766 }
767 
768 /// A materialization unit for symbol aliases. Allows existing symbols to be
769 /// aliased with alternate flags.
771 public:
772  /// SourceJD is allowed to be nullptr, in which case the source JITDylib is
773  /// taken to be whatever JITDylib these definitions are materialized in (and
774  /// MatchNonExported has no effect). This is useful for defining aliases
775  /// within a JITDylib.
776  ///
777  /// Note: Care must be taken that no sets of aliases form a cycle, as such
778  /// a cycle will result in a deadlock when any symbol in the cycle is
779  /// resolved.
781  JITDylibLookupFlags SourceJDLookupFlags,
782  SymbolAliasMap Aliases);
783 
784  StringRef getName() const override;
785 
786 private:
787  void materialize(std::unique_ptr<MaterializationResponsibility> R) override;
788  void discard(const JITDylib &JD, const SymbolStringPtr &Name) override;
790  extractFlags(const SymbolAliasMap &Aliases);
791 
792  JITDylib *SourceJD = nullptr;
793  JITDylibLookupFlags SourceJDLookupFlags;
794  SymbolAliasMap Aliases;
795 };
796 
797 /// Create a ReExportsMaterializationUnit with the given aliases.
798 /// Useful for defining symbol aliases.: E.g., given a JITDylib JD containing
799 /// symbols "foo" and "bar", we can define aliases "baz" (for "foo") and "qux"
800 /// (for "bar") with: \code{.cpp}
801 /// SymbolStringPtr Baz = ...;
802 /// SymbolStringPtr Qux = ...;
803 /// if (auto Err = JD.define(symbolAliases({
804 /// {Baz, { Foo, JITSymbolFlags::Exported }},
805 /// {Qux, { Bar, JITSymbolFlags::Weak }}}))
806 /// return Err;
807 /// \endcode
808 inline std::unique_ptr<ReExportsMaterializationUnit>
810  return std::make_unique<ReExportsMaterializationUnit>(
812 }
813 
814 /// Create a materialization unit for re-exporting symbols from another JITDylib
815 /// with alternative names/flags.
816 /// SourceJD will be searched using the given JITDylibLookupFlags.
817 inline std::unique_ptr<ReExportsMaterializationUnit>
818 reexports(JITDylib &SourceJD, SymbolAliasMap Aliases,
819  JITDylibLookupFlags SourceJDLookupFlags =
821  return std::make_unique<ReExportsMaterializationUnit>(
822  &SourceJD, SourceJDLookupFlags, std::move(Aliases));
823 }
824 
825 /// Build a SymbolAliasMap for the common case where you want to re-export
826 /// symbols from another JITDylib with the same linkage/flags.
828 buildSimpleReexportsAliasMap(JITDylib &SourceJD, const SymbolNameSet &Symbols);
829 
830 /// Represents the state that a symbol has reached during materialization.
831 enum class SymbolState : uint8_t {
832  Invalid, /// No symbol should be in this state.
833  NeverSearched, /// Added to the symbol table, never queried.
834  Materializing, /// Queried, materialization begun.
835  Resolved, /// Assigned address, still materializing.
836  Emitted, /// Emitted to memory, but waiting on transitive dependencies.
837  Ready = 0x3f /// Ready and safe for clients to access.
838 };
839 
840 /// A symbol query that returns results via a callback when results are
841 /// ready.
842 ///
843 /// makes a callback when all symbols are available.
845  friend class ExecutionSession;
847  friend class JITDylib;
850 
851 public:
852  /// Create a query for the given symbols. The NotifyComplete
853  /// callback will be called once all queried symbols reach the given
854  /// minimum state.
856  SymbolState RequiredState,
857  SymbolsResolvedCallback NotifyComplete);
858 
859  /// Notify the query that a requested symbol has reached the required state.
861  JITEvaluatedSymbol Sym);
862 
863  /// Returns true if all symbols covered by this query have been
864  /// resolved.
865  bool isComplete() const { return OutstandingSymbolsCount == 0; }
866 
867 
868 private:
869  void handleComplete(ExecutionSession &ES);
870 
871  SymbolState getRequiredState() { return RequiredState; }
872 
873  void addQueryDependence(JITDylib &JD, SymbolStringPtr Name);
874 
875  void removeQueryDependence(JITDylib &JD, const SymbolStringPtr &Name);
876 
877  void dropSymbol(const SymbolStringPtr &Name);
878 
879  void handleFailed(Error Err);
880 
881  void detach();
882 
883  SymbolsResolvedCallback NotifyComplete;
884  SymbolDependenceMap QueryRegistrations;
885  SymbolMap ResolvedSymbols;
886  size_t OutstandingSymbolsCount;
887  SymbolState RequiredState;
888 };
889 
890 /// Wraps state for a lookup-in-progress.
891 /// DefinitionGenerators can optionally take ownership of a LookupState object
892 /// to suspend a lookup-in-progress while they search for definitions.
893 class LookupState {
894  friend class OrcV2CAPIHelper;
895  friend class ExecutionSession;
896 
897 public:
898  LookupState();
901  ~LookupState();
902 
903  /// Continue the lookup. This can be called by DefinitionGenerators
904  /// to re-start a captured query-application operation.
905  void continueLookup(Error Err);
906 
907 private:
908  LookupState(std::unique_ptr<InProgressLookupState> IPLS);
909 
910  // For C API.
911  void reset(InProgressLookupState *IPLS);
912 
913  std::unique_ptr<InProgressLookupState> IPLS;
914 };
915 
916 /// Definition generators can be attached to JITDylibs to generate new
917 /// definitions for otherwise unresolved symbols during lookup.
919 public:
920  virtual ~DefinitionGenerator();
921 
922  /// DefinitionGenerators should override this method to insert new
923  /// definitions into the parent JITDylib. K specifies the kind of this
924  /// lookup. JD specifies the target JITDylib being searched, and
925  /// JDLookupFlags specifies whether the search should match against
926  /// hidden symbols. Finally, Symbols describes the set of unresolved
927  /// symbols and their associated lookup flags.
929  JITDylibLookupFlags JDLookupFlags,
930  const SymbolLookupSet &LookupSet) = 0;
931 };
932 
933 /// Represents a JIT'd dynamic library.
934 ///
935 /// This class aims to mimic the behavior of a regular dylib or shared object,
936 /// but without requiring the contained program representations to be compiled
937 /// up-front. The JITDylib's content is defined by adding MaterializationUnits,
938 /// and contained MaterializationUnits will typically rely on the JITDylib's
939 /// links-against order to resolve external references (similar to a regular
940 /// dylib).
941 ///
942 /// The JITDylib object is a thin wrapper that references state held by the
943 /// ExecutionSession. JITDylibs can be removed, clearing this underlying state
944 /// and leaving the JITDylib object in a defunct state. In this state the
945 /// JITDylib's name is guaranteed to remain accessible. If the ExecutionSession
946 /// is still alive then other operations are callable but will return an Error
947 /// or null result (depending on the API). It is illegal to call any operation
948 /// other than getName on a JITDylib after the ExecutionSession has been torn
949 /// down.
950 ///
951 /// JITDylibs cannot be moved or copied. Their address is stable, and useful as
952 /// a key in some JIT data structures.
953 class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
954  public jitlink::JITLinkDylib {
956  friend class ExecutionSession;
957  friend class Platform;
959 public:
960 
961  JITDylib(const JITDylib &) = delete;
962  JITDylib &operator=(const JITDylib &) = delete;
963  JITDylib(JITDylib &&) = delete;
964  JITDylib &operator=(JITDylib &&) = delete;
965  ~JITDylib();
966 
967  /// Get a reference to the ExecutionSession for this JITDylib.
968  ///
969  /// It is legal to call this method on a defunct JITDylib, however the result
970  /// will only usable if the ExecutionSession is still alive. If this JITDylib
971  /// is held by an error that may have torn down the JIT then the result
972  /// should not be used.
973  ExecutionSession &getExecutionSession() const { return ES; }
974 
975  /// Dump current JITDylib state to OS.
976  ///
977  /// It is legal to call this method on a defunct JITDylib.
978  void dump(raw_ostream &OS);
979 
980  /// Calls remove on all trackers currently associated with this JITDylib.
981  /// Does not run static deinits.
982  ///
983  /// Note that removal happens outside the session lock, so new code may be
984  /// added concurrently while the clear is underway, and the newly added
985  /// code will *not* be cleared. Adding new code concurrently with a clear
986  /// is usually a bug and should be avoided.
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.
990  Error clear();
991 
992  /// Get the default 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  /// Create a resource tracker for this JITDylib.
999  ///
1000  /// It is illegal to call this method on a defunct JITDylib and the client
1001  /// is responsible for ensuring that they do not do so.
1003 
1004  /// Adds a definition generator to this JITDylib and returns a referenece to
1005  /// it.
1006  ///
1007  /// When JITDylibs are searched during lookup, if no existing definition of
1008  /// a symbol is found, then any generators that have been added are run (in
1009  /// the order that they were added) to potentially generate a definition.
1010  ///
1011  /// It is illegal to call this method on a defunct JITDylib and the client
1012  /// is responsible for ensuring that they do not do so.
1013  template <typename GeneratorT>
1014  GeneratorT &addGenerator(std::unique_ptr<GeneratorT> DefGenerator);
1015 
1016  /// Remove a definition generator from this JITDylib.
1017  ///
1018  /// The given generator must exist in this JITDylib's generators list (i.e.
1019  /// have been added and not yet removed).
1020  ///
1021  /// It is illegal to call this method on a defunct JITDylib and the client
1022  /// is responsible for ensuring that they do not do so.
1024 
1025  /// Set the link order to be used when fixing up definitions in JITDylib.
1026  /// This will replace the previous link order, and apply to any symbol
1027  /// resolutions made for definitions in this JITDylib after the call to
1028  /// setLinkOrder (even if the definition itself was added before the
1029  /// call).
1030  ///
1031  /// If LinkAgainstThisJITDylibFirst is true (the default) then this JITDylib
1032  /// will add itself to the beginning of the LinkOrder (Clients should not
1033  /// put this JITDylib in the list in this case, to avoid redundant lookups).
1034  ///
1035  /// If LinkAgainstThisJITDylibFirst is false then the link order will be used
1036  /// as-is. The primary motivation for this feature is to support deliberate
1037  /// shadowing of symbols in this JITDylib by a facade JITDylib. For example,
1038  /// the facade may resolve function names to stubs, and the stubs may compile
1039  /// lazily by looking up symbols in this dylib. Adding the facade dylib
1040  /// as the first in the link order (instead of this dylib) ensures that
1041  /// definitions within this dylib resolve to the lazy-compiling stubs,
1042  /// rather than immediately materializing the definitions in this dylib.
1043  ///
1044  /// It is illegal to call this method on a defunct JITDylib and the client
1045  /// is responsible for ensuring that they do not do so.
1046  void setLinkOrder(JITDylibSearchOrder NewSearchOrder,
1047  bool LinkAgainstThisJITDylibFirst = true);
1048 
1049  /// Add the given JITDylib to the link order for definitions in this
1050  /// JITDylib.
1051  ///
1052  /// It is illegal to call this method on a defunct JITDylib and the client
1053  /// is responsible for ensuring that they do not do so.
1054  void addToLinkOrder(JITDylib &JD,
1055  JITDylibLookupFlags JDLookupFlags =
1057 
1058  /// Replace OldJD with NewJD in the link order if OldJD is present.
1059  /// Otherwise this operation is a no-op.
1060  ///
1061  /// It is illegal to call this method on a defunct JITDylib and the client
1062  /// is responsible for ensuring that they do not do so.
1063  void replaceInLinkOrder(JITDylib &OldJD, JITDylib &NewJD,
1064  JITDylibLookupFlags JDLookupFlags =
1066 
1067  /// Remove the given JITDylib from the link order for this JITDylib if it is
1068  /// present. Otherwise this operation is a no-op.
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  void removeFromLinkOrder(JITDylib &JD);
1073 
1074  /// Do something with the link order (run under the session lock).
1075  ///
1076  /// It is illegal to call this method on a defunct JITDylib and the client
1077  /// is responsible for ensuring that they do not do so.
1078  template <typename Func>
1079  auto withLinkOrderDo(Func &&F)
1080  -> decltype(F(std::declval<const JITDylibSearchOrder &>()));
1081 
1082  /// Define all symbols provided by the materialization unit to be part of this
1083  /// JITDylib.
1084  ///
1085  /// If RT is not specified then the default resource tracker will be used.
1086  ///
1087  /// This overload always takes ownership of the MaterializationUnit. If any
1088  /// errors occur, the MaterializationUnit consumed.
1089  ///
1090  /// It is illegal to call this method on a defunct JITDylib and the client
1091  /// is responsible for ensuring that they do not do so.
1092  template <typename MaterializationUnitType>
1093  Error define(std::unique_ptr<MaterializationUnitType> &&MU,
1094  ResourceTrackerSP RT = nullptr);
1095 
1096  /// Define all symbols provided by the materialization unit to be part of this
1097  /// JITDylib.
1098  ///
1099  /// This overload only takes ownership of the MaterializationUnit no error is
1100  /// generated. If an error occurs, ownership remains with the caller. This
1101  /// may allow the caller to modify the MaterializationUnit to correct the
1102  /// issue, then re-call define.
1103  ///
1104  /// It is illegal to call this method on a defunct JITDylib and the client
1105  /// is responsible for ensuring that they do not do so.
1106  template <typename MaterializationUnitType>
1107  Error define(std::unique_ptr<MaterializationUnitType> &MU,
1108  ResourceTrackerSP RT = nullptr);
1109 
1110  /// Tries to remove the given symbols.
1111  ///
1112  /// If any symbols are not defined in this JITDylib this method will return
1113  /// a SymbolsNotFound error covering the missing symbols.
1114  ///
1115  /// If all symbols are found but some symbols are in the process of being
1116  /// materialized this method will return a SymbolsCouldNotBeRemoved error.
1117  ///
1118  /// On success, all symbols are removed. On failure, the JITDylib state is
1119  /// left unmodified (no symbols are removed).
1120  ///
1121  /// It is illegal to call this method on a defunct JITDylib and the client
1122  /// is responsible for ensuring that they do not do so.
1123  Error remove(const SymbolNameSet &Names);
1124 
1125  /// Returns the given JITDylibs and all of their transitive dependencies in
1126  /// DFS order (based on linkage relationships). Each JITDylib will appear
1127  /// only once.
1128  ///
1129  /// If any JITDylib in the order is defunct then this method will return an
1130  /// error, otherwise returns the order.
1133 
1134  /// Returns the given JITDylibs and all of their transitive dependencies in
1135  /// reverse DFS order (based on linkage relationships). Each JITDylib will
1136  /// appear only once.
1137  ///
1138  /// If any JITDylib in the order is defunct then this method will return an
1139  /// error, otherwise returns the order.
1142 
1143  /// Return this JITDylib and its transitive dependencies in DFS order
1144  /// based on linkage relationships.
1145  ///
1146  /// If any JITDylib in the order is defunct then this method will return an
1147  /// error, otherwise returns the order.
1149 
1150  /// Rteurn this JITDylib and its transitive dependencies in reverse DFS order
1151  /// based on linkage relationships.
1152  ///
1153  /// If any JITDylib in the order is defunct then this method will return an
1154  /// error, otherwise returns the order.
1156 
1157 private:
1158  using AsynchronousSymbolQuerySet =
1159  std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
1160 
1161  using AsynchronousSymbolQueryList =
1162  std::vector<std::shared_ptr<AsynchronousSymbolQuery>>;
1163 
1164  struct UnmaterializedInfo {
1165  UnmaterializedInfo(std::unique_ptr<MaterializationUnit> MU,
1166  ResourceTracker *RT)
1167  : MU(std::move(MU)), RT(RT) {}
1168 
1169  std::unique_ptr<MaterializationUnit> MU;
1170  ResourceTracker *RT;
1171  };
1172 
1173  using UnmaterializedInfosMap =
1174  DenseMap<SymbolStringPtr, std::shared_ptr<UnmaterializedInfo>>;
1175 
1176  using UnmaterializedInfosList =
1177  std::vector<std::shared_ptr<UnmaterializedInfo>>;
1178 
1179  struct MaterializingInfo {
1180  SymbolDependenceMap Dependants;
1181  SymbolDependenceMap UnemittedDependencies;
1182 
1183  void addQuery(std::shared_ptr<AsynchronousSymbolQuery> Q);
1184  void removeQuery(const AsynchronousSymbolQuery &Q);
1185  AsynchronousSymbolQueryList takeQueriesMeeting(SymbolState RequiredState);
1186  AsynchronousSymbolQueryList takeAllPendingQueries() {
1187  return std::move(PendingQueries);
1188  }
1189  bool hasQueriesPending() const { return !PendingQueries.empty(); }
1190  const AsynchronousSymbolQueryList &pendingQueries() const {
1191  return PendingQueries;
1192  }
1193  private:
1194  AsynchronousSymbolQueryList PendingQueries;
1195  };
1196 
1197  using MaterializingInfosMap = DenseMap<SymbolStringPtr, MaterializingInfo>;
1198 
1199  class SymbolTableEntry {
1200  public:
1201  SymbolTableEntry() = default;
1202  SymbolTableEntry(JITSymbolFlags Flags)
1203  : Flags(Flags), State(static_cast<uint8_t>(SymbolState::NeverSearched)),
1204  MaterializerAttached(false), PendingRemoval(false) {}
1205 
1206  JITTargetAddress getAddress() const { return Addr; }
1207  JITSymbolFlags getFlags() const { return Flags; }
1208  SymbolState getState() const { return static_cast<SymbolState>(State); }
1209 
1210  bool hasMaterializerAttached() const { return MaterializerAttached; }
1211  bool isPendingRemoval() const { return PendingRemoval; }
1212 
1213  void setAddress(JITTargetAddress Addr) { this->Addr = Addr; }
1214  void setFlags(JITSymbolFlags Flags) { this->Flags = Flags; }
1215  void setState(SymbolState State) {
1216  assert(static_cast<uint8_t>(State) < (1 << 6) &&
1217  "State does not fit in bitfield");
1218  this->State = static_cast<uint8_t>(State);
1219  }
1220 
1221  void setMaterializerAttached(bool MaterializerAttached) {
1222  this->MaterializerAttached = MaterializerAttached;
1223  }
1224 
1225  void setPendingRemoval(bool PendingRemoval) {
1226  this->PendingRemoval = PendingRemoval;
1227  }
1228 
1229  JITEvaluatedSymbol getSymbol() const {
1230  return JITEvaluatedSymbol(Addr, Flags);
1231  }
1232 
1233  private:
1234  JITTargetAddress Addr = 0;
1235  JITSymbolFlags Flags;
1236  uint8_t State : 6;
1237  uint8_t MaterializerAttached : 1;
1238  uint8_t PendingRemoval : 1;
1239  };
1240 
1241  using SymbolTable = DenseMap<SymbolStringPtr, SymbolTableEntry>;
1242 
1243  JITDylib(ExecutionSession &ES, std::string Name);
1244 
1245  std::pair<AsynchronousSymbolQuerySet, std::shared_ptr<SymbolDependenceMap>>
1246  removeTracker(ResourceTracker &RT);
1247 
1248  void transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
1249 
1250  Error defineImpl(MaterializationUnit &MU);
1251 
1252  void installMaterializationUnit(std::unique_ptr<MaterializationUnit> MU,
1253  ResourceTracker &RT);
1254 
1255  void detachQueryHelper(AsynchronousSymbolQuery &Q,
1256  const SymbolNameSet &QuerySymbols);
1257 
1258  void transferEmittedNodeDependencies(MaterializingInfo &DependantMI,
1259  const SymbolStringPtr &DependantName,
1260  MaterializingInfo &EmittedMI);
1261 
1262  Expected<SymbolFlagsMap> defineMaterializing(SymbolFlagsMap SymbolFlags);
1263 
1264  Error replace(MaterializationResponsibility &FromMR,
1265  std::unique_ptr<MaterializationUnit> MU);
1266 
1267  Expected<std::unique_ptr<MaterializationResponsibility>>
1269  SymbolStringPtr InitSymbol);
1270 
1271  SymbolNameSet getRequestedSymbols(const SymbolFlagsMap &SymbolFlags) const;
1272 
1273  void addDependencies(const SymbolStringPtr &Name,
1274  const SymbolDependenceMap &Dependants);
1275 
1276  Error resolve(MaterializationResponsibility &MR, const SymbolMap &Resolved);
1277 
1278  Error emit(MaterializationResponsibility &MR, const SymbolFlagsMap &Emitted);
1279 
1280  void unlinkMaterializationResponsibility(MaterializationResponsibility &MR);
1281 
1282  using FailedSymbolsWorklist =
1283  std::vector<std::pair<JITDylib *, SymbolStringPtr>>;
1284 
1285  static std::pair<AsynchronousSymbolQuerySet,
1286  std::shared_ptr<SymbolDependenceMap>>
1287  failSymbols(FailedSymbolsWorklist);
1288 
1289  ExecutionSession &ES;
1290  enum { Open, Closing, Closed } State = Open;
1291  std::mutex GeneratorsMutex;
1292  SymbolTable Symbols;
1293  UnmaterializedInfosMap UnmaterializedInfos;
1294  MaterializingInfosMap MaterializingInfos;
1295  std::vector<std::shared_ptr<DefinitionGenerator>> DefGenerators;
1296  JITDylibSearchOrder LinkOrder;
1297  ResourceTrackerSP DefaultTracker;
1298 
1299  // Map trackers to sets of symbols tracked.
1300  DenseMap<ResourceTracker *, SymbolNameVector> TrackerSymbols;
1301  DenseMap<ResourceTracker *, DenseSet<MaterializationResponsibility *>>
1302  TrackerMRs;
1303 };
1304 
1305 /// Platforms set up standard symbols and mediate interactions between dynamic
1306 /// initializers (e.g. C++ static constructors) and ExecutionSession state.
1307 /// Note that Platforms do not automatically run initializers: clients are still
1308 /// responsible for doing this.
1309 class Platform {
1310 public:
1311  virtual ~Platform();
1312 
1313  /// This method will be called outside the session lock each time a JITDylib
1314  /// is created (unless it is created with EmptyJITDylib set) to allow the
1315  /// Platform to install any JITDylib specific standard symbols (e.g
1316  /// __dso_handle).
1317  virtual Error setupJITDylib(JITDylib &JD) = 0;
1318 
1319  /// This method will be called outside the session lock each time a JITDylib
1320  /// is removed to allow the Platform to remove any JITDylib-specific data.
1321  virtual Error teardownJITDylib(JITDylib &JD) = 0;
1322 
1323  /// This method will be called under the ExecutionSession lock each time a
1324  /// MaterializationUnit is added to a JITDylib.
1325  virtual Error notifyAdding(ResourceTracker &RT,
1326  const MaterializationUnit &MU) = 0;
1327 
1328  /// This method will be called under the ExecutionSession lock when a
1329  /// ResourceTracker is removed.
1330  virtual Error notifyRemoving(ResourceTracker &RT) = 0;
1331 
1332  /// A utility function for looking up initializer symbols. Performs a blocking
1333  /// lookup for the given symbols in each of the given JITDylibs.
1334  ///
1335  /// Note: This function is deprecated and will be removed in the near future.
1338  const DenseMap<JITDylib *, SymbolLookupSet> &InitSyms);
1339 
1340  /// Performs an async lookup for the given symbols in each of the given
1341  /// JITDylibs, calling the given handler once all lookups have completed.
1342  static void
1343  lookupInitSymbolsAsync(unique_function<void(Error)> OnComplete,
1344  ExecutionSession &ES,
1345  const DenseMap<JITDylib *, SymbolLookupSet> &InitSyms);
1346 };
1347 
1348 /// A materialization task.
1349 class MaterializationTask : public RTTIExtends<MaterializationTask, Task> {
1350 public:
1351  static char ID;
1352 
1353  MaterializationTask(std::unique_ptr<MaterializationUnit> MU,
1354  std::unique_ptr<MaterializationResponsibility> MR)
1355  : MU(std::move(MU)), MR(std::move(MR)) {}
1356  void printDescription(raw_ostream &OS) override;
1357  void run() override;
1358 
1359 private:
1360  std::unique_ptr<MaterializationUnit> MU;
1361  std::unique_ptr<MaterializationResponsibility> MR;
1362 };
1363 
1364 /// An ExecutionSession represents a running JIT program.
1368  friend class JITDylib;
1369  friend class LookupState;
1371  friend class ResourceTracker;
1372 
1373 public:
1374  /// For reporting errors.
1376 
1377  /// Send a result to the remote.
1379 
1380  /// For dispatching ORC tasks (typically materialization tasks).
1381  using DispatchTaskFunction = unique_function<void(std::unique_ptr<Task> T)>;
1382 
1383  /// An asynchronous wrapper-function callable from the executor via
1384  /// jit-dispatch.
1386  SendResultFunction SendResult,
1387  const char *ArgData, size_t ArgSize)>;
1388 
1389  /// A map associating tag names with asynchronous wrapper function
1390  /// implementations in the JIT.
1393 
1394  /// Construct an ExecutionSession with the given ExecutorProcessControl
1395  /// object.
1396  ExecutionSession(std::unique_ptr<ExecutorProcessControl> EPC);
1397 
1398  /// Destroy an ExecutionSession. Verifies that endSession was called prior to
1399  /// destruction.
1401 
1402  /// End the session. Closes all JITDylibs and disconnects from the
1403  /// executor. Clients must call this method before destroying the session.
1404  Error endSession();
1405 
1406  /// Get the ExecutorProcessControl object associated with this
1407  /// ExecutionSession.
1409 
1410  /// Get the SymbolStringPool for this instance.
1411  std::shared_ptr<SymbolStringPool> getSymbolStringPool() {
1412  return EPC->getSymbolStringPool();
1413  }
1414 
1415  /// Add a symbol name to the SymbolStringPool and return a pointer to it.
1416  SymbolStringPtr intern(StringRef SymName) { return EPC->intern(SymName); }
1417 
1418  /// Set the Platform for this ExecutionSession.
1419  void setPlatform(std::unique_ptr<Platform> P) { this->P = std::move(P); }
1420 
1421  /// Get the Platform for this session.
1422  /// Will return null if no Platform has been set for this ExecutionSession.
1423  Platform *getPlatform() { return P.get(); }
1424 
1425  /// Run the given lambda with the session mutex locked.
1426  template <typename Func> decltype(auto) runSessionLocked(Func &&F) {
1427  std::lock_guard<std::recursive_mutex> Lock(SessionMutex);
1428  return F();
1429  }
1430 
1431  /// Register the given ResourceManager with this ExecutionSession.
1432  /// Managers will be notified of events in reverse order of registration.
1434 
1435  /// Deregister the given ResourceManager with this ExecutionSession.
1436  /// Manager must have been previously registered.
1438 
1439  /// Return a pointer to the "name" JITDylib.
1440  /// Ownership of JITDylib remains within Execution Session
1442 
1443  /// Add a new bare JITDylib to this ExecutionSession.
1444  ///
1445  /// The JITDylib Name is required to be unique. Clients should verify that
1446  /// names are not being re-used (E.g. by calling getJITDylibByName) if names
1447  /// are based on user input.
1448  ///
1449  /// This call does not install any library code or symbols into the newly
1450  /// created JITDylib. The client is responsible for all configuration.
1451  JITDylib &createBareJITDylib(std::string Name);
1452 
1453  /// Add a new JITDylib to this ExecutionSession.
1454  ///
1455  /// The JITDylib Name is required to be unique. Clients should verify that
1456  /// names are not being re-used (e.g. by calling getJITDylibByName) if names
1457  /// are based on user input.
1458  ///
1459  /// If a Platform is attached then Platform::setupJITDylib will be called to
1460  /// install standard platform symbols (e.g. standard library interposes).
1461  /// If no Platform is attached this call is equivalent to createBareJITDylib.
1463 
1464  /// Closes the given JITDylib.
1465  ///
1466  /// This method clears all resources held for the JITDylib, puts it in the
1467  /// closed state, and clears all references held by the ExecutionSession and
1468  /// other JITDylibs. No further code can be added to the JITDylib, and the
1469  /// object will be freed once any remaining JITDylibSPs to it are destroyed.
1470  ///
1471  /// This method does *not* run static destructors.
1472  ///
1473  /// This method can only be called once for each JITDylib.
1475 
1476  /// Set the error reporter function.
1478  this->ReportError = std::move(ReportError);
1479  return *this;
1480  }
1481 
1482  /// Report a error for this execution session.
1483  ///
1484  /// Unhandled errors can be sent here to log them.
1485  void reportError(Error Err) { ReportError(std::move(Err)); }
1486 
1487  /// Set the task dispatch function.
1489  this->DispatchTask = std::move(DispatchTask);
1490  return *this;
1491  }
1492 
1493  /// Search the given JITDylibs to find the flags associated with each of the
1494  /// given symbols.
1495  void lookupFlags(LookupKind K, JITDylibSearchOrder SearchOrder,
1496  SymbolLookupSet Symbols,
1497  unique_function<void(Expected<SymbolFlagsMap>)> OnComplete);
1498 
1499  /// Blocking version of lookupFlags.
1501  JITDylibSearchOrder SearchOrder,
1502  SymbolLookupSet Symbols);
1503 
1504  /// Search the given JITDylibs for the given symbols.
1505  ///
1506  /// SearchOrder lists the JITDylibs to search. For each dylib, the associated
1507  /// boolean indicates whether the search should match against non-exported
1508  /// (hidden visibility) symbols in that dylib (true means match against
1509  /// non-exported symbols, false means do not match).
1510  ///
1511  /// The NotifyComplete callback will be called once all requested symbols
1512  /// reach the required state.
1513  ///
1514  /// If all symbols are found, the RegisterDependencies function will be called
1515  /// while the session lock is held. This gives clients a chance to register
1516  /// dependencies for on the queried symbols for any symbols they are
1517  /// materializing (if a MaterializationResponsibility instance is present,
1518  /// this can be implemented by calling
1519  /// MaterializationResponsibility::addDependencies). If there are no
1520  /// dependenant symbols for this query (e.g. it is being made by a top level
1521  /// client to get an address to call) then the value NoDependenciesToRegister
1522  /// can be used.
1523  void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder,
1524  SymbolLookupSet Symbols, SymbolState RequiredState,
1525  SymbolsResolvedCallback NotifyComplete,
1526  RegisterDependenciesFunction RegisterDependencies);
1527 
1528  /// Blocking version of lookup above. Returns the resolved symbol map.
1529  /// If WaitUntilReady is true (the default), will not return until all
1530  /// requested symbols are ready (or an error occurs). If WaitUntilReady is
1531  /// false, will return as soon as all requested symbols are resolved,
1532  /// or an error occurs. If WaitUntilReady is false and an error occurs
1533  /// after resolution, the function will return a success value, but the
1534  /// error will be reported via reportErrors.
1535  Expected<SymbolMap> lookup(const JITDylibSearchOrder &SearchOrder,
1536  SymbolLookupSet Symbols,
1538  SymbolState RequiredState = SymbolState::Ready,
1539  RegisterDependenciesFunction RegisterDependencies =
1541 
1542  /// Convenience version of blocking lookup.
1543  /// Searches each of the JITDylibs in the search order in turn for the given
1544  /// symbol.
1546  lookup(const JITDylibSearchOrder &SearchOrder, SymbolStringPtr Symbol,
1547  SymbolState RequiredState = SymbolState::Ready);
1548 
1549  /// Convenience version of blocking lookup.
1550  /// Searches each of the JITDylibs in the search order in turn for the given
1551  /// symbol. The search will not find non-exported symbols.
1554  SymbolState RequiredState = SymbolState::Ready);
1555 
1556  /// Convenience version of blocking lookup.
1557  /// Searches each of the JITDylibs in the search order in turn for the given
1558  /// symbol. The search will not find non-exported symbols.
1561  SymbolState RequiredState = SymbolState::Ready);
1562 
1563  /// Materialize the given unit.
1564  void dispatchTask(std::unique_ptr<Task> T) {
1565  assert(T && "T must be non-null");
1566  DEBUG_WITH_TYPE("orc", dumpDispatchInfo(*T));
1567  DispatchTask(std::move(T));
1568  }
1569 
1570  /// Run a wrapper function in the executor.
1571  ///
1572  /// The wrapper function should be callable as:
1573  ///
1574  /// \code{.cpp}
1575  /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
1576  /// \endcode{.cpp}
1577  ///
1578  /// The given OnComplete function will be called to return the result.
1579  template <typename... ArgTs>
1580  void callWrapperAsync(ArgTs &&... Args) {
1581  EPC->callWrapperAsync(std::forward<ArgTs>(Args)...);
1582  }
1583 
1584  /// Run a wrapper function in the executor. The wrapper function should be
1585  /// callable as:
1586  ///
1587  /// \code{.cpp}
1588  /// CWrapperFunctionResult fn(uint8_t *Data, uint64_t Size);
1589  /// \endcode{.cpp}
1591  ArrayRef<char> ArgBuffer) {
1592  return EPC->callWrapper(WrapperFnAddr, ArgBuffer);
1593  }
1594 
1595  /// Run a wrapper function using SPS to serialize the arguments and
1596  /// deserialize the results.
1597  template <typename SPSSignature, typename SendResultT, typename... ArgTs>
1598  void callSPSWrapperAsync(ExecutorAddr WrapperFnAddr, SendResultT &&SendResult,
1599  const ArgTs &...Args) {
1600  EPC->callSPSWrapperAsync<SPSSignature, SendResultT, ArgTs...>(
1601  WrapperFnAddr, std::forward<SendResultT>(SendResult), Args...);
1602  }
1603 
1604  /// Run a wrapper function using SPS to serialize the arguments and
1605  /// deserialize the results.
1606  ///
1607  /// If SPSSignature is a non-void function signature then the second argument
1608  /// (the first in the Args list) should be a reference to a return value.
1609  template <typename SPSSignature, typename... WrapperCallArgTs>
1611  WrapperCallArgTs &&...WrapperCallArgs) {
1612  return EPC->callSPSWrapper<SPSSignature, WrapperCallArgTs...>(
1613  WrapperFnAddr, std::forward<WrapperCallArgTs>(WrapperCallArgs)...);
1614  }
1615 
1616  /// Wrap a handler that takes concrete argument types (and a sender for a
1617  /// concrete return type) to produce an AsyncHandlerWrapperFunction. Uses SPS
1618  /// to unpack the arguments and pack the result.
1619  ///
1620  /// This function is intended to support easy construction of
1621  /// AsyncHandlerWrapperFunctions that can be associated with a tag
1622  /// (using registerJITDispatchHandler) and called from the executor.
1623  template <typename SPSSignature, typename HandlerT>
1625  return [H = std::forward<HandlerT>(H)](
1626  SendResultFunction SendResult,
1627  const char *ArgData, size_t ArgSize) mutable {
1629  std::move(SendResult));
1630  };
1631  }
1632 
1633  /// Wrap a class method that takes concrete argument types (and a sender for
1634  /// a concrete return type) to produce an AsyncHandlerWrapperFunction. Uses
1635  /// SPS to unpack teh arguments and pack the result.
1636  ///
1637  /// This function is intended to support easy construction of
1638  /// AsyncHandlerWrapperFunctions that can be associated with a tag
1639  /// (using registerJITDispatchHandler) and called from the executor.
1640  template <typename SPSSignature, typename ClassT, typename... MethodArgTs>
1642  wrapAsyncWithSPS(ClassT *Instance, void (ClassT::*Method)(MethodArgTs...)) {
1643  return wrapAsyncWithSPS<SPSSignature>(
1644  [Instance, Method](MethodArgTs &&...MethodArgs) {
1645  (Instance->*Method)(std::forward<MethodArgTs>(MethodArgs)...);
1646  });
1647  }
1648 
1649  /// For each tag symbol name, associate the corresponding
1650  /// AsyncHandlerWrapperFunction with the address of that symbol. The
1651  /// handler becomes callable from the executor using the ORC runtime
1652  /// __orc_rt_jit_dispatch function and the given tag.
1653  ///
1654  /// Tag symbols will be looked up in JD using LookupKind::Static,
1655  /// JITDylibLookupFlags::MatchAllSymbols (hidden tags will be found), and
1656  /// LookupFlags::WeaklyReferencedSymbol. Missing tag definitions will not
1657  /// cause an error, the handler will simply be dropped.
1660 
1661  /// Run a registered jit-side wrapper function.
1662  /// This should be called by the ExecutorProcessControl instance in response
1663  /// to incoming jit-dispatch requests from the executor.
1664  void
1666  JITTargetAddress HandlerFnTagAddr,
1667  ArrayRef<char> ArgBuffer);
1668 
1669  /// Dump the state of all the JITDylibs in this session.
1670  void dump(raw_ostream &OS);
1671 
1672 private:
1673  static void logErrorsToStdErr(Error Err) {
1674  logAllUnhandledErrors(std::move(Err), errs(), "JIT session error: ");
1675  }
1676 
1677  static void runOnCurrentThread(std::unique_ptr<Task> T) { T->run(); }
1678 
1679  void dispatchOutstandingMUs();
1680 
1681  static std::unique_ptr<MaterializationResponsibility>
1682  createMaterializationResponsibility(ResourceTracker &RT,
1683  SymbolFlagsMap Symbols,
1684  SymbolStringPtr InitSymbol) {
1685  auto &JD = RT.getJITDylib();
1686  std::unique_ptr<MaterializationResponsibility> MR(
1687  new MaterializationResponsibility(&RT, std::move(Symbols),
1688  std::move(InitSymbol)));
1689  JD.TrackerMRs[&RT].insert(MR.get());
1690  return MR;
1691  }
1692 
1693  Error removeResourceTracker(ResourceTracker &RT);
1694  void transferResourceTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT);
1695  void destroyResourceTracker(ResourceTracker &RT);
1696 
1697  // State machine functions for query application..
1698 
1699  /// IL_updateCandidatesFor is called to remove already-defined symbols that
1700  /// match a given query from the set of candidate symbols to generate
1701  /// definitions for (no need to generate a definition if one already exists).
1702  Error IL_updateCandidatesFor(JITDylib &JD, JITDylibLookupFlags JDLookupFlags,
1703  SymbolLookupSet &Candidates,
1704  SymbolLookupSet *NonCandidates);
1705 
1706  /// OL_applyQueryPhase1 is an optionally re-startable loop for triggering
1707  /// definition generation. It is called when a lookup is performed, and again
1708  /// each time that LookupState::continueLookup is called.
1709  void OL_applyQueryPhase1(std::unique_ptr<InProgressLookupState> IPLS,
1710  Error Err);
1711 
1712  /// OL_completeLookup is run once phase 1 successfully completes for a lookup
1713  /// call. It attempts to attach the symbol to all symbol table entries and
1714  /// collect all MaterializationUnits to dispatch. If this method fails then
1715  /// all MaterializationUnits will be left un-materialized.
1716  void OL_completeLookup(std::unique_ptr<InProgressLookupState> IPLS,
1717  std::shared_ptr<AsynchronousSymbolQuery> Q,
1718  RegisterDependenciesFunction RegisterDependencies);
1719 
1720  /// OL_completeLookupFlags is run once phase 1 successfully completes for a
1721  /// lookupFlags call.
1722  void OL_completeLookupFlags(
1723  std::unique_ptr<InProgressLookupState> IPLS,
1724  unique_function<void(Expected<SymbolFlagsMap>)> OnComplete);
1725 
1726  // State machine functions for MaterializationResponsibility.
1727  void OL_destroyMaterializationResponsibility(
1729  SymbolNameSet OL_getRequestedSymbols(const MaterializationResponsibility &MR);
1730  Error OL_notifyResolved(MaterializationResponsibility &MR,
1731  const SymbolMap &Symbols);
1732  Error OL_notifyEmitted(MaterializationResponsibility &MR);
1733  Error OL_defineMaterializing(MaterializationResponsibility &MR,
1735  void OL_notifyFailed(MaterializationResponsibility &MR);
1736  Error OL_replace(MaterializationResponsibility &MR,
1737  std::unique_ptr<MaterializationUnit> MU);
1738  Expected<std::unique_ptr<MaterializationResponsibility>>
1739  OL_delegate(MaterializationResponsibility &MR, const SymbolNameSet &Symbols);
1740  void OL_addDependencies(MaterializationResponsibility &MR,
1741  const SymbolStringPtr &Name,
1742  const SymbolDependenceMap &Dependencies);
1743  void OL_addDependenciesForAll(MaterializationResponsibility &MR,
1744  const SymbolDependenceMap &Dependencies);
1745 
1746 #ifndef NDEBUG
1747  void dumpDispatchInfo(Task &T);
1748 #endif // NDEBUG
1749 
1750  mutable std::recursive_mutex SessionMutex;
1751  bool SessionOpen = true;
1752  std::unique_ptr<ExecutorProcessControl> EPC;
1753  std::unique_ptr<Platform> P;
1754  ErrorReporter ReportError = logErrorsToStdErr;
1755  DispatchTaskFunction DispatchTask = runOnCurrentThread;
1756 
1757  std::vector<ResourceManager *> ResourceManagers;
1758 
1759  std::vector<JITDylibSP> JDs;
1760 
1761  // FIXME: Remove this (and runOutstandingMUs) once the linking layer works
1762  // with callbacks from asynchronous queries.
1763  mutable std::recursive_mutex OutstandingMUsMutex;
1764  std::vector<std::pair<std::unique_ptr<MaterializationUnit>,
1765  std::unique_ptr<MaterializationResponsibility>>>
1766  OutstandingMUs;
1767 
1768  mutable std::mutex JITDispatchHandlersMutex;
1769  DenseMap<JITTargetAddress, std::shared_ptr<JITDispatchHandlerFunction>>
1770  JITDispatchHandlers;
1771 };
1772 
1773 inline ExecutionSession &
1775  return JD.getExecutionSession();
1776 }
1777 
1778 template <typename Func>
1780  return JD.getExecutionSession().runSessionLocked([&]() -> Error {
1781  if (RT->isDefunct())
1782  return make_error<ResourceTrackerDefunct>(RT);
1783  F(RT->getKeyUnsafe());
1784  return Error::success();
1785  });
1786 }
1787 
1788 template <typename GeneratorT>
1789 GeneratorT &JITDylib::addGenerator(std::unique_ptr<GeneratorT> DefGenerator) {
1790  auto &G = *DefGenerator;
1791  ES.runSessionLocked([&] {
1792  assert(State == Open && "Cannot add generator to closed JITDylib");
1793  DefGenerators.push_back(std::move(DefGenerator));
1794  });
1795  return G;
1796 }
1797 
1798 template <typename Func>
1800  -> decltype(F(std::declval<const JITDylibSearchOrder &>())) {
1801  assert(State == Open && "Cannot use link order of closed JITDylib");
1802  return ES.runSessionLocked([&]() { return F(LinkOrder); });
1803 }
1804 
1805 template <typename MaterializationUnitType>
1806 Error JITDylib::define(std::unique_ptr<MaterializationUnitType> &&MU,
1807  ResourceTrackerSP RT) {
1808  assert(MU && "Can not define with a null MU");
1809 
1810  if (MU->getSymbols().empty()) {
1811  // Empty MUs are allowable but pathological, so issue a warning.
1812  DEBUG_WITH_TYPE("orc", {
1813  dbgs() << "Warning: Discarding empty MU " << MU->getName() << " for "
1814  << getName() << "\n";
1815  });
1816  return Error::success();
1817  } else
1818  DEBUG_WITH_TYPE("orc", {
1819  dbgs() << "Defining MU " << MU->getName() << " for " << getName()
1820  << " (tracker: ";
1821  if (RT == getDefaultResourceTracker())
1822  dbgs() << "default)";
1823  else if (RT)
1824  dbgs() << RT.get() << ")\n";
1825  else
1826  dbgs() << "0x0, default will be used)\n";
1827  });
1828 
1829  return ES.runSessionLocked([&, this]() -> Error {
1830  assert(State == Open && "JD is defunct");
1831 
1832  if (auto Err = defineImpl(*MU))
1833  return Err;
1834 
1835  if (!RT)
1837 
1838  if (auto *P = ES.getPlatform()) {
1839  if (auto Err = P->notifyAdding(*RT, *MU))
1840  return Err;
1841  }
1842 
1843  installMaterializationUnit(std::move(MU), *RT);
1844  return Error::success();
1845  });
1846 }
1847 
1848 template <typename MaterializationUnitType>
1849 Error JITDylib::define(std::unique_ptr<MaterializationUnitType> &MU,
1850  ResourceTrackerSP RT) {
1851  assert(MU && "Can not define with a null MU");
1852 
1853  if (MU->getSymbols().empty()) {
1854  // Empty MUs are allowable but pathological, so issue a warning.
1855  DEBUG_WITH_TYPE("orc", {
1856  dbgs() << "Warning: Discarding empty MU " << MU->getName() << getName()
1857  << "\n";
1858  });
1859  return Error::success();
1860  } else
1861  DEBUG_WITH_TYPE("orc", {
1862  dbgs() << "Defining MU " << MU->getName() << " for " << getName()
1863  << " (tracker: ";
1864  if (RT == getDefaultResourceTracker())
1865  dbgs() << "default)";
1866  else if (RT)
1867  dbgs() << RT.get() << ")\n";
1868  else
1869  dbgs() << "0x0, default will be used)\n";
1870  });
1871 
1872  return ES.runSessionLocked([&, this]() -> Error {
1873  assert(State == Open && "JD is defunct");
1874 
1875  if (auto Err = defineImpl(*MU))
1876  return Err;
1877 
1878  if (!RT)
1880 
1881  if (auto *P = ES.getPlatform()) {
1882  if (auto Err = P->notifyAdding(*RT, *MU))
1883  return Err;
1884  }
1885 
1886  installMaterializationUnit(std::move(MU), *RT);
1887  return Error::success();
1888  });
1889 }
1890 
1891 /// ReexportsGenerator can be used with JITDylib::addGenerator to automatically
1892 /// re-export a subset of the source JITDylib's symbols in the target.
1894 public:
1896 
1897  /// Create a reexports generator. If an Allow predicate is passed, only
1898  /// symbols for which the predicate returns true will be reexported. If no
1899  /// Allow predicate is passed, all symbols will be exported.
1900  ReexportsGenerator(JITDylib &SourceJD,
1901  JITDylibLookupFlags SourceJDLookupFlags,
1902  SymbolPredicate Allow = SymbolPredicate());
1903 
1905  JITDylibLookupFlags JDLookupFlags,
1906  const SymbolLookupSet &LookupSet) override;
1907 
1908 private:
1909  JITDylib &SourceJD;
1910  JITDylibLookupFlags SourceJDLookupFlags;
1911  SymbolPredicate Allow;
1912 };
1913 
1914 // --------------- IMPLEMENTATION --------------
1915 // Implementations for inline functions/methods.
1916 // ---------------------------------------------
1917 
1919  getExecutionSession().OL_destroyMaterializationResponsibility(*this);
1920 }
1921 
1923  return getExecutionSession().OL_getRequestedSymbols(*this);
1924 }
1925 
1927  const SymbolMap &Symbols) {
1928  return getExecutionSession().OL_notifyResolved(*this, Symbols);
1929 }
1930 
1932  return getExecutionSession().OL_notifyEmitted(*this);
1933 }
1934 
1937  return getExecutionSession().OL_defineMaterializing(*this,
1938  std::move(SymbolFlags));
1939 }
1940 
1942  getExecutionSession().OL_notifyFailed(*this);
1943 }
1944 
1946  std::unique_ptr<MaterializationUnit> MU) {
1947  return getExecutionSession().OL_replace(*this, std::move(MU));
1948 }
1949 
1952  return getExecutionSession().OL_delegate(*this, Symbols);
1953 }
1954 
1956  const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies) {
1957  getExecutionSession().OL_addDependencies(*this, Name, Dependencies);
1958 }
1959 
1961  const SymbolDependenceMap &Dependencies) {
1962  getExecutionSession().OL_addDependenciesForAll(*this, Dependencies);
1963 }
1964 
1965 } // End namespace orc
1966 } // End namespace llvm
1967 
1968 #endif // LLVM_EXECUTIONENGINE_ORC_CORE_H
llvm::orc::ExecutorAddr
Represents an address in the executor process.
Definition: ExecutorAddress.h:31
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:1945
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:1349
llvm::orc::MaterializationResponsibility
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:519
llvm::orc::MaterializationTask::MaterializationTask
MaterializationTask(std::unique_ptr< MaterializationUnit > MU, std::unique_ptr< MaterializationResponsibility > MR)
Definition: Core.h:1353
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:1799
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::orc::SymbolsNotFound::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:123
llvm::orc::JITDylib
Represents a JIT'd dynamic library.
Definition: Core.h:953
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:599
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:173
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:1316
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:1598
llvm::orc::DefinitionGenerator::~DefinitionGenerator
virtual ~DefinitionGenerator()
llvm::orc::ExecutionSession::reportError
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:1485
llvm::orc::InProgressLookupState
Definition: Core.cpp:511
llvm::orc::ExecutionSession::callWrapperAsync
void callWrapperAsync(ArgTs &&... Args)
Run a wrapper function in the executor.
Definition: Core.h:1580
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:1381
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:133
llvm::orc::ResourceTrackerDefunct
Definition: Core.h:401
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:1331
llvm::orc::ExecutionSession::getJITDylibByName
JITDylib * getJITDylibByName(StringRef Name)
Return a pointer to the "name" JITDylib.
Definition: Core.cpp:1931
llvm::orc::LookupState::operator=
LookupState & operator=(LookupState &&)
llvm::orc::ResourceTrackerDefunct::ID
static char ID
Definition: Core.h:403
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:1418
llvm::orc::JITDylib::getDefaultResourceTracker
ResourceTrackerSP getDefaultResourceTracker()
Get the default resource tracker for this JITDylib.
Definition: Core.cpp:661
llvm::orc::JITDylib::ExecutionSession
friend class ExecutionSession
Definition: Core.h:956
llvm::orc::AbsoluteSymbolsMaterializationUnit
A MaterializationUnit implementation for pre-existing absolute symbols.
Definition: Core.h:738
llvm::orc::ResourceTrackerDefunct::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:75
llvm::orc::SymbolAliasMapEntry::SymbolAliasMapEntry
SymbolAliasMapEntry(SymbolStringPtr Aliasee, JITSymbolFlags AliasFlags)
Definition: Core.h:380
llvm::orc::MaterializationResponsibility::notifyResolved
Error notifyResolved(const SymbolMap &Symbols)
Notifies the target JITDylib that the given symbols have been resolved.
Definition: Core.h:1926
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:708
llvm::orc::ExecutionSession::removeJITDylib
Error removeJITDylib(JITDylib &JD)
Closes the given JITDylib.
Definition: Core.cpp:1956
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()
llvm::orc::LookupKind::Static
@ Static
llvm::orc::SymbolsCouldNotBeRemoved::getSymbols
const SymbolNameSet & getSymbols() const
Definition: Core.h:459
llvm::orc::SymbolStringPtr
Pointer to a pooled string representing a symbol name.
Definition: SymbolStringPool.h:57
llvm::orc::ReExportsMaterializationUnit::getName
StringRef getName() const override
Return the name of this materialization unit.
Definition: Core.cpp:304
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()
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::orc::JITDylib::clear
Error clear()
Calls remove on all trackers currently associated with this JITDylib.
Definition: Core.cpp:646
llvm::orc::ExecutionSession::ResourceTracker
friend class ResourceTracker
Definition: Core.h:1371
llvm::orc::UnexpectedSymbolDefinitions::UnexpectedSymbolDefinitions
UnexpectedSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
Definition: Core.h:497
llvm::orc::ReExportsMaterializationUnit
A materialization unit for symbol aliases.
Definition: Core.h:770
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:450
WrapperFunctionUtils.h
llvm::orc::FailedToMaterialize::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:97
llvm::orc::SymbolsNotFound::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:441
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:642
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:1935
llvm::orc::ExecutionSession::registerResourceManager
void registerResourceManager(ResourceManager &RM)
Register the given ResourceManager with this ExecutionSession.
Definition: Core.cpp:1914
llvm::orc::MaterializationTask::run
void run() override
Definition: Core.cpp:1881
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:682
llvm::orc::SymbolsCouldNotBeRemoved::SymbolsCouldNotBeRemoved
SymbolsCouldNotBeRemoved(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
Definition: Core.cpp:127
llvm::orc::FailedToMaterialize::getSymbols
const SymbolDependenceMap & getSymbols() const
Definition: Core.h:424
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:891
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::orc::LookupState::continueLookup
void continueLookup(Error Err)
Continue the lookup.
Definition: Core.cpp:634
llvm::orc::UnexpectedSymbolDefinitions::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:503
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 given symbols in each of the given JITDylibs, calling the given hand...
Definition: Core.cpp:1833
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::orc::UnexpectedSymbolDefinitions
Errors of this type should be returned if a module contains definitions for symbols that are not clai...
Definition: Core.h:493
llvm::orc::SymbolsNotFound::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:119
llvm::orc::SymbolsCouldNotBeRemoved::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:458
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:24
llvm::orc::MaterializationUnit
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Definition: Core.h:665
llvm::orc::ExecutionSession::runJITDispatchHandler
void runJITDispatchHandler(SendResultFunction SendResult, JITTargetAddress HandlerFnTagAddr, ArrayRef< char > ArgBuffer)
Run a registered jit-side wrapper function.
Definition: Core.cpp:2216
llvm::orc::ExecutionSession::dispatchTask
void dispatchTask(std::unique_ptr< Task > T)
Materialize the given unit.
Definition: Core.h:1564
llvm::orc::ExecutionSession::JITDylib
friend class JITDylib
Definition: Core.h:1368
llvm::orc::SymbolLookupSet::sortByName
void sortByName()
Sort the lookup set lexicographically.
Definition: Core.h:346
llvm::orc::MissingSymbolDefinitions::getModuleName
const std::string & getModuleName() const
Definition: Core.h:481
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:670
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:417
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::orc::RegisterDependenciesFunction
std::function< void(const SymbolDependenceMap &)> RegisterDependenciesFunction
Callback to register the dependencies for a given query.
Definition: Core.h:395
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:1335
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:1378
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:2237
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
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:2185
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:831
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:145
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:547
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:154
llvm::orc::UnexpectedSymbolDefinitions::getModuleName
const std::string & getModuleName() const
Definition: Core.h:504
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:1784
llvm::orc::SymbolLookupSet::containsDuplicates
bool containsDuplicates()
Returns true if this set contains any duplicates.
Definition: Core.h:363
llvm::orc::SymbolsNotFound
Used to notify clients when symbols can not be found during a lookup.
Definition: Core.h:432
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::less_first
Function object to check whether the first component of a std::pair compares less than the first comp...
Definition: STLExtras.h:1476
llvm::orc::UnexpectedSymbolDefinitions::ID
static char ID
Definition: Core.h:495
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:35
llvm::orc::AsynchronousSymbolQuery::JITSymbolResolverAdapter
friend class JITSymbolResolverAdapter
Definition: Core.h:848
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:1931
DenseSet.h
false
Definition: StackSlotColoring.cpp:141
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:1960
llvm::orc::FailedToMaterialize::~FailedToMaterialize
~FailedToMaterialize()
Definition: Core.cpp:92
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:1416
llvm::detail::DenseSetImpl::size
size_type size() const
Definition: DenseSet.h:81
llvm::ThreadSafeRefCountedBase
A thread-safe version of RefCountedBase.
Definition: IntrusiveRefCntPtr.h:106
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:1789
llvm::orc::AsynchronousSymbolQuery
A symbol query that returns results via a callback when results are ready.
Definition: Core.h:844
llvm::orc::ExecutionSession::runSessionLocked
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Definition: Core.h:1426
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::orc::LookupKind::DLSym
@ DLSym
llvm::orc::MaterializationUnit::Interface
Definition: Core.h:672
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:261
llvm::orc::MaterializationResponsibility::operator=
MaterializationResponsibility & operator=(MaterializationResponsibility &&)=delete
llvm::orc::SymbolsNotFound::ID
static char ID
Definition: Core.h:434
llvm::RTTIExtends
Inheritance utility for extensible RTTI.
Definition: ExtensibleRTTI.h:114
llvm::orc::ExecutionSession::setPlatform
void setPlatform(std::unique_ptr< Platform > P)
Set the Platform for this ExecutionSession.
Definition: Core.h:1419
llvm::orc::SymbolLookupFlags::WeaklyReferencedSymbol
@ WeaklyReferencedSymbol
llvm::orc::SymbolsNotFound::SymbolsNotFound
SymbolsNotFound(std::shared_ptr< SymbolStringPool > SSP, SymbolNameSet Symbols)
Definition: Core.cpp:105
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:1922
llvm::orc::UnexpectedSymbolDefinitions::getSymbols
const SymbolNameVector & getSymbols() const
Definition: Core.h:505
llvm::orc::ExecutionSession::createBareJITDylib
JITDylib & createBareJITDylib(std::string Name)
Add a new bare JITDylib to this ExecutionSession.
Definition: Core.cpp:1940
llvm::orc::ExecutionSession::endSession
Error endSession()
End the session.
Definition: Core.cpp:1895
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:552
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1682
llvm::orc::MaterializationResponsibility::withResourceKeyDo
Error withResourceKeyDo(Func &&F) const
Returns the ResourceTracker for this instance.
Definition: Core.h:1779
llvm::orc::MaterializationTask::printDescription
void printDescription(raw_ostream &OS) override
Definition: Core.cpp:1876
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::DenseSet< SymbolStringPtr >
llvm::orc::InProgressLookupFlagsState
Definition: Core.cpp:539
llvm::orc::ExecutionSession::callWrapper
shared::WrapperFunctionResult callWrapper(ExecutorAddr WrapperFnAddr, ArrayRef< char > ArgBuffer)
Run a wrapper function in the executor.
Definition: Core.h:1590
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:264
llvm::orc::ExecutionSession::JITDispatchHandlerAssociationMap
DenseMap< SymbolStringPtr, JITDispatchHandlerFunction > JITDispatchHandlerAssociationMap
A map associating tag names with asynchronous wrapper function implementations in the JIT.
Definition: Core.h:1392
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:470
llvm::orc::JITDylib::MaterializationResponsibility
friend class MaterializationResponsibility
Definition: Core.h:958
llvm::orc::JITDylib::getDFSLinkOrder
Expected< std::vector< JITDylibSP > > getDFSLinkOrder()
Return this JITDylib and its transitive dependencies in DFS order based on linkage relationships.
Definition: Core.cpp:2042
llvm::orc::ExecutionSession::~ExecutionSession
~ExecutionSession()
Destroy an ExecutionSession.
Definition: Core.cpp:1889
llvm::orc::MaterializationResponsibility::getTargetJITDylib
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition: Core.h:538
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:1488
llvm::orc::MissingSymbolDefinitions::MissingSymbolDefinitions
MissingSymbolDefinitions(std::shared_ptr< SymbolStringPool > SSP, std::string ModuleName, SymbolNameVector Symbols)
Definition: Core.h:474
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:698
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
llvm::orc::JITDylib::getReverseDFSLinkOrder
Expected< std::vector< JITDylibSP > > getReverseDFSLinkOrder()
Rteurn this JITDylib and its transitive dependencies in reverse DFS order based on linkage relationsh...
Definition: Core.cpp:2046
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:2050
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
Definition: DenseMap.h:714
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:1642
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:695
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:1955
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:1387
llvm::orc::ReexportsGenerator::ReexportsGenerator
ReexportsGenerator(JITDylib &SourceJD, JITDylibLookupFlags SourceJDLookupFlags, SymbolPredicate Allow=SymbolPredicate())
Create a reexports generator.
Definition: Core.cpp:593
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::orc::AbsoluteSymbolsMaterializationUnit::AbsoluteSymbolsMaterializationUnit
AbsoluteSymbolsMaterializationUnit(SymbolMap Symbols)
Definition: Core.cpp:257
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:1861
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:955
std::swap
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:853
llvm::orc::ExecutionSession::ExecutionSession
ExecutionSession(std::unique_ptr< ExecutorProcessControl > EPC)
Construct an ExecutionSession with the given ExecutorProcessControl object.
Definition: Core.cpp:1883
ModuleName
Definition: ItaniumDemangle.h:999
llvm::orc::MaterializationUnit::MaterializationUnit
MaterializationUnit(Interface I)
Definition: Core.h:685
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:1610
llvm::orc::JITDylib::remove
Error remove(const SymbolNameSet &Names)
Tries to remove the given symbols.
Definition: Core.cpp:1359
llvm::orc::SymbolLookupSet::begin
const_iterator begin() const
Definition: Core.h:254
llvm::orc::MaterializationResponsibility::JITDylib
friend class JITDylib
Definition: Core.h:521
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:82
llvm::orc::MaterializationUnit::Interface::Interface
Interface(SymbolFlagsMap InitalSymbolFlags, SymbolStringPtr InitSymbol)
Definition: Core.h:674
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::DefinitionGenerator
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
Definition: Core.h:918
llvm::orc::ExecutionSession::getExecutorProcessControl
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1408
llvm::ErrorInfo
Base class for user error types.
Definition: Error.h:347
llvm::DenseMapBase::empty
bool empty() const
Definition: DenseMap.h:98
llvm::orc::MaterializationUnit::~MaterializationUnit
virtual ~MaterializationUnit()=default
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:1774
llvm::orc::SymbolAliasMapEntry::Aliasee
SymbolStringPtr Aliasee
Definition: Core.h:383
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:818
llvm::orc::ExecutionSession::deregisterResourceManager
void deregisterResourceManager(ResourceManager &RM)
Deregister the given ResourceManager with this ExecutionSession.
Definition: Core.cpp:1918
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:487
llvm::orc::SymbolLookupSet::SymbolLookupSet
SymbolLookupSet()=default
llvm::orc::MaterializationResponsibility::~MaterializationResponsibility
~MaterializationResponsibility()
Destruct a MaterializationResponsibility instance.
Definition: Core.h:1918
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:1370
llvm::orc::ReexportsGenerator::SymbolPredicate
std::function< bool(SymbolStringPtr)> SymbolPredicate
Definition: Core.h:1895
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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:1309
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:893
llvm::orc::SymbolLookupSet::iterator
UnderlyingVector::iterator iterator
Definition: Core.h:179
llvm::orc::MaterializationUnit::ID
static char ID
Definition: Core.h:670
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:378
llvm::orc::InProgressFullLookupState
Definition: Core.cpp:563
llvm::orc::ExecutionSession::createJITDylib
Expected< JITDylib & > createJITDylib(std::string Name)
Add a new JITDylib to this ExecutionSession.
Definition: Core.cpp:1948
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:71
llvm::orc::SymbolFlagsMap
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
Definition: Core.h:116
llvm::logAllUnhandledErrors
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner={})
Log all errors (if any) in E to OS.
Definition: Error.cpp:63
llvm::orc::AsynchronousSymbolQuery::AsynchronousSymbolQuery
AsynchronousSymbolQuery(const SymbolLookupSet &Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete)
Create a query for the given symbols.
Definition: Core.cpp:159
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:1411
llvm::orc::MaterializationResponsibility::failMaterialization
void failMaterialization()
Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has o...
Definition: Core.h:1941
llvm::orc::ReexportsGenerator
ReexportsGenerator can be used with JITDylib::addGenerator to automatically re-export a subset of the...
Definition: Core.h:1893
llvm::orc::ExecutionSession::getPlatform
Platform * getPlatform()
Get the Platform for this session.
Definition: Core.h:1423
llvm::orc::ExecutionSession::ErrorReporter
std::function< void(Error)> ErrorReporter
For reporting errors.
Definition: Core.h:1375
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
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:1347
getFlags
static uint32_t getFlags(const Symbol *Sym)
Definition: TapiFile.cpp:27
llvm::orc::OrcV2CAPIHelper
Definition: OrcV2CBindings.cpp:28
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::orc::MissingSymbolDefinitions::getSymbolStringPool
std::shared_ptr< SymbolStringPool > getSymbolStringPool()
Definition: Core.h:480
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:354
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1365
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:415
llvm::orc::MissingSymbolDefinitions::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:141
llvm::orc::symbolAliases
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition: Core.h:809
llvm::unique
auto unique(Range &&R, Predicate P)
Definition: STLExtras.h:1965
llvm::orc::absoluteSymbols
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
Definition: Core.h:763
llvm::orc::FailedToMaterialize::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:101
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:442
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:83
llvm::orc::ResourceTrackerDefunct::ResourceTrackerDefunct
ResourceTrackerDefunct(ResourceTrackerSP RT)
Definition: Core.cpp:68
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:1951
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:1806
llvm::orc::SymbolAliasMapEntry::AliasFlags
JITSymbolFlags AliasFlags
Definition: Core.h:384
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:2076
llvm::orc::AsynchronousSymbolQuery::JITDylib
friend class JITDylib
Definition: Core.h:847
llvm::orc::JITDylib::getExecutionSession
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
Definition: Core.h:973
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
TaskDispatch.h
llvm::orc::MissingSymbolDefinitions::getSymbols
const SymbolNameVector & getSymbols() const
Definition: Core.h:482
llvm::orc::MissingSymbolDefinitions::ID
static char ID
Definition: Core.h:472
llvm::orc::MaterializationUnit::Interface::SymbolFlags
SymbolFlagsMap SymbolFlags
Definition: Core.h:681
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::omp::RTLDependInfoFields::Flags
@ Flags
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:1624
llvm::orc::MaterializationTask::ID
static char ID
Definition: Core.h:1351
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:298
llvm::orc::FailedToMaterialize::FailedToMaterialize
FailedToMaterialize(std::shared_ptr< SymbolStringPool > SSP, std::shared_ptr< SymbolDependenceMap > Symbols)
Definition: Core.cpp:79
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::orc::MaterializationUnit::SymbolFlags
SymbolFlagsMap SymbolFlags
Definition: Core.h:721
llvm::orc::UnexpectedSymbolDefinitions::convertToErrorCode
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
Definition: Core.cpp:150
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:391
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:1477
llvm::IntrusiveRefCntPtr
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
Definition: IntrusiveRefCntPtr.h:168
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:452
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1251
llvm::orc::AsynchronousSymbolQuery::isComplete
bool isComplete() const
Returns true if all symbols covered by this query have been resolved.
Definition: Core.h:865
llvm::orc::SymbolsCouldNotBeRemoved::log
void log(raw_ostream &OS) const override
Print an error message to an output stream.
Definition: Core.cpp:137
llvm::orc::MaterializationUnit::InitSymbol
SymbolStringPtr InitSymbol
Definition: Core.h:722
llvm::orc::JITDylib::removeGenerator
void removeGenerator(DefinitionGenerator &G)
Remove a definition generator from this JITDylib.
Definition: Core.cpp:678