LLVM API Documentation

Classes | Public Types | Public Member Functions | Public Attributes
llvm::LiveRange Class Reference

#include <LiveInterval.h>

Inheritance diagram for llvm::LiveRange:
Inheritance graph
[legend]
Collaboration diagram for llvm::LiveRange:
Collaboration graph
[legend]

List of all members.

Classes

struct  Segment

Public Types

typedef SmallVector< Segment, 4 > Segments
typedef SmallVector< VNInfo *, 4 > VNInfoList
typedef Segments::iterator iterator
typedef Segments::const_iterator const_iterator
typedef VNInfoList::iterator vni_iterator
typedef VNInfoList::const_iterator const_vni_iterator

Public Member Functions

iterator begin ()
iterator end ()
const_iterator begin () const
const_iterator end () const
vni_iterator vni_begin ()
vni_iterator vni_end ()
const_vni_iterator vni_begin () const
const_vni_iterator vni_end () const
iterator advanceTo (iterator I, SlotIndex Pos)
iterator find (SlotIndex Pos)
const_iterator find (SlotIndex Pos) const
void clear ()
size_t size () const
bool hasAtLeastOneValue () const
bool containsOneValue () const
unsigned getNumValNums () const
VNInfogetValNumInfo (unsigned ValNo)
const VNInfogetValNumInfo (unsigned ValNo) const
bool containsValue (const VNInfo *VNI) const
 containsValue - Returns true if VNI belongs to this range.
VNInfogetNextValue (SlotIndex def, VNInfo::Allocator &VNInfoAllocator)
VNInfocreateDeadDef (SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
VNInfocreateValueCopy (const VNInfo *orig, VNInfo::Allocator &VNInfoAllocator)
void RenumberValues ()
VNInfoMergeValueNumberInto (VNInfo *V1, VNInfo *V2)
void MergeSegmentsInAsValue (const LiveRange &RHS, VNInfo *LHSValNo)
void MergeValueInAsValue (const LiveRange &RHS, const VNInfo *RHSValNo, VNInfo *LHSValNo)
bool empty () const
SlotIndex beginIndex () const
 beginIndex - Return the lowest numbered slot covered.
SlotIndex endIndex () const
bool expiredAt (SlotIndex index) const
bool liveAt (SlotIndex index) const
const SegmentgetSegmentContaining (SlotIndex Idx) const
SegmentgetSegmentContaining (SlotIndex Idx)
VNInfogetVNInfoAt (SlotIndex Idx) const
 getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
VNInfogetVNInfoBefore (SlotIndex Idx) const
iterator FindSegmentContaining (SlotIndex Idx)
const_iterator FindSegmentContaining (SlotIndex Idx) const
bool overlaps (const LiveRange &other) const
bool overlaps (const LiveRange &Other, const CoalescerPair &CP, const SlotIndexes &) const
bool overlaps (SlotIndex Start, SlotIndex End) const
bool overlapsFrom (const LiveRange &Other, const_iterator I) const
iterator addSegment (Segment S)
VNInfoextendInBlock (SlotIndex StartIdx, SlotIndex Kill)
void join (LiveRange &Other, const int *ValNoAssignments, const int *RHSValNoAssignments, SmallVectorImpl< VNInfo * > &NewVNInfo)
bool isLocal (SlotIndex Start, SlotIndex End) const
void removeSegment (SlotIndex Start, SlotIndex End, bool RemoveDeadValNo=false)
void removeSegment (Segment S, bool RemoveDeadValNo=false)
LiveQueryResult Query (SlotIndex Idx) const
void removeValNo (VNInfo *ValNo)
bool isZeroLength (SlotIndexes *Indexes) const
bool operator< (const LiveRange &other) const
void print (raw_ostream &OS) const
void dump () const
void verify () const
 Walk the range and assert if any invariants fail to hold.

Public Attributes

Segments segments
VNInfoList valnos

Detailed Description

This class represents the liveness of a register, stack slot, etc. It manages an ordered list of Segment objects. The Segments are organized in a static single assignment form: At places where a new value is defined or different values reach a CFG join a new segment with a new value number is used.

Definition at line 146 of file LiveInterval.h.


Member Typedef Documentation

Definition at line 195 of file LiveInterval.h.

Definition at line 203 of file LiveInterval.h.

Definition at line 191 of file LiveInterval.h.

Definition at line 185 of file LiveInterval.h.

Definition at line 199 of file LiveInterval.h.

Definition at line 186 of file LiveInterval.h.


Member Function Documentation

Add the specified Segment to this range, merging segments as appropriate. This returns an iterator to the inserted segment (which may have grown since it was inserted).

Definition at line 403 of file LiveInterval.h.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), and segments.

