LLVM 19.0.0git
Classes | Typedefs | Functions
llvm::codelayout Namespace Reference

Classes

struct  CDSortConfig
 Algorithm-specific params for Cache-Directed Sort. More...
 
struct  EdgeCount
 

Typedefs

using EdgeT = std::pair< uint64_t, uint64_t >
 

Functions

std::vector< uint64_tcomputeExtTspLayout (ArrayRef< uint64_t > NodeSizes, ArrayRef< uint64_t > NodeCounts, ArrayRef< EdgeCount > EdgeCounts)
 Find a layout of nodes (basic blocks) of a given CFG optimizing jump locality and thus processor I-cache utilization.
 
double calcExtTspScore (ArrayRef< uint64_t > Order, ArrayRef< uint64_t > NodeSizes, ArrayRef< uint64_t > NodeCounts, ArrayRef< EdgeCount > EdgeCounts)
 Estimate the "quality" of a given node order in CFG.
 
double calcExtTspScore (ArrayRef< uint64_t > NodeSizes, ArrayRef< uint64_t > NodeCounts, ArrayRef< EdgeCount > EdgeCounts)
 Estimate the "quality" of the current node order in CFG.
 
std::vector< uint64_tcomputeCacheDirectedLayout (ArrayRef< uint64_t > FuncSizes, ArrayRef< uint64_t > FuncCounts, ArrayRef< EdgeCount > CallCounts, ArrayRef< uint64_t > CallOffsets)
 Apply a Cache-Directed Sort for functions represented by a call graph.
 
std::vector< uint64_tcomputeCacheDirectedLayout (const CDSortConfig &Config, ArrayRef< uint64_t > FuncSizes, ArrayRef< uint64_t > FuncCounts, ArrayRef< EdgeCount > CallCounts, ArrayRef< uint64_t > CallOffsets)
 Apply a Cache-Directed Sort with a custom config.
 

Typedef Documentation

◆ EdgeT

using llvm::codelayout::EdgeT = typedef std::pair<uint64_t, uint64_t>

Definition at line 24 of file CodeLayout.h.

Function Documentation

◆ calcExtTspScore() [1/2]

double llvm::codelayout::calcExtTspScore ( ArrayRef< uint64_t NodeSizes,
ArrayRef< uint64_t NodeCounts,
ArrayRef< EdgeCount EdgeCounts 
)

Estimate the "quality" of the current node order in CFG.

Definition at line 1451 of file CodeLayout.cpp.

References calcExtTspScore(), Idx, and llvm::ArrayRef< T >::size().

◆ calcExtTspScore() [2/2]

double llvm::codelayout::calcExtTspScore ( ArrayRef< uint64_t Order,
ArrayRef< uint64_t NodeSizes,
ArrayRef< uint64_t NodeCounts,
ArrayRef< EdgeCount EdgeCounts 
)

Estimate the "quality" of a given node order in CFG.

The higher the score, the better the order is. The score is designed to reflect the locality of the given order, which is anti-correlated with the number of I-cache misses in a typical execution of the function.

Definition at line 1428 of file CodeLayout.cpp.

References Addr, Idx, and llvm::ArrayRef< T >::size().

Referenced by calcExtTspScore().

◆ computeCacheDirectedLayout() [1/2]

std::vector< uint64_t > llvm::codelayout::computeCacheDirectedLayout ( ArrayRef< uint64_t FuncSizes,
ArrayRef< uint64_t FuncCounts,
ArrayRef< EdgeCount CallCounts,
ArrayRef< uint64_t CallOffsets 
)

Apply a Cache-Directed Sort for functions represented by a call graph.

The placement is done by optimizing the call locality by co-locating frequently executed functions. FuncSizes: The sizes of the nodes (in bytes). FuncCounts: The execution counts of the nodes in the profile. CallCounts: The execution counts of every edge (jump) in the profile. The map also defines the edges in CFG and should include 0-count edges. CallOffsets: The offsets of the calls from their source nodes.

Returns
The best function order found.

Definition at line 1475 of file CodeLayout.cpp.

References CacheEntries, CacheSize, CDMaxChainSize, computeCacheDirectedLayout(), Config, DistancePower, and FrequencyScale.

Referenced by computeCacheDirectedLayout().

◆ computeCacheDirectedLayout() [2/2]

std::vector< uint64_t > llvm::codelayout::computeCacheDirectedLayout ( const CDSortConfig Config,
ArrayRef< uint64_t FuncSizes,
ArrayRef< uint64_t FuncCounts,
ArrayRef< EdgeCount CallCounts,
ArrayRef< uint64_t CallOffsets 
)

Apply a Cache-Directed Sort with a custom config.

Definition at line 1461 of file CodeLayout.cpp.

References assert(), Config, and llvm::ArrayRef< T >::size().

◆ computeExtTspLayout()

std::vector< uint64_t > llvm::codelayout::computeExtTspLayout ( ArrayRef< uint64_t NodeSizes,
ArrayRef< uint64_t NodeCounts,
ArrayRef< EdgeCount EdgeCounts 
)

Find a layout of nodes (basic blocks) of a given CFG optimizing jump locality and thus processor I-cache utilization.

This is achieved via increasing the number of fall-through jumps and co-locating frequently executed nodes together. The nodes are assumed to be indexed by integers from [0, |V|) so that the current order is the identity permutation. NodeSizes: The sizes of the nodes (in bytes). NodeCounts: The execution counts of the nodes in the profile. EdgeCounts: The execution counts of every edge (jump) in the profile. The map also defines the edges in CFG and should include 0-count edges.

Returns
The best block order found.

Definition at line 1411 of file CodeLayout.cpp.

References assert(), and llvm::ArrayRef< T >::size().