LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
llvm::orc::ReOptimizeLayer Class Reference

#include "llvm/ExecutionEngine/Orc/ReOptimizeLayer.h"

Inheritance diagram for llvm::orc::ReOptimizeLayer:
Inheritance graph
[legend]

Public Types

using ReOptMaterializationUnitID = uint64_t
 
using AddProfilerFunc = unique_function< Error(ReOptimizeLayer &Parent, ReOptMaterializationUnitID MUID, unsigned CurVersion, ThreadSafeModule &TSM)>
 AddProfilerFunc will be called when ReOptimizeLayer emits the first version of a materialization unit in order to inject profiling code and reoptimization request code.
 
using ReOptimizeFunc = unique_function< Error(ReOptimizeLayer &Parent, ReOptMaterializationUnitID MUID, unsigned CurVersion, ResourceTrackerSP OldRT, ThreadSafeModule &TSM)>
 ReOptimizeFunc will be called when ReOptimizeLayer reoptimization of a materialization unit was requested in order to reoptimize the IR module based on profile data.
 

Public Member Functions

 ReOptimizeLayer (ExecutionSession &ES, DataLayout &DL, IRLayer &BaseLayer, RedirectableSymbolManager &RM)
 
void setReoptimizeFunc (ReOptimizeFunc ReOptFunc)
 
void setAddProfilerFunc (AddProfilerFunc ProfilerFunc)
 
Error reigsterRuntimeFunctions (JITDylib &PlatformJD)
 Registers reoptimize runtime dispatch handlers to given PlatformJD.
 
void emit (std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM) override
 Emits the given module.
 
Error handleRemoveResources (JITDylib &JD, ResourceKey K) override
 This function will be called outside the session lock.
 
void handleTransferResources (JITDylib &JD, ResourceKey DstK, ResourceKey SrcK) override
 This function will be called inside the session lock.
 
- Public Member Functions inherited from llvm::orc::IRLayer
 IRLayer (ExecutionSession &ES, const IRSymbolMapper::ManglingOptions *&MO)
 
virtual ~IRLayer ()
 
ExecutionSessiongetExecutionSession ()
 Returns the ExecutionSession for this layer.
 
const IRSymbolMapper::ManglingOptions *& getManglingOptions () const
 Get the mangling options for this layer.
 
void setCloneToNewContextOnEmit (bool CloneToNewContextOnEmit)
 Sets the CloneToNewContextOnEmit flag (false by default).
 
bool getCloneToNewContextOnEmit () const
 Returns the current value of the CloneToNewContextOnEmit flag.
 
virtual Error add (ResourceTrackerSP RT, ThreadSafeModule TSM)
 Add a MaterializatinoUnit representing the given IR to the JITDylib targeted by the given tracker.
 
Error add (JITDylib &JD, ThreadSafeModule TSM)
 Adds a MaterializationUnit representing the given IR to the given JITDylib.
 
virtual void emit (std::unique_ptr< MaterializationResponsibility > R, ThreadSafeModule TSM)=0
 Emit should materialize the given IR.
 
- Public Member Functions inherited from llvm::orc::ResourceManager
virtual ~ResourceManager ()
 
virtual Error handleRemoveResources (JITDylib &JD, ResourceKey K)=0
 This function will be called outside the session lock.
 
virtual void handleTransferResources (JITDylib &JD, ResourceKey DstK, ResourceKey SrcK)=0
 This function will be called inside the session lock.
 

Static Public Member Functions

static Error reoptimizeIfCallFrequent (ReOptimizeLayer &Parent, ReOptMaterializationUnitID MUID, unsigned CurVersion, ThreadSafeModule &TSM)
 Basic AddProfilerFunc that reoptimizes the function when the call count exceeds CallCountThreshold.
 
static Error identity (ReOptimizeLayer &Parent, ReOptMaterializationUnitID MUID, unsigned CurVersion, ResourceTrackerSP OldRT, ThreadSafeModule &TSM)
 
static void createReoptimizeCall (Module &M, Instruction &IP, GlobalVariable *ArgBuffer)
 

Static Public Attributes

static const uint64_t CallCountThreshold = 10
 

Detailed Description

Definition at line 27 of file ReOptimizeLayer.h.

Member Typedef Documentation

◆ AddProfilerFunc

AddProfilerFunc will be called when ReOptimizeLayer emits the first version of a materialization unit in order to inject profiling code and reoptimization request code.

