LLVM API Documentation

Public Member Functions | Static Public Attributes
llvm::SlotIndexes Class Reference

#include <SlotIndexes.h>

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

List of all members.

Public Member Functions

 SlotIndexes ()
virtual void getAnalysisUsage (AnalysisUsage &au) const
virtual void releaseMemory ()
virtual bool runOnMachineFunction (MachineFunction &fn)
void dump () const
 Dump the indexes.
void renumberIndexes ()
 Renumber the index list, providing space for new instructions.
void repairIndexesInRange (MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End)
 Repair indexes after adding and removing instructions.
SlotIndex getZeroIndex ()
 Returns the zero index for this analysis.
SlotIndex getLastIndex ()
 Returns the base index of the last slot in this analysis.
bool hasIndex (const MachineInstr *instr) const
SlotIndex getInstructionIndex (const MachineInstr *MI) const
 Returns the base index for the given instruction.
MachineInstrgetInstructionFromIndex (SlotIndex index) const
SlotIndex getNextNonNullIndex (SlotIndex Index)
SlotIndex getIndexBefore (const MachineInstr *MI) const
SlotIndex getIndexAfter (const MachineInstr *MI) const
const std::pair< SlotIndex,
SlotIndex > & 
getMBBRange (unsigned Num) const
 Return the (start,end) range of the given basic block number.
const std::pair< SlotIndex,
SlotIndex > & 
getMBBRange (const MachineBasicBlock *MBB) const
 Return the (start,end) range of the given basic block.
SlotIndex getMBBStartIdx (unsigned Num) const
 Returns the first index in the given basic block number.
SlotIndex getMBBStartIdx (const MachineBasicBlock *mbb) const
 Returns the first index in the given basic block.
SlotIndex getMBBEndIdx (unsigned Num) const
 Returns the last index in the given basic block number.
SlotIndex getMBBEndIdx (const MachineBasicBlock *mbb) const
 Returns the last index in the given basic block.
MachineBasicBlockgetMBBFromIndex (SlotIndex index) const
 Returns the basic block which the given index falls in.
bool findLiveInMBBs (SlotIndex start, SlotIndex end, SmallVectorImpl< MachineBasicBlock * > &mbbs) const
MachineBasicBlockgetMBBCoveringRange (SlotIndex start, SlotIndex end) const
SlotIndex insertMachineInstrInMaps (MachineInstr *mi, bool Late=false)
void removeMachineInstrFromMaps (MachineInstr *mi)
 Remove the given machine instruction from the mapping.
void replaceMachineInstrInMaps (MachineInstr *mi, MachineInstr *newMI)
void insertMBBInMaps (MachineBasicBlock *mbb)
 Add the given MachineBasicBlock into the maps.
void eraseIndex (SlotIndex index)
 Free the resources that were required to maintain a SlotIndex.

Static Public Attributes

static char ID = 0

Detailed Description

SlotIndexes pass.

This pass assigns indexes to each instruction.

Definition at line 327 of file SlotIndexes.h.


Constructor & Destructor Documentation

llvm::SlotIndexes::SlotIndexes ( ) [inline]

Member Function Documentation

void SlotIndexes::dump ( ) const
void llvm::SlotIndexes::eraseIndex ( SlotIndex  index) [inline]

Free the resources that were required to maintain a SlotIndex.

Once an index is no longer needed (for instance because the instruction at that index has been moved), the resources required to maintain the index can be relinquished to reduce memory use and improve renumbering performance. Any remaining SlotIndex objects that point to the same index are left 'dangling' (much the same as a dangling pointer to a freed object) and should not be accessed, except to destruct them.

Like dangling pointers, access to dangling SlotIndexes can cause painful-to-track-down bugs, especially if the memory for the index previously pointed to has been re-used. To detect dangling SlotIndex bugs, build with EXPENSIVE_CHECKS=1. This will cause "erased" indexes to be retained in a graveyard instead of being freed. Operations on indexes in the graveyard will trigger an assertion.

Definition at line 682 of file SlotIndexes.h.

References llvm::iplist< NodeTy, Traits >::erase(), and llvm::iplist< NodeTy, Traits >::remove().

bool llvm::SlotIndexes::findLiveInMBBs ( SlotIndex  start,
SlotIndex  end,
SmallVectorImpl< MachineBasicBlock * > &  mbbs 
) const [inline]
void SlotIndexes::getAnalysisUsage ( AnalysisUsage AU) const [virtual]

getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.

For MachineFunctionPasses, calling AU.preservesCFG() indicates that the pass does not modify the MachineBasicBlock CFG.

Reimplemented from llvm::MachineFunctionPass.

Definition at line 28 of file SlotIndexes.cpp.

References llvm::MachineFunctionPass::getAnalysisUsage().

SlotIndex llvm::SlotIndexes::getIndexAfter ( const MachineInstr MI) const [inline]

getIndexAfter - Returns the index of the first indexed instruction after MI, or the end index of its basic block. MI is not required to have an index.

Definition at line 452 of file SlotIndexes.h.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::MachineBasicBlock::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), getMBBEndIdx(), llvm::MachineInstr::getParent(), I, and llvm::A64CC::MI.

Referenced by insertMachineInstrInMaps().

SlotIndex llvm::SlotIndexes::getIndexBefore ( const MachineInstr MI) const [inline]

getIndexBefore - Returns the index of the last indexed instruction before MI, or the start index of its basic block. MI is not required to have an index.

Definition at line 435 of file SlotIndexes.h.

