29#define DEBUG_TYPE "orc"
55 std::vector<Type *> HelperArgTypes;
56 for (
auto *
Arg : HelperPrefixArgs)
57 HelperArgTypes.push_back(
Arg->getType());
58 for (
auto *
T : WrapperFnType->params())
59 HelperArgTypes.push_back(
T);
61 FunctionType::get(WrapperFnType->getReturnType(), HelperArgTypes,
false);
67 WrapperFn->setVisibility(WrapperVisibility);
72 std::vector<Value *> HelperArgs;
73 for (
auto *
Arg : HelperPrefixArgs)
74 HelperArgs.push_back(
Arg);
75 for (
auto &
Arg : WrapperFn->args())
76 HelperArgs.push_back(&
Arg);
77 auto *HelperResult = IB.CreateCall(HelperFn, HelperArgs);
78 if (HelperFn->getReturnType()->isVoidTy())
81 IB.CreateRet(HelperResult);
93 using SPSDLOpenSig = SPSExecutorAddr(SPSString, int32_t);
94 enum dlopen_mode : int32_t {
95 ORC_RT_RTLD_LAZY = 0x1,
96 ORC_RT_RTLD_NOW = 0x2,
97 ORC_RT_RTLD_LOCAL = 0x4,
98 ORC_RT_RTLD_GLOBAL = 0x8
101 if (
auto WrapperAddr = J.
lookup(
"__orc_rt_jit_dlopen_wrapper")) {
103 *WrapperAddr, DSOHandles[&JD], JD.
getName(),
104 int32_t(ORC_RT_RTLD_LAZY));
106 return WrapperAddr.takeError();
111 using SPSDLCloseSig = int32_t(SPSExecutorAddr);
113 if (
auto WrapperAddr = J.
lookup(
"__orc_rt_jit_dlclose_wrapper")) {
116 *WrapperAddr, result, DSOHandles[&JD]);
120 return make_error<StringError>(
"dlclose failed",
122 DSOHandles.erase(&JD);
124 return WrapperAddr.takeError();
133class GenericLLVMIRPlatformSupport;
137class GenericLLVMIRPlatform :
public Platform {
139 GenericLLVMIRPlatform(GenericLLVMIRPlatformSupport &S) : S(S) {}
150 GenericLLVMIRPlatformSupport &S;
156class GlobalCtorDtorScraper {
158 GlobalCtorDtorScraper(GenericLLVMIRPlatformSupport &PS,
161 : PS(PS), InitFunctionPrefix(InitFunctionPrefix),
162 DeInitFunctionPrefix(DeInitFunctionPrefix) {}
167 GenericLLVMIRPlatformSupport &PS;
179 GenericLLVMIRPlatformSupport(
LLJIT &J)
180 : J(J), InitFunctionPrefix(J.
mangle(
"__orc_init_func.")),
181 DeInitFunctionPrefix(J.
mangle(
"__orc_deinit_func.")) {
184 std::make_unique<GenericLLVMIRPlatform>(*
this));
187 DeInitFunctionPrefix));
191 StdInterposes[J.
mangleAndIntern(
"__lljit.platform_support_instance")] =
219 auto Ctx = std::make_unique<LLVMContext>();
220 auto M = std::make_unique<Module>(
"__standard_lib", *Ctx);
229 DSOHandle->setInitializer(
232 auto *GenericIRPlatformSupportTy =
237 nullptr,
"__lljit.platform_support_instance");
241 *M,
"__lljit_run_atexits", FunctionType::get(VoidTy, {},
false),
243 {PlatformInstanceDecl, DSOHandle});
248 addHelperAndWrapper(*M,
"atexit",
249 FunctionType::get(IntTy, {AtExitCallbackPtrTy},
false),
251 {PlatformInstanceDecl, DSOHandle});
259 InitSymbols[&JD].add(InitSym, SymbolLookupFlags::WeaklyReferencedSymbol);
267 if ((*KV.first).startswith(InitFunctionPrefix)) {
268 InitSymbols[&JD].add(KV.first,
269 SymbolLookupFlags::WeaklyReferencedSymbol);
270 InitFunctions[&JD].add(KV.first);
271 }
else if ((*KV.first).startswith(DeInitFunctionPrefix)) {
272 DeInitFunctions[&JD].add(KV.first);
280 dbgs() <<
"GenericLLVMIRPlatformSupport getting initializers to run\n";
282 if (
auto Initializers = getInitializers(JD)) {
284 {
dbgs() <<
"GenericLLVMIRPlatformSupport running initializers\n"; });
285 for (
auto InitFnAddr : *Initializers) {
287 dbgs() <<
" Running init " <<
formatv(
"{0:x16}", InitFnAddr)
290 auto *InitFn = jitTargetAddressToFunction<void (*)()>(InitFnAddr);
294 return Initializers.takeError();
300 dbgs() <<
"GenericLLVMIRPlatformSupport getting deinitializers to run\n";
302 if (
auto Deinitializers = getDeinitializers(JD)) {
304 dbgs() <<
"GenericLLVMIRPlatformSupport running deinitializers\n";
306 for (
auto DeinitFnAddr : *Deinitializers) {
308 dbgs() <<
" Running deinit " <<
formatv(
"{0:x16}", DeinitFnAddr)
311 auto *DeinitFn = jitTargetAddressToFunction<void (*)()>(DeinitFnAddr);
315 return Deinitializers.takeError();
322 InitFunctions[&JD].add(InitName);
328 [&]() { DeInitFunctions[&JD].add(DeInitName); });
334 if (
auto Err = issueInitLookups(JD))
335 return std::move(Err);
338 std::vector<JITDylibSP> DFSLinkOrder;
342 DFSLinkOrder = std::move(*DFSLinkOrderOrErr);
344 return DFSLinkOrderOrErr.takeError();
346 for (
auto &NextJD : DFSLinkOrder) {
347 auto IFItr = InitFunctions.find(NextJD.get());
348 if (IFItr != InitFunctions.end()) {
349 LookupSymbols[NextJD.get()] = std::move(IFItr->second);
350 InitFunctions.erase(IFItr);
355 return std::move(Err);
358 dbgs() <<
"JITDylib init order is [ ";
362 dbgs() <<
"Looking up init functions:\n";
363 for (
auto &KV : LookupSymbols)
364 dbgs() <<
" \"" << KV.first->getName() <<
"\": " << KV.second <<
"\n";
371 return LookupResult.takeError();
373 std::vector<JITTargetAddress> Initializers;
374 while (!DFSLinkOrder.empty()) {
375 auto &NextJD = *DFSLinkOrder.back();
376 DFSLinkOrder.pop_back();
377 auto InitsItr = LookupResult->find(&NextJD);
378 if (InitsItr == LookupResult->end())
380 for (
auto &KV : InitsItr->second)
381 Initializers.push_back(KV.second.getAddress());
393 std::vector<JITDylibSP> DFSLinkOrder;
395 if (
auto Err = ES.runSessionLocked([&]() ->
Error {
396 if (auto DFSLinkOrderOrErr = JD.getDFSLinkOrder())
397 DFSLinkOrder = std::move(*DFSLinkOrderOrErr);
399 return DFSLinkOrderOrErr.takeError();
401 for (auto &NextJD : DFSLinkOrder) {
402 auto &JDLookupSymbols = LookupSymbols[NextJD.get()];
403 auto DIFItr = DeInitFunctions.find(NextJD.get());
404 if (DIFItr != DeInitFunctions.end()) {
405 LookupSymbols[NextJD.get()] = std::move(DIFItr->second);
406 DeInitFunctions.erase(DIFItr);
408 JDLookupSymbols.add(LLJITRunAtExits,
409 SymbolLookupFlags::WeaklyReferencedSymbol);
413 return std::move(Err);
416 dbgs() <<
"JITDylib deinit order is [ ";
417 for (
auto &JD : DFSLinkOrder)
420 dbgs() <<
"Looking up deinit functions:\n";
421 for (
auto &KV : LookupSymbols)
422 dbgs() <<
" \"" << KV.first->getName() <<
"\": " << KV.second <<
"\n";
428 return LookupResult.takeError();
430 std::vector<JITTargetAddress> DeInitializers;
431 for (
auto &NextJD : DFSLinkOrder) {
432 auto DeInitsItr = LookupResult->find(NextJD.get());
433 assert(DeInitsItr != LookupResult->end() &&
434 "Every JD should have at least __lljit_run_atexits");
436 auto RunAtExitsItr = DeInitsItr->second.find(LLJITRunAtExits);
437 if (RunAtExitsItr != DeInitsItr->second.end())
438 DeInitializers.push_back(RunAtExitsItr->second.getAddress());
440 for (
auto &KV : DeInitsItr->second)
441 if (KV.first != LLJITRunAtExits)
442 DeInitializers.push_back(KV.second.getAddress());
445 return DeInitializers;
452 std::vector<JITDylibSP> DFSLinkOrder;
454 if (
auto Err = getExecutionSession().runSessionLocked([&]() ->
Error {
456 DFSLinkOrder = std::move(*DFSLinkOrderOrErr);
458 return DFSLinkOrderOrErr.takeError();
460 for (
auto &NextJD : DFSLinkOrder) {
461 auto ISItr = InitSymbols.find(NextJD.get());
462 if (ISItr != InitSymbols.end()) {
463 RequiredInitSymbols[NextJD.get()] = std::move(ISItr->second);
464 InitSymbols.erase(ISItr);
476 static void registerCxaAtExitHelper(
void *Self,
void (*
F)(
void *),
void *Ctx,
479 dbgs() <<
"Registering cxa atexit function " << (
void *)
F <<
" for JD "
482 static_cast<GenericLLVMIRPlatformSupport *
>(Self)->AtExitMgr.registerAtExit(
486 static void registerAtExitHelper(
void *Self,
void *DSOHandle,
void (*
F)()) {
488 dbgs() <<
"Registering atexit function " << (
void *)
F <<
" for JD "
491 static_cast<GenericLLVMIRPlatformSupport *
>(Self)->AtExitMgr.registerAtExit(
492 reinterpret_cast<void (*)(
void *)
>(
F),
nullptr, DSOHandle);
495 static void runAtExitsHelper(
void *Self,
void *DSOHandle) {
497 dbgs() <<
"Running atexit functions for JD "
498 << (*
static_cast<JITDylib **
>(DSOHandle))->getName() <<
"\n";
500 static_cast<GenericLLVMIRPlatformSupport *
>(Self)->AtExitMgr.runAtExits(
507 auto Ctx = std::make_unique<LLVMContext>();
508 auto M = std::make_unique<Module>(
"__standard_lib", *Ctx);
509 M->setDataLayout(J.getDataLayout());
511 auto *GenericIRPlatformSupportTy =
516 nullptr,
"__lljit.platform_support_instance");
521 auto *BytePtrTy = PointerType::getUnqual(Int8Ty);
522 auto *CxaAtExitCallbackTy = FunctionType::get(VoidTy, {BytePtrTy},
false);
523 auto *CxaAtExitCallbackPtrTy = PointerType::getUnqual(CxaAtExitCallbackTy);
527 FunctionType::get(IntTy, {CxaAtExitCallbackPtrTy, BytePtrTy, BytePtrTy},
530 {PlatformInstanceDecl});
536 std::string InitFunctionPrefix;
537 std::string DeInitFunctionPrefix;
545 return S.setupJITDylib(JD);
554 return S.notifyAdding(RT, MU);
561 auto &Ctx =
M.getContext();
562 auto *GlobalCtors =
M.getNamedGlobal(
"llvm.global_ctors");
563 auto *GlobalDtors =
M.getNamedGlobal(
"llvm.global_dtors");
566 bool isCtor) ->
Error {
570 std::string InitOrDeInitFunctionName;
573 << InitFunctionPrefix <<
M.getModuleIdentifier();
576 << DeInitFunctionPrefix <<
M.getModuleIdentifier();
579 auto InternedInitOrDeInitName =
Mangle(InitOrDeInitFunctionName);
580 if (
auto Err =
R.defineMaterializing(
581 {{InternedInitOrDeInitName, JITSymbolFlags::Callable}}))
588 std::vector<std::pair<Function *, unsigned>> InitsOrDeInits;
591 for (
auto E : COrDtors)
592 InitsOrDeInits.push_back(std::make_pair(
E.Func,
E.Priority));
595 auto *InitOrDeInitFuncEntryBlock =
598 for (
auto &KV : InitsOrDeInits)
599 IB.CreateCall(KV.first);
603 PS.registerInitFunc(
R.getTargetJITDylib(), InternedInitOrDeInitName);
605 PS.registerDeInitFunc(
R.getTargetJITDylib(), InternedInitOrDeInitName);
611 if (
auto Err = RegisterCOrDtors(GlobalCtors,
true))
613 if (
auto Err = RegisterCOrDtors(GlobalDtors,
false))
620 return std::move(Err);
622 return std::move(TSM);
631 InactivePlatformSupport() =
default;
634 LLVM_DEBUG(
dbgs() <<
"InactivePlatformSupport: no initializers running for "
641 dbgs() <<
"InactivePlatformSupport: no deinitializers running for "
665 dbgs() <<
" No explicitly set JITTargetMachineBuilder. "
666 "Detecting host...\n";
669 JTMB = std::move(*JTMBOrErr);
671 return JTMBOrErr.takeError();
675 dbgs() <<
" JITTargetMachineBuilder is "
677 <<
" Pre-constructed ExecutionSession: " << (
ES ?
"Yes" :
"No")
683 dbgs() <<
"None (will be created by JITTargetMachineBuilder)\n";
685 dbgs() <<
" Custom object-linking-layer creator: "
686 << (CreateObjectLinkingLayer ?
"Yes" :
"No") <<
"\n"
687 <<
" Custom compile-function creator: "
688 << (CreateCompileFunction ?
"Yes" :
"No") <<
"\n"
689 <<
" Custom platform-setup function: "
690 << (SetUpPlatform ?
"Yes" :
"No") <<
"\n"
691 <<
" Number of compile threads: " << NumCompileThreads;
692 if (!NumCompileThreads)
693 dbgs() <<
" (code will be compiled on the execution thread)\n";
701 dbgs() <<
"ExecutorProcessControl not specified, "
702 "Creating SelfExecutorProcessControl instance\n";
705 EPC = std::move(*EPCOrErr);
707 return EPCOrErr.takeError();
710 dbgs() <<
"Using explicitly specified ExecutorProcessControl instance "
711 << EPC.get() <<
"\n";
716 if (!CreateObjectLinkingLayer) {
717 auto &
TT = JTMB->getTargetTriple();
718 bool UseJITLink =
false;
736 CreateObjectLinkingLayer =
742 std::make_unique<EHFrameRegistrationPlugin>(
743 ES, std::move(*EHFrameRegistrar)));
745 return EHFrameRegistrar.takeError();
757 if (
auto Err =
ES->endSession())
758 ES->reportError(std::move(Err));
762 assert(TSM &&
"Can not add null module");
776 std::unique_ptr<MemoryBuffer> Obj) {
777 assert(Obj &&
"Can not add null object");
788 if (
auto Sym =
ES->lookup(
793 return Sym.takeError();
805 auto GetMemMgr = []() {
return std::make_unique<SectionMemoryManager>(); };
807 std::make_unique<RTDyldObjectLinkingLayer>(
ES, std::move(GetMemMgr));
809 if (S.
JTMB->getTargetTriple().isOSBinFormatCOFF()) {
810 Layer->setOverrideObjectFlagsWithResponsibilityFlags(
true);
811 Layer->setAutoClaimResponsibilityForObjectSymbols(
true);
814 if (S.
JTMB->getTargetTriple().isOSBinFormatELF() &&
817 Layer->setAutoClaimResponsibilityForObjectSymbols(
true);
822 return std::unique_ptr<ObjectLayer>(std::move(Layer));
836 return std::make_unique<ConcurrentIRCompiler>(std::move(JTMB));
840 return TM.takeError();
842 return std::make_unique<TMOwningSimpleCompiler>(std::move(*
TM));
850 assert(!(S.
EPC && S.
ES) &&
"EPC and ES should not both be set");
853 ES = std::make_unique<ExecutionSession>(std::move(S.
EPC));
855 ES = std::move(S.
ES);
858 ES = std::make_unique<ExecutionSession>(std::move(*EPC));
860 Err = EPC.takeError();
865 if (
auto MainOrErr = this->
ES->createJITDylib(
"main"))
868 Err = MainOrErr.takeError();
873 DL = std::move(*S.
DL);
874 else if (
auto DLOrErr = S.
JTMB->getDefaultDataLayoutForTarget())
875 DL = std::move(*DLOrErr);
877 Err = DLOrErr.takeError();
883 Err = ObjLayer.takeError();
892 if (!CompileFunction) {
893 Err = CompileFunction.takeError();
907 ES->setDispatchTask([
this](std::unique_ptr<Task>
T) {
913 std::unique_ptr<Task> T(UnownedT);
926 std::string MangledName;
935 if (M.getDataLayout().isDefault())
938 if (M.getDataLayout() !=
DL)
939 return make_error<StringError>(
940 "Added modules have incompatible data layouts: " +
941 M.getDataLayout().getStringRepresentation() +
" (module) vs " +
950 {
dbgs() <<
"Setting up orc platform support for LLJIT\n"; });
957 {
dbgs() <<
"Setting up GenericLLVMIRPlatform support for LLJIT\n"; });
963 {
dbgs() <<
"Explicitly deactivated platform support for LLJIT\n"; });
971 TT =
JTMB->getTargetTriple();
976 assert(TSM &&
"Can not add null module");
979 [&](
Module &M) ->
Error { return applyDataLayout(M); }))
982 return CODLayer->add(JD, std::move(TSM));
995 LCTMgr = std::move(S.
LCTMgr);
999 LCTMgr = std::move(*LCTMgrOrErr);
1001 Err = LCTMgrOrErr.takeError();
1015 Err = make_error<StringError>(
"Could not construct "
1016 "IndirectStubsManagerBuilder for target " +
1023 CODLayer = std::make_unique<CompileOnDemandLayer>(
1027 CODLayer->setCloneToNewContextOnEmit(
true);
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ATTRIBUTE_USED
Module.h This file contains the declarations for the Module class.
const char LLVMTargetMachineRef TM
static StringRef getName(Value *V)
llvm::orc::shared::CWrapperFunctionResult llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size)
llvm::orc::shared::CWrapperFunctionResult llvm_orc_registerEHFrameSectionWrapper(const char *Data, uint64_t Size)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
const std::string & getStringRepresentation() const
Returns the string representation of the DataLayout.
Helper for Errors used as out-parameters.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
VisibilityTypes
An enumeration for the kinds of visibility of global values.
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ExternalLinkage
Externally visible function.
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Represents a symbol that has been evaluated to an address already.
Flags for symbols in the JIT.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
A Module instance is used to store all the information related to an LLVM module.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
StringRef - Represent a constant reference to a string, i.e.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Triple - Helper class for working with autoconf configuration names.
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
ArchType getArch() const
Get the parsed architecture type of this triple.
bool isOSBinFormatCOFF() const
Tests whether the OS uses the COFF binary format.
const std::string & str() const
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static Type * getVoidTy(LLVMContext &C)
static IntegerType * getInt8Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
const std::string & getName() const
Get the name for this JITLinkDylib.
static Expected< std::unique_ptr< EPCEHFrameRegistrar > > Create(ExecutionSession &ES, std::optional< ExecutorAddr > RegistrationFunctionsDylib=std::nullopt)
Create from a ExecutorProcessControl instance alone.
An ExecutionSession represents a running JIT program.
void setPlatform(std::unique_ptr< Platform > P)
Set the Platform for this ExecutionSession.
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Represents an address in the executor process.
uint64_t getValue() const
An interface for Itanium __cxa_atexit interposer implementations.
Represents a JIT'd dynamic library.
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
static Expected< std::vector< JITDylibSP > > getDFSLinkOrder(ArrayRef< JITDylibSP > JDs)
Returns the given JITDylibs and all of their transitive dependencies in DFS order (based on linkage r...
ResourceTrackerSP getDefaultResourceTracker()
Get the default resource tracker for this JITDylib.
A utility class for building TargetMachines for JITs.
static Expected< JITTargetMachineBuilder > detectHost()
Create a JITTargetMachineBuilder for the host system.
Expected< std::unique_ptr< TargetMachine > > createTargetMachine()
Create a TargetMachine.
Error prepareForConstruction()
Called prior to JIT class construcion to fix up defaults.
ObjectLinkingLayerCreator CreateObjectLinkingLayer
unsigned NumCompileThreads
std::unique_ptr< ExecutionSession > ES
CompileFunctionCreator CreateCompileFunction
std::unique_ptr< ExecutorProcessControl > EPC
std::optional< DataLayout > DL
std::optional< JITTargetMachineBuilder > JTMB
PlatformSetupFunction SetUpPlatform
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
static Expected< std::unique_ptr< ObjectLayer > > createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES)
void setPlatformSupport(std::unique_ptr< PlatformSupport > PS)
Set the PlatformSupport instance.
std::unique_ptr< ExecutionSession > ES
LLJIT(LLJITBuilderState &S, Error &Err)
Create an LLJIT instance with a single compile thread.
Error addObjectFile(ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
JITDylib & getMainJITDylib()
Returns a reference to the JITDylib representing the JIT'd main program.
const DataLayout & getDataLayout() const
Returns a reference to the DataLayout for this instance.
std::unique_ptr< ObjectTransformLayer > ObjTransformLayer
virtual ~LLJIT()
Destruct this instance.
std::string mangle(StringRef UnmangledName) const
Returns a linker-mangled version of UnmangledName.
Expected< ExecutorAddr > lookup(JITDylib &JD, StringRef UnmangledName)
Look up a symbol in JITDylib JD based on its IR symbol name.
std::unique_ptr< IRTransformLayer > InitHelperTransformLayer
std::unique_ptr< IRCompileLayer > CompileLayer
const Triple & getTargetTriple() const
Returns a reference to the triple for this instance.
Expected< ExecutorAddr > lookupLinkerMangled(JITDylib &JD, SymbolStringPtr Name)
Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on thei...
static Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > createCompileFunction(LLJITBuilderState &S, JITTargetMachineBuilder JTMB)
ExecutionSession & getExecutionSession()
Returns the ExecutionSession for this instance.
std::unique_ptr< IRTransformLayer > TransformLayer
SymbolStringPtr mangleAndIntern(StringRef UnmangledName) const
Returns an interned, linker-mangled version of UnmangledName.
friend void setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
Error applyDataLayout(Module &M)
std::unique_ptr< ThreadPool > CompileThreads
std::unique_ptr< ObjectLayer > ObjLinkingLayer
Error addIRModule(ResourceTrackerSP RT, ThreadSafeModule TSM)
Adds an IR module with the given ResourceTracker.
ExecutorAddr LazyCompileFailureAddr
std::unique_ptr< LazyCallThroughManager > LCTMgr
Error prepareForConstruction()
IndirectStubsManagerBuilderFunction ISMBuilder
Error addLazyIRModule(JITDylib &JD, ThreadSafeModule M)
Add a module to be lazily compiled to JITDylib JD.
Mangles symbol names then uniques them in the context of an ExecutionSession.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
const SymbolFlagsMap & getSymbols() const
Return the set of symbols that this source provides.
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
API to remove / transfer ownership of JIT resources.
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
static Expected< std::unique_ptr< SelfExecutorProcessControl > > Create(std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr=nullptr)
Create a SelfExecutorProcessControl with the given symbol string pool and memory manager.
Pointer to a pooled string representing a symbol name.
An LLVM Module together with a shared ThreadSafeContext.
decltype(auto) withModuleDo(Func &&F)
Locks the associated ThreadSafeContext and calls the given function on the contained Module.
SPS tag type for sequences.
A raw_ostream that writes to an std::string.
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...
iterator_range< CtorDtorIterator > getDestructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
Error setUpOrcPlatform(LLJIT &J)
Configure the LLJIT instance to use orc runtime support.
iterator_range< CtorDtorIterator > getConstructors(const Module &M)
Create an iterator range over the entries of the llvm.global_ctors array.
LLVM_ATTRIBUTE_USED void linkComponents()
std::function< std::unique_ptr< IndirectStubsManager >()> createLocalIndirectStubsManagerBuilder(const Triple &T)
Create a local indriect stubs manager builder.
void setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
Error setUpInactivePlatform(LLJIT &J)
Configure the LLJIT instance to disable platform support explicitly.
Expected< std::unique_ptr< LazyCallThroughManager > > createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES, JITTargetAddress ErrorHandlerAddr)
Create a LocalLazyCallThroughManager from the given triple and execution session.
This is an optimization pass for GlobalISel generic memory operations.
ThreadPoolStrategy hardware_concurrency(unsigned ThreadCount=0)
Returns a default thread strategy where all available hardware resources are to be used,...
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
auto reverse(ContainerTy &&C)
void sort(IteratorTy Start, IteratorTy End)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
JITTargetAddress pointerToJITTargetAddress(T *Ptr)
Convert a pointer to a JITTargetAddress.
Function object to check whether the second component of a container supported by std::get (like std:...