LLVM  11.0.0git
Classes | Public Types | Public Member Functions | List of all members
llvm::jitlink::LinkGraph Class Reference

#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 SplitBlockCache = Optional< SmallVector< Symbol *, 8 > >
 Cache type for the splitBlock function. More...
 

Public Member Functions

 LinkGraph (std::string Name, unsigned PointerSize, support::endianness Endianness)
 
const std::string & getName ()
 Returns the name of this graph (usually the name of the original underlying MemoryBuffer). 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...
 
SectioncreateSection (StringRef Name, sys::Memory::ProtectionFlags Prot)
 Create a section with the given name, protection flags, and alignment. More...
 
BlockcreateContentBlock (Section &Parent, StringRef Content, uint64_t Address, uint64_t Alignment, uint64_t AlignmentOffset)
 Create a content block. More...
 
BlockcreateZeroFillBlock (Section &Parent, uint64_t Size, uint64_t Address, uint64_t Alignment, uint64_t AlignmentOffset)
 Create a zero-fill block. More...
 
BlocksplitBlock (Block &B, size_t SplitIndex, SplitBlockCache *Cache=nullptr)
 Splits block B at the given index which must be greater than zero. More...
 
SymboladdExternalSymbol (StringRef Name, uint64_t Size, Linkage L)
 Add an external symbol. More...
 
SymboladdAbsoluteSymbol (StringRef Name, JITTargetAddress Address, uint64_t Size, Linkage L, Scope S, bool IsLive)
 Add an absolute symbol. More...
 
SymboladdCommonSymbol (StringRef Name, Scope S, Section &Section, JITTargetAddress Address, uint64_t Size, uint64_t Alignment, bool IsLive)
 Convenience method for adding a weak zero-fill symbol. More...
 
SymboladdAnonymousSymbol (Block &Content, JITTargetAddress Offset, JITTargetAddress Size, bool IsCallable, bool IsLive)
 Add an anonymous symbol. More...
 
SymboladdDefinedSymbol (Block &Content, JITTargetAddress Offset, StringRef Name, JITTargetAddress Size, Linkage L, Scope S, bool IsCallable, bool IsLive)
 Add a named symbol. More...
 
iterator_range< section_iteratorsections ()
 
SectionfindSectionByName (StringRef Name)
 Returns the section with the given name if it exists, otherwise returns null. More...
 
iterator_range< block_iteratorblocks ()
 
iterator_range< const_block_iteratorblocks () const
 
iterator_range< external_symbol_iteratorexternal_symbols ()
 
iterator_range< external_symbol_iteratorabsolute_symbols ()
 
iterator_range< defined_symbol_iteratordefined_symbols ()
 
iterator_range< const_defined_symbol_iteratordefined_symbols () const
 
void makeExternal (Symbol &Sym)
 Turn a defined symbol into an external one. 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 dump (raw_ostream &OS, std::function< StringRef(Edge::Kind)> EdegKindToName=std::function< StringRef(Edge::Kind)>())
 Dump the graph. More...
 

Detailed Description

Definition at line 656 of file JITLink.h.

Member Typedef Documentation

◆ block_iterator

Definition at line 776 of file JITLink.h.

◆ const_block_iterator

Definition at line 781 of file JITLink.h.

◆ const_defined_symbol_iterator

Definition at line 772 of file JITLink.h.

◆ const_section_iterator

Definition at line 715 of file JITLink.h.

◆ defined_symbol_iterator

Definition at line 767 of file JITLink.h.

◆ external_symbol_iterator

Definition at line 712 of file JITLink.h.

◆ section_iterator

Definition at line 714 of file JITLink.h.

◆ SplitBlockCache

Cache type for the splitBlock function.

Definition at line 819 of file JITLink.h.

Constructor & Destructor Documentation

◆ LinkGraph()

llvm::jitlink::LinkGraph::LinkGraph ( std::string  Name,
unsigned  PointerSize,
support::endianness  Endianness 
)
inline

Definition at line 783 of file JITLink.h.

Member Function Documentation

◆ absolute_symbols()

iterator_range<external_symbol_iterator> llvm::jitlink::LinkGraph::absolute_symbols ( )
inline