Referenced by llvm::LiveIntervals::addSegmentToEndOfBlock(), llvm::LiveIntervals::repairIntervalsInRange(), llvm::LiveIntervals::shrinkToUses(), and llvm::MachineBasicBlock::SplitCriticalEdge().

advanceTo - Advance the specified iterator to point to the Segment containing the specified position, or end() if the position is past the end of the range. If no Segment contains this position, but the position is in a hole, this method returns an iterator pointing to the Segment immediately after the hole.

Definition at line 212 of file LiveInterval.h.

References end(), endIndex(), and I.

Referenced by llvm::LiveIntervals::addKillFlags(), llvm::LiveIntervals::checkRegMaskInterference(), llvm::SplitAnalysis::countLiveBlocks(), and llvm::LiveIntervalUnion::extract().

beginIndex - Return the lowest numbered slot covered.

Definition at line 314 of file LiveInterval.h.

References empty(), llvm::SmallVectorTemplateCommon< T, typename >::front(), and segments.

Referenced by llvm::LiveIntervals::intervalIsInOneMBB(), isLocal(), operator<(), llvm::LiveInterval::operator<(), and overlaps().

void llvm::LiveRange::clear ( ) [inline]

Definition at line 233 of file LiveInterval.h.

References llvm::SmallVectorImpl< T >::clear(), segments, and valnos.

bool llvm::LiveRange::containsValue ( const VNInfo VNI) const [inline]

containsValue - Returns true if VNI belongs to this range.

Definition at line 258 of file LiveInterval.h.

References getNumValNums(), getValNumInfo(), and llvm::VNInfo::id.

VNInfo * LiveRange::createDeadDef ( SlotIndex  Def,
VNInfo::Allocator VNInfoAllocator 
)

createDeadDef - Make sure the range has a value defined at Def. If one already exists, return it. Otherwise allocate a new value and add liveness for a dead def.

Definition at line 52 of file LiveInterval.cpp.

References llvm::tgtok::Def, end(), find(), llvm::SlotIndex::getDeadSlot(), getNextValue(), I, llvm::SmallVectorImpl< T >::insert(), llvm::SlotIndex::isDead(), llvm::SlotIndex::isEarlierInstr(), llvm::SlotIndex::isSameInstr(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), and segments.

Referenced by llvm::LiveRangeCalc::createDeadDefs().

VNInfo* llvm::LiveRange::createValueCopy ( const VNInfo orig,
VNInfo::Allocator VNInfoAllocator 
) [inline]

Create a copy of the given value. The new value will be identical except for the Value number.

Definition at line 278 of file LiveInterval.h.

References llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and valnos.

void LiveRange::dump ( ) const

Reimplemented in llvm::LiveInterval.

Definition at line 626 of file LiveInterval.cpp.

References llvm::dbgs().

bool llvm::LiveRange::empty ( ) const [inline]

endNumber - return the maximum point of the range of the whole, exclusive.

Definition at line 321 of file LiveInterval.h.

References llvm::SmallVectorTemplateCommon< T, typename >::back(), empty(), and segments.

Referenced by advanceTo(), expiredAt(), find(), llvm::LiveIntervals::intervalIsInOneMBB(), and isLocal().

bool llvm::LiveRange::expiredAt ( SlotIndex  index) const [inline]

Definition at line 326 of file LiveInterval.h.

References endIndex().

Referenced by llvm::ConnectedVNInfoEqClasses::Distribute().

VNInfo * LiveRange::extendInBlock ( SlotIndex  StartIdx,
SlotIndex  Kill 
)

extendInBlock - If this range is live before Kill in the basic block that starts at StartIdx, extend it to be live up to Kill, and return the value. If there is no segment before Kill, return NULL.

extendInBlock - If this range is live before Kill in the basic block that starts at StartIdx, extend it to be live up to Kill and return the value. If there is no live range before Kill, return NULL.

Definition at line 332 of file LiveInterval.cpp.

References begin(), empty(), end(), llvm::SlotIndex::getPrevSlot(), and I.

Referenced by llvm::LiveRangeCalc::extend(), and llvm::LiveIntervals::shrinkToUses().

find - Return an iterator pointing to the first segment that ends after Pos, or end(). This is the same as advanceTo(begin(), Pos), but faster when searching large ranges.

If Pos is contained in a Segment, that segment is returned. If Pos is in a hole, the following Segment is returned. If Pos is beyond endIndex, end() is returned.

Definition at line 34 of file LiveInterval.cpp.

References begin(), empty(), end(), endIndex(), I, and size().

Referenced by llvm::LiveIntervals::addKillFlags(), createDeadDef(), find(), FindSegmentContaining(), llvm::SplitAnalysis::isOriginalEndpoint(), isPlainlyKilled(), liveAt(), overlaps(), Query(), removeSegment(), and llvm::LiveIntervals::repairIntervalsInRange().

Definition at line 229 of file LiveInterval.h.

References find().

Return an iterator to the segment that contains the specified index, or end() if there is none.

Definition at line 365 of file LiveInterval.h.

References end(), find(), and I.

Referenced by llvm::LiveIntervals::computeDeadValues(), getSegmentContaining(), getVNInfoAt(), and getVNInfoBefore().

Definition at line 370 of file LiveInterval.h.

References end(), find(), and I.

VNInfo* llvm::LiveRange::getNextValue ( SlotIndex  def,
VNInfo::Allocator VNInfoAllocator 
) [inline]

getNextValue - Create a new value number and return it. MIIdx specifies the instruction that defines the value number.

Definition at line 264 of file LiveInterval.h.

References llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and valnos.

Referenced by llvm::LiveIntervals::addSegmentToEndOfBlock(), createDeadDef(), and llvm::LiveIntervals::repairIntervalsInRange().

Return the segment that contains the specified index, or null if there is none.

Definition at line 337 of file LiveInterval.h.

References end(), FindSegmentContaining(), and I.

Return the live segment that contains the specified index, or null if there is none.

Definition at line 344 of file LiveInterval.h.

References end(), FindSegmentContaining(), and I.

getValNumInfo - Returns pointer to the specified val#.

Definition at line 250 of file LiveInterval.h.

References valnos.

Referenced by containsValue(), llvm::ConnectedVNInfoEqClasses::Distribute(), join(), and print().

Definition at line 253 of file LiveInterval.h.

References valnos.

VNInfo* llvm::LiveRange::getVNInfoAt ( SlotIndex  Idx) const [inline]

getVNInfoBefore - Return the VNInfo that is live up to but not necessarilly including Idx, or NULL. Use this to find the reaching def used by an instruction at this SlotIndex position.

Definition at line 358 of file LiveInterval.h.

References end(), FindSegmentContaining(), llvm::SlotIndex::getPrevSlot(), and I.

Referenced by llvm::ConnectedVNInfoEqClasses::Classify(), llvm::ScheduleDAGMILive::computeCyclicCriticalPath(), llvm::LiveIntervals::hasPHIKill(), llvm::SplitEditor::overlapIntv(), llvm::LiveIntervals::shrinkToUses(), and llvm::ScheduleDAGMILive::updatePressureDiffs().

