LLVM  7.0.0
OrcCBindingsStack.h
Go to the documentation of this file.
1 //===- OrcCBindingsStack.h - Orc JIT stack for C bindings -----*- C++ -*---===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_LIB_EXECUTIONENGINE_ORC_ORCCBINDINGSSTACK_H
11 #define LLVM_LIB_EXECUTIONENGINE_ORC_ORCCBINDINGSSTACK_H
12 
13 #include "llvm-c/OrcBindings.h"
14 #include "llvm-c/TargetMachine.h"
15 #include "llvm/ADT/STLExtras.h"
16 #include "llvm/ADT/StringRef.h"
27 #include "llvm/IR/DataLayout.h"
28 #include "llvm/IR/Mangler.h"
29 #include "llvm/IR/Module.h"
31 #include "llvm/Support/Error.h"
34 #include <algorithm>
35 #include <cstdint>
36 #include <functional>
37 #include <map>
38 #include <memory>
39 #include <set>
40 #include <string>
41 #include <vector>
42 
43 namespace llvm {
44 
45 class OrcCBindingsStack;
46 
49 
50 namespace detail {
51 
52 // FIXME: Kill this off once the Layer concept becomes an interface.
53 class GenericLayer {
54 public:
55  virtual ~GenericLayer() = default;
56 
57  virtual JITSymbol findSymbolIn(orc::VModuleKey K, const std::string &Name,
58  bool ExportedSymbolsOnly) = 0;
59  virtual Error removeModule(orc::VModuleKey K) = 0;
60  };
61 
62  template <typename LayerT> class GenericLayerImpl : public GenericLayer {
63  public:
64  GenericLayerImpl(LayerT &Layer) : Layer(Layer) {}
65 
66  JITSymbol findSymbolIn(orc::VModuleKey K, const std::string &Name,
67  bool ExportedSymbolsOnly) override {
68  return Layer.findSymbolIn(K, Name, ExportedSymbolsOnly);
69  }
70 
72  return Layer.removeModule(K);
73  }
74 
75  private:
76  LayerT &Layer;
77  };
78 
79  template <>
80  class GenericLayerImpl<orc::RTDyldObjectLinkingLayer> : public GenericLayer {
81  private:
83  public:
84  GenericLayerImpl(LayerT &Layer) : Layer(Layer) {}
85 
86  JITSymbol findSymbolIn(orc::VModuleKey K, const std::string &Name,
87  bool ExportedSymbolsOnly) override {
88  return Layer.findSymbolIn(K, Name, ExportedSymbolsOnly);
89  }
90 
92  return Layer.removeObject(K);
93  }
94 
95  private:
96  LayerT &Layer;
97  };
98 
99  template <typename LayerT>
100  std::unique_ptr<GenericLayerImpl<LayerT>> createGenericLayer(LayerT &Layer) {
101  return llvm::make_unique<GenericLayerImpl<LayerT>>(Layer);
102  }
103 
104 } // end namespace detail
105 
107 public:
108 
112  using CODLayerT =
114 
115  using CallbackManagerBuilder =
116  std::function<std::unique_ptr<CompileCallbackMgr>()>;
117 
119 
120 private:
121 
123 
124  class CBindingsResolver : public orc::SymbolResolver {
125  public:
126  CBindingsResolver(OrcCBindingsStack &Stack,
127  LLVMOrcSymbolResolverFn ExternalResolver,
128  void *ExternalResolverCtx)
129  : Stack(Stack), ExternalResolver(std::move(ExternalResolver)),
130  ExternalResolverCtx(std::move(ExternalResolverCtx)) {}
131 
133  lookupFlags(const orc::SymbolNameSet &Symbols) override {
134  orc::SymbolFlagsMap SymbolFlags;
135 
136  for (auto &S : Symbols) {
137  if (auto Sym = findSymbol(*S))
138  SymbolFlags[S] = Sym.getFlags();
139  else if (auto Err = Sym.takeError()) {
140  Stack.reportError(std::move(Err));
141  return orc::SymbolFlagsMap();
142  }
143  }
144 
145  return SymbolFlags;
146  }
147 
149  lookup(std::shared_ptr<orc::AsynchronousSymbolQuery> Query,
150  orc::SymbolNameSet Symbols) override {
151  orc::SymbolNameSet UnresolvedSymbols;
152 
153  for (auto &S : Symbols) {
154  if (auto Sym = findSymbol(*S)) {
155  if (auto Addr = Sym.getAddress()) {
156  Query->resolve(S, JITEvaluatedSymbol(*Addr, Sym.getFlags()));
157  Query->notifySymbolReady();
158  } else {
159  Stack.ES.legacyFailQuery(*Query, Addr.takeError());
160  return orc::SymbolNameSet();
161  }
162  } else if (auto Err = Sym.takeError()) {
163  Stack.ES.legacyFailQuery(*Query, std::move(Err));
164  return orc::SymbolNameSet();
165  } else
166  UnresolvedSymbols.insert(S);
167  }
168 
169  if (Query->isFullyResolved())
170  Query->handleFullyResolved();
171 
172  if (Query->isFullyReady())
173  Query->handleFullyReady();
174 
175  return UnresolvedSymbols;
176  }
177 
178  private:
179  JITSymbol findSymbol(const std::string &Name) {
180  // Search order:
181  // 1. JIT'd symbols.
182  // 2. Runtime overrides.
183  // 3. External resolver (if present).
184 
185  if (auto Sym = Stack.CODLayer.findSymbol(Name, true))
186  return Sym;
187  else if (auto Err = Sym.takeError())
188  return Sym.takeError();
189 
190  if (auto Sym = Stack.CXXRuntimeOverrides.searchOverrides(Name))
191  return Sym;
192 
193  if (ExternalResolver)
194  return JITSymbol(ExternalResolver(Name.c_str(), ExternalResolverCtx),
196 
197  return JITSymbol(nullptr);
198  }
199 
200  OrcCBindingsStack &Stack;
201  LLVMOrcSymbolResolverFn ExternalResolver;
202  void *ExternalResolverCtx = nullptr;
203  };
204 
205 public:
207  IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
208  : CCMgr(createLocalCompileCallbackManager(TM.getTargetTriple(), ES, 0)),
209  DL(TM.createDataLayout()), IndirectStubsMgr(IndirectStubsMgrBuilder()),
210  ObjectLayer(ES,
211  [this](orc::VModuleKey K) {
212  auto ResolverI = Resolvers.find(K);
213  assert(ResolverI != Resolvers.end() &&
214  "No resolver for module K");
215  auto Resolver = std::move(ResolverI->second);
216  Resolvers.erase(ResolverI);
217  return ObjLayerT::Resources{
218  std::make_shared<SectionMemoryManager>(), Resolver};
219  },
220  nullptr,
221  [this](orc::VModuleKey K, const object::ObjectFile &Obj,
222  const RuntimeDyld::LoadedObjectInfo &LoadedObjInfo) {
223  this->notifyFinalized(K, Obj, LoadedObjInfo);
224  },
225  [this](orc::VModuleKey K, const object::ObjectFile &Obj) {
226  this->notifyFreed(K, Obj);
227  }),
228  CompileLayer(ObjectLayer, orc::SimpleCompiler(TM)),
229  CODLayer(ES, CompileLayer,
230  [this](orc::VModuleKey K) {
231  auto ResolverI = Resolvers.find(K);
232  assert(ResolverI != Resolvers.end() &&
233  "No resolver for module K");
234  return ResolverI->second;
235  },
236  [this](orc::VModuleKey K,
237  std::shared_ptr<orc::SymbolResolver> Resolver) {
238  assert(!Resolvers.count(K) && "Resolver already present");
239  Resolvers[K] = std::move(Resolver);
240  },
241  [](Function &F) { return std::set<Function *>({&F}); },
242  *this->CCMgr, std::move(IndirectStubsMgrBuilder), false),
243  CXXRuntimeOverrides(
244  [this](const std::string &S) { return mangle(S); }) {}
245 
247  // Run any destructors registered with __cxa_atexit.
248  CXXRuntimeOverrides.runDestructors();
249  // Run any IR destructors.
250  for (auto &DtorRunner : IRStaticDestructorRunners)
251  if (auto Err = DtorRunner.runViaLayer(*this))
252  return mapError(std::move(Err));
253  return LLVMOrcErrSuccess;
254  }
255 
256  std::string mangle(StringRef Name) {
257  std::string MangledName;
258  {
259  raw_string_ostream MangledNameStream(MangledName);
260  Mangler::getNameWithPrefix(MangledNameStream, Name, DL);
261  }
262  return MangledName;
263  }
264 
265  template <typename PtrTy>
266  static PtrTy fromTargetAddress(JITTargetAddress Addr) {
267  return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
268  }
269 
270 
274  void *CallbackCtx) {
275  auto WrappedCallback = [=]() -> JITTargetAddress {
276  return Callback(wrap(this), CallbackCtx);
277  };
278 
279  if (auto CCAddr = CCMgr->getCompileCallback(std::move(WrappedCallback))) {
280  RetAddr = *CCAddr;
281  return LLVMOrcErrSuccess;
282  } else
283  return mapError(CCAddr.takeError());
284  }
285 
287  JITTargetAddress Addr) {
288  return mapError(
289  IndirectStubsMgr->createStub(StubName, Addr, JITSymbolFlags::Exported));
290  }
291 
293  JITTargetAddress Addr) {
294  return mapError(IndirectStubsMgr->updatePointer(Name, Addr));
295  }
296  template <typename LayerT>
298  addIRModule(orc::VModuleKey &RetKey, LayerT &Layer, std::unique_ptr<Module> M,
299  std::unique_ptr<RuntimeDyld::MemoryManager> MemMgr,
300  LLVMOrcSymbolResolverFn ExternalResolver,
301  void *ExternalResolverCtx) {
302 
303  // Attach a data-layout if one isn't already present.
304  if (M->getDataLayout().isDefault())
305  M->setDataLayout(DL);
306 
307  // Record the static constructors and destructors. We have to do this before
308  // we hand over ownership of the module to the JIT.
309  std::vector<std::string> CtorNames, DtorNames;
310  for (auto Ctor : orc::getConstructors(*M))
311  CtorNames.push_back(mangle(Ctor.Func->getName()));
312  for (auto Dtor : orc::getDestructors(*M))
313  DtorNames.push_back(mangle(Dtor.Func->getName()));
314 
315  // Add the module to the JIT.
316  RetKey = ES.allocateVModule();
317  Resolvers[RetKey] = std::make_shared<CBindingsResolver>(
318  *this, ExternalResolver, ExternalResolverCtx);
319  if (auto Err = Layer.addModule(RetKey, std::move(M)))
320  return mapError(std::move(Err));
321 
322  KeyLayers[RetKey] = detail::createGenericLayer(Layer);
323 
324  // Run the static constructors, and save the static destructor runner for
325  // execution when the JIT is torn down.
326  orc::CtorDtorRunner<OrcCBindingsStack> CtorRunner(std::move(CtorNames),
327  RetKey);
328  if (auto Err = CtorRunner.runViaLayer(*this))
329  return mapError(std::move(Err));
330 
331  IRStaticDestructorRunners.emplace_back(std::move(DtorNames), RetKey);
332 
333  return LLVMOrcErrSuccess;
334  }
335 
337  std::unique_ptr<Module> M,
338  LLVMOrcSymbolResolverFn ExternalResolver,
339  void *ExternalResolverCtx) {
340  return addIRModule(RetKey, CompileLayer, std::move(M),
341  llvm::make_unique<SectionMemoryManager>(),
342  std::move(ExternalResolver), ExternalResolverCtx);
343  }
344 
346  std::unique_ptr<Module> M,
347  LLVMOrcSymbolResolverFn ExternalResolver,
348  void *ExternalResolverCtx) {
349  return addIRModule(RetKey, CODLayer, std::move(M),
350  llvm::make_unique<SectionMemoryManager>(),
351  std::move(ExternalResolver), ExternalResolverCtx);
352  }
353 
355  // FIXME: Should error release the module key?
356  if (auto Err = KeyLayers[K]->removeModule(K))
357  return mapError(std::move(Err));
358  ES.releaseVModule(K);
359  KeyLayers.erase(K);
360  return LLVMOrcErrSuccess;
361  }
362 
364  std::unique_ptr<MemoryBuffer> ObjBuffer,
365  LLVMOrcSymbolResolverFn ExternalResolver,
366  void *ExternalResolverCtx) {
368  ObjBuffer->getMemBufferRef())) {
369 
370  RetKey = ES.allocateVModule();
371  Resolvers[RetKey] = std::make_shared<CBindingsResolver>(
372  *this, ExternalResolver, ExternalResolverCtx);
373 
374  if (auto Err = ObjectLayer.addObject(RetKey, std::move(ObjBuffer)))
375  return mapError(std::move(Err));
376 
377  KeyLayers[RetKey] = detail::createGenericLayer(ObjectLayer);
378 
379  return LLVMOrcErrSuccess;
380  } else
381  return mapError(Obj.takeError());
382  }
383 
384  JITSymbol findSymbol(const std::string &Name,
385  bool ExportedSymbolsOnly) {
386  if (auto Sym = IndirectStubsMgr->findStub(Name, ExportedSymbolsOnly))
387  return Sym;
388  return CODLayer.findSymbol(mangle(Name), ExportedSymbolsOnly);
389  }
390 
392  bool ExportedSymbolsOnly) {
393  assert(KeyLayers.count(K) && "looking up symbol in unknown module");
394  return KeyLayers[K]->findSymbolIn(K, mangle(Name), ExportedSymbolsOnly);
395  }
396 
398  const std::string &Name,
399  bool ExportedSymbolsOnly) {
400  RetAddr = 0;
401  if (auto Sym = findSymbol(Name, ExportedSymbolsOnly)) {
402  // Successful lookup, non-null symbol:
403  if (auto AddrOrErr = Sym.getAddress()) {
404  RetAddr = *AddrOrErr;
405  return LLVMOrcErrSuccess;
406  } else
407  return mapError(AddrOrErr.takeError());
408  } else if (auto Err = Sym.takeError()) {
409  // Lookup failure - report error.
410  return mapError(std::move(Err));
411  }
412  // Otherwise we had a successful lookup but got a null result. We already
413  // set RetAddr to '0' above, so just return success.
414  return LLVMOrcErrSuccess;
415  }
416 
418  orc::VModuleKey K,
419  const std::string &Name,
420  bool ExportedSymbolsOnly) {
421  RetAddr = 0;
422  if (auto Sym = findSymbolIn(K, Name, ExportedSymbolsOnly)) {
423  // Successful lookup, non-null symbol:
424  if (auto AddrOrErr = Sym.getAddress()) {
425  RetAddr = *AddrOrErr;
426  return LLVMOrcErrSuccess;
427  } else
428  return mapError(AddrOrErr.takeError());
429  } else if (auto Err = Sym.takeError()) {
430  // Lookup failure - report error.
431  return mapError(std::move(Err));
432  }
433  // Otherwise we had a successful lookup but got a null result. We already
434  // set RetAddr to '0' above, so just return success.
435  return LLVMOrcErrSuccess;
436  }
437 
438  const std::string &getErrorMessage() const { return ErrMsg; }
439 
441  if (!L)
442  return;
443  EventListeners.push_back(L);
444  }
445 
447  if (!L)
448  return;
449 
450  auto I = find(reverse(EventListeners), L);
451  if (I != EventListeners.rend()) {
452  std::swap(*I, EventListeners.back());
453  EventListeners.pop_back();
454  }
455  }
456 
457 private:
458 
459  LLVMOrcErrorCode mapError(Error Err) {
461  handleAllErrors(std::move(Err), [&](ErrorInfoBase &EIB) {
462  // Handler of last resort.
463  Result = LLVMOrcErrGeneric;
464  ErrMsg = "";
465  raw_string_ostream ErrStream(ErrMsg);
466  EIB.log(ErrStream);
467  });
468  return Result;
469  }
470 
471  void reportError(Error Err) {
472  // FIXME: Report errors on the execution session.
473  logAllUnhandledErrors(std::move(Err), errs(), "ORC error: ");
474  };
475 
476  void notifyFinalized(orc::VModuleKey K,
477  const object::ObjectFile &Obj,
478  const RuntimeDyld::LoadedObjectInfo &LoadedObjInfo) {
479  for (auto &Listener : EventListeners)
480  Listener->NotifyObjectEmitted(Obj, LoadedObjInfo);
481  }
482 
483  void notifyFreed(orc::VModuleKey K, const object::ObjectFile &Obj) {
484  for (auto &Listener : EventListeners)
485  Listener->NotifyFreeingObject(Obj);
486  }
487 
489  std::unique_ptr<CompileCallbackMgr> CCMgr;
490 
491  std::vector<JITEventListener *> EventListeners;
492 
493  DataLayout DL;
494  SectionMemoryManager CCMgrMemMgr;
495 
496  std::unique_ptr<orc::IndirectStubsManager> IndirectStubsMgr;
497 
498  ObjLayerT ObjectLayer;
499  CompileLayerT CompileLayer;
500  CODLayerT CODLayer;
501 
502  std::map<orc::VModuleKey, std::unique_ptr<detail::GenericLayer>> KeyLayers;
503 
504  orc::LocalCXXRuntimeOverrides CXXRuntimeOverrides;
505  std::vector<orc::CtorDtorRunner<OrcCBindingsStack>> IRStaticDestructorRunners;
506  std::string ErrMsg;
507 
508  std::map<orc::VModuleKey, std::shared_ptr<orc::SymbolResolver>> Resolvers;
509 };
510 
511 } // end namespace llvm
512 
513 #endif // LLVM_LIB_EXECUTIONENGINE_ORC_ORCCBINDINGSSTACK_H
static Expected< OwningBinary< ObjectFile > > createObjectFile(StringRef ObjectPath)
Definition: ObjectFile.cpp:153
Information about the loaded object.
Definition: RuntimeDyld.h:69
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
void RegisterJITEventListener(JITEventListener *L)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
CODLayerT::IndirectStubsManagerBuilderT IndirectStubsManagerBuilder
Represents a symbol in the JIT.
Definition: JITSymbol.h:186
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner)
Log all errors (if any) in E to OS.
Definition: Error.cpp:57
std::function< std::unique_ptr< CompileCallbackMgr >()> CallbackManagerBuilder
LLVMOrcErrorCode setIndirectStubPointer(StringRef Name, JITTargetAddress Addr)
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
Bare bones object linking layer.
This class is the base class for all object file types.
Definition: ObjectFile.h:190
F(f)
Base class for error info classes.
Definition: Error.h:48
void legacyFailQuery(AsynchronousSymbolQuery &Q, Error Err)
Definition: Core.cpp:145
uint64_t VModuleKey
VModuleKey provides a unique identifier (allocated and managed by ExecutionSessions) for a module add...
Definition: Core.h:40
LLVMOrcErrorCode addIRModuleEager(orc::VModuleKey &RetKey, std::unique_ptr< Module > M, LLVMOrcSymbolResolverFn ExternalResolver, void *ExternalResolverCtx)
Target-independent base class for compile callback management.
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
struct LLVMOpaqueTargetMachine * LLVMTargetMachineRef
Definition: TargetMachine.h:28
JITSymbol findSymbolIn(orc::VModuleKey K, const std::string &Name, bool ExportedSymbolsOnly) override
std::map< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
Definition: Core.h:57
std::function< std::unique_ptr< IndirectStubsManager >()> IndirectStubsManagerBuilderT
Builder for IndirectStubsManagers.
virtual void log(raw_ostream &OS) const =0
Print an error message to an output stream.
LLVMOrcErrorCode shutdown()
Simple compile functor: Takes a single IR module and returns an ObjectFile.
Definition: CompileUtils.h:42
static const uint16_t * lookup(unsigned opcode, unsigned domain, ArrayRef< uint16_t[3]> Table)
JITEvaluatedSymbol searchOverrides(const std::string &Name)
Search overrided symbols.
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
Definition: STLExtras.h:250
iterator_range< CtorDtorIterator > getDestructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
LLVMOrcErrorCode addObject(orc::VModuleKey &RetKey, std::unique_ptr< MemoryBuffer > ObjBuffer, LLVMOrcSymbolResolverFn ExternalResolver, void *ExternalResolverCtx)
JITSymbol findSymbolIn(orc::VModuleKey K, const std::string &Name, bool ExportedSymbolsOnly) override
LLVMOrcErrorCode removeModule(orc::VModuleKey K)
LLVMOrcErrorCode
Definition: OrcBindings.h:39
uint64_t JITTargetAddress
Represents an address in the target process&#39;s address space.
Definition: JITSymbol.h:40
Error runViaLayer(JITLayerT &JITLayer) const
Run the recorded constructors/destructors through the given JIT layer.
Convenience class for recording constructor/destructor names for later execution. ...
virtual ~GenericLayer()=default
void UnregisterJITEventListener(JITEventListener *L)
LLVMOrcErrorCode createIndirectStub(StringRef StubName, JITTargetAddress Addr)
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:1774
virtual Error removeModule(orc::VModuleKey K)=0
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:942
std::string mangle(StringRef Name)
JITSymbol findSymbolIn(orc::VModuleKey K, const std::string &Name, bool ExportedSymbolsOnly)
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition: Error.h:898
LLVMOrcErrorCode addIRModuleLazy(orc::VModuleKey &RetKey, std::unique_ptr< Module > M, LLVMOrcSymbolResolverFn ExternalResolver, void *ExternalResolverCtx)
std::unique_ptr< GenericLayerImpl< LayerT > > createGenericLayer(LayerT &Layer)
Module.h This file contains the declarations for the Module class.
virtual JITSymbol findSymbolIn(orc::VModuleKey K, const std::string &Name, bool ExportedSymbolsOnly)=0
LLVMOrcErrorCode createLazyCompileCallback(JITTargetAddress &RetAddr, LLVMOrcLazyCompileCallbackFn Callback, void *CallbackCtx)
uint64_t(* LLVMOrcLazyCompileCallbackFn)(LLVMOrcJITStackRef JITStack, void *CallbackCtx)
Definition: OrcBindings.h:36
An ExecutionSession represents a running JIT program.
Definition: Core.h:735
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition: BitVector.h:924
SymbolResolver is a composable interface for looking up symbol flags and addresses using the Asynchro...
Definition: Legacy.h:30
LLVMOrcErrorCode addIRModule(orc::VModuleKey &RetKey, LayerT &Layer, std::unique_ptr< Module > M, std::unique_ptr< RuntimeDyld::MemoryManager > MemMgr, LLVMOrcSymbolResolverFn ExternalResolver, void *ExternalResolverCtx)
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:157
const std::string & getErrorMessage() const
static PtrTy fromTargetAddress(JITTargetAddress Addr)
static int reportError(const char *ProgName, Twine Msg)
Definition: Main.cpp:49
uint64_t(* LLVMOrcSymbolResolverFn)(const char *Name, void *LookupCtx)
Definition: OrcBindings.h:35
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:190
OrcCBindingsStack(TargetMachine &TM, IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
#define I(x, y, z)
Definition: MD5.cpp:58
LLVMOrcErrorCode findSymbolAddressIn(JITTargetAddress &RetAddr, orc::VModuleKey K, const std::string &Name, bool ExportedSymbolsOnly)
std::unique_ptr< JITCompileCallbackManager > createLocalCompileCallbackManager(const Triple &T, ExecutionSession &ES, JITTargetAddress ErrorHandlerAddress)
Create a local compile callback manager.
static void Query(const MachineInstr &MI, AliasAnalysis &AA, bool &Read, bool &Write, bool &Effects, bool &StackPointer)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This is a simple memory manager which implements the methods called by the RuntimeDyld class to alloc...
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:477
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly)
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:59
Error removeModule(orc::VModuleKey K) override
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable&#39;s name.
Definition: Mangler.cpp:112
Error takeError()
Move the error field value out of this JITSymbol.
Definition: JITSymbol.h:254
JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly)
Search for the given named symbol.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
struct LLVMOrcOpaqueJITStack * LLVMOrcJITStackRef
Definition: OrcBindings.h:32
std::set< SymbolStringPtr > SymbolNameSet
A set of symbol names (represented by SymbolStringPtrs for.
Definition: Core.h:44
LLVMOrcErrorCode findSymbolAddress(JITTargetAddress &RetAddr, const std::string &Name, bool ExportedSymbolsOnly)