References llvm::MachineBasicBlock::begin(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::find(), getMBBStartIdx(), llvm::MachineInstr::getParent(), I, and llvm::A64CC::MI.

Referenced by insertMachineInstrInMaps().

MachineInstr* llvm::SlotIndexes::getInstructionFromIndex ( SlotIndex  index) const [inline]

Returns the instruction for the given index, or null if the given index has no instruction associated with it.

Definition at line 416 of file SlotIndexes.h.

References llvm::IndexListEntry::getInstr(), and llvm::SlotIndex::isValid().

Referenced by llvm::LiveIntervals::getInstructionFromIndex(), getMBBFromIndex(), and llvm::LiveInterval::overlaps().

SlotIndex llvm::SlotIndexes::getInstructionIndex ( const MachineInstr MI) const [inline]
SlotIndex llvm::SlotIndexes::getLastIndex ( ) [inline]

Returns the base index of the last slot in this analysis.

Definition at line 396 of file SlotIndexes.h.

References llvm::iplist< NodeTy, Traits >::back().

Referenced by getNextNonNullIndex().

MachineBasicBlock* llvm::SlotIndexes::getMBBCoveringRange ( SlotIndex  start,
SlotIndex  end 
) const [inline]

Returns the MBB covering the given range, or null if the range covers more than one basic block.

Definition at line 533 of file SlotIndexes.h.

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

SlotIndex llvm::SlotIndexes::getMBBEndIdx ( unsigned  Num) const [inline]

Returns the last index in the given basic block number.

Definition at line 489 of file SlotIndexes.h.

References getMBBRange().

Referenced by llvm::LiveRangeCalc::extendToUses(), getIndexAfter(), llvm::LiveIntervals::getMBBEndIdx(), getMBBFromIndex(), llvm::LiveIntervals::hasPHIKill(), and repairIndexesInRange().

SlotIndex llvm::SlotIndexes::getMBBEndIdx ( const MachineBasicBlock mbb) const [inline]

Returns the last index in the given basic block.

Definition at line 494 of file SlotIndexes.h.

References getMBBRange().

MachineBasicBlock* llvm::SlotIndexes::getMBBFromIndex ( SlotIndex  index) const [inline]
const std::pair<SlotIndex, SlotIndex>& llvm::SlotIndexes::getMBBRange ( unsigned  Num) const [inline]
const std::pair<SlotIndex, SlotIndex>& llvm::SlotIndexes::getMBBRange ( const MachineBasicBlock MBB) const [inline]

Return the (start,end) range of the given basic block.

Definition at line 474 of file SlotIndexes.h.

References getMBBRange(), and llvm::MachineBasicBlock::getNumber().

SlotIndex llvm::SlotIndexes::getMBBStartIdx ( unsigned  Num) const [inline]
SlotIndex llvm::SlotIndexes::getMBBStartIdx ( const MachineBasicBlock mbb) const [inline]

Returns the first index in the given basic block.

Definition at line 484 of file SlotIndexes.h.

References getMBBRange().

SlotIndex llvm::SlotIndexes::getNextNonNullIndex ( SlotIndex  Index) [inline]

Returns the next non-null index, if one exists. Otherwise returns getLastIndex().

Definition at line 422 of file SlotIndexes.h.

References llvm::iplist< NodeTy, Traits >::end(), getLastIndex(), and I.

Referenced by llvm::LiveInterval::isZeroLength().

SlotIndex llvm::SlotIndexes::getZeroIndex ( ) [inline]

Returns the zero index for this analysis.

Definition at line 390 of file SlotIndexes.h.

References llvm::iplist< NodeTy, Traits >::front().

bool llvm::SlotIndexes::hasIndex ( const MachineInstr instr) const [inline]

Returns true if the given machine instr is mapped to an index, otherwise returns false.

Definition at line 402 of file SlotIndexes.h.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::count().

Referenced by llvm::LiveIntervals::isNotInMIMap(), llvm::MachineBasicBlock::print(), repairIndexesInRange(), and llvm::LiveIntervals::repairIntervalsInRange().

SlotIndex llvm::SlotIndexes::insertMachineInstrInMaps ( MachineInstr mi,
bool  Late = false 
) [inline]
void llvm::SlotIndexes::insertMBBInMaps ( MachineBasicBlock mbb) [inline]
void SlotIndexes::releaseMemory ( ) [virtual]

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.

Reimplemented from llvm::Pass.

Definition at line 33 of file SlotIndexes.cpp.

References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::iplist< NodeTy, Traits >::clear(), and llvm::BumpPtrAllocator::Reset().

void llvm::SlotIndexes::removeMachineInstrFromMaps ( MachineInstr mi) [inline]
void SlotIndexes::renumberIndexes ( )

Renumber the index list, providing space for new instructions.

Definition at line 111 of file SlotIndexes.cpp.

References llvm::iplist< NodeTy, Traits >::begin(), llvm::dbgs(), DEBUG, llvm::iplist< NodeTy, Traits >::end(), I, and llvm::SlotIndex::InstrDist.

Referenced by insertMachineInstrInMaps(), and insertMBBInMaps().

void SlotIndexes::repairIndexesInRange ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  Begin,
MachineBasicBlock::iterator  End 
)
void llvm::SlotIndexes::replaceMachineInstrInMaps ( MachineInstr mi,
MachineInstr newMI 
) [inline]
bool SlotIndexes::runOnMachineFunction ( MachineFunction MF) [virtual]

Member Data Documentation

char SlotIndexes::ID = 0 [static]

Definition at line 367 of file SlotIndexes.h.


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