LLVM 20.0.0git
|
An ObjectLayer implementation built on JITLink. More...
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
Classes | |
class | Plugin |
Plugin instances can be added to the ObjectLinkingLayer to receive callbacks when code is loaded or emitted, and when JITLink is being configured. More... | |
Public Types | |
using | ReturnObjectBufferFunction = std::function< void(std::unique_ptr< MemoryBuffer >)> |
Public Member Functions | |
ObjectLinkingLayer (ExecutionSession &ES) | |
Construct an ObjectLinkingLayer using the ExecutorProcessControl instance's memory manager. | |
ObjectLinkingLayer (ExecutionSession &ES, jitlink::JITLinkMemoryManager &MemMgr) | |
Construct an ObjectLinkingLayer using a custom memory manager. | |
ObjectLinkingLayer (ExecutionSession &ES, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr) | |
Construct an ObjectLinkingLayer. | |
~ObjectLinkingLayer () | |
Destruct an ObjectLinkingLayer. | |
void | setReturnObjectBuffer (ReturnObjectBufferFunction ReturnObjectBuffer) |
Set an object buffer return function. | |
ObjectLinkingLayer & | addPlugin (std::shared_ptr< Plugin > P) |
Add a plugin. | |
void | removePlugin (Plugin &P) |
Remove a plugin. | |
Error | add (ResourceTrackerSP, std::unique_ptr< jitlink::LinkGraph > G) |
Add a LinkGraph to the JITDylib targeted by the given tracker. | |
Error | add (JITDylib &JD, std::unique_ptr< jitlink::LinkGraph > G) |
Add a LinkGraph to the given JITDylib. | |
void | emit (std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override |
Emit an object file. | |
void | emit (std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< jitlink::LinkGraph > G) |
Emit a LinkGraph. | |
ObjectLinkingLayer & | setOverrideObjectFlagsWithResponsibilityFlags (bool OverrideObjectFlags) |
Instructs this ObjectLinkingLayer instance to override the symbol flags found in the AtomGraph with the flags supplied by the MaterializationResponsibility instance. | |
ObjectLinkingLayer & | setAutoClaimResponsibilityForObjectSymbols (bool AutoClaimObjectSymbols) |
If set, this ObjectLinkingLayer instance will claim responsibility for any symbols provided by a given object file that were not already in the MaterializationResponsibility instance. | |
virtual Error | add (ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > O, MaterializationUnit::Interface I) |
Adds a MaterializationUnit for the object file in the given memory buffer to the JITDylib for the given ResourceTracker. | |
Error | add (ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > O) |
Adds a MaterializationUnit for the object file in the given memory buffer to the JITDylib for the given ResourceTracker. | |
Error | add (JITDylib &JD, std::unique_ptr< MemoryBuffer > O, MaterializationUnit::Interface I) |
Adds a MaterializationUnit for the object file in the given memory buffer to the given JITDylib. | |
Error | add (JITDylib &JD, std::unique_ptr< MemoryBuffer > O) |
Adds a MaterializationUnit for the object file in the given memory buffer to the given JITDylib. | |
Public Member Functions inherited from llvm::RTTIExtends< ObjectLinkingLayer, ObjectLayer > | |
const void * | dynamicClassID () const override |
bool | isA (const void *const ClassID) const override |
Static Public Attributes | |
static char | ID |
Friends | |
class | ObjectLinkingLayerJITLinkContext |
Additional Inherited Members | |
Static Public Member Functions inherited from llvm::RTTIExtends< ObjectLinkingLayer, ObjectLayer > | |
static const void * | classID () |
static bool | classof (const RTTIRoot *R) |
An ObjectLayer implementation built on JITLink.
Clients can use this class to add relocatable object files to an ExecutionSession, and it typically serves as the base layer (underneath a compiling layer like IRCompileLayer) for the rest of the JIT.
Definition at line 49 of file ObjectLinkingLayer.h.
using llvm::orc::ObjectLinkingLayer::ReturnObjectBufferFunction = std::function<void(std::unique_ptr<MemoryBuffer>)> |
Definition at line 96 of file ObjectLinkingLayer.h.
llvm::orc::ObjectLinkingLayer::ObjectLinkingLayer | ( | ExecutionSession & | ES | ) |
Construct an ObjectLinkingLayer using the ExecutorProcessControl instance's memory manager.
Definition at line 683 of file ObjectLinkingLayer.cpp.
References llvm::orc::ExecutionSession::registerResourceManager().
llvm::orc::ObjectLinkingLayer::ObjectLinkingLayer | ( | ExecutionSession & | ES, |
jitlink::JITLinkMemoryManager & | MemMgr | ||
) |
Construct an ObjectLinkingLayer using a custom memory manager.
Definition at line 688 of file ObjectLinkingLayer.cpp.
References llvm::orc::ExecutionSession::registerResourceManager().
llvm::orc::ObjectLinkingLayer::ObjectLinkingLayer | ( | ExecutionSession & | ES, |
std::unique_ptr< jitlink::JITLinkMemoryManager > | MemMgr | ||
) |
Construct an ObjectLinkingLayer.
Takes ownership of the given JITLinkMemoryManager. This method is a temporary hack to simplify co-existence with RTDyldObjectLinkingLayer (which also owns its allocators).
llvm::orc::ObjectLinkingLayer::~ObjectLinkingLayer | ( | ) |
Destruct an ObjectLinkingLayer.
Definition at line 700 of file ObjectLinkingLayer.cpp.
References assert().
|
inline |
Add a LinkGraph to the given JITDylib.
Definition at line 148 of file ObjectLinkingLayer.h.
References add(), G, and llvm::orc::JITDylib::getDefaultResourceTracker().
Error ObjectLayer::add | ( | JITDylib & | JD, |
std::unique_ptr< MemoryBuffer > | O | ||
) |
Adds a MaterializationUnit for the object file in the given memory buffer to the given JITDylib.
The interface for the object will be built using the default object interface builder.
|
inline |
Adds a MaterializationUnit for the object file in the given memory buffer to the given JITDylib.
Error ObjectLayer::add | ( | ResourceTrackerSP | RT, |
std::unique_ptr< MemoryBuffer > | O | ||
) |
Adds a MaterializationUnit for the object file in the given memory buffer to the JITDylib for the given ResourceTracker.
The interface for the object will be built using the default object interface builder.
Error ObjectLayer::add | ( | ResourceTrackerSP | RT, |
std::unique_ptr< MemoryBuffer > | O, | ||
MaterializationUnit::Interface | I | ||
) |
Adds a MaterializationUnit for the object file in the given memory buffer to the JITDylib for the given ResourceTracker.
Error llvm::orc::ObjectLinkingLayer::add | ( | ResourceTrackerSP | , |
std::unique_ptr< jitlink::LinkGraph > | G | ||
) |
Add a LinkGraph to the JITDylib targeted by the given tracker.
Referenced by add(), and llvm::orc::COFFPlatform::setupJITDylib().
|
inline |
void llvm::orc::ObjectLinkingLayer::emit | ( | std::unique_ptr< MaterializationResponsibility > | R, |
std::unique_ptr< jitlink::LinkGraph > | G | ||
) |
Emit a LinkGraph.
|
override |
Emit an object file.
Definition at line 712 of file ObjectLinkingLayer.cpp.
References assert(), llvm::jitlink::createLinkGraphFromObject(), G, and llvm::jitlink::link().
Referenced by llvm::orc::SimpleMachOHeaderMU::materialize(), and llvm::orc::SectCreateMaterializationUnit::materialize().
|
inline |
Remove a plugin.
This remove applies only to subsequent links (links already underway will continue to use the plugin), and does not of itself destroy the plugin – destruction will happen once all shared pointers (including those held by in-progress links) are destroyed.
Definition at line 135 of file ObjectLinkingLayer.h.
References assert(), llvm::find_if(), I, and P.
|
inline |
If set, this ObjectLinkingLayer instance will claim responsibility for any symbols provided by a given object file that were not already in the MaterializationResponsibility instance.
Setting this flag allows higher-level program representations (e.g. LLVM IR) to be added based on only a subset of the symbols they provide, without having to write intervening layers to scan and add the additional symbols. This trades diagnostic quality for convenience however: If all symbols are enumerated up-front then clashes can be detected and reported early (and usually deterministically). If this option is set, clashes for the additional symbols may not be detected until late, and detection may depend on the flow of control through JIT'd code. Use with care.
Definition at line 189 of file ObjectLinkingLayer.h.
|
inline |
Instructs this ObjectLinkingLayer instance to override the symbol flags found in the AtomGraph with the flags supplied by the MaterializationResponsibility instance.
This is a workaround to support symbol visibility in COFF, which does not use the libObject's SF_Exported flag. Use only when generating / adding COFF object files.
FIXME: We should be able to remove this if/when COFF properly tracks exported symbols.
Definition at line 172 of file ObjectLinkingLayer.h.
|
inline |
Set an object buffer return function.
By default object buffers are deleted once the JIT has linked them. If a return function is set then it will be called to transfer ownership of the buffer instead.
Definition at line 120 of file ObjectLinkingLayer.h.
|
friend |
Definition at line 51 of file ObjectLinkingLayer.h.
|
static |
Definition at line 54 of file ObjectLinkingLayer.h.