19 #define DEBUG_TYPE "slotindexes"
23 "Slot index numbering",
false,
false)
26 STATISTIC(NumGlobalRenum, "Number of global renumberings");
57 assert(indexList.empty() &&
"Index list non-empty at initial numbering?");
59 "Index -> MBB mapping non-empty at initial numbering?");
60 assert(MBBRanges.empty() &&
61 "MBB -> Index mapping non-empty at initial numbering?");
63 "MachineInstr -> Index mapping non-empty at initial numbering?");
69 indexList.
push_back(createEntry(
nullptr, index));
74 SlotIndex blockStartIndex(&indexList.back(), SlotIndex::Slot_Block);
77 if (
MI.isDebugValue())
84 mi2iMap.
insert(std::make_pair(
85 &
MI,
SlotIndex(&indexList.back(), SlotIndex::Slot_Block)));
91 MBBRanges[MBB.getNumber()].first = blockStartIndex;
92 MBBRanges[MBB.getNumber()].second =
SlotIndex(&indexList.back(),
93 SlotIndex::Slot_Block);
108 DEBUG(
dbgs() <<
"\n*** Renumbering SlotIndexes ***\n");
125 static_assert((Space & 3) == 0,
"InstrDist must be a multiple of 2*NUM");
128 unsigned index = startItr->getIndex();
130 curItr->setIndex(index += Space);
133 }
while (curItr != indexList.end() && curItr->getIndex() <= index);
135 DEBUG(
dbgs() <<
"\n*** Renumbered SlotIndexes " << startItr->getIndex() <<
'-'
136 << index <<
" ***\n");
153 bool includeStart = (Begin == MBB->
begin());
161 if (End == MBB->
end())
173 bool pastStart =
false;
174 while (ListI != ListB || MBBI != Begin || (includeStart && !pastStart)) {
175 assert(ListI->getIndex() >= startIdx.getIndex() &&
176 (includeStart || !pastStart) &&
177 "Decremented past the beginning of region to repair.");
181 bool MBBIAtBegin = MBBI == Begin && (!includeStart || pastStart);
183 if (SlotMI == MI && !MBBIAtBegin) {
189 }
else if (MI && mi2iMap.
find(MI) == mi2iMap.
end()) {
211 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
214 itr != indexList.end(); ++itr) {
215 dbgs() << itr->getIndex() <<
" ";
217 if (itr->getInstr()) {
218 dbgs() << *itr->getInstr();
224 for (
unsigned i = 0, e = MBBRanges.size();
i != e; ++
i)
225 dbgs() <<
"BB#" <<
i <<
"\t[" << MBBRanges[
i].first <<
';'
226 << MBBRanges[
i].second <<
")\n";
233 os << listEntry()->
getIndex() <<
"Berd"[getSlot()];
238 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void push_back(const T &Elt)
void renumberIndexes()
Renumber the index list, providing space for new instructions.
std::pair< SlotIndex, MachineBasicBlock * > IdxMBBPair
SlotIndex getInstructionIndex(const MachineInstr &MI) const
Returns the base index for the given instruction.
STATISTIC(NumFunctions,"Total number of functions")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void removeMachineInstrFromMaps(MachineInstr &MI)
Remove the given machine instruction from the mapping.
void reserve(size_type N)
void dump() const
Dump this index to stderr.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it...
void dump() const
Dump the indexes.
bool hasIndex(const MachineInstr &instr) const
Returns true if the given machine instr is mapped to an index, otherwise returns false.
LLVM_NODISCARD bool empty() const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool isDebugValue() const
SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late=false)
Insert the given machine instruction into the mapping.
unsigned getIndex() const
bool isValid() const
Returns true if this is a valid index.
The default distance between instructions as returned by distance().
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Represent the analysis usage information of a pass.
static const unsigned End
self_iterator getIterator()
Iterator for intrusive lists based on ilist_node.
base_list_type::iterator iterator
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
SlotIndex getMBBEndIdx(unsigned Num) const
Returns the last index in the given basic block number.
void push_back(pointer val)
void repairIndexesInRange(MachineBasicBlock *MBB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End)
Repair indexes after adding and removing instructions.
void print(raw_ostream &os) const
Print this index to the given raw_ostream.
Representation of each machine instruction.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool runOnMachineFunction(MachineFunction &fn) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
iterator find(const KeyT &Val)
SlotIndex getMBBStartIdx(unsigned Num) const
Returns the first index in the given basic block number.
LLVM_NODISCARD bool empty() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
INITIALIZE_PASS(SlotIndexes,"slotindexes","Slot index numbering", false, false) STATISTIC(NumLocalRenum
SlotIndex - An opaque wrapper around machine indexes.
Number of local renumberings