Definition at line 34 of file ReOptimizeLayer.h.

◆ ReOptimizeFunc

ReOptimizeFunc will be called when ReOptimizeLayer reoptimization of a materialization unit was requested in order to reoptimize the IR module based on profile data.

OldRT is the ResourceTracker that tracks the old function definitions. The OldRT must be kept alive until it can be guaranteed that every invocation of the old function definitions has been terminated.

Definition at line 44 of file ReOptimizeLayer.h.

◆ ReOptMaterializationUnitID

Definition at line 29 of file ReOptimizeLayer.h.

Constructor & Destructor Documentation

◆ ReOptimizeLayer()

llvm::orc::ReOptimizeLayer::ReOptimizeLayer ( ExecutionSession ES,
DataLayout DL,
IRLayer BaseLayer,
RedirectableSymbolManager RM 
)
inline

Definition at line 48 of file ReOptimizeLayer.h.

Member Function Documentation

◆ createReoptimizeCall()

void ReOptimizeLayer::createReoptimizeCall ( Module M,
Instruction IP,
GlobalVariable ArgBuffer 
)
static

◆ emit()

void ReOptimizeLayer::emit ( std::unique_ptr< MaterializationResponsibility R,
ThreadSafeModule  TSM 
)
overridevirtual

Emits the given module.

This should not be called by clients: it will be called by the JIT when a definition added via the add method is requested.

Implements llvm::orc::IRLayer.

Definition at line 38 of file ReOptimizeLayer.cpp.

References llvm::orc::IRLayer::emit(), llvm::orc::RedirectableSymbolManager::emitRedirectableSymbols(), and llvm::orc::ExecutionSession::reportError().

◆ handleRemoveResources()

Error ReOptimizeLayer::handleRemoveResources ( JITDylib JD,
ResourceKey  K 
)
overridevirtual

This function will be called outside the session lock.

ResourceManagers should perform book-keeping under the session lock, and any expensive cleanup outside the session lock.

Implements llvm::orc::ResourceManager.

Definition at line 265 of file ReOptimizeLayer.cpp.

References llvm::Error::success().

◆ handleTransferResources()

void ReOptimizeLayer::handleTransferResources ( JITDylib JD,
ResourceKey  DstK,
ResourceKey  SrcK 
)
overridevirtual

This function will be called inside the session lock.

ResourceManagers DO NOT need to re-lock the session.

Implements llvm::orc::ResourceManager.

Definition at line 274 of file ReOptimizeLayer.cpp.

◆ identity()

static Error llvm::orc::ReOptimizeLayer::identity ( ReOptimizeLayer Parent,
ReOptMaterializationUnitID  MUID,
unsigned  CurVersion,
ResourceTrackerSP  OldRT,
ThreadSafeModule TSM 
)
inlinestatic

Definition at line 81 of file ReOptimizeLayer.h.

References llvm::Error::success().

◆ reigsterRuntimeFunctions()

Error ReOptimizeLayer::reigsterRuntimeFunctions ( JITDylib PlatformJD)

Registers reoptimize runtime dispatch handlers to given PlatformJD.

The reoptimization request will not be handled if dispatch handler is not registered by using this function.

Definition at line 29 of file ReOptimizeLayer.cpp.

References llvm::orc::ExecutionSession::registerJITDispatchHandlers(), and llvm::orc::ExecutionSession::wrapAsyncWithSPS().

◆ reoptimizeIfCallFrequent()

Error ReOptimizeLayer::reoptimizeIfCallFrequent ( ReOptimizeLayer Parent,
ReOptMaterializationUnitID  MUID,
unsigned  CurVersion,
ThreadSafeModule TSM 
)
static

◆ setAddProfilerFunc()

void llvm::orc::ReOptimizeLayer::setAddProfilerFunc ( AddProfilerFunc  ProfilerFunc)
inline

Definition at line 58 of file ReOptimizeLayer.h.

◆ setReoptimizeFunc()

void llvm::orc::ReOptimizeLayer::setReoptimizeFunc ( ReOptimizeFunc  ReOptFunc)
inline

Definition at line 54 of file ReOptimizeLayer.h.

Member Data Documentation

◆ CallCountThreshold

const uint64_t llvm::orc::ReOptimizeLayer::CallCountThreshold = 10
static

Definition at line 72 of file ReOptimizeLayer.h.

Referenced by reoptimizeIfCallFrequent().


The documentation for this class was generated from the following files: