LLVM 20.0.0git
|
#include "llvm/ExecutionEngine/Orc/ReOptimizeLayer.h"
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 () |
ExecutionSession & | getExecutionSession () |
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 |
Definition at line 27 of file ReOptimizeLayer.h.
using llvm::orc::ReOptimizeLayer::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.
Definition at line 34 of file ReOptimizeLayer.h.
using llvm::orc::ReOptimizeLayer::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.
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.
Definition at line 29 of file ReOptimizeLayer.h.
|
inline |
Definition at line 48 of file ReOptimizeLayer.h.
|
static |
Definition at line 209 of file ReOptimizeLayer.cpp.
References llvm::Function::Create(), llvm::IRBuilderBase::CreateCall(), llvm::GlobalValue::ExternalLinkage, llvm::IntegerType::get(), llvm::PointerType::get(), llvm::FunctionType::get(), and llvm::Type::getVoidTy().
Referenced by reoptimizeIfCallFrequent().
|
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().
|
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().
|
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.
|
inlinestatic |
Definition at line 81 of file ReOptimizeLayer.h.
References llvm::Error::success().
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().
|
static |
Basic AddProfilerFunc that reoptimizes the function when the call count exceeds CallCountThreshold.
Definition at line 82 of file ReOptimizeLayer.cpp.
References CallCountThreshold, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateLoad(), createReoptimizeCall(), llvm::IRBuilderBase::CreateStore(), F, llvm::Type::getInt64Ty(), llvm::Constant::getNullValue(), llvm::GlobalValue::InternalLinkage, llvm::SplitBlockAndInsertIfThen(), llvm::Error::success(), and llvm::orc::ThreadSafeModule::withModuleDo().
|
inline |
Definition at line 58 of file ReOptimizeLayer.h.
|
inline |
Definition at line 54 of file ReOptimizeLayer.h.
Definition at line 72 of file ReOptimizeLayer.h.
Referenced by reoptimizeIfCallFrequent().