LLVM 22.0.0git
llvm::orc::ReOptimizeLayer Class Reference

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

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

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 ()
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.
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

Detailed Description

Definition at line 28 of file ReOptimizeLayer.h.

Member Typedef Documentation

◆ AddProfilerFunc

Initial value:
unsigned CurVersion, ThreadSafeModule &TSM)>
ReOptimizeLayer(ExecutionSession &ES, DataLayout &DL, IRLayer &BaseLayer, RedirectableSymbolManager &RM)
An LLVM Module together with a shared ThreadSafeContext.
unique_function is a type-erasing functor similar to std::function.

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

Initial value:
unsigned CurVersion, ResourceTrackerSP OldRT, ThreadSafeModule &TSM)>
IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP
Definition Core.h:52

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.

◆ ReOptMaterializationUnitID

Constructor & Destructor Documentation

◆ ReOptimizeLayer()

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

Member Function Documentation

◆ createReoptimizeCall()

◆ 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::InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key.

◆ 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()

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

Definition at line 82 of file ReOptimizeLayer.h.

References ReOptimizeLayer(), and llvm::Error::success().

Referenced by ReOptimizeLayer().

◆ 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.

◆ reoptimizeIfCallFrequent()

◆ setAddProfilerFunc()

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

Definition at line 59 of file ReOptimizeLayer.h.

◆ setReoptimizeFunc()

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

Definition at line 55 of file ReOptimizeLayer.h.

Member Data Documentation

◆ CallCountThreshold

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

Definition at line 73 of file ReOptimizeLayer.h.

Referenced by reoptimizeIfCallFrequent().


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