LLVM 17.0.0git
|
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
Classes | |
class | nested_collection_iterator |
Public Types | |
using | external_symbol_iterator = ExternalSymbolSet::iterator |
using | section_iterator = pointee_iterator< SectionList::iterator > |
using | const_section_iterator = pointee_iterator< SectionList::const_iterator > |
using | defined_symbol_iterator = nested_collection_iterator< const_section_iterator, Section::symbol_iterator, Symbol *, getSectionSymbols > |
using | const_defined_symbol_iterator = nested_collection_iterator< const_section_iterator, Section::const_symbol_iterator, const Symbol *, getSectionConstSymbols > |
using | block_iterator = nested_collection_iterator< const_section_iterator, Section::block_iterator, Block *, getSectionBlocks > |
using | const_block_iterator = nested_collection_iterator< const_section_iterator, Section::const_block_iterator, const Block *, getSectionConstBlocks > |
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, const Triple &TT, unsigned PointerSize, support::endianness Endianness, GetEdgeKindNameFunction GetEdgeKindName) | |
LinkGraph (const LinkGraph &)=delete | |
LinkGraph & | operator= (const LinkGraph &)=delete |
LinkGraph (LinkGraph &&)=delete | |
LinkGraph & | operator= (LinkGraph &&)=delete |
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. | |
unsigned | getPointerSize () const |
Returns the pointer size for use in this graph. | |
support::endianness | getEndianness () const |
Returns the endianness of content in this graph. | |
const char * | getEdgeKindName (Edge::Kind K) const |
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 > | allocateString (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, and alignment. | |
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. | |
Block & | splitBlock (Block &B, size_t SplitIndex, SplitBlockCache *Cache=nullptr) |
Splits block B at the given index which must be greater than zero. | |
Symbol & | addExternalSymbol (StringRef Name, orc::ExecutorAddrDiff Size, bool IsWeaklyReferenced) |
Add an external symbol. | |
Symbol & | addAbsoluteSymbol (StringRef Name, orc::ExecutorAddr Address, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsLive) |
Add an absolute symbol. | |
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. | |
iterator_range< section_iterator > | sections () |
SectionList::size_type | 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 () |
iterator_range< external_symbol_iterator > | absolute_symbols () |
iterator_range< defined_symbol_iterator > | defined_symbols () |
iterator_range< const_defined_symbol_iterator > | defined_symbols () const |
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. | |
void | dump (raw_ostream &OS) |
Dump the graph. | |
using llvm::jitlink::LinkGraph::block_iterator = nested_collection_iterator<const_section_iterator, Section::block_iterator, Block *, getSectionBlocks> |
using llvm::jitlink::LinkGraph::const_block_iterator = nested_collection_iterator<const_section_iterator, Section::const_block_iterator, const Block *, getSectionConstBlocks> |
using llvm::jitlink::LinkGraph::const_defined_symbol_iterator = nested_collection_iterator<const_section_iterator, Section::const_symbol_iterator, const Symbol *, getSectionConstSymbols> |
using llvm::jitlink::LinkGraph::const_section_iterator = pointee_iterator<SectionList::const_iterator> |
using llvm::jitlink::LinkGraph::defined_symbol_iterator = nested_collection_iterator<const_section_iterator, Section::symbol_iterator, Symbol *, getSectionSymbols> |
using llvm::jitlink::LinkGraph::GetEdgeKindNameFunction = const char *(*)(Edge::Kind) |
using llvm::jitlink::LinkGraph::section_iterator = pointee_iterator<SectionList::iterator> |
using llvm::jitlink::LinkGraph::SplitBlockCache = std::optional<SmallVector<Symbol *, 8> > |
|
inline |
|
delete |
|
inline |
Definition at line 1204 of file JITLink.h.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::begin(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), and llvm::make_range().
|
inline |
Add an absolute symbol.
Definition at line 1135 of file JITLink.h.
References llvm::Address, Allocator, assert(), llvm::count_if(), llvm::jitlink::Symbol::getName(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::jitlink::Local, and Size.
|
inline |
|
inline |
Add a named symbol.
Definition at line 1160 of file JITLink.h.
References Allocator, assert(), Content, llvm::count_if(), defined_symbols(), llvm::jitlink::Symbol::getName(), llvm::jitlink::Local, llvm::Offset, and Size.
|
inline |
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 1120 of file JITLink.h.
References Allocator, assert(), llvm::count_if(), llvm::jitlink::Symbol::getName(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), Size, and llvm::jitlink::Strong.
|
inline |
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 1427 of file JITLink.h.
Referenced by llvm::orc::EPCGenericJITLinkMemoryManager::InFlightAlloc::finalize(), llvm::orc::MapperJITLinkMemoryManager::InFlightAlloc::finalize(), llvm::jitlink::InProcessMemoryManager::IPInFlightAlloc::finalize(), and llvm::jitlink::BasicLayout::graphAllocActions().
|
inline |
|
inline |
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 986 of file JITLink.h.
References Allocator, and llvm::copy().
Referenced by createMutableContentBlock().
|
inline |
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<char> overload should be preferred where possible.
Definition at line 999 of file JITLink.h.
References Allocator, and llvm::copy().
|
inline |
Definition at line 1190 of file JITLink.h.
References llvm::make_range().
Referenced by llvm::jitlink::PerGraphGOTAndPLTStubsBuilder< BuilderImplT >::run().
|
inline |
Definition at line 1195 of file JITLink.h.
References llvm::make_range().
|
inline |
Create a content block.
Definition at line 1020 of file JITLink.h.
References llvm::Address, and Content.
Referenced by splitBlock().
|
inline |
Create a content block with initially mutable data.
Definition at line 1027 of file JITLink.h.
References llvm::Address.
|
inline |
Create a content block with initially mutable data of the given size.
Content will be allocated via the LinkGraph's allocateBuffer method. By default the memory will be zero-initialized. Passing false for ZeroInitialize will prevent this.
Definition at line 1040 of file JITLink.h.
References llvm::Address, allocateContent(), and Content.
|
inline |
Create a section with the given name, protection flags, and alignment.
Definition at line 1008 of file JITLink.h.
References assert(), and llvm::none_of().
|
inline |
Create a zero-fill block.
Definition at line 1051 of file JITLink.h.
References llvm::Address, and Size.
Referenced by splitBlock().
|
inline |
Definition at line 1208 of file JITLink.h.
References llvm::make_range().
Referenced by addDefinedSymbol(), and dump().
|
inline |
Definition at line 1213 of file JITLink.h.
References llvm::make_range().
void llvm::jitlink::LinkGraph::dump | ( | raw_ostream & | OS | ) |
Dump the graph.
Definition at line 230 of file JITLink.cpp.
References defined_symbols(), LHS, RHS, and llvm::sort().
|
inline |
Definition at line 1200 of file JITLink.h.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::begin(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), and llvm::make_range().
Returns the section with the given name if it exists, otherwise returns null.
Definition at line 1183 of file JITLink.h.
References llvm::jitlink::Symbol::getName(), and sections().
|
inline |
Returns a BinaryStreamReader for the given block.
Definition at line 1058 of file JITLink.h.
References B, llvm::CallingConv::C, and getEndianness().
|
inline |
Returns a BinaryStreamWriter for the given block.
This will call getMutableContent to obtain mutable content for the block.
Definition at line 1066 of file JITLink.h.
References B, llvm::CallingConv::C, and getEndianness().
|
inline |
Definition at line 975 of file JITLink.h.
Referenced by llvm::jitlink::PerGraphGOTAndPLTStubsBuilder< BuilderImplT >::run().
|
inline |
Returns the endianness of content in this graph.
Definition at line 973 of file JITLink.h.
Referenced by getBlockContentReader(), and getBlockContentWriter().
|
inline |
Returns the name of this graph (usually the name of the original underlying MemoryBuffer).
Definition at line 964 of file JITLink.h.
Referenced by llvm::orc::GDBJITDebugInfoRegistrationPlugin::modifyPassConfig().
|
inline |
Returns the target triple for this Graph.
Definition at line 967 of file JITLink.h.
Referenced by llvm::orc::GDBJITDebugInfoRegistrationPlugin::modifyPassConfig().
|
inline |
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 1250 of file JITLink.h.
References A, llvm::Address, assert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::jitlink::Symbol::getAddressable(), llvm::jitlink::Symbol::getBlock(), llvm::jitlink::Symbol::getOffset(), llvm::jitlink::Block::getSection(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), llvm::jitlink::Symbol::isExternal(), llvm::jitlink::Local, and llvm::jitlink::Symbol::setScope().
|
inline |
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 1272 of file JITLink.h.
References assert(), Content, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), llvm::Offset, llvm::jitlink::Symbol::setLinkage(), llvm::jitlink::Symbol::setLive(), llvm::jitlink::Symbol::setScope(), llvm::jitlink::Symbol::setSize(), and Size.
|
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 1223 of file JITLink.h.
References A, assert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::jitlink::Symbol::getAddressable(), llvm::jitlink::Symbol::getBlock(), llvm::jitlink::Symbol::getOffset(), llvm::jitlink::Block::getSection(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), and llvm::jitlink::Symbol::isExternal().
|
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 1353 of file JITLink.h.
References B, llvm::jitlink::Section::blocks(), and removeSection().
|
inline |
Remove an absolute symbol. Also removes the underlying Addressable.
Definition at line 1379 of file JITLink.h.
References assert(), llvm::sampleprof::Base, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), and llvm::none_of().
|
inline |
Remove a block.
The block reference is defunct after calling this function and should no longer be used.
Definition at line 1402 of file JITLink.h.
References assert(), B, and llvm::none_of().
|
inline |
Removes defined symbols. Does not remove the underlying block.
Definition at line 1394 of file JITLink.h.
References assert(), llvm::jitlink::Symbol::getBlock(), llvm::jitlink::Block::getSection(), and llvm::jitlink::Symbol::isDefined().
|
inline |
Removes an external symbol. Also removes the underlying Addressable.
Definition at line 1365 of file JITLink.h.
References assert(), llvm::sampleprof::Base, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::jitlink::Symbol::isAbsolute(), llvm::jitlink::Symbol::isDefined(), and llvm::none_of().
|
inline |
Remove a section.
The section reference is defunct after calling this function and should no longer be used.
Definition at line 1414 of file JITLink.h.
References assert(), llvm::find_if(), and I.
Referenced by mergeSections().
|
inline |
Definition at line 1174 of file JITLink.h.
References llvm::make_range().
Referenced by findSectionByName(), and llvm::orc::DebugObjectManagerPlugin::modifyPassConfig().
|
inline |
Block & llvm::jitlink::LinkGraph::splitBlock | ( | Block & | B, |
size_t | SplitIndex, | ||
SplitBlockCache * | Cache = nullptr |
||
) |
Splits block B at the given index which must be greater than zero.
If SplitIndex == B.getSize() then this function is a no-op and returns B. If SplitIndex < B.getSize() then this function returns a new block covering the range [ 0, SplitIndex ), and B is modified to cover the range [ SplitIndex, B.size() ).
The optional Cache parameter can be used to speed up repeated calls to splitBlock for a single block. If the value is None 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:
Definition at line 150 of file JITLink.cpp.
References assert(), B, createContentBlock(), createZeroFillBlock(), I, LHS, RHS, and llvm::sort().
Transfers the given Block and all Symbols pointing to it to the given Section.
No attempt is made to check compatibility of the source and destination sections. Blocks may be moved between sections with incompatible permissions (e.g. from data to text). The client is responsible for ensuring that this is safe.
Definition at line 1332 of file JITLink.h.
References B, llvm::jitlink::Symbol::getBlock(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().
|
inline |
Transfer a defined symbol from one block to another.
The symbol's offset within DestBlock is set to NewOffset.
If ExplicitNewSize is given as None then the size of the symbol will be checked and auto-truncated to at most the size of the remainder (from the given offset) of the size of the new block.
All other symbol attributes are unchanged.
Definition at line 1306 of file JITLink.h.
References llvm::jitlink::Symbol::getBlock(), llvm::jitlink::Block::getSection(), llvm::jitlink::Block::getSize(), llvm::jitlink::Symbol::getSize(), and llvm::jitlink::Symbol::setSize().