13#ifndef LLVM_EXECUTIONENGINE_ORC_LLJIT_H 
   14#define LLVM_EXECUTIONENGINE_ORC_LLJIT_H 
   95    return ES->getJITDylibByName(Name);
 
 
  114                              std::unique_ptr<MemoryBuffer> LibBuffer);
 
  152  Error addObjectFile(
JITDylib &JD, std::unique_ptr<MemoryBuffer> Obj);
 
  190    this->PS = std::move(
PS);
 
 
  199      dbgs() << 
"LLJIT running initializers for JITDylib \"" << JD.
getName()
 
  202    assert(
PS && 
"PlatformSupport must be set to run initializers.");
 
  203    return PS->initialize(JD);
 
 
  209      dbgs() << 
"LLJIT running deinitializers for JITDylib \"" << JD.
getName()
 
  212    assert(
PS && 
"PlatformSupport must be set to run initializers.");
 
  213    return PS->deinitialize(JD);
 
 
  229  std::string mangle(
StringRef UnmangledName) 
const;
 
  233    return ES->intern(
mangle(UnmangledName));
 
 
  248  std::unique_ptr<ExecutionSession> 
ES;
 
  249  std::unique_ptr<PlatformSupport> 
PS;
 
 
  276    IPLayer->setPartitionFunction(std::move(Partition));
 
 
  295  std::unique_ptr<LazyCallThroughManager> LCTMgr;
 
  296  std::unique_ptr<IRPartitionLayer> IPLayer;
 
  297  std::unique_ptr<CompileOnDemandLayer> CODLayer;
 
 
  306      std::function<Expected<std::unique_ptr<IRCompileLayer::IRCompiler>>(
 
  316  std::unique_ptr<ExecutorProcessControl> 
EPC;
 
  317  std::unique_ptr<ExecutionSession> 
ES;
 
  318  std::optional<JITTargetMachineBuilder> 
JTMB;
 
  319  std::optional<DataLayout> 
DL;
 
 
  334template <
typename JITType, 
typename SetterImpl, 
typename State>
 
  343        "setExecutorProcessControl should not be called if an ExecutionSession " 
  344        "has already been set");
 
  345    impl().EPC = std::move(EPC);
 
 
  353        "setExecutionSession should not be called if an ExecutorProcessControl " 
  354        "object has already been set");
 
  355    impl().ES = std::move(ES);
 
 
  364    impl().JTMB = std::move(JTMB);
 
 
  377    impl().DL = std::move(
DL);
 
 
  388    impl().LinkProcessSymbolsByDefault = LinkProcessSymbolsByDefault;
 
 
  398          SetupProcessSymbolsJITDylib) {
 
  399    impl().SetupProcessSymbolsJITDylib = std::move(SetupProcessSymbolsJITDylib);
 
 
  409    impl().CreateObjectLinkingLayer = std::move(CreateObjectLinkingLayer);
 
 
  421    impl().CreateCompileFunction = std::move(CreateCompileFunction);
 
 
  434    impl().PrePlatformSetup = std::move(PrePlatformSetup);
 
 
  444    impl().SetUpPlatform = std::move(SetUpPlatform);
 
 
  454    impl().NotifyCreated = std::move(Callback);
 
 
  471    impl().NumCompileThreads = NumCompileThreads;
 
 
  484      std::optional<bool> SupportConcurrentCompilation) {
 
  485    impl().SupportConcurrentCompilation = SupportConcurrentCompilation;
 
 
  491    if (
auto Err = 
impl().prepareForConstruction())
 
  492      return std::move(Err);
 
  495    std::unique_ptr<JITType> J(
new JITType(
impl(), Err));
 
  497      return std::move(Err);
 
  499    if (
impl().NotifyCreated)
 
  500      if (
Error Err = 
impl().NotifyCreated(*J))
 
  501        return std::move(Err);
 
 
  507  SetterImpl &
impl() { 
return static_cast<SetterImpl &
>(*this); }
 
 
  520      std::function<std::unique_ptr<IndirectStubsManager>()>;
 
  524  std::unique_ptr<LazyCallThroughManager> 
LCTMgr;
 
 
  530template <
typename JITType, 
typename SetterImpl, 
typename State>
 
  538    this->
impl().LazyCompileFailureAddr = Addr;
 
 
  548    this->
impl().LCTMgr = std::move(LCTMgr);
 
 
  558    this->
impl().ISMBuilder = std::move(ISMBuilder);
 
 
 
  567                                     LLLazyJITBuilderState> {};
 
 
  579      : OrcRuntime(
std::
move(OrcRuntimePath)) {}
 
 
  583      : OrcRuntime(
std::
move(OrcRuntimeMB)) {}
 
 
  589                                       bool StaticVCRuntime) {
 
  590    VCRuntime = {std::move(VCRuntimePath), StaticVCRuntime};
 
 
  597  std::variant<std::string, std::unique_ptr<MemoryBuffer>> OrcRuntime;
 
  598  std::optional<std::pair<std::string, bool>> VCRuntime;
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
 
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
 
This file defines the SmallSet class.
 
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
 
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
 
A parsed version of the target data layout string in and methods for querying it.
 
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.
 
A Module instance is used to store all the information related to an LLVM module.
 
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
 
StringRef - Represent a constant reference to a string, i.e.
 
Triple - Helper class for working with autoconf configuration names.
 
const std::string & getName() const
Get the name for this JITLinkDylib.
 
An ExecutionSession represents a running JIT program.
 
Represents an address in the executor process.
 
ExecutorProcessControl supports interaction with a JIT target process.
 
std::function< std::optional< GlobalValueSet >(GlobalValueSet Requested)> PartitionFunction
Partitioning function.
 
Represents a JIT'd dynamic library.
 
A utility class for building TargetMachines for JITs.
 
SetterImpl & setLinkProcessSymbolsByDefault(bool LinkProcessSymbolsByDefault)
The LinkProcessSymbolsDyDefault flag determines whether the "Process" JITDylib will be added to the d...
 
SetterImpl & setNotifyCreatedCallback(LLJITBuilderState::NotifyCreatedFunction Callback)
Set up a callback after successful construction of the JIT.
 
std::optional< JITTargetMachineBuilder > & getJITTargetMachineBuilder()
Return a reference to the JITTargetMachineBuilder.
 
SetterImpl & setPrePlatformSetup(unique_function< Error(LLJIT &)> PrePlatformSetup)
Set a setup function to be run just before the PlatformSetupFunction is run.
 
SetterImpl & setCompileFunctionCreator(LLJITBuilderState::CompileFunctionCreator CreateCompileFunction)
Set a CompileFunctionCreator.
 
SetterImpl & setNumCompileThreads(unsigned NumCompileThreads)
Set the number of compile threads to use.
 
SetterImpl & setDataLayout(std::optional< DataLayout > DL)
Set a DataLayout for this instance.
 
SetterImpl & setJITTargetMachineBuilder(JITTargetMachineBuilder JTMB)
Set the JITTargetMachineBuilder for this instance.
 
SetterImpl & setExecutorProcessControl(std::unique_ptr< ExecutorProcessControl > EPC)
Set an ExecutorProcessControl for this instance.
 
SetterImpl & setObjectLinkingLayerCreator(LLJITBuilderState::ObjectLinkingLayerCreator CreateObjectLinkingLayer)
Set an ObjectLinkingLayer creation function.
 
SetterImpl & setPlatformSetUp(LLJITBuilderState::PlatformSetupFunction SetUpPlatform)
Set up an PlatformSetupFunction.
 
Expected< std::unique_ptr< JITType > > create()
Create an instance of the JIT.
 
SetterImpl & setExecutionSession(std::unique_ptr< ExecutionSession > ES)
Set an ExecutionSession for this instance.
 
SetterImpl & setSupportConcurrentCompilation(std::optional< bool > SupportConcurrentCompilation)
If set, this forces LLJIT concurrent compilation support to be either on or off.
 
SetterImpl & setProcessSymbolsJITDylibSetup(LLJITBuilderState::ProcessSymbolsJITDylibSetupFunction SetupProcessSymbolsJITDylib)
Set a setup function for the process symbols dylib.
 
LLVM_ABI Error prepareForConstruction()
Called prior to JIT class construcion to fix up defaults.
 
ProcessSymbolsJITDylibSetupFunction SetupProcessSymbolsJITDylib
 
ObjectLinkingLayerCreator CreateObjectLinkingLayer
 
unsigned NumCompileThreads
 
std::function< Error(LLJIT &)> NotifyCreatedFunction
 
std::unique_ptr< ExecutionSession > ES
 
unique_function< Error(LLJIT &)> PrePlatformSetup
 
CompileFunctionCreator CreateCompileFunction
 
std::optional< bool > SupportConcurrentCompilation
 
bool LinkProcessSymbolsByDefault
 
std::unique_ptr< ExecutorProcessControl > EPC
 
std::optional< DataLayout > DL
 
std::optional< JITTargetMachineBuilder > JTMB
 
unique_function< Expected< JITDylibSP >(LLJIT &J)> PlatformSetupFunction
 
std::function< Expected< std::unique_ptr< ObjectLayer > >(ExecutionSession &)> ObjectLinkingLayerCreator
 
PlatformSetupFunction SetUpPlatform
 
NotifyCreatedFunction NotifyCreated
 
unique_function< Expected< JITDylibSP >(LLJIT &J)> ProcessSymbolsJITDylibSetupFunction
 
std::function< Expected< std::unique_ptr< IRCompileLayer::IRCompiler > >( JITTargetMachineBuilder JTMB)> CompileFunctionCreator
 
Constructs LLJIT instances.
 
A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
 
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.
 
JITDylibSearchOrder DefaultLinks
 
const DataLayout & getDataLayout() const
Returns a reference to the DataLayout for this instance.
 
Error initialize(JITDylib &JD)
Run the initializers for the given JITDylib.
 
Error addIRModule(ThreadSafeModule TSM)
Adds an IR module to the Main JITDylib.
 
ObjectLayer & getObjLinkingLayer()
Returns a reference to the ObjLinkingLayer.
 
Expected< ExecutorAddr > lookupLinkerMangled(JITDylib &JD, StringRef Name)
Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on thei...
 
IRCompileLayer & getIRCompileLayer()
Returns a reference to the IR compile layer.
 
std::unique_ptr< ObjectTransformLayer > ObjTransformLayer
 
IRTransformLayer & getIRTransformLayer()
Returns a reference to the IR transform layer.
 
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
 
Error deinitialize(JITDylib &JD)
Run the deinitializers for the given JITDylib.
 
std::unique_ptr< IRCompileLayer > CompileLayer
 
Expected< ExecutorAddr > lookup(StringRef UnmangledName)
Look up a symbol in the main JITDylib based on its IR symbol name.
 
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...
 
PlatformSupport * getPlatformSupport()
Get the PlatformSupport instance.
 
JITDylib * ProcessSymbols
 
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.
 
Error addObjectFile(std::unique_ptr< MemoryBuffer > Obj)
Adds an object file to the given JITDylib.
 
std::unique_ptr< ObjectLayer > ObjLinkingLayer
 
std::unique_ptr< PlatformSupport > PS
 
JITDylibSearchOrder defaultLinkOrder()
Returns the default link order for this LLJIT instance.
 
LLVM_ABI friend Expected< JITDylibSP > setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
 
JITDylib * getJITDylibByName(StringRef Name)
Returns the JITDylib with the given name, or nullptr if no JITDylib with that name exists.
 
ObjectTransformLayer & getObjTransformLayer()
Returns a reference to the object transform layer.
 
Error addIRModule(ResourceTrackerSP RT, ThreadSafeModule TSM)
Adds an IR module with the given ResourceTracker.
 
friend class LLJITBuilderSetters
 
Expected< ExecutorAddr > lookupLinkerMangled(StringRef Name)
Look up a symbol in the main JITDylib by the symbol's linker-mangled name (to look up symbols based o...
 
SetterImpl & setLazyCompileFailureAddr(ExecutorAddr Addr)
Set the address in the target address to call if a lazy compile fails.
 
SetterImpl & setLazyCallthroughManager(std::unique_ptr< LazyCallThroughManager > LCTMgr)
Set the lazy-callthrough manager.
 
SetterImpl & setIndirectStubsManagerBuilder(LLLazyJITBuilderState::IndirectStubsManagerBuilderFunction ISMBuilder)
Set the IndirectStubsManager builder function.
 
ExecutorAddr LazyCompileFailureAddr
 
std::function< std::unique_ptr< IndirectStubsManager >()> IndirectStubsManagerBuilderFunction
 
std::unique_ptr< LazyCallThroughManager > LCTMgr
 
LLVM_ABI Error prepareForConstruction()
 
IndirectStubsManagerBuilderFunction ISMBuilder
 
Constructs LLLazyJIT instances.
 
An extended version of LLJIT that supports lazy function-at-a-time compilation of LLVM IR.
 
void setPartitionFunction(IRPartitionLayer::PartitionFunction Partition)
Sets the partition function.
 
Error addLazyIRModule(ThreadSafeModule M)
Add a module to be lazily compiled to the main JITDylib.
 
CompileOnDemandLayer & getCompileOnDemandLayer()
Returns a reference to the on-demand layer.
 
friend class LLJITBuilderSetters
 
LLVM_ABI Error addLazyIRModule(JITDylib &JD, ThreadSafeModule M)
Add a module to be lazily compiled to JITDylib JD.
 
Interface for Layers that accept object files.
 
Pointer to a pooled string representing a symbol name.
 
An LLVM Module together with a shared ThreadSafeContext.
 
unique_function is a type-erasing functor similar to std::function.
 
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
 
IntrusiveRefCntPtr< JITDylib > JITDylibSP
 
IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
 
LLVM_ABI Expected< JITDylibSP > setUpInactivePlatform(LLJIT &J)
Configure the LLJIT instance to disable platform support explicitly.
 
LLVM_ABI Expected< JITDylibSP > setUpGenericLLVMIRPlatform(LLJIT &J)
Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...
 
LLVM_ABI Error setUpOrcPlatformManually(LLJIT &J)
Configure the LLJIT instance to use orc runtime support.
 
This is an optimization pass for GlobalISel generic memory operations.
 
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
 
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
 
Implement std::hash so that hash_code can be used in STL containers.