LLVM 22.0.0git
|
#include "llvm/ExecutionEngine/Orc/ReOptimizeLayer.h"
Public Types | |
using | ReOptMaterializationUnitID = uint64_t |
using | 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. | |
using | 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. |
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. | |
Public Member Functions inherited from llvm::orc::ResourceManager | |
virtual | ~ResourceManager () |
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 28 of file ReOptimizeLayer.h.
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 35 of file ReOptimizeLayer.h.
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 45 of file ReOptimizeLayer.h.
Definition at line 30 of file ReOptimizeLayer.h.
|
inline |
Definition at line 49 of file ReOptimizeLayer.h.
References DL, llvm::orc::IRLayer::getManglingOptions(), identity(), llvm::orc::IRLayer::IRLayer(), and reoptimizeIfCallFrequent().
Referenced by identity(), and reoptimizeIfCallFrequent().
|
static |
Definition at line 209 of file ReOptimizeLayer.cpp.
References llvm::Function::Create(), llvm::IRBuilderBase::CreateCall(), llvm::GlobalValue::ExternalLinkage, llvm::FunctionType::get(), llvm::IntegerType::get(), llvm::PointerType::get(), llvm::Function::getFunction(), 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::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key.
|
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 82 of file ReOptimizeLayer.h.
References ReOptimizeLayer(), and llvm::Error::success().
Referenced by ReOptimizeLayer().
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.
|
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, ReOptimizeLayer(), llvm::SplitBlockAndInsertIfThen(), llvm::Error::success(), and llvm::orc::ThreadSafeModule::withModuleDo().
Referenced by ReOptimizeLayer().
|
inline |
Definition at line 59 of file ReOptimizeLayer.h.
|
inline |
Definition at line 55 of file ReOptimizeLayer.h.
Definition at line 73 of file ReOptimizeLayer.h.
Referenced by reoptimizeIfCallFrequent().