◆ addAbsoluteSymbol()

Symbol& llvm::jitlink::LinkGraph::addAbsoluteSymbol ( StringRef  Name,
JITTargetAddress  Address,
uint64_t  Size,
Linkage  L,
Scope  S,
bool  IsLive 
)
inline

Add an absolute symbol.

Definition at line 864 of file JITLink.h.

References Allocator.

◆ addAnonymousSymbol()

Symbol& llvm::jitlink::LinkGraph::addAnonymousSymbol ( Block Content,
JITTargetAddress  Offset,
JITTargetAddress  Size,
bool  IsCallable,
bool  IsLive 
)
inline

Add an anonymous symbol.

Definition at line 886 of file JITLink.h.

References Allocator, and llvm::jitlink::Block::getSection().

◆ addCommonSymbol()

Symbol& llvm::jitlink::LinkGraph::addCommonSymbol ( StringRef  Name,
Scope  S,
Section Section,
JITTargetAddress  Address,
uint64_t  Size,
uint64_t  Alignment,
bool  IsLive 
)
inline

Convenience method for adding a weak zero-fill symbol.

Definition at line 874 of file JITLink.h.

References Allocator.

◆ addDefinedSymbol()

Symbol& llvm::jitlink::LinkGraph::addDefinedSymbol ( Block Content,
JITTargetAddress  Offset,
StringRef  Name,
JITTargetAddress  Size,
Linkage  L,
Scope  S,
bool  IsCallable,
bool  IsLive 
)
inline

Add a named symbol.

Definition at line 896 of file JITLink.h.

References Allocator, and llvm::jitlink::Block::getSection().

◆ addExternalSymbol()

Symbol& llvm::jitlink::LinkGraph::addExternalSymbol ( StringRef  Name,
uint64_t  Size,
Linkage  L 
)
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 855 of file JITLink.h.

References Allocator.

◆ blocks() [1/2]

iterator_range<block_iterator> llvm::jitlink::LinkGraph::blocks ( )
inline

◆ blocks() [2/2]

iterator_range<const_block_iterator> llvm::jitlink::LinkGraph::blocks ( ) const
inline

Definition at line 925 of file JITLink.h.

References llvm::make_range().

◆ createContentBlock()

Block& llvm::jitlink::LinkGraph::createContentBlock ( Section Parent,
StringRef  Content,
uint64_t  Address,
uint64_t  Alignment,
uint64_t  AlignmentOffset 
)
inline

Create a content block.

Definition at line 806 of file JITLink.h.

◆ createSection()

Section& llvm::jitlink::LinkGraph::createSection ( StringRef  Name,
sys::Memory::ProtectionFlags  Prot 
)
inline

Create a section with the given name, protection flags, and alignment.

Definition at line 799 of file JITLink.h.

References llvm::ARMBuildAttrs::Section, and llvm::StringRef::size().

◆ createZeroFillBlock()

Block& llvm::jitlink::LinkGraph::createZeroFillBlock ( Section Parent,
uint64_t  Size,
uint64_t  Address,
uint64_t  Alignment,
uint64_t  AlignmentOffset 
)
inline

Create a zero-fill block.

Definition at line 813 of file JITLink.h.

◆ defined_symbols() [1/2]

iterator_range<defined_symbol_iterator> llvm::jitlink::LinkGraph::defined_symbols ( )
inline

◆ defined_symbols() [2/2]

iterator_range<const_defined_symbol_iterator> llvm::jitlink::LinkGraph::defined_symbols ( ) const
inline

Definition at line 943 of file JITLink.h.

References llvm::make_range().

◆ dump()

void llvm::jitlink::LinkGraph::dump ( raw_ostream OS,
std::function< StringRef(Edge::Kind)>  EdegKindToName = std::function<StringRef(Edge::Kind)>() 
)

Dump the graph.

If supplied, the EdgeKindToName function will be used to name edge kinds in the debug output. Otherwise raw edge kind numbers will be displayed.

Definition at line 228 of file JITLink.cpp.

References E, llvm::StringRef::empty(), llvm::format(), llvm::jitlink::getGenericEdgeKindName(), llvm::jitlink::printEdge(), and llvm::to_string().

