LLVM 20.0.0git
|
Calculate auxiliary information for a virtual register such as its spill weight and allocation hint. More...
#include "llvm/CodeGen/CalcSpillWeights.h"
Public Member Functions | |
VirtRegAuxInfo (MachineFunction &MF, LiveIntervals &LIS, const VirtRegMap &VRM, const MachineLoopInfo &Loops, const MachineBlockFrequencyInfo &MBFI, ProfileSummaryInfo *PSI=nullptr) | |
virtual | ~VirtRegAuxInfo ()=default |
void | calculateSpillWeightAndHint (LiveInterval &LI) |
(re)compute li's spill weight and allocation hint. | |
void | calculateSpillWeightsAndHints () |
Compute spill weights and allocation hints for all virtual register live intervals. | |
Static Public Member Functions | |
static Register | copyHint (const MachineInstr *MI, unsigned Reg, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI) |
Return the preferred allocation register for reg, given a COPY instruction. | |
static bool | isRematerializable (const LiveInterval &LI, const LiveIntervals &LIS, const VirtRegMap &VRM, const TargetInstrInfo &TII) |
Determine if all values in LI are rematerializable. | |
Protected Member Functions | |
float | weightCalcHelper (LiveInterval &LI, SlotIndex *Start=nullptr, SlotIndex *End=nullptr) |
Helper function for weight calculations. | |
virtual float | normalize (float UseDefFreq, unsigned Size, unsigned NumInstr) |
Weight normalization function. | |
Calculate auxiliary information for a virtual register such as its spill weight and allocation hint.
Definition at line 46 of file CalcSpillWeights.h.
|
inline |
Definition at line 59 of file CalcSpillWeights.h.
References Loops.
|
virtualdefault |
void VirtRegAuxInfo::calculateSpillWeightAndHint | ( | LiveInterval & | LI | ) |
(re)compute li's spill weight and allocation hint.
Definition at line 141 of file CalcSpillWeights.cpp.
References llvm::LiveInterval::setWeight(), and weightCalcHelper().
Referenced by llvm::LiveRangeEdit::calculateRegClassAndHint(), and calculateSpillWeightsAndHints().
void VirtRegAuxInfo::calculateSpillWeightsAndHints | ( | ) |
Compute spill weights and allocation hints for all virtual register live intervals.
Definition at line 33 of file CalcSpillWeights.cpp.
References calculateSpillWeightAndHint(), llvm::dbgs(), llvm::LiveIntervals::getInterval(), llvm::MachineFunction::getName(), llvm::MachineFunction::getRegInfo(), I, llvm::Register::index2VirtReg(), LLVM_DEBUG, and MRI.
|
static |
Return the preferred allocation register for reg, given a COPY instruction.
Definition at line 47 of file CalcSpillWeights.cpp.
References llvm::Register::asMCReg(), llvm::TargetRegisterClass::contains(), llvm::Register::isVirtual(), MI, MRI, and TRI.
Referenced by weightCalcHelper().
|
static |
Determine if all values in LI are rematerializable.
Definition at line 81 of file CalcSpillWeights.cpp.
References assert(), llvm::VNInfo::def, llvm::LiveIntervals::getInstructionFromIndex(), llvm::LiveIntervals::getInterval(), llvm::VirtRegMap::getOriginal(), I, llvm::VNInfo::isPHIDef(), llvm::VNInfo::isUnused(), MI, llvm::LiveRange::Query(), llvm::LiveInterval::reg(), TII, llvm::LiveQueryResult::valueIn(), llvm::LiveRange::vni_begin(), and llvm::LiveRange::vni_end().
Referenced by weightCalcHelper().
|
inlineprotectedvirtual |
Weight normalization function.
Definition at line 103 of file CalcSpillWeights.h.
References llvm::normalizeSpillWeight(), and Size.
Referenced by weightCalcHelper().
|
protected |
Helper function for weight calculations.
(Re)compute LI's spill weight and allocation hint, or, for non null start and end - compute future expected spill weight of a split artifact of LI that will span between start and end slot indexes.
LI | The live interval for which to compute the weight. |
Start | The expected beginning of the split artifact. Instructions before start will not affect the weight. Relevant for weight calculation of future split artifact. |
End | The expected end of the split artifact. Instructions after end will not affect the weight. Relevant for weight calculation of future split artifact. |
Definition at line 160 of file CalcSpillWeights.cpp.
References assert(), canMemFoldInlineAsm(), copyHint(), llvm::SmallVectorImpl< T >::emplace_back(), End, llvm::TargetSubtargetInfo::getInstrInfo(), llvm::LiveIntervals::getInstructionIndex(), llvm::LiveIntervals::getInterval(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::LiveIntervals::getMBBFromIndex(), llvm::VirtRegMap::getOriginal(), llvm::MachineOperand::getReg(), llvm::MachineFunction::getRegInfo(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::LiveIntervals::getRegMaskSlots(), llvm::LiveInterval::getSize(), llvm::LiveIntervals::getSlotIndexes(), llvm::LiveIntervals::getSpillWeight(), llvm::MachineOperand::getSubReg(), llvm::MachineFunction::getSubtarget(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::LiveRange::isLiveAtIndexes(), llvm::LiveIntervals::isLiveOutOfMBB(), llvm::LoopBase< BlockT, LoopT >::isLoopExiting(), isRematerializable(), llvm::LiveInterval::isSpillable(), llvm::Register::isVirtual(), llvm::LiveRange::isZeroLength(), llvm::LiveInterval::markNotSpillable(), MBB, MI, MRI, normalize(), llvm::operator<(), llvm::LiveInterval::reg(), Reg, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::size(), llvm::sort(), TII, TRI, and Writes.
Referenced by calculateSpillWeightAndHint().