LLVM: llvm::jitlink::LinkGraph Class Reference (original) (raw)
#include "[llvm/ExecutionEngine/JITLink/JITLink.h](JITLink%5F8h%5Fsource.html)"
| Public Types | |
|---|---|
| using | external_symbol_iterator |
| using | absolute_symbol_iterator = AbsoluteSymbolSet::iterator |
| using | section_iterator |
| using | const_section_iterator |
| using | defined_symbol_iterator |
| using | const_defined_symbol_iterator |
| using | block_iterator |
| using | const_block_iterator |
| using | GetEdgeKindNameFunction = const char *(*)(Edge::Kind) |
| using | SplitBlockCache = std::optional<SmallVector<Symbol *, 8>> |
| Cache type for the splitBlock function. |
| Public Member Functions | |
|---|---|
| LinkGraph (std::string Name, std::shared_ptr< orc::SymbolStringPool > SSP, Triple TT, SubtargetFeatures Features, GetEdgeKindNameFunction GetEdgeKindName) | |
| LinkGraph (const LinkGraph &)=delete | |
| LinkGraph & | operator= (const LinkGraph &)=delete |
| LinkGraph (LinkGraph &&)=delete | |
| LinkGraph & | operator= (LinkGraph &&)=delete |
| LLVM_ABI | ~LinkGraph () |
| const std::string & | getName () const |
| Returns the name of this graph (usually the name of the original underlying MemoryBuffer). | |
| const Triple & | getTargetTriple () const |
| Returns the target triple for this Graph. | |
| const SubtargetFeatures & | getFeatures () const |
| Return the subtarget features for this Graph. | |
| unsigned | getPointerSize () const |
| Returns the pointer size for use in this graph. | |
| llvm::endianness | getEndianness () const |
| Returns the endianness of content in this graph. | |
| const char * | getEdgeKindName (Edge::Kind K) const |
| std::shared_ptr< orc::SymbolStringPool > | getSymbolStringPool () |
| MutableArrayRef< char > | allocateBuffer (size_t Size) |
| Allocate a mutable buffer of the given size using the LinkGraph's allocator. | |
| MutableArrayRef< char > | allocateContent (ArrayRef< char > Source) |
| Allocate a copy of the given string using the LinkGraph's allocator. | |
| MutableArrayRef< char > | allocateContent (Twine Source) |
| Allocate a copy of the given string using the LinkGraph's allocator. | |
| StringRef | allocateName (Twine Source) |
| Allocate a copy of the given string using the LinkGraph's allocator and return it as a StringRef. | |
| MutableArrayRef< char > | allocateCString (StringRef Source) |
| Allocate a copy of the given string using the LinkGraph's allocator. | |
| MutableArrayRef< char > | allocateCString (Twine Source) |
| Allocate a copy of the given string using the LinkGraph's allocator. | |
| Section & | createSection (StringRef Name, orc::MemProt Prot) |
| Create a section with the given name, protection flags. | |
| Block & | createContentBlock (Section &Parent, ArrayRef< char > Content, orc::ExecutorAddr Address, uint64_t Alignment, uint64_t AlignmentOffset) |
| Create a content block. | |
| Block & | createMutableContentBlock (Section &Parent, MutableArrayRef< char > MutableContent, orc::ExecutorAddr Address, uint64_t Alignment, uint64_t AlignmentOffset) |
| Create a content block with initially mutable data. | |
| Block & | createMutableContentBlock (Section &Parent, size_t ContentSize, orc::ExecutorAddr Address, uint64_t Alignment, uint64_t AlignmentOffset, bool ZeroInitialize=true) |
| Create a content block with initially mutable data of the given size. | |
| Block & | createZeroFillBlock (Section &Parent, orc::ExecutorAddrDiff Size, orc::ExecutorAddr Address, uint64_t Alignment, uint64_t AlignmentOffset) |
| Create a zero-fill block. | |
| BinaryStreamReader | getBlockContentReader (Block &B) |
| Returns a BinaryStreamReader for the given block. | |
| BinaryStreamWriter | getBlockContentWriter (Block &B) |
| Returns a BinaryStreamWriter for the given block. | |
| template | |
| std::vector< Block * > | splitBlock (Block &B, SplitOffsetRange &&SplitOffsets, LinkGraph::SplitBlockCache *Cache=nullptr) |
| Splits block B into a sequence of smaller blocks. | |
| orc::SymbolStringPtr | intern (StringRef SymbolName) |
| Intern the given string in the LinkGraph's SymbolStringPool. | |
| Symbol & | addExternalSymbol (orc::SymbolStringPtr Name, orc::ExecutorAddrDiff Size, bool IsWeaklyReferenced) |
| Add an external symbol. | |
| Symbol & | addExternalSymbol (StringRef Name, orc::ExecutorAddrDiff Size, bool IsWeaklyReferenced) |
| Symbol & | addAbsoluteSymbol (orc::SymbolStringPtr Name, orc::ExecutorAddr Address, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsLive) |
| Add an absolute symbol. | |
| Symbol & | addAbsoluteSymbol (StringRef Name, orc::ExecutorAddr Address, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsLive) |
| Symbol & | addAnonymousSymbol (Block &Content, orc::ExecutorAddrDiff Offset, orc::ExecutorAddrDiff Size, bool IsCallable, bool IsLive) |
| Add an anonymous symbol. | |
| Symbol & | addDefinedSymbol (Block &Content, orc::ExecutorAddrDiff Offset, StringRef Name, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsCallable, bool IsLive) |
| Add a named symbol. | |
| Symbol & | addDefinedSymbol (Block &Content, orc::ExecutorAddrDiff Offset, orc::SymbolStringPtr Name, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsCallable, bool IsLive) |
| iterator_range< section_iterator > | sections () |
| iterator_range< const_section_iterator > | sections () const |
| size_t | sections_size () const |
| Section * | findSectionByName (StringRef Name) |
| Returns the section with the given name if it exists, otherwise returns null. | |
| iterator_range< block_iterator > | blocks () |
| iterator_range< const_block_iterator > | blocks () const |
| iterator_range< external_symbol_iterator > | external_symbols () |
| Symbol * | findExternalSymbolByName (const orc::SymbolStringPtrBase &Name) |
| Returns the external symbol with the given name if one exists, otherwise returns nullptr. | |
| iterator_range< absolute_symbol_iterator > | absolute_symbols () |
| Symbol * | findAbsoluteSymbolByName (const orc::SymbolStringPtrBase &Name) |
| iterator_range< defined_symbol_iterator > | defined_symbols () |
| iterator_range< const_defined_symbol_iterator > | defined_symbols () const |
| Symbol * | findDefinedSymbolByName (const orc::SymbolStringPtrBase &Name) |
| Returns the defined symbol with the given name if one exists, otherwise returns nullptr. | |
| void | makeExternal (Symbol &Sym) |
| Make the given symbol external (must not already be external). | |
| void | makeAbsolute (Symbol &Sym, orc::ExecutorAddr Address) |
| Make the given symbol an absolute with the given address (must not already be absolute). | |
| void | makeDefined (Symbol &Sym, Block &Content, orc::ExecutorAddrDiff Offset, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsLive) |
| Turn an absolute or external symbol into a defined one by attaching it to a block. | |
| void | transferDefinedSymbol (Symbol &Sym, Block &DestBlock, orc::ExecutorAddrDiff NewOffset, std::optional< orc::ExecutorAddrDiff > ExplicitNewSize) |
| Transfer a defined symbol from one block to another. | |
| void | transferBlock (Block &B, Section &NewSection) |
| Transfers the given Block and all Symbols pointing to it to the given Section. | |
| void | mergeSections (Section &DstSection, Section &SrcSection, bool PreserveSrcSection=false) |
| Move all blocks and symbols from the source section to the destination section. | |
| void | removeExternalSymbol (Symbol &Sym) |
| Removes an external symbol. Also removes the underlying Addressable. | |
| void | removeAbsoluteSymbol (Symbol &Sym) |
| Remove an absolute symbol. Also removes the underlying Addressable. | |
| void | removeDefinedSymbol (Symbol &Sym) |
| Removes defined symbols. Does not remove the underlying block. | |
| void | removeBlock (Block &B) |
| Remove a block. | |
| void | removeSection (Section &Sec) |
| Remove a section. | |
| orc::shared::AllocActions & | allocActions () |
| Accessor for the AllocActions object for this graph. | |
| LLVM_ABI void | dump (raw_ostream &OS) |
| Dump the graph. |
Definition at line 879 of file JITLink.h.
◆ absolute_symbol_iterator
◆ block_iterator
Initial value:
Block *, getSectionBlocks>
An Addressable with content and edges.
mapped_iterator< SectionMap::iterator, GetSectionMapEntryValue > section_iterator
BlockSet::iterator block_iterator
Definition at line 1018 of file JITLink.h.
◆ const_block_iterator
Initial value:
getSectionConstBlocks>
mapped_iterator< SectionMap::const_iterator, GetSectionMapEntryConstValue > const_section_iterator
BlockSet::const_iterator const_block_iterator
Definition at line 1022 of file JITLink.h.
◆ const_defined_symbol_iterator
Initial value:
getSectionConstSymbols>
SymbolSet::const_iterator const_symbol_iterator
Definition at line 1013 of file JITLink.h.
◆ const_section_iterator
◆ defined_symbol_iterator
Initial value:
Symbol *, getSectionSymbols>
SymbolSet::iterator symbol_iterator
Definition at line 1009 of file JITLink.h.
◆ external_symbol_iterator
Initial value:
GetExternalSymbolMapEntryValue>
StringMapIterBase< Symbol *, false > iterator
Definition at line 952 of file JITLink.h.
◆ GetEdgeKindNameFunction
◆ section_iterator
◆ SplitBlockCache
Cache type for the splitBlock function.
Definition at line 1199 of file JITLink.h.
◆ LinkGraph() [2/3]
◆ LinkGraph() [3/3]
| llvm::jitlink::LinkGraph::LinkGraph ( LinkGraph && ) | delete |
|---|
◆ ~LinkGraph()
| llvm::jitlink::LinkGraph::~LinkGraph | ( | ) |
|---|
◆ absolute_symbols()
◆ addAbsoluteSymbol() [1/2]
◆ addAbsoluteSymbol() [2/2]
◆ addAnonymousSymbol()
◆ addDefinedSymbol() [1/2]
◆ addDefinedSymbol() [2/2]
◆ addExternalSymbol() [1/2]
Add an external symbol.
Some formats (e.g. ELF) allow Symbols to have sizes. For Symbols whose size is not known, you should substitute '0'. The IsWeaklyReferenced argument determines whether the symbol must be present during lookup: Externals that are strongly referenced must be found or an error will be emitted. Externals that are weakly referenced are permitted to be undefined, in which case they are assigned an address of 0.
Definition at line 1293 of file JITLink.h.
References assert(), Size, and llvm::jitlink::Strong.
Referenced by addExternalSymbol().
◆ addExternalSymbol() [2/2]
◆ allocActions()
Accessor for the AllocActions object for this graph.
This can be used to register allocation action calls prior to finalization.
Accessing this object after finalization will result in undefined behavior.
Definition at line 1659 of file JITLink.h.
◆ allocateBuffer()
◆ allocateContent() [1/2]
Allocate a copy of the given string using the LinkGraph's allocator.
This can be useful when renaming symbols or adding new content to the graph.
Definition at line 1076 of file JITLink.h.
References llvm::copy().
Referenced by allocateName().
◆ allocateContent() [2/2]
Allocate a copy of the given string using the LinkGraph's allocator.
This can be useful when renaming symbols or adding new content to the graph.
Note: This Twine-based overload requires an extra string copy and an extra heap allocation for large strings. The ArrayRef overload should be preferred where possible.
Definition at line 1089 of file JITLink.h.
References llvm::copy().
◆ allocateCString() [1/2]
Allocate a copy of the given string using the LinkGraph's allocator.
The allocated string will be terminated with a null character, and the returned MutableArrayRef will include this null character in the last position.
Definition at line 1112 of file JITLink.h.
References llvm::copy().
◆ allocateCString() [2/2]
Allocate a copy of the given string using the LinkGraph's allocator.
The allocated string will be terminated with a null character, and the returned MutableArrayRef will include this null character in the last position.
Note: This Twine-based overload requires an extra string copy and an extra heap allocation for large strings. The ArrayRef overload should be preferred where possible.
Definition at line 1128 of file JITLink.h.
References llvm::copy().
◆ allocateName()
| StringRef llvm::jitlink::LinkGraph::allocateName ( Twine Source) | inline |
|---|
Allocate a copy of the given string using the LinkGraph's allocator and return it as a StringRef.
This is a convenience wrapper around allocateContent(Twine) that is handy when creating new symbol names within the graph.
Definition at line 1102 of file JITLink.h.
References allocateContent().
◆ blocks() [1/2]
◆ blocks() [2/2]
◆ createContentBlock()
◆ createMutableContentBlock() [1/2]
◆ createMutableContentBlock() [2/2]
◆ createSection()
Create a section with the given name, protection flags.
Definition at line 1138 of file JITLink.h.
References assert().
◆ createZeroFillBlock()
◆ defined_symbols() [1/2]
◆ defined_symbols() [2/2]
◆ dump()
| void llvm::jitlink::LinkGraph::dump | ( | raw_ostream & | OS | ) |
|---|
◆ external_symbols()
◆ findAbsoluteSymbolByName()
◆ findDefinedSymbolByName()
Returns the defined symbol with the given name if one exists, otherwise returns nullptr.
Definition at line 1444 of file JITLink.h.
References defined_symbols().
◆ findExternalSymbolByName()
Returns the external symbol with the given name if one exists, otherwise returns nullptr.
Definition at line 1412 of file JITLink.h.
References external_symbols().
◆ findSectionByName()
Returns the section with the given name if it exists, otherwise returns null.
Definition at line 1383 of file JITLink.h.
References I.
◆ getBlockContentReader()
◆ getBlockContentWriter()
◆ getEdgeKindName()
| const char * llvm::jitlink::LinkGraph::getEdgeKindName ( Edge::Kind K) const | inline |
|---|
◆ getEndianness()
◆ getFeatures()
Return the subtarget features for this Graph.
Definition at line 1053 of file JITLink.h.
◆ getName()
| const std::string & llvm::jitlink::LinkGraph::getName ( ) const | inline |
|---|
◆ getPointerSize()
| unsigned llvm::jitlink::LinkGraph::getPointerSize ( ) const | inline |
|---|
Returns the pointer size for use in this graph.
Definition at line 1056 of file JITLink.h.
◆ getSymbolStringPool()
◆ getTargetTriple()
| const Triple & llvm::jitlink::LinkGraph::getTargetTriple ( ) const | inline |
|---|
◆ intern()
◆ makeAbsolute()
Make the given symbol an absolute with the given address (must not already be absolute).
The symbol's size, linkage, and callability, and liveness will be left unchanged, and its offset will be reset to 0.
If the symbol was external then its scope will be set to local, otherwise it will be left unchanged.
Definition at line 1482 of file JITLink.h.
References A(), llvm::Address, assert(), llvm::jitlink::Symbol::getAddressable(), llvm::jitlink::Symbol::getName(), llvm::jitlink::Symbol::getOffset(), llvm::jitlink::Symbol::getSection(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), llvm::jitlink::Symbol::isExternal(), llvm::jitlink::Local, and llvm::jitlink::Symbol::setScope().
◆ makeDefined()
Turn an absolute or external symbol into a defined one by attaching it to a block.
Symbol must not already be defined.
Definition at line 1504 of file JITLink.h.
References assert(), llvm::jitlink::Symbol::getName(), llvm::jitlink::Block::getSection(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), llvm::Offset, llvm::jitlink::Symbol::setLinkage(), llvm::jitlink::Symbol::setLive(), llvm::jitlink::Symbol::setOffset(), llvm::jitlink::Symbol::setScope(), llvm::jitlink::Symbol::setSize(), and Size.
◆ makeExternal()
| void llvm::jitlink::LinkGraph::makeExternal ( Symbol & Sym) | inline |
|---|
Make the given symbol external (must not already be external).
Symbol size, linkage and callability will be left unchanged. Symbol scope will be set to Default, and offset will be reset to 0.
Definition at line 1455 of file JITLink.h.
References A(), assert(), llvm::jitlink::Symbol::getAddressable(), llvm::jitlink::Symbol::getName(), llvm::jitlink::Symbol::getOffset(), llvm::jitlink::Symbol::getSection(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), and llvm::jitlink::Symbol::isExternal().
◆ mergeSections()
| void llvm::jitlink::LinkGraph::mergeSections ( Section & DstSection, Section & SrcSection, bool PreserveSrcSection = false ) | inline |
|---|
Move all blocks and symbols from the source section to the destination section.
If PreserveSrcSection is true (or SrcSection and DstSection are the same) then SrcSection is preserved, otherwise it is removed (the default).
Definition at line 1585 of file JITLink.h.
References B(), llvm::jitlink::Section::blocks(), and removeSection().
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ removeAbsoluteSymbol()
| void llvm::jitlink::LinkGraph::removeAbsoluteSymbol ( Symbol & Sym) | inline |
|---|
◆ removeBlock()
| void llvm::jitlink::LinkGraph::removeBlock ( Block & B) | inline |
|---|
◆ removeDefinedSymbol()
| void llvm::jitlink::LinkGraph::removeDefinedSymbol ( Symbol & Sym) | inline |
|---|
◆ removeExternalSymbol()
| void llvm::jitlink::LinkGraph::removeExternalSymbol ( Symbol & Sym) | inline |
|---|
◆ removeSection()
| void llvm::jitlink::LinkGraph::removeSection ( Section & Sec) | inline |
|---|
◆ sections() [1/2]
◆ sections() [2/2]
◆ sections_size()
| size_t llvm::jitlink::LinkGraph::sections_size ( ) const | inline |
|---|
◆ splitBlock()
template
| std::vector< Block * > llvm::jitlink::LinkGraph::splitBlock ( Block & B, SplitOffsetRange && SplitOffsets, LinkGraph::SplitBlockCache * Cache = nullptr ) | inline |
|---|
Splits block B into a sequence of smaller blocks.
SplitOffsets should be a sequence of ascending offsets in B. The starting offset should be greater than zero, and the final offset less than B.getSize() - 1.
The resulting seqeunce of blocks will start with the original block B (truncated to end at the first split offset) followed by newly introduced blocks starting at the subsequent split points.
The optional Cache parameter can be used to speed up repeated calls to splitBlock for blocks within a single Section. If the value is None then the cache will be treated as uninitialized and splitBlock will populate it. Otherwise it is assumed to contain the list of Symbols pointing at B, sorted in descending order of offset.
Notes:
- splitBlock must be used with care. Splitting a block may cause incoming edges to become invalid if the edge target subexpression points outside the bounds of the newly split target block (E.g. an edge 'S + 10 : Pointer64' where S points to a newly split block whose size is less than 10). No attempt is made to detect invalidation of incoming edges, as in general this requires context that the LinkGraph does not have. Clients are responsible for ensuring that splitBlock is not used in a way that invalidates edges.
- The newly introduced blocks will have new ordinals that will be higher than any other ordinals in the section. Clients are responsible for re-assigning block ordinals to restore a compatible order if needed.
- The cache is not automatically updated if new symbols are introduced between calls to splitBlock. Any newly introduced symbols may be added to the cache manually (descending offset order must be preserved), or the cache can be set to None and rebuilt by splitBlock on the next call.
Definition at line 1239 of file JITLink.h.
References assert(), B(), createContentBlock(), createZeroFillBlock(), and llvm::Offset.
◆ transferBlock()
| void llvm::jitlink::LinkGraph::transferBlock ( Block & B, Section & NewSection ) | inline |
|---|
◆ transferDefinedSymbol()
The documentation for this class was generated from the following files:
- include/llvm/ExecutionEngine/JITLink/JITLink.h
- lib/ExecutionEngine/JITLink/JITLink.cpp