LLVM  10.0.0
Public Member Functions | Friends | List of all members
llvm::orc::MaterializationResponsibility Class Reference

Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and JDs. More...

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

Public Member Functions

 MaterializationResponsibility (MaterializationResponsibility &&)=default
 
MaterializationResponsibility & operator= (MaterializationResponsibility &&)=delete
 
 ~MaterializationResponsibility ()
 Destruct a MaterializationResponsibility instance. More...
 
JITDylib & getTargetJITDylib () const
 Returns the target JITDylib that these symbols are being materialized into. More...
 
VModuleKey getVModuleKey () const
 Returns the VModuleKey for this instance. More...
 
const SymbolFlagsMap & getSymbols () const
 Returns the symbol flags map for this responsibility instance. More...
 
SymbolNameSet getRequestedSymbols () const
 Returns the names of any symbols covered by this MaterializationResponsibility object that have queries pending. More...
 
Error notifyResolved (const SymbolMap &Symbols)
 Notifies the target JITDylib that the given symbols have been resolved. More...
 
Error notifyEmitted ()
 Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by this MaterializationResponsibility instance have been emitted. More...
 
Error defineMaterializing (SymbolFlagsMap SymbolFlags)
 Attempt to claim responsibility for new definitions. More...
 
void failMaterialization ()
 Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has occurred. More...
 
void replace (std::unique_ptr< MaterializationUnit > MU)
 Transfers responsibility to the given MaterializationUnit for all symbols defined by that MaterializationUnit. More...
 
MaterializationResponsibility delegate (const SymbolNameSet &Symbols, VModuleKey NewKey=VModuleKey())
 Delegates responsibility for the given symbols to the returned materialization responsibility. More...
 
void addDependencies (const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies)
 
void addDependenciesForAll (const SymbolDependenceMap &Dependencies)
 Add dependencies that apply to all symbols covered by this instance. More...
 

Friends

class MaterializationUnit
 

Detailed Description

Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and JDs.

An instance of this class is passed to MaterializationUnits when their materialize method is called. It allows MaterializationUnits to resolve and emit symbols, or abandon materialization by notifying any unmaterialized symbols of an error.

Definition at line 434 of file Core.h.

Constructor & Destructor Documentation

◆ MaterializationResponsibility()

llvm::orc::MaterializationResponsibility::MaterializationResponsibility ( MaterializationResponsibility &&  )
default

◆ ~MaterializationResponsibility()

llvm::orc::MaterializationResponsibility::~MaterializationResponsibility ( )

Destruct a MaterializationResponsibility instance.

In debug mode this asserts that all symbols being tracked have been either emitted or notified of an error.

Definition at line 430 of file Core.cpp.

References assert(), and llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::empty().

Member Function Documentation

◆ addDependencies()

void llvm::orc::MaterializationResponsibility::addDependencies ( const SymbolStringPtr &  Name,
const SymbolDependenceMap &  Dependencies 
)

◆ addDependenciesForAll()

void llvm::orc::MaterializationResponsibility::addDependenciesForAll ( const SymbolDependenceMap &  Dependencies)

Add dependencies that apply to all symbols covered by this instance.

Definition at line 545 of file Core.cpp.

Referenced by llvm::orc::JITSymbolResolverAdapter::lookup().

◆ defineMaterializing()

Error llvm::orc::MaterializationResponsibility::defineMaterializing ( SymbolFlagsMap  SymbolFlags)

Attempt to claim responsibility for new definitions.

This method can be used to claim responsibility for symbols that are added to a materialization unit during the compilation process (e.g. literal pool symbols). Symbol linkage rules are the same as for symbols that are defined up front: duplicate strong definitions will result in errors. Duplicate weak definitions will be discarded (in which case they will not be added to this responsibility instance).

This method can be used by materialization units that want to add additional symbols at materialization time (e.g. stubs, compile callbacks, metadata).

Definition at line 470 of file Core.cpp.

References llvm::dbgs(), llvm::orc::JITDylib::getName(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::insert(), LLVM_DEBUG, and llvm::Error::success().

◆ delegate()

MaterializationResponsibility llvm::orc::MaterializationResponsibility::delegate ( const SymbolNameSet &  Symbols,
VModuleKey  NewKey = VModuleKey() 
)

Delegates responsibility for the given symbols to the returned materialization responsibility.

Useful for breaking up work between threads, or different kinds of materialization processes.

Definition at line 516 of file Core.cpp.

References assert(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), I, and Name.

Referenced by llvm::orc::ReExportsMaterializationUnit::getName().

◆ failMaterialization()

void llvm::orc::MaterializationResponsibility::failMaterialization ( )

Notify all not-yet-emitted covered by this MaterializationResponsibility instance that an error has occurred.

This will remove all symbols covered by this MaterializationResponsibilty from the target JITDylib, and send an error to any queries waiting on these symbols.

Definition at line 486 of file Core.cpp.

References llvm::dbgs(), llvm::orc::JITDylib::getName(), and LLVM_DEBUG.

Referenced by llvm::orc::ObjectTransformLayer::emit(), llvm::orc::IRTransformLayer::emit(), llvm::orc::IRCompileLayer::emit(), llvm::orc::RTDyldObjectLinkingLayer::emit(), and llvm::orc::LazyReexportsMaterializationUnit::getName().

◆ getRequestedSymbols()

SymbolNameSet llvm::orc::MaterializationResponsibility::getRequestedSymbols ( ) const

Returns the names of any symbols covered by this MaterializationResponsibility object that have queries pending.

This information can be used to return responsibility for unrequested symbols back to the JITDylib via the delegate method.

Definition at line 435 of file Core.cpp.

Referenced by llvm::orc::LazyReexportsMaterializationUnit::getName(), and llvm::orc::ReExportsMaterializationUnit::getName().

◆ getSymbols()

const SymbolFlagsMap& llvm::orc::MaterializationResponsibility::getSymbols ( ) const
inline

Returns the symbol flags map for this responsibility instance.

Note: The returned flags may have transient flags (Lazy, Materializing) set. These should be stripped with JITSymbolFlags::stripTransientFlags before using.

Definition at line 457 of file Core.h.

References Name, and llvm::replace().

Referenced by llvm::orc::CompileOnDemandLayer::emit().

◆ getTargetJITDylib()

JITDylib& llvm::orc::MaterializationResponsibility::getTargetJITDylib ( ) const
inline

◆ getVModuleKey()

VModuleKey llvm::orc::MaterializationResponsibility::getVModuleKey ( ) const
inline

Returns the VModuleKey for this instance.

Definition at line 451 of file Core.h.

Referenced by llvm::orc::IRCompileLayer::emit(), llvm::orc::RTDyldObjectLinkingLayer::emit(), and llvm::orc::EHFrameRegistrationPlugin::notifyEmitted().

◆ notifyEmitted()

Error llvm::orc::MaterializationResponsibility::notifyEmitted ( )

Notifies the target JITDylib (and any pending queries on that JITDylib) that all symbols covered by this MaterializationResponsibility instance have been emitted.

This method will return an error if any symbols being resolved have been moved to the error state due to the failure of a dependency. If this method returns an error then clients should log it and call failMaterialize. If no dependencies have been registered for the symbols covered by this MaterializationResponsibiility then this method is guaranteed to return Error::success() and can be wrapped with cantFail.

Definition at line 457 of file Core.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::dbgs(), llvm::orc::JITDylib::getName(), LLVM_DEBUG, and llvm::Error::success().

Referenced by llvm::orc::AbsoluteSymbolsMaterializationUnit::getName().

◆ notifyResolved()

Error llvm::orc::MaterializationResponsibility::notifyResolved ( const SymbolMap &  Symbols)

Notifies the target JITDylib that the given symbols have been resolved.

This will update the given symbols' addresses in the JITDylib, and notify any pending queries on the given symbols of their resolution. The given symbols must be ones covered by this MaterializationResponsibility instance. Individual calls to this method may resolve a subset of the symbols, but all symbols must have been resolved prior to calling emit.

This method will return an error if any symbols being resolved have been moved to the error state due to the failure of a dependency. If this method returns an error then clients should log it and call failMaterialize. If no dependencies have been registered for the symbols covered by this MaterializationResponsibiility then this method is guaranteed to return Error::success() and can be wrapped with cantFail.

Definition at line 439 of file Core.cpp.

References assert(), llvm::JITSymbolFlags::Common, llvm::dbgs(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::orc::JITDylib::getName(), I, LLVM_DEBUG, and llvm::JITSymbolFlags::Weak.

Referenced by llvm::orc::AbsoluteSymbolsMaterializationUnit::getName().

◆ operator=()

MaterializationResponsibility& llvm::orc::MaterializationResponsibility::operator= ( MaterializationResponsibility &&  )
delete

◆ replace()

void llvm::orc::MaterializationResponsibility::replace ( std::unique_ptr< MaterializationUnit >  MU)

Transfers responsibility to the given MaterializationUnit for all symbols defined by that MaterializationUnit.

This allows materializers to break up work based on run-time information (e.g. by introspecting which symbols have actually been looked up and materializing only those).

Definition at line 502 of file Core.cpp.

References llvm::dbgs(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::erase(), llvm::orc::JITDylib::getExecutionSession(), llvm::orc::JITDylib::getName(), LLVM_DEBUG, and llvm::orc::ExecutionSession::runSessionLocked().

Referenced by llvm::orc::LazyReexportsMaterializationUnit::getName(), and llvm::orc::ReExportsMaterializationUnit::getName().

Friends And Related Function Documentation

◆ MaterializationUnit

friend class MaterializationUnit
friend

Definition at line 435 of file Core.h.


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