class SpillPlacement

Declaration

class SpillPlacement : public MachineFunctionPass { /* full declaration omitted */ };

Description

MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of passes that operate on the MachineFunction representation. Instead of overriding runOnFunction, subclasses override runOnMachineFunction.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:43

Inherits from: MachineFunctionPass

Member Variables

private const llvm::MachineFunction* MF
private const llvm::EdgeBundles* bundles
private const llvm::MachineLoopInfo* loops
private const llvm::MachineBlockFrequencyInfo* MBFI
private llvm::SpillPlacement::Node* nodes = nullptr
private llvm::BitVector* ActiveNodes
private SmallVector<unsigned int, 8> Linked
private SmallVector<unsigned int, 8> RecentPositive
private SmallVector<llvm::BlockFrequency, 8> BlockFrequencies
private llvm::BlockFrequency Threshold
Decision threshold. A node gets the output value 0 if the weighted sum of its inputs falls in the open interval (-Threshold;Threshold).
private SparseSet<unsigned int> TodoList
List of nodes that need to be updated in ::iterate.
public static char ID

Method Overview

Inherited from MachineFunctionPass:

Inherited from FunctionPass:

Inherited from Pass:

Methods

SpillPlacement()

Declared at: llvm/lib/CodeGen/SpillPlacement.h:75

void activate(unsigned int n)

Declared at: llvm/lib/CodeGen/SpillPlacement.h:164

Parameters

unsigned int n

void addConstraints(
    ArrayRef<
        llvm::SpillPlacement::BlockConstraint>
        LiveBlocks)

Description

addConstraints - Add constraints and biases. This method may be called more than once to accumulate constraints.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:116

Parameters

ArrayRef<llvm::SpillPlacement::BlockConstraint> LiveBlocks
Constraints for blocks that have the variable live in or live out.

void addLinks(ArrayRef<unsigned int> Links)

Description

addLinks - Add transparent blocks with the given numbers.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:127

Parameters

ArrayRef<unsigned int> Links

void addPrefSpill(ArrayRef<unsigned int> Blocks,
                  bool Strong)

Description

addPrefSpill - Add PrefSpill constraints to all blocks listed. This is equivalent to calling addConstraint with identical BlockConstraints with Entry = Exit = PrefSpill, and ChangesValue = false.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:124

Parameters

ArrayRef<unsigned int> Blocks
Array of block numbers that prefer to spill in and out.
bool Strong
When true, double the negative bias for these blocks.

bool finish()

Description

finish - Compute the optimal spill code placement given the constraints. No MustSpill constraints will be violated, and the smallest possible number of PrefX constraints will be violated, weighted by expected execution frequencies. The selected bundles are returned in the bitvector passed to prepare().

Declared at: llvm/lib/CodeGen/SpillPlacement.h:151

Returns

True if a perfect solution was found, allowing the variable to be in a register through all relevant bundles.

void getAnalysisUsage(
    llvm::AnalysisUsage& AU) const

Description

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this. For MachineFunctionPasses, calling AU.preservesCFG() indicates that the pass does not modify the MachineBasicBlock CFG.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:161

Parameters

llvm::AnalysisUsage& AU

llvm::BlockFrequency getBlockFrequency(
    unsigned int Number) const

Description

getBlockFrequency - Return the estimated block execution frequency per function invocation.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:155

Parameters

unsigned int Number

ArrayRef<unsigned int> getRecentPositive()

Description

getRecentPositive - Return an array of bundles that became positive during the previous call to scanActiveBundles or iterate.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:142

void iterate()

Description

iterate - Update the network iteratively until convergence, or new bundles are found.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:138

void prepare(llvm::BitVector& RegBundles)

Description

prepare - Reset state and prepare for a new spill placement computation.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:110

Parameters

llvm::BitVector& RegBundles
Bit vector to receive the edge bundles where the variable should be kept in a register. Each bit corresponds to an edge bundle, a set bit means the variable should be kept in a register through the bundle. A clear bit means the variable should be spilled. This vector is retained.

void releaseMemory()

Description

releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memory when it is no longer needed. The default behavior of passes is to hold onto memory for the entire duration of their lifetime (which is the entire compile time). For pipelined passes, this is not a big deal because that memory gets recycled every time the pass is invoked on another program unit. For IP passes, it is more important to free memory when it is unused. Optionally implement this function to release pass memory when it is no longer used.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:162

bool runOnMachineFunction(
    llvm::MachineFunction& mf)

Description

runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:160

Parameters

llvm::MachineFunction& mf

bool scanActiveBundles()

Description

scanActiveBundles - Perform an initial scan of all bundles activated by addConstraints and addLinks, updating their state. Add all the bundles that now prefer a register to RecentPositive. Prepare internal data structures for iterate. Return true is there are any positive nodes.

Declared at: llvm/lib/CodeGen/SpillPlacement.h:134

void setThreshold(
    const llvm::BlockFrequency& Entry)

Declared at: llvm/lib/CodeGen/SpillPlacement.h:165

Parameters

const llvm::BlockFrequency& Entry

bool update(unsigned int n)

Declared at: llvm/lib/CodeGen/SpillPlacement.h:167

Parameters

unsigned int n

~SpillPlacement()

Declared at: llvm/lib/CodeGen/SpillPlacement.h:76