◆ external_symbols()

iterator_range<external_symbol_iterator> llvm::jitlink::LinkGraph::external_symbols ( )
inline

Definition at line 930 of file JITLink.h.

References llvm::make_range().

◆ findSectionByName()

Section* llvm::jitlink::LinkGraph::findSectionByName ( StringRef  Name)
inline

Returns the section with the given name if it exists, otherwise returns null.

Definition at line 913 of file JITLink.h.

References llvm::jitlink::Section::getName(), and Name.

Referenced by llvm::jitlink::createEHFrameRecorderPass(), llvm::orc::getSectionExtent(), llvm::jitlink::EHFrameSplitter::operator()(), and llvm::jitlink::EHFrameEdgeFixer::operator()().

◆ getEndianness()

support::endianness llvm::jitlink::LinkGraph::getEndianness ( ) const
inline

Returns the endianness of content in this graph.

Definition at line 796 of file JITLink.h.

References llvm::msgpack::Endianness.

◆ getName()

const std::string& llvm::jitlink::LinkGraph::getName ( )
inline

Returns the name of this graph (usually the name of the original underlying MemoryBuffer).

Definition at line 790 of file JITLink.h.

References Name.

◆ getPointerSize()

unsigned llvm::jitlink::LinkGraph::getPointerSize ( ) const
inline

Returns the pointer size for use in this graph.

Definition at line 793 of file JITLink.h.

Referenced by llvm::orc::getSectionExtent(), and optimizeMachO_x86_64_GOTAndStubs().

◆ makeExternal()

void llvm::jitlink::LinkGraph::makeExternal ( Symbol Sym)
inline

◆ removeAbsoluteSymbol()

void llvm::jitlink::LinkGraph::removeAbsoluteSymbol ( Symbol Sym)
inline

Remove an absolute symbol. Also removes the underlying Addressable.

Definition at line 976 of file JITLink.h.

References assert(), llvm::jitlink::Symbol::isAbsolute(), and llvm::jitlink::Symbol::isDefined().

◆ removeBlock()

void llvm::jitlink::LinkGraph::removeBlock ( Block B)
inline

◆ removeDefinedSymbol()

void llvm::jitlink::LinkGraph::removeDefinedSymbol ( Symbol Sym)
inline

Removes defined symbols. Does not remove the underlying block.

Definition at line 988 of file JITLink.h.

References assert(), llvm::jitlink::Symbol::getBlock(), llvm::jitlink::Block::getSection(), and llvm::jitlink::Symbol::isDefined().

Referenced by llvm::jitlink::prune().

◆ removeExternalSymbol()

void llvm::jitlink::LinkGraph::removeExternalSymbol ( Symbol Sym)
inline

Removes an external symbol. Also removes the underlying Addressable.

Definition at line 965 of file JITLink.h.

References assert(), llvm::jitlink::Symbol::isAbsolute(), and llvm::jitlink::Symbol::isDefined().

◆ sections()

iterator_range<section_iterator> llvm::jitlink::LinkGraph::sections ( )
inline

Definition at line 906 of file JITLink.h.

References llvm::make_range().

Referenced by llvm::jitlink::EHFrameEdgeFixer::operator()().

◆ splitBlock()

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:

  1. The newly introduced block will have a new ordinal which 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.
  2. 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 153 of file JITLink.cpp.

References assert(), B, llvm::jitlink::Block::edges(), llvm::jitlink::Addressable::getAddress(), llvm::jitlink::Block::getAlignment(), llvm::jitlink::Block::getAlignmentOffset(), llvm::jitlink::Block::getContent(), llvm::jitlink::Symbol::getOffset(), llvm::jitlink::Block::getSection(), llvm::jitlink::Block::getSize(), I, llvm::jitlink::Block::isZeroFill(), llvm::None, llvm::jitlink::Block::removeEdge(), llvm::jitlink::Addressable::setAddress(), llvm::jitlink::Block::setAlignmentOffset(), llvm::jitlink::Block::setContent(), llvm::sort(), llvm::StringRef::substr(), and llvm::jitlink::Section::symbols().


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