bool llvm::LiveRange::isLocal ( SlotIndex  Start,
SlotIndex  End 
) const [inline]

True iff this segment is a single segment that lies between the specified boundaries, exclusively. Vregs live across a backedge are not considered local. The boundaries are expected to lie within an extended basic block, so vregs that are not live out should contain no holes.

Definition at line 424 of file LiveInterval.h.

References beginIndex(), endIndex(), llvm::SlotIndex::getBaseIndex(), and llvm::SlotIndex::getBoundaryIndex().

bool llvm::LiveRange::isZeroLength ( SlotIndexes Indexes) const [inline]

Returns true if the live range is zero length, i.e. no live segments span instructions. It doesn't pay to spill such a range.

Definition at line 486 of file LiveInterval.h.

References begin(), end(), llvm::SlotIndex::getBaseIndex(), and llvm::SlotIndexes::getNextNonNullIndex().

Referenced by llvm::VirtRegAuxInfo::calculateSpillWeightAndHint().

void LiveRange::join ( LiveRange Other,
const int ValNoAssignments,
const int RHSValNoAssignments,
SmallVectorImpl< VNInfo * > &  NewVNInfo 
)

join - Join two live ranges (this, and other) together. This applies mappings to the value numbers in the LHS/RHS ranges as specified. If the ranges are not joinable, this aborts.

Definition at line 410 of file LiveInterval.cpp.

References llvm::LiveRangeUpdater::add(), begin(), empty(), end(), llvm::SmallVectorImpl< T >::erase(), getNumValNums(), getValNumInfo(), I, llvm::VNInfo::id, llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorImpl< T >::resize(), segments, llvm::SmallVectorTemplateCommon< T, typename >::size(), valnos, and verify().

bool llvm::LiveRange::liveAt ( SlotIndex  index) const [inline]
void LiveRange::MergeSegmentsInAsValue ( const LiveRange RHS,
VNInfo LHSValNo 
)

Merge all of the live segments of a specific val# in RHS into this live range as the specified value number. The segments in RHS are allowed to overlap with segments in the current range, it will replace the value numbers of the overlaped live segments with the specified value number.

Merge all of the segments in RHS into this live range as the specified value number. The segments in RHS are allowed to overlap with segments in the current range, but only if the overlapping segments have the specified value number.

Definition at line 493 of file LiveInterval.cpp.

References llvm::LiveRangeUpdater::add(), begin(), end(), and I.

void LiveRange::MergeValueInAsValue ( const LiveRange RHS,
const VNInfo RHSValNo,
VNInfo LHSValNo 
)

MergeValueInAsValue - Merge all of the segments of a specific val# in RHS into this live range as the specified value number. The segments in RHS are allowed to overlap with segments in the current range, but only if the overlapping segments have the specified value number.

MergeValueInAsValue - Merge all of the live segments of a specific val# in RHS into this live range as the specified value number. The segments in RHS are allowed to overlap with segments in the current range, it will replace the value numbers of the overlaped segments with the specified value number.

Definition at line 505 of file LiveInterval.cpp.

References llvm::LiveRangeUpdater::add(), begin(), end(), and I.

MergeValueNumberInto - This method is called when two value numbers are found to be equivalent. This eliminates V1, replacing all segments with the V1 value number with the V2 value number. This can cause merging of V1/V2 values numbers and compaction of the value space.

MergeValueNumberInto - This method is called when two value nubmers are found to be equivalent. This eliminates V1, replacing all segments with the V1 value number with the V2 value number. This can cause merging of V1/V2 values numbers and compaction of the value space.

Definition at line 518 of file LiveInterval.cpp.

References begin(), llvm::VNInfo::copyFrom(), end(), llvm::SmallVectorImpl< T >::erase(), llvm::VNInfo::id, segments, std::swap(), and llvm::NVPTX::PTXLdStInstCode::V2.

bool llvm::LiveRange::operator< ( const LiveRange other) const [inline]

Definition at line 494 of file LiveInterval.h.

References beginIndex().

bool llvm::LiveRange::overlaps ( const LiveRange other) const [inline]

overlaps - Return true if the intersection of the two live ranges is not empty.

Definition at line 377 of file LiveInterval.h.

References begin(), empty(), and overlapsFrom().

Referenced by llvm::PBQPBuilder::build(), and llvm::LiveRegMatrix::checkRegUnitInterference().

bool LiveRange::overlaps ( const LiveRange Other,
const CoalescerPair CP,
const SlotIndexes Indexes 
) const

overlaps - Return true if the two ranges have overlapping segments that are not coalescable according to CP.

Overlapping segments where one range is defined by a coalescable copy are allowed.

Definition at line 139 of file LiveInterval.cpp.

References beginIndex(), llvm::tgtok::Def, empty(), end(), find(), llvm::SlotIndexes::getInstructionFromIndex(), I, llvm::ARM_PROC::IE, llvm::SlotIndex::isBlock(), llvm::CoalescerPair::isCoalescable(), and std::swap().

bool LiveRange::overlaps ( SlotIndex  Start,
SlotIndex  End 
) const

overlaps - Return true if the live range overlaps an interval specified by [Start, End).

Definition at line 182 of file LiveInterval.cpp.

References begin(), end(), and I.

overlapsFrom - Return true if the intersection of the two live ranges is not empty. The specified iterator is a hint that we can begin scanning the Other range starting at I.

Definition at line 98 of file LiveInterval.cpp.

References begin(), empty(), end(), and std::swap().

Referenced by overlaps().

void LiveRange::print ( raw_ostream OS) const
void LiveRange::removeSegment ( SlotIndex  Start,
SlotIndex  End,
bool  RemoveDeadValNo = false 
)

Remove the specified segment from this range. Note that the segment must be a single Segment in its entirety.

Remove the specified segment from this range. Note that the segment must be in a single Segment in its entirety.

Definition at line 348 of file LiveInterval.cpp.

References begin(), end(), llvm::SmallVectorImpl< T >::erase(), find(), llvm::SmallVectorImpl< T >::insert(), and segments.

Referenced by llvm::LiveIntervals::computeDeadValues(), llvm::LiveIntervals::pruneValue(), removeSegment(), llvm::LiveIntervals::repairIntervalsInRange(), and llvm::MachineBasicBlock::SplitCriticalEdge().

void llvm::LiveRange::removeSegment ( Segment  S,
bool  RemoveDeadValNo = false 
) [inline]
void LiveRange::removeValNo ( VNInfo ValNo)

removeValNo - Remove all the segments defined by the specified value#. Also remove the value# from value# list.

Definition at line 397 of file LiveInterval.cpp.

References begin(), empty(), end(), llvm::SmallVectorImpl< T >::erase(), I, and segments.

RenumberValues - Renumber all values in order of appearance and remove unused values.

RenumberValues - Renumber all values in order of appearance and delete the remaining unused values.

Definition at line 204 of file LiveInterval.cpp.

References begin(), llvm::SmallVectorImpl< T >::clear(), end(), I, llvm::VNInfo::id, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::VNInfo::isUnused(), llvm::SmallVectorTemplateBase< T, isPodLike >::push_back(), llvm::SmallVectorTemplateCommon< T, typename >::size(), and valnos.

Referenced by llvm::LiveRangeEdit::eliminateDeadDefs(), and llvm::SplitEditor::finish().

size_t llvm::LiveRange::size ( ) const [inline]
void LiveRange::verify ( ) const

Walk the range and assert if any invariants fail to hold.

Note that this is a no-op when asserts are disabled.

Definition at line 636 of file LiveInterval.cpp.

References begin(), end(), I, llvm::SmallVectorTemplateCommon< T, typename >::size(), and valnos.

Referenced by join().


Member Data Documentation


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