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

An ObjectLayer implementation built on JITLink. More...

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

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

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.
 
ObjectLinkingLayeraddPlugin (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.
 
ObjectLinkingLayersetOverrideObjectFlagsWithResponsibilityFlags (bool OverrideObjectFlags)
 Instructs this ObjectLinkingLayer instance to override the symbol flags found in the AtomGraph with the flags supplied by the MaterializationResponsibility instance.
 
ObjectLinkingLayersetAutoClaimResponsibilityForObjectSymbols (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)
 

Detailed Description

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.

Member Typedef Documentation

◆ ReturnObjectBufferFunction

using llvm::orc::ObjectLinkingLayer::ReturnObjectBufferFunction = std::function<void(std::unique_ptr<MemoryBuffer>)>

Definition at line 96 of file ObjectLinkingLayer.h.

Constructor & Destructor Documentation

◆ ObjectLinkingLayer() [1/3]

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

◆ ObjectLinkingLayer() [2/3]

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

◆ ObjectLinkingLayer() [3/3]

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

◆ ~ObjectLinkingLayer()

llvm::orc::ObjectLinkingLayer::~ObjectLinkingLayer ( )

Destruct an ObjectLinkingLayer.

Definition at line 700 of file ObjectLinkingLayer.cpp.

References assert().

Member Function Documentation

◆ add() [1/6]

Error llvm::orc::ObjectLinkingLayer::add ( JITDylib JD,
std::unique_ptr< jitlink::LinkGraph G 
)
inline

Add a LinkGraph to the given JITDylib.

Definition at line 148 of file ObjectLinkingLayer.h.

References add(), G, and llvm::orc::JITDylib::getDefaultResourceTracker().

◆ add() [2/6]

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.

Definition at line 163 of file Layer.cpp.

◆ add() [3/6]

Error llvm::orc::ObjectLayer::add ( JITDylib JD,
std::unique_ptr< MemoryBuffer O,
MaterializationUnit::Interface  I 
)
inline

Adds a MaterializationUnit for the object file in the given memory buffer to the given JITDylib.

Definition at line 155 of file Layer.h.

◆ add() [4/6]

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.

Definition at line 151 of file Layer.cpp.

◆ add() [5/6]

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.

Definition at line 145 of file Layer.cpp.

◆ add() [6/6]

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

◆ addPlugin()

ObjectLinkingLayer & llvm::orc::ObjectLinkingLayer::addPlugin ( std::shared_ptr< Plugin P)
inline

Add a plugin.

Definition at line 125 of file ObjectLinkingLayer.h.

References P.

◆ emit() [1/2]

void llvm::orc::ObjectLinkingLayer::emit ( std::unique_ptr< MaterializationResponsibility R,
std::unique_ptr< jitlink::LinkGraph G 
)

Emit a LinkGraph.

◆ emit() [2/2]

void llvm::orc::ObjectLinkingLayer::emit ( std::unique_ptr< MaterializationResponsibility R,
std::unique_ptr< MemoryBuffer O 
)
override

◆ removePlugin()

void llvm::orc::ObjectLinkingLayer::removePlugin ( Plugin P)
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.

◆ setAutoClaimResponsibilityForObjectSymbols()

ObjectLinkingLayer & llvm::orc::ObjectLinkingLayer::setAutoClaimResponsibilityForObjectSymbols ( bool  AutoClaimObjectSymbols)
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.

◆ setOverrideObjectFlagsWithResponsibilityFlags()

ObjectLinkingLayer & llvm::orc::ObjectLinkingLayer::setOverrideObjectFlagsWithResponsibilityFlags ( bool  OverrideObjectFlags)
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.

◆ setReturnObjectBuffer()

void llvm::orc::ObjectLinkingLayer::setReturnObjectBuffer ( ReturnObjectBufferFunction  ReturnObjectBuffer)
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.

Friends And Related Function Documentation

◆ ObjectLinkingLayerJITLinkContext

friend class ObjectLinkingLayerJITLinkContext
friend

Definition at line 51 of file ObjectLinkingLayer.h.

Member Data Documentation

◆ ID

char llvm::orc::ObjectLinkingLayer::ID
static

Definition at line 54 of file ObjectLinkingLayer.h.


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