LLVM  15.0.0git
ExecutionUtils.cpp
Go to the documentation of this file.
1 //===---- ExecutionUtils.cpp - Utilities for executing functions in Orc ---===//
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 
12 #include "llvm/IR/Constants.h"
13 #include "llvm/IR/Function.h"
14 #include "llvm/IR/GlobalVariable.h"
15 #include "llvm/IR/Module.h"
16 #include "llvm/MC/TargetRegistry.h"
20 #include <string>
21 
22 namespace llvm {
23 namespace orc {
24 
26  : InitList(
27  GV ? dyn_cast_or_null<ConstantArray>(GV->getInitializer()) : nullptr),
28  I((InitList && End) ? InitList->getNumOperands() : 0) {
29 }
30 
32  assert(InitList == Other.InitList && "Incomparable iterators.");
33  return I == Other.I;
34 }
35 
37  return !(*this == Other);
38 }
39 
41  ++I;
42  return *this;
43 }
44 
46  CtorDtorIterator Temp = *this;
47  ++I;
48  return Temp;
49 }
50 
52  ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(I));
53  assert(CS && "Unrecognized type in llvm.global_ctors/llvm.global_dtors");
54 
55  Constant *FuncC = CS->getOperand(1);
56  Function *Func = nullptr;
57 
58  // Extract function pointer, pulling off any casts.
59  while (FuncC) {
60  if (Function *F = dyn_cast_or_null<Function>(FuncC)) {
61  Func = F;
62  break;
63  } else if (ConstantExpr *CE = dyn_cast_or_null<ConstantExpr>(FuncC)) {
64  if (CE->isCast())
65  FuncC = CE->getOperand(0);
66  else
67  break;
68  } else {
69  // This isn't anything we recognize. Bail out with Func left set to null.
70  break;
71  }
72  }
73 
74  auto *Priority = cast<ConstantInt>(CS->getOperand(0));
75  Value *Data = CS->getNumOperands() == 3 ? CS->getOperand(2) : nullptr;
76  if (Data && !isa<GlobalValue>(Data))
77  Data = nullptr;
78  return Element(Priority->getZExtValue(), Func, Data);
79 }
80 
82  const GlobalVariable *CtorsList = M.getNamedGlobal("llvm.global_ctors");
83  return make_range(CtorDtorIterator(CtorsList, false),
84  CtorDtorIterator(CtorsList, true));
85 }
86 
88  const GlobalVariable *DtorsList = M.getNamedGlobal("llvm.global_dtors");
89  return make_range(CtorDtorIterator(DtorsList, false),
90  CtorDtorIterator(DtorsList, true));
91 }
92 
93 bool StaticInitGVIterator::isStaticInitGlobal(GlobalValue &GV) {
94  if (GV.isDeclaration())
95  return false;
96 
97  if (GV.hasName() && (GV.getName() == "llvm.global_ctors" ||
98  GV.getName() == "llvm.global_dtors"))
99  return true;
100 
101  if (ObjFmt == Triple::MachO) {
102  // FIXME: These section checks are too strict: We should match first and
103  // second word split by comma.
104  if (GV.hasSection() &&
105  (GV.getSection().startswith("__DATA,__objc_classlist") ||
106  GV.getSection().startswith("__DATA,__objc_selrefs")))
107  return true;
108  }
109 
110  return false;
111 }
112 
114  if (CtorDtors.empty())
115  return;
116 
117  MangleAndInterner Mangle(
118  JD.getExecutionSession(),
119  (*CtorDtors.begin()).Func->getParent()->getDataLayout());
120 
121  for (auto CtorDtor : CtorDtors) {
122  assert(CtorDtor.Func && CtorDtor.Func->hasName() &&
123  "Ctor/Dtor function must be named to be runnable under the JIT");
124 
125  // FIXME: Maybe use a symbol promoter here instead.
126  if (CtorDtor.Func->hasLocalLinkage()) {
127  CtorDtor.Func->setLinkage(GlobalValue::ExternalLinkage);
128  CtorDtor.Func->setVisibility(GlobalValue::HiddenVisibility);
129  }
130 
131  if (CtorDtor.Data && cast<GlobalValue>(CtorDtor.Data)->isDeclaration()) {
132  dbgs() << " Skipping because why now?\n";
133  continue;
134  }
135 
136  CtorDtorsByPriority[CtorDtor.Priority].push_back(
137  Mangle(CtorDtor.Func->getName()));
138  }
139 }
140 
142  using CtorDtorTy = void (*)();
143 
144  SymbolLookupSet LookupSet;
145  for (auto &KV : CtorDtorsByPriority)
146  for (auto &Name : KV.second)
147  LookupSet.add(Name);
148  assert(!LookupSet.containsDuplicates() &&
149  "Ctor/Dtor list contains duplicates");
150 
151  auto &ES = JD.getExecutionSession();
152  if (auto CtorDtorMap = ES.lookup(
154  std::move(LookupSet))) {
155  for (auto &KV : CtorDtorsByPriority) {
156  for (auto &Name : KV.second) {
157  assert(CtorDtorMap->count(Name) && "No entry for Name");
158  auto CtorDtor = reinterpret_cast<CtorDtorTy>(
159  static_cast<uintptr_t>((*CtorDtorMap)[Name].getAddress()));
160  CtorDtor();
161  }
162  }
163  CtorDtorsByPriority.clear();
164  return Error::success();
165  } else
166  return CtorDtorMap.takeError();
167 }
168 
170  auto& CXXDestructorDataPairs = DSOHandleOverride;
171  for (auto &P : CXXDestructorDataPairs)
172  P.first(P.second);
173  CXXDestructorDataPairs.clear();
174 }
175 
177  void *Arg,
178  void *DSOHandle) {
179  auto& CXXDestructorDataPairs =
180  *reinterpret_cast<CXXDestructorDataPairList*>(DSOHandle);
181  CXXDestructorDataPairs.push_back(std::make_pair(Destructor, Arg));
182  return 0;
183 }
184 
186  MangleAndInterner &Mangle) {
187  SymbolMap RuntimeInterposes;
188  RuntimeInterposes[Mangle("__dso_handle")] =
191  RuntimeInterposes[Mangle("__cxa_atexit")] =
194 
195  return JD.define(absoluteSymbols(std::move(RuntimeInterposes)));
196 }
197 
198 void ItaniumCXAAtExitSupport::registerAtExit(void (*F)(void *), void *Ctx,
199  void *DSOHandle) {
200  std::lock_guard<std::mutex> Lock(AtExitsMutex);
201  AtExitRecords[DSOHandle].push_back({F, Ctx});
202 }
203 
204 void ItaniumCXAAtExitSupport::runAtExits(void *DSOHandle) {
205  std::vector<AtExitRecord> AtExitsToRun;
206 
207  {
208  std::lock_guard<std::mutex> Lock(AtExitsMutex);
209  auto I = AtExitRecords.find(DSOHandle);
210  if (I != AtExitRecords.end()) {
211  AtExitsToRun = std::move(I->second);
212  AtExitRecords.erase(I);
213  }
214  }
215 
216  while (!AtExitsToRun.empty()) {
217  AtExitsToRun.back().F(AtExitsToRun.back().Ctx);
218  AtExitsToRun.pop_back();
219  }
220 }
221 
224  : Dylib(std::move(Dylib)), Allow(std::move(Allow)),
226 
230  std::string ErrMsg;
231  auto Lib = sys::DynamicLibrary::getPermanentLibrary(FileName, &ErrMsg);
232  if (!Lib.isValid())
233  return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
234  return std::make_unique<DynamicLibrarySearchGenerator>(
235  std::move(Lib), GlobalPrefix, std::move(Allow));
236 }
237 
240  JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
241  orc::SymbolMap NewSymbols;
242 
243  bool HasGlobalPrefix = (GlobalPrefix != '\0');
244 
245  for (auto &KV : Symbols) {
246  auto &Name = KV.first;
247 
248  if ((*Name).empty())
249  continue;
250 
251  if (Allow && !Allow(Name))
252  continue;
253 
254  if (HasGlobalPrefix && (*Name).front() != GlobalPrefix)
255  continue;
256 
257  std::string Tmp((*Name).data() + HasGlobalPrefix,
258  (*Name).size() - HasGlobalPrefix);
259  if (void *Addr = Dylib.getAddressOfSymbol(Tmp.c_str())) {
260  NewSymbols[Name] = JITEvaluatedSymbol(
261  static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(Addr)),
263  }
264  }
265 
266  if (NewSymbols.empty())
267  return Error::success();
268 
269  return JD.define(absoluteSymbols(std::move(NewSymbols)));
270 }
271 
274  ObjectLayer &L, const char *FileName,
275  GetObjectFileInterface GetObjFileInterface) {
276  auto ArchiveBuffer = MemoryBuffer::getFile(FileName);
277 
278  if (!ArchiveBuffer)
279  return createFileError(FileName, ArchiveBuffer.getError());
280 
281  return Create(L, std::move(*ArchiveBuffer), std::move(GetObjFileInterface));
282 }
283 
286  ObjectLayer &L, const char *FileName, const Triple &TT,
287  GetObjectFileInterface GetObjFileInterface) {
288 
289  auto B = object::createBinary(FileName);
290  if (!B)
291  return createFileError(FileName, B.takeError());
292 
293  // If this is a regular archive then create an instance from it.
294  if (isa<object::Archive>(B->getBinary()))
295  return Create(L, std::move(B->takeBinary().second),
296  std::move(GetObjFileInterface));
297 
298  // If this is a universal binary then search for a slice matching the given
299  // Triple.
300  if (auto *UB = cast<object::MachOUniversalBinary>(B->getBinary())) {
301  for (const auto &Obj : UB->objects()) {
302  auto ObjTT = Obj.getTriple();
303  if (ObjTT.getArch() == TT.getArch() &&
304  ObjTT.getSubArch() == TT.getSubArch() &&
305  (TT.getVendor() == Triple::UnknownVendor ||
306  ObjTT.getVendor() == TT.getVendor())) {
307  // We found a match. Create an instance from a buffer covering this
308  // slice.
309  auto SliceBuffer = MemoryBuffer::getFileSlice(FileName, Obj.getSize(),
310  Obj.getOffset());
311  if (!SliceBuffer)
312  return make_error<StringError>(
313  Twine("Could not create buffer for ") + TT.str() + " slice of " +
314  FileName + ": [ " + formatv("{0:x}", Obj.getOffset()) +
315  " .. " + formatv("{0:x}", Obj.getOffset() + Obj.getSize()) +
316  ": " + SliceBuffer.getError().message(),
317  SliceBuffer.getError());
318  return Create(L, std::move(*SliceBuffer),
319  std::move(GetObjFileInterface));
320  }
321  }
322 
323  return make_error<StringError>(Twine("Universal binary ") + FileName +
324  " does not contain a slice for " +
325  TT.str(),
327  }
328 
329  return make_error<StringError>(Twine("Unrecognized file type for ") +
330  FileName,
332 }
333 
336  ObjectLayer &L, std::unique_ptr<MemoryBuffer> ArchiveBuffer,
337  GetObjectFileInterface GetObjFileInterface) {
338  Error Err = Error::success();
339 
340  std::unique_ptr<StaticLibraryDefinitionGenerator> ADG(
342  L, std::move(ArchiveBuffer), std::move(GetObjFileInterface), Err));
343 
344  if (Err)
345  return std::move(Err);
346 
347  return std::move(ADG);
348 }
349 
352  JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
353 
354  // Don't materialize symbols from static archives unless this is a static
355  // lookup.
356  if (K != LookupKind::Static)
357  return Error::success();
358 
359  // Bail out early if we've already freed the archive.
360  if (!Archive)
361  return Error::success();
362 
364 
365  for (const auto &KV : Symbols) {
366  const auto &Name = KV.first;
367  auto Child = Archive->findSym(*Name);
368  if (!Child)
369  return Child.takeError();
370  if (*Child == None)
371  continue;
372  auto ChildBuffer = (*Child)->getMemoryBufferRef();
373  if (!ChildBuffer)
374  return ChildBuffer.takeError();
375  ChildBufferInfos.insert(
376  {ChildBuffer->getBuffer(), ChildBuffer->getBufferIdentifier()});
377  }
378 
379  for (auto ChildBufferInfo : ChildBufferInfos) {
380  MemoryBufferRef ChildBufferRef(ChildBufferInfo.first,
381  ChildBufferInfo.second);
382 
383  auto I = GetObjFileInterface(L.getExecutionSession(), ChildBufferRef);
384  if (!I)
385  return I.takeError();
386 
387  if (auto Err = L.add(JD, MemoryBuffer::getMemBuffer(ChildBufferRef, false),
388  std::move(*I)))
389  return Err;
390  }
391 
392  return Error::success();
393 }
394 
395 StaticLibraryDefinitionGenerator::StaticLibraryDefinitionGenerator(
396  ObjectLayer &L, std::unique_ptr<MemoryBuffer> ArchiveBuffer,
397  GetObjectFileInterface GetObjFileInterface, Error &Err)
398  : L(L), GetObjFileInterface(std::move(GetObjFileInterface)),
399  ArchiveBuffer(std::move(ArchiveBuffer)),
400  Archive(std::make_unique<object::Archive>(*this->ArchiveBuffer, Err)) {
401 
402  if (!this->GetObjFileInterface)
403  this->GetObjFileInterface = getObjectFileInterface;
404 }
405 
406 } // End namespace orc.
407 } // End namespace llvm.
llvm::StringRef::startswith
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:290
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::orc::JITDylib
Represents a JIT'd dynamic library.
Definition: Core.h:946
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
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::orc::CtorDtorRunner::add
void add(iterator_range< CtorDtorIterator > CtorDtors)
Definition: ExecutionUtils.cpp:113
llvm::unique_function< Expected< MaterializationUnit::Interface >(ExecutionSession &ES, MemoryBufferRef ObjBuffer)>
llvm::sys::DynamicLibrary::getAddressOfSymbol
void * getAddressOfSymbol(const char *symbolName)
Searches through the library for the symbol symbolName.
Definition: DynamicLibrary.cpp:168
llvm::orc::getConstructors
iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
Definition: ExecutionUtils.cpp:81
llvm::GlobalValue::HiddenVisibility
@ HiddenVisibility
The GV is hidden.
Definition: GlobalValue.h:64
llvm::Function
Definition: Function.h:60
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::SymbolLookupSet
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:175
llvm::orc::LookupKind::Static
@ Static
llvm::orc::ObjectLayer::add
virtual Error add(ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > O, MaterializationUnit::Interface I)
Adds a MaterializationUnit for the object file in the given memory buffer to the JITDylib for the giv...
Definition: Layer.cpp:163
llvm::Value::hasName
bool hasName() const
Definition: Value.h:261
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
GlobalPrefix
@ GlobalPrefix
Definition: AsmWriter.cpp:341
Module.h
llvm::GlobalValue::hasSection
bool hasSection() const
Definition: GlobalValue.h:272
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::orc::LocalCXXRuntimeOverridesBase::DSOHandleOverride
CXXDestructorDataPairList DSOHandleOverride
Definition: ExecutionUtils.h:185
llvm::orc::LookupKind
LookupKind
Describes the kind of lookup being performed.
Definition: Core.h:149
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
Layer.h
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::MemoryBufferRef
Definition: MemoryBufferRef.h:22
llvm::orc::CtorDtorIterator::operator==
bool operator==(const CtorDtorIterator &Other) const
Test iterators for equality.
Definition: ExecutionUtils.cpp:31
llvm::JITEvaluatedSymbol
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:229
llvm::sys::DynamicLibrary
This class provides a portable interface to dynamic libraries which also might be known as shared lib...
Definition: DynamicLibrary.h:36
ExecutionUtils.h
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::orc::CtorDtorIterator
This iterator provides a convenient way to iterate over the elements of an llvm.global_ctors/llvm....
Definition: ExecutionUtils.h:47
llvm::GlobalValue::getSection
StringRef getSection() const
Definition: Globals.cpp:171
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::Lock
static sys::Mutex Lock
Definition: NVPTXUtilities.cpp:39
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:186
llvm::orc::DynamicLibrarySearchGenerator::DynamicLibrarySearchGenerator
DynamicLibrarySearchGenerator(sys::DynamicLibrary Dylib, char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate())
Create a DynamicLibrarySearchGenerator that searches for symbols in the given sys::DynamicLibrary.
Definition: ExecutionUtils.cpp:222
llvm::formatv
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Definition: FormatVariadic.h:251
llvm::MemoryBuffer::getFile
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Definition: MemoryBuffer.cpp:239
llvm::MemoryBuffer::getMemBuffer
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
Definition: MemoryBuffer.cpp:115
TargetMachine.h
llvm::GlobalValue::isDeclaration
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:264
Constants.h
llvm::createFileError
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Definition: Error.h:1320
llvm::orc::SymbolLookupSet::containsDuplicates
bool containsDuplicates()
Returns true if this set contains any duplicates.
Definition: Core.h:363
llvm::sys::DynamicLibrary::getPermanentLibrary
static DynamicLibrary getPermanentLibrary(const char *filename, std::string *errMsg=nullptr)
This function permanently loads the dynamic library at the given path.
Definition: DynamicLibrary.cpp:143
llvm::orc::LocalCXXRuntimeOverrides::enable
Error enable(JITDylib &JD, MangleAndInterner &Mangler)
Definition: ExecutionUtils.cpp:185
MachOUniversal.h
llvm::SubDirectoryType::Lib
@ Lib
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::ConstantArray
ConstantArray - Constant Array Declarations.
Definition: Constants.h:410
llvm::orc::ObjectLayer::getExecutionSession
ExecutionSession & getExecutionSession()
Returns the execution session for this layer.
Definition: Layer.h:141
llvm::orc::ObjectLayer
Interface for Layers that accept object files.
Definition: Layer.h:133
llvm::orc::SymbolLookupSet::add
SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Add an element to the set.
Definition: Core.h:236
llvm::iterator_range::empty
bool empty() const
Definition: iterator_range.h:46
FormatVariadic.h
llvm::None
const NoneType None
Definition: None.h:24
llvm::orc::LocalCXXRuntimeOverridesBase::runDestructors
void runDestructors()
Run any destructors recorded by the overriden __cxa_atexit function (CXAAtExitOverride).
Definition: ExecutionUtils.cpp:169
llvm::orc::DynamicLibrarySearchGenerator::tryToGenerate
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
Definition: ExecutionUtils.cpp:238
llvm::orc::LocalCXXRuntimeOverridesBase::CXXDestructorDataPairList
std::vector< CXXDestructorDataPair > CXXDestructorDataPairList
Definition: ExecutionUtils.h:184
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::orc::LocalCXXRuntimeOverridesBase::DestructorPtr
void(*)(void *) DestructorPtr
Definition: ExecutionUtils.h:182
llvm::GlobalValue
Definition: GlobalValue.h:44
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::orc::getDestructors
iterator_range< CtorDtorIterator > getDestructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
Definition: ExecutionUtils.cpp:87
uint64_t
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:78
llvm::MemoryBuffer::getFileSlice
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile=false)
Map a subrange of the specified file as a MemoryBuffer.
Definition: MemoryBuffer.cpp:158
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::DenseMap< SymbolStringPtr, JITEvaluatedSymbol >
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::orc::LocalCXXRuntimeOverridesBase::CXAAtExitOverride
static int CXAAtExitOverride(DestructorPtr Destructor, void *Arg, void *DSOHandle)
Definition: ExecutionUtils.cpp:176
llvm::orc::CtorDtorIterator::Element
Accessor for an element of the global_ctors/global_dtors array.
Definition: ExecutionUtils.h:53
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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:1675
llvm::orc::CtorDtorIterator::operator!=
bool operator!=(const CtorDtorIterator &Other) const
Test iterators for inequality.
Definition: ExecutionUtils.cpp:36
llvm::orc::StaticLibraryDefinitionGenerator
A utility class to expose symbols from a static library.
Definition: ExecutionUtils.h:259
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::ConstantStruct
Definition: Constants.h:442
llvm::orc::CtorDtorIterator::operator++
CtorDtorIterator & operator++()
Pre-increment iterator.
Definition: ExecutionUtils.cpp:40
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::orc::LookupState
Wraps state for a lookup-in-progress.
Definition: Core.h:886
llvm::Triple::UnknownVendor
@ UnknownVendor
Definition: Triple.h:163
llvm::orc::StaticLibraryDefinitionGenerator::Load
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibraryDefinitionGenerator from the given path.
Definition: ExecutionUtils.cpp:273
llvm::orc::ItaniumCXAAtExitSupport::runAtExits
void runAtExits(void *DSOHandle)
Definition: ExecutionUtils.cpp:204
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:305
llvm::orc::ItaniumCXAAtExitSupport::registerAtExit
void registerAtExit(void(*F)(void *), void *Ctx, void *DSOHandle)
Definition: ExecutionUtils.cpp:198
llvm::orc::MangleAndInterner
Mangles symbol names then uniques them in the context of an ExecutionSession.
Definition: Mangling.h:26
llvm::DenseMapBase::empty
LLVM_NODISCARD bool empty() const
Definition: DenseMap.h:98
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::ConstantExpr
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:972
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
GlobalVariable.h
llvm::AArch64CC::LS
@ LS
Definition: AArch64BaseInfo.h:264
llvm::Triple::MachO
@ MachO
Definition: Triple.h:276
Function.h
llvm::orc::StaticLibraryDefinitionGenerator::tryToGenerate
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
Definition: ExecutionUtils.cpp:350
llvm::orc::absoluteSymbols
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
Definition: Core.h:756
llvm::orc::CtorDtorIterator::CtorDtorIterator
CtorDtorIterator(const GlobalVariable *GV, bool End)
Construct an iterator instance.
Definition: ExecutionUtils.cpp:25
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
llvm::orc::CtorDtorIterator::operator*
Element operator*() const
Dereference iterator.
Definition: ExecutionUtils.cpp:51
llvm::User::getNumOperands
unsigned getNumOperands() const
Definition: User.h:191
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:1799
llvm::orc::DynamicLibrarySearchGenerator::SymbolPredicate
std::function< bool(const SymbolStringPtr &)> SymbolPredicate
Definition: ExecutionUtils.h:218
llvm::orc::DynamicLibrarySearchGenerator::Load
static Expected< std::unique_ptr< DynamicLibrarySearchGenerator > > Load(const char *FileName, char GlobalPrefix, SymbolPredicate Allow=SymbolPredicate())
Permanently loads the library at the given path and, on success, returns a DynamicLibrarySearchGenera...
Definition: ExecutionUtils.cpp:228
llvm::TPLoop::Allow
@ Allow
Definition: ARMTargetTransformInfo.h:53
llvm::orc::getObjectFileInterface
Expected< MaterializationUnit::Interface > getObjectFileInterface(ExecutionSession &ES, MemoryBufferRef ObjBuffer)
Returns a MaterializationUnit::Interface for the object file contained in the given buffer,...
Definition: ObjectFileInterface.cpp:189
llvm::orc::JITDylib::getExecutionSession
ExecutionSession & getExecutionSession() const
Get a reference to the ExecutionSession for this JITDylib.
Definition: Core.h:966
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::orc::LocalCXXRuntimeOverridesBase::toTargetAddress
JITTargetAddress toTargetAddress(PtrTy *P)
Definition: ExecutionUtils.h:178
llvm::object::createBinary
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
Definition: Binary.cpp:45
llvm::orc::StaticLibraryDefinitionGenerator::Create
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Create(ObjectLayer &L, std::unique_ptr< MemoryBuffer > ArchiveBuffer, GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibrarySearchGenerator from the given memory buffer.
Definition: ExecutionUtils.cpp:335
llvm::orc::JITDylibLookupFlags
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition: Core.h:127
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::orc::CtorDtorRunner::run
Error run()
Definition: ExecutionUtils.cpp:141
llvm::orc::JITDylibLookupFlags::MatchAllSymbols
@ MatchAllSymbols
TargetRegistry.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
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::iterator_range::begin
IteratorT begin() const
Definition: iterator_range.h:44
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1236
ObjectFileInterface.h
llvm::JITSymbolFlags::Exported
@ Exported
Definition: JITSymbol.h:85
llvm::dyn_cast_or_null
auto dyn_cast_or_null(const Y &Val)
Definition: Casting.h:756