LLVM 20.0.0git
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
llvm::SpillPlacement Class Reference

#include "CodeGen/SpillPlacement.h"

Inheritance diagram for llvm::SpillPlacement:
Inheritance graph
[legend]

Classes

struct  BlockConstraint
 BlockConstraint - Entry and exit constraints for a basic block. More...
 
struct  Node
 Node - Each edge bundle corresponds to a Hopfield node. More...
 

Public Types

enum  BorderConstraint {
  DontCare , PrefReg , PrefSpill , PrefBoth ,
  MustSpill
}
 BorderConstraint - A basic block has separate constraints for entry and exit. More...
 

Public Member Functions

 SpillPlacement ()
 
 ~SpillPlacement () override
 
void prepare (BitVector &RegBundles)
 prepare - Reset state and prepare for a new spill placement computation.
 
void addConstraints (ArrayRef< BlockConstraint > LiveBlocks)
 addConstraints - Add constraints and biases.
 
void addPrefSpill (ArrayRef< unsigned > Blocks, bool Strong)
 addPrefSpill - Add PrefSpill constraints to all blocks listed.
 
void addLinks (ArrayRef< unsigned > Links)
 addLinks - Add transparent blocks with the given numbers.
 
bool scanActiveBundles ()
 scanActiveBundles - Perform an initial scan of all bundles activated by addConstraints and addLinks, updating their state.
 
void iterate ()
 iterate - Update the network iteratively until convergence, or new bundles are found.
 
ArrayRef< unsignedgetRecentPositive ()
 getRecentPositive - Return an array of bundles that became positive during the previous call to scanActiveBundles or iterate.
 
bool finish ()
 finish - Compute the optimal spill code placement given the constraints.
 
BlockFrequency getBlockFrequency (unsigned Number) const
 getBlockFrequency - Return the estimated block execution frequency per function invocation.
 
- Public Member Functions inherited from llvm::MachineFunctionPass
bool doInitialization (Module &) override
 doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run.
 
- Public Member Functions inherited from llvm::FunctionPass
 FunctionPass (char &pid)
 
PasscreatePrinterPass (raw_ostream &OS, const std::string &Banner) const override
 createPrinterPass - Get a function printer pass.
 
virtual bool runOnFunction (Function &F)=0
 runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
 
void assignPassManager (PMStack &PMS, PassManagerType T) override
 Find appropriate Function Pass Manager or Call Graph Pass Manager in the PM Stack and add self into that manager.
 
PassManagerType getPotentialPassManagerType () const override
 Return what kind of Pass Manager can manage this pass.
 
- Public Member Functions inherited from llvm::Pass
 Pass (PassKind K, char &pid)
 
 Pass (const Pass &)=delete
 
Passoperator= (const Pass &)=delete
 
virtual ~Pass ()
 
PassKind getPassKind () const
 
virtual StringRef getPassName () const
 getPassName - Return a nice clean name for a pass.
 
AnalysisID getPassID () const
 getPassID - Return the PassID number that corresponds to this pass.
 
virtual bool doInitialization (Module &)
 doInitialization - Virtual method overridden by subclasses to do any necessary initialization before any pass is run.
 
virtual bool doFinalization (Module &)
 doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes have run.
 
virtual void print (raw_ostream &OS, const Module *M) const
 print - Print out the internal state of the pass.
 
void dump () const
 
virtual PasscreatePrinterPass (raw_ostream &OS, const std::string &Banner) const =0
 createPrinterPass - Get a Pass appropriate to print the IR this pass operates on (Module, Function or MachineFunction).
 
virtual void assignPassManager (PMStack &, PassManagerType)
 Each pass is responsible for assigning a pass manager to itself.
 
virtual void preparePassManager (PMStack &)
 Check if available pass managers are suitable for this pass or not.
 
virtual PassManagerType getPotentialPassManagerType () const
 Return what kind of Pass Manager can manage this pass.
 
void setResolver (AnalysisResolver *AR)
 
AnalysisResolvergetResolver () const
 
virtual void getAnalysisUsage (AnalysisUsage &) const
 getAnalysisUsage - This function should be overriden by passes that need analysis information to do their job.
 
virtual void releaseMemory ()
 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.
 
virtual void * getAdjustedAnalysisPointer (AnalysisID ID)
 getAdjustedAnalysisPointer - This method is used when a pass implements an analysis interface through multiple inheritance.
 
virtual ImmutablePassgetAsImmutablePass ()
 
virtual PMDataManagergetAsPMDataManager ()
 
virtual void verifyAnalysis () const
 verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis information.
 
virtual void dumpPassStructure (unsigned Offset=0)
 
template<typename AnalysisType >
AnalysisType * getAnalysisIfAvailable () const
 getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information that might be around, for example to update it.
 
bool mustPreserveAnalysisID (char &AID) const
 mustPreserveAnalysisID - This method serves the same function as getAnalysisIfAvailable, but works if you just have an AnalysisID.
 
template<typename AnalysisType >
AnalysisType & getAnalysis () const
 getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function.
 
template<typename AnalysisType >
AnalysisType & getAnalysis (Function &F, bool *Changed=nullptr)
 getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information that they claim to use by overriding the getAnalysisUsage function.
 
template<typename AnalysisType >
AnalysisType & getAnalysisID (AnalysisID PI) const
 
template<typename AnalysisType >
AnalysisType & getAnalysisID (AnalysisID PI, Function &F, bool *Changed=nullptr)
 

Static Public Attributes

static char ID = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from llvm::Pass
static const PassInfolookupPassInfo (const void *TI)
 
static const PassInfolookupPassInfo (StringRef Arg)
 
static PasscreatePass (AnalysisID ID)
 
- Protected Member Functions inherited from llvm::MachineFunctionPass
 MachineFunctionPass (char &ID)
 
virtual bool runOnMachineFunction (MachineFunction &MF)=0
 runOnMachineFunction - This method must be overloaded to perform the desired machine code transformation or analysis.
 
void getAnalysisUsage (AnalysisUsage &AU) const override
 getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
 
virtual MachineFunctionProperties getRequiredProperties () const
 
virtual MachineFunctionProperties getSetProperties () const
 
virtual MachineFunctionProperties getClearedProperties () const
 
- Protected Member Functions inherited from llvm::FunctionPass
bool skipFunction (const Function &F) const
 Optional passes call this function to check whether the pass should be skipped.
 

Detailed Description

Definition at line 42 of file SpillPlacement.h.

Member Enumeration Documentation

◆ BorderConstraint

BorderConstraint - A basic block has separate constraints for entry and exit.

Enumerator
DontCare 

Block doesn't care / variable not live.

PrefReg 

Block entry/exit prefers a register.

PrefSpill 

Block entry/exit prefers a stack slot.

PrefBoth 

Block entry prefers both register and stack.

MustSpill 

A register is impossible, variable must be spilled.

Definition at line 78 of file SpillPlacement.h.

Constructor & Destructor Documentation

◆ SpillPlacement()

llvm::SpillPlacement::SpillPlacement ( )
inline

Definition at line 73 of file SpillPlacement.h.

◆ ~SpillPlacement()

llvm::SpillPlacement::~SpillPlacement ( )
inlineoverride

Definition at line 74 of file SpillPlacement.h.

Member Function Documentation

◆ addConstraints()

void SpillPlacement::addConstraints ( ArrayRef< BlockConstraint LiveBlocks)

addConstraints - Add constraints and biases.

addConstraints - Compute node biases and weights from a set of constraints.

This method may be called more than once to accumulate constraints.

Parameters
LiveBlocksConstraints for blocks that have the variable live in or live out.

Set a bit in NodeMask for each active node.

Definition at line 260 of file SpillPlacement.cpp.

References llvm::SpillPlacement::Node::addBias(), DontCare, and llvm::EdgeBundles::getBundle().

◆ addLinks()

void SpillPlacement::addLinks ( ArrayRef< unsigned Links)

addLinks - Add transparent blocks with the given numbers.

Definition at line 295 of file SpillPlacement.cpp.

References llvm::SpillPlacement::Node::addLink(), llvm::EdgeBundles::getBundle(), and llvm::Number.

◆ addPrefSpill()

void SpillPlacement::addPrefSpill ( ArrayRef< unsigned Blocks,
bool  Strong 
)

addPrefSpill - Add PrefSpill constraints to all blocks listed.

addPrefSpill - Same as addConstraints(PrefSpill)

This is equivalent to calling addConstraint with identical BlockConstraints with Entry = Exit = PrefSpill, and ChangesValue = false.

Parameters
BlocksArray of block numbers that prefer to spill in and out.
StrongWhen true, double the negative bias for these blocks.

Definition at line 281 of file SpillPlacement.cpp.

References llvm::SpillPlacement::Node::addBias(), B, Blocks, llvm::EdgeBundles::getBundle(), and PrefSpill.

◆ finish()

bool SpillPlacement::finish ( )

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().

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

Definition at line 363 of file SpillPlacement.cpp.

References assert(), llvm::BitVector::reset(), and llvm::BitVector::set_bits().

◆ getBlockFrequency()

BlockFrequency llvm::SpillPlacement::getBlockFrequency ( unsigned  Number) const
inline

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

Definition at line 153 of file SpillPlacement.h.

References llvm::Number.

◆ getRecentPositive()

ArrayRef< unsigned > llvm::SpillPlacement::getRecentPositive ( )
inline

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

Definition at line 140 of file SpillPlacement.h.

◆ iterate()

void SpillPlacement::iterate ( )

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

iterate - Repeatedly update the Hopfield nodes until stability or the maximum number of iterations is reached.

Definition at line 334 of file SpillPlacement.cpp.

References llvm::SmallVectorImpl< T >::clear(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::empty(), llvm::EdgeBundles::getNumBundles(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::pop_back_val(), and llvm::SmallVectorTemplateBase< T, bool >::push_back().

◆ prepare()

void SpillPlacement::prepare ( BitVector RegBundles)

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

Parameters
RegBundlesBit 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.

Definition at line 353 of file SpillPlacement.cpp.

References llvm::BitVector::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::SparseSet< ValueT, KeyFunctorT, SparseT >::clear(), llvm::EdgeBundles::getNumBundles(), and llvm::BitVector::resize().

◆ scanActiveBundles()

bool SpillPlacement::scanActiveBundles ( )

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.

Definition at line 311 of file SpillPlacement.cpp.

References llvm::SmallVectorImpl< T >::clear(), llvm::SmallVectorBase< Size_T >::empty(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::BitVector::set_bits().

Member Data Documentation

◆ ID

char SpillPlacement::ID = 0
static

Definition at line 71 of file SpillPlacement.h.


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