LLVM
15.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 = Optional< SmallVector< Symbol *, 8 > > |
Cache type for the splitBlock function. More... | |
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). More... | |
const Triple & | getTargetTriple () const |
Returns the target triple for this Graph. More... | |
unsigned | getPointerSize () const |
Returns the pointer size for use in this graph. More... | |
support::endianness | getEndianness () const |
Returns the endianness of content in this graph. More... | |
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. More... | |
MutableArrayRef< char > | allocateContent (ArrayRef< char > Source) |
Allocate a copy of the given string using the LinkGraph's allocator. More... | |
MutableArrayRef< char > | allocateString (Twine Source) |
Allocate a copy of the given string using the LinkGraph's allocator. More... | |
Section & | createSection (StringRef Name, MemProt Prot) |
Create a section with the given name, protection flags, and alignment. More... | |
Block & | createContentBlock (Section &Parent, ArrayRef< char > Content, orc::ExecutorAddr Address, uint64_t Alignment, uint64_t AlignmentOffset) |
Create a content block. More... | |
Block & | createMutableContentBlock (Section &Parent, MutableArrayRef< char > MutableContent, orc::ExecutorAddr Address, uint64_t Alignment, uint64_t AlignmentOffset) |
Create a content block with initially mutable data. More... | |
Block & | createZeroFillBlock (Section &Parent, orc::ExecutorAddrDiff Size, orc::ExecutorAddr Address, uint64_t Alignment, uint64_t AlignmentOffset) |
Create a zero-fill block. More... | |
Block & | splitBlock (Block &B, size_t SplitIndex, SplitBlockCache *Cache=nullptr) |
Splits block B at the given index which must be greater than zero. More... | |
Symbol & | addExternalSymbol (StringRef Name, orc::ExecutorAddrDiff Size, Linkage L) |
Add an external symbol. More... | |
Symbol & | addAbsoluteSymbol (StringRef Name, orc::ExecutorAddr Address, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsLive) |
Add an absolute symbol. More... | |
Symbol & | addCommonSymbol (StringRef Name, Scope S, Section &Section, orc::ExecutorAddr Address, orc::ExecutorAddrDiff Size, uint64_t Alignment, bool IsLive) |
Convenience method for adding a weak zero-fill symbol. More... | |
Symbol & | addAnonymousSymbol (Block &Content, orc::ExecutorAddrDiff Offset, orc::ExecutorAddrDiff Size, bool IsCallable, bool IsLive) |
Add an anonymous symbol. More... | |
Symbol & | addDefinedSymbol (Block &Content, orc::ExecutorAddrDiff Offset, StringRef Name, orc::ExecutorAddrDiff Size, Linkage L, Scope S, bool IsCallable, bool IsLive) |
Add a named symbol. More... | |
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. More... | |
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). More... | |
void | makeAbsolute (Symbol &Sym, orc::ExecutorAddr Address) |
Make the given symbol an absolute with the given address (must not already be absolute). More... | |
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. More... | |
void | transferDefinedSymbol (Symbol &Sym, Block &DestBlock, orc::ExecutorAddrDiff NewOffset, Optional< orc::ExecutorAddrDiff > ExplicitNewSize) |
Transfer a defined symbol from one block to another. More... | |
void | transferBlock (Block &B, Section &NewSection) |
Transfers the given Block and all Symbols pointing to it to the given Section. More... | |
void | mergeSections (Section &DstSection, Section &SrcSection, bool PreserveSrcSection=false) |
Move all blocks and symbols from the source section to the destination section. More... | |
void | removeExternalSymbol (Symbol &Sym) |
Removes an external symbol. Also removes the underlying Addressable. More... | |
void | removeAbsoluteSymbol (Symbol &Sym) |
Remove an absolute symbol. Also removes the underlying Addressable. More... | |
void | removeDefinedSymbol (Symbol &Sym) |
Removes defined symbols. Does not remove the underlying block. More... | |
void | removeBlock (Block &B) |
Remove a block. More... | |
void | removeSection (Section &Sec) |
Remove a section. More... | |
orc::shared::AllocActions & | allocActions () |
Accessor for the AllocActions object for this graph. More... | |
void | dump (raw_ostream &OS) |
Dump the graph. More... | |
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 = Optional<SmallVector<Symbol *, 8> > |
|
inline |
|
delete |
|
inline |
Definition at line 1189 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 1101 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), assert(), llvm::count_if(), llvm::jitlink::Symbol::getName(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), and S.
|
inline |
Add an anonymous symbol.
Definition at line 1134 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), and Content.
|
inline |
Convenience method for adding a weak zero-fill symbol.
Definition at line 1117 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), assert(), llvm::count_if(), defined_symbols(), llvm::jitlink::Symbol::getName(), and S.
|
inline |
Add a named symbol.
Definition at line 1144 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), assert(), Content, llvm::count_if(), defined_symbols(), llvm::jitlink::Symbol::getName(), llvm::jitlink::Local, and S.
|
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'. For external symbols Linkage determines whether the symbol must be present during lookup: Externals with strong linkage must be found or an error will be emitted. Externals with weak linkage are permitted to be undefined, in which case they are assigned a value of 0.
Definition at line 1086 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), assert(), llvm::count_if(), llvm::jitlink::Symbol::getName(), and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert().
|
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 1409 of file JITLink.h.
Referenced by llvm::jitlink::BasicLayout::graphAllocActions().
|
inline |
Allocate a mutable buffer of the given size using the LinkGraph's allocator.
Definition at line 976 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate().
|
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 983 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), llvm::copy(), and llvm::Sched::Source.
|
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 996 of file JITLink.h.
References llvm::BumpPtrAllocatorImpl< AllocatorT, SlabSize, SizeThreshold, GrowthDelay >::Allocate(), llvm::copy(), and llvm::Sched::Source.
|
inline |
Definition at line 1175 of file JITLink.h.
References llvm::make_range().
Referenced by llvm::jitlink::PerGraphGOTAndPLTStubsBuilder< BuilderImplT >::run().
|
inline |
Definition at line 1180 of file JITLink.h.
References llvm::make_range().
|
inline |
Create a section with the given name, protection flags, and alignment.
Definition at line 1005 of file JITLink.h.
References assert(), llvm::find_if(), and move.
|
inline |
|
inline |
Definition at line 1193 of file JITLink.h.
References llvm::make_range().
Referenced by addCommonSymbol(), and addDefinedSymbol().
|
inline |
Definition at line 1198 of file JITLink.h.
References llvm::make_range().
void llvm::jitlink::LinkGraph::dump | ( | raw_ostream & | OS | ) |
|
inline |
Definition at line 1185 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 1168 of file JITLink.h.
References S, and sections().
|
inline |
Definition at line 972 of file JITLink.h.
Referenced by llvm::jitlink::PerGraphGOTAndPLTStubsBuilder< BuilderImplT >::run().
|
inline |
|
inline |
Returns the name of this graph (usually the name of the original underlying MemoryBuffer).
Definition at line 961 of file JITLink.h.
Referenced by llvm::orc::GDBJITDebugInfoRegistrationPlugin::modifyPassConfig().
|
inline |
Returns the target triple for this Graph.
Definition at line 964 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 1233 of file JITLink.h.
References 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 1253 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(), S, llvm::jitlink::Symbol::setLinkage(), llvm::jitlink::Symbol::setLive(), llvm::jitlink::Symbol::setScope(), and llvm::jitlink::Symbol::setSize().
|
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 1208 of file JITLink.h.
References 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 1333 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 1360 of file JITLink.h.
References assert(), llvm::sampleprof::Base, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::find_if(), llvm::jitlink::Symbol::isAbsolute(), and llvm::jitlink::Symbol::isDefined().
|
inline |
Remove a block.
The block reference is defunct after calling this function and should no longer be used.
Definition at line 1384 of file JITLink.h.
References assert(), B, and llvm::none_of().
|
inline |
Removes defined symbols. Does not remove the underlying block.
Definition at line 1376 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 1345 of file JITLink.h.
References assert(), llvm::sampleprof::Base, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::count(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::erase(), llvm::find_if(), llvm::jitlink::Symbol::isAbsolute(), and llvm::jitlink::Symbol::isDefined().
|
inline |
Remove a section.
The section reference is defunct after calling this function and should no longer be used.
Definition at line 1396 of file JITLink.h.
References assert(), llvm::find_if(), I, and S.
Referenced by mergeSections().
|
inline |
Definition at line 1159 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 151 of file JITLink.cpp.
References assert(), B, I, LHS, llvm::None, 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.
|
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 1286 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().