Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 1 | //===-- SlotIndexes.cpp - Slot Indexes Pass ------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 10 | #include "llvm/CodeGen/SlotIndexes.h" |
Jakob Stoklund Olesen | b88f6ad | 2011-03-04 18:08:29 +0000 | [diff] [blame] | 11 | #include "llvm/ADT/Statistic.h" |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 12 | #include "llvm/CodeGen/MachineFunction.h" |
| 13 | #include "llvm/Support/Debug.h" |
| 14 | #include "llvm/Support/raw_ostream.h" |
| 15 | |
| 16 | using namespace llvm; |
| 17 | |
Chandler Carruth | 1b9dde0 | 2014-04-22 02:02:50 +0000 | [diff] [blame] | 18 | #define DEBUG_TYPE "slotindexes" |
| 19 | |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 20 | char SlotIndexes::ID = 0; |
Matthias Braun | 1527baa | 2017-05-25 21:26:32 +0000 | [diff] [blame] | 21 | INITIALIZE_PASS(SlotIndexes, DEBUG_TYPE, |
Owen Anderson | df7a4f2 | 2010-10-07 22:25:06 +0000 | [diff] [blame] | 22 | "Slot index numbering", false, false) |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 23 | |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 24 | STATISTIC(NumLocalRenum, "Number of local renumberings"); |
| 25 | STATISTIC(NumGlobalRenum, "Number of global renumberings"); |
Jakob Stoklund Olesen | b88f6ad | 2011-03-04 18:08:29 +0000 | [diff] [blame] | 26 | |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 27 | void SlotIndexes::getAnalysisUsage(AnalysisUsage &au) const { |
| 28 | au.setPreservesAll(); |
| 29 | MachineFunctionPass::getAnalysisUsage(au); |
| 30 | } |
| 31 | |
| 32 | void SlotIndexes::releaseMemory() { |
| 33 | mi2iMap.clear(); |
Jakob Stoklund Olesen | 3617128 | 2011-04-02 06:03:31 +0000 | [diff] [blame] | 34 | MBBRanges.clear(); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 35 | idx2MBBMap.clear(); |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 36 | indexList.clear(); |
| 37 | ileAllocator.Reset(); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) { |
| 41 | |
| 42 | // Compute numbering as follows: |
| 43 | // Grab an iterator to the start of the index list. |
| 44 | // Iterate over all MBBs, and within each MBB all MIs, keeping the MI |
| 45 | // iterator in lock-step (though skipping it over indexes which have |
| 46 | // null pointers in the instruction field). |
| 47 | // At each iteration assert that the instruction pointed to in the index |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 48 | // is the same one pointed to by the MI iterator. This |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 49 | |
| 50 | // FIXME: This can be simplified. The mi2iMap_, Idx2MBBMap, etc. should |
| 51 | // only need to be set up once after the first numbering is computed. |
| 52 | |
| 53 | mf = &fn; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 54 | |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 55 | // Check that the list contains only the sentinal. |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 56 | assert(indexList.empty() && "Index list non-empty at initial numbering?"); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 57 | assert(idx2MBBMap.empty() && |
| 58 | "Index -> MBB mapping non-empty at initial numbering?"); |
Jakob Stoklund Olesen | 3617128 | 2011-04-02 06:03:31 +0000 | [diff] [blame] | 59 | assert(MBBRanges.empty() && |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 60 | "MBB -> Index mapping non-empty at initial numbering?"); |
| 61 | assert(mi2iMap.empty() && |
| 62 | "MachineInstr -> Index mapping non-empty at initial numbering?"); |
| 63 | |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 64 | unsigned index = 0; |
Jakob Stoklund Olesen | 3617128 | 2011-04-02 06:03:31 +0000 | [diff] [blame] | 65 | MBBRanges.resize(mf->getNumBlockIDs()); |
| 66 | idx2MBBMap.reserve(mf->size()); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 67 | |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 68 | indexList.push_back(createEntry(nullptr, index)); |
Lang Hames | 4c05226 | 2009-12-22 00:11:50 +0000 | [diff] [blame] | 69 | |
Dan Gohman | 4a61882 | 2010-02-10 16:03:48 +0000 | [diff] [blame] | 70 | // Iterate over the function. |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 71 | for (MachineBasicBlock &MBB : *mf) { |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 72 | // Insert an index for the MBB start. |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 73 | SlotIndex blockStartIndex(&indexList.back(), SlotIndex::Slot_Block); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 74 | |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 75 | for (MachineInstr &MI : MBB) { |
| 76 | if (MI.isDebugValue()) |
Dale Johannesen | 7048797 | 2010-01-22 22:38:21 +0000 | [diff] [blame] | 77 | continue; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 78 | |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 79 | // Insert a store index for the instr. |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 80 | indexList.push_back(createEntry(&MI, index += SlotIndex::InstrDist)); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 81 | |
| 82 | // Save this base index in the maps. |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 83 | mi2iMap.insert(std::make_pair( |
| 84 | &MI, SlotIndex(&indexList.back(), SlotIndex::Slot_Block))); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Jakob Stoklund Olesen | 348d8e8 | 2011-03-04 18:51:09 +0000 | [diff] [blame] | 87 | // We insert one blank instructions between basic blocks. |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 88 | indexList.push_back(createEntry(nullptr, index += SlotIndex::InstrDist)); |
Lang Hames | 4c05226 | 2009-12-22 00:11:50 +0000 | [diff] [blame] | 89 | |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 90 | MBBRanges[MBB.getNumber()].first = blockStartIndex; |
| 91 | MBBRanges[MBB.getNumber()].second = SlotIndex(&indexList.back(), |
Jakob Stoklund Olesen | 90b5e56 | 2011-11-13 20:45:27 +0000 | [diff] [blame] | 92 | SlotIndex::Slot_Block); |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 93 | idx2MBBMap.push_back(IdxMBBPair(blockStartIndex, &MBB)); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 96 | // Sort the Idx2MBBMap |
| 97 | std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare()); |
| 98 | |
Jakob Stoklund Olesen | 66ef9ad | 2012-01-24 23:28:38 +0000 | [diff] [blame] | 99 | DEBUG(mf->print(dbgs(), this)); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 100 | |
| 101 | // And we're done! |
| 102 | return false; |
| 103 | } |
| 104 | |
Matthias Braun | fa289ec | 2017-03-17 00:41:33 +0000 | [diff] [blame] | 105 | void SlotIndexes::removeMachineInstrFromMaps(MachineInstr &MI) { |
| 106 | assert(!MI.isBundledWithPred() && |
| 107 | "Use removeSingleMachineInstrFromMaps() instread"); |
| 108 | Mi2IndexMap::iterator mi2iItr = mi2iMap.find(&MI); |
| 109 | if (mi2iItr == mi2iMap.end()) |
| 110 | return; |
| 111 | |
| 112 | SlotIndex MIIndex = mi2iItr->second; |
| 113 | IndexListEntry &MIEntry = *MIIndex.listEntry(); |
| 114 | assert(MIEntry.getInstr() == &MI && "Instruction indexes broken."); |
| 115 | mi2iMap.erase(mi2iItr); |
| 116 | // FIXME: Eventually we want to actually delete these indexes. |
| 117 | MIEntry.setInstr(nullptr); |
| 118 | } |
| 119 | |
| 120 | void SlotIndexes::removeSingleMachineInstrFromMaps(MachineInstr &MI) { |
| 121 | Mi2IndexMap::iterator mi2iItr = mi2iMap.find(&MI); |
| 122 | if (mi2iItr == mi2iMap.end()) |
| 123 | return; |
| 124 | |
| 125 | SlotIndex MIIndex = mi2iItr->second; |
| 126 | IndexListEntry &MIEntry = *MIIndex.listEntry(); |
| 127 | assert(MIEntry.getInstr() == &MI && "Instruction indexes broken."); |
| 128 | mi2iMap.erase(mi2iItr); |
| 129 | |
| 130 | // When removing the first instruction of a bundle update mapping to next |
| 131 | // instruction. |
| 132 | if (MI.isBundledWithSucc()) { |
| 133 | // Only the first instruction of a bundle should have an index assigned. |
| 134 | assert(!MI.isBundledWithPred() && "Should have first bundle isntruction"); |
| 135 | |
| 136 | MachineBasicBlock::instr_iterator Next = std::next(MI.getIterator()); |
| 137 | MachineInstr &NextMI = *Next; |
| 138 | MIEntry.setInstr(&NextMI); |
| 139 | mi2iMap.insert(std::make_pair(&NextMI, MIIndex)); |
| 140 | return; |
| 141 | } else { |
| 142 | // FIXME: Eventually we want to actually delete these indexes. |
| 143 | MIEntry.setInstr(nullptr); |
| 144 | } |
| 145 | } |
| 146 | |
Lang Hames | 6b7233a | 2009-11-14 00:02:51 +0000 | [diff] [blame] | 147 | void SlotIndexes::renumberIndexes() { |
Lang Hames | 933c541 | 2009-11-05 22:20:57 +0000 | [diff] [blame] | 148 | // Renumber updates the index of every element of the index list. |
Jakob Stoklund Olesen | db4cf7e | 2011-02-03 20:29:41 +0000 | [diff] [blame] | 149 | DEBUG(dbgs() << "\n*** Renumbering SlotIndexes ***\n"); |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 150 | ++NumGlobalRenum; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 151 | |
Lang Hames | 933c541 | 2009-11-05 22:20:57 +0000 | [diff] [blame] | 152 | unsigned index = 0; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 153 | |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 154 | for (IndexList::iterator I = indexList.begin(), E = indexList.end(); |
| 155 | I != E; ++I) { |
| 156 | I->setIndex(index); |
Jakob Stoklund Olesen | 348d8e8 | 2011-03-04 18:51:09 +0000 | [diff] [blame] | 157 | index += SlotIndex::InstrDist; |
Lang Hames | 933c541 | 2009-11-05 22:20:57 +0000 | [diff] [blame] | 158 | } |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 159 | } |
| 160 | |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 161 | // Renumber indexes locally after curItr was inserted, but failed to get a new |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 162 | // index. |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 163 | void SlotIndexes::renumberIndexes(IndexList::iterator curItr) { |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 164 | // Number indexes with half the default spacing so we can catch up quickly. |
| 165 | const unsigned Space = SlotIndex::InstrDist/2; |
Gabor Horvath | fee0434 | 2015-03-16 09:53:42 +0000 | [diff] [blame] | 166 | static_assert((Space & 3) == 0, "InstrDist must be a multiple of 2*NUM"); |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 167 | |
Benjamin Kramer | b6d0bd4 | 2014-03-02 12:27:27 +0000 | [diff] [blame] | 168 | IndexList::iterator startItr = std::prev(curItr); |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 169 | unsigned index = startItr->getIndex(); |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 170 | do { |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 171 | curItr->setIndex(index += Space); |
| 172 | ++curItr; |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 173 | // If the next index is bigger, we have caught up. |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 174 | } while (curItr != indexList.end() && curItr->getIndex() <= index); |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 175 | |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 176 | DEBUG(dbgs() << "\n*** Renumbered SlotIndexes " << startItr->getIndex() << '-' |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 177 | << index << " ***\n"); |
| 178 | ++NumLocalRenum; |
| 179 | } |
| 180 | |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 181 | // Repair indexes after adding and removing instructions. |
| 182 | void SlotIndexes::repairIndexesInRange(MachineBasicBlock *MBB, |
| 183 | MachineBasicBlock::iterator Begin, |
| 184 | MachineBasicBlock::iterator End) { |
Cameron Zwarich | caad7e1 | 2013-02-20 22:10:00 +0000 | [diff] [blame] | 185 | // FIXME: Is this really necessary? The only caller repairIntervalsForRange() |
| 186 | // does the same thing. |
| 187 | // Find anchor points, which are at the beginning/end of blocks or at |
| 188 | // instructions that already have indexes. |
Duncan P. N. Exon Smith | 3ac9cc6 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 189 | while (Begin != MBB->begin() && !hasIndex(*Begin)) |
Cameron Zwarich | caad7e1 | 2013-02-20 22:10:00 +0000 | [diff] [blame] | 190 | --Begin; |
Duncan P. N. Exon Smith | 3ac9cc6 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 191 | while (End != MBB->end() && !hasIndex(*End)) |
Cameron Zwarich | caad7e1 | 2013-02-20 22:10:00 +0000 | [diff] [blame] | 192 | ++End; |
| 193 | |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 194 | bool includeStart = (Begin == MBB->begin()); |
| 195 | SlotIndex startIdx; |
| 196 | if (includeStart) |
| 197 | startIdx = getMBBStartIdx(MBB); |
| 198 | else |
Duncan P. N. Exon Smith | 3ac9cc6 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 199 | startIdx = getInstructionIndex(*Begin); |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 200 | |
| 201 | SlotIndex endIdx; |
| 202 | if (End == MBB->end()) |
| 203 | endIdx = getMBBEndIdx(MBB); |
| 204 | else |
Duncan P. N. Exon Smith | 3ac9cc6 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 205 | endIdx = getInstructionIndex(*End); |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 206 | |
| 207 | // FIXME: Conceptually, this code is implementing an iterator on MBB that |
| 208 | // optionally includes an additional position prior to MBB->begin(), indicated |
| 209 | // by the includeStart flag. This is done so that we can iterate MIs in a MBB |
| 210 | // in parallel with SlotIndexes, but there should be a better way to do this. |
Duncan P. N. Exon Smith | 5ec1568 | 2015-10-09 19:40:45 +0000 | [diff] [blame] | 211 | IndexList::iterator ListB = startIdx.listEntry()->getIterator(); |
| 212 | IndexList::iterator ListI = endIdx.listEntry()->getIterator(); |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 213 | MachineBasicBlock::iterator MBBI = End; |
| 214 | bool pastStart = false; |
| 215 | while (ListI != ListB || MBBI != Begin || (includeStart && !pastStart)) { |
| 216 | assert(ListI->getIndex() >= startIdx.getIndex() && |
| 217 | (includeStart || !pastStart) && |
| 218 | "Decremented past the beginning of region to repair."); |
| 219 | |
| 220 | MachineInstr *SlotMI = ListI->getInstr(); |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 221 | MachineInstr *MI = (MBBI != MBB->end() && !pastStart) ? &*MBBI : nullptr; |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 222 | bool MBBIAtBegin = MBBI == Begin && (!includeStart || pastStart); |
| 223 | |
| 224 | if (SlotMI == MI && !MBBIAtBegin) { |
| 225 | --ListI; |
| 226 | if (MBBI != Begin) |
| 227 | --MBBI; |
| 228 | else |
| 229 | pastStart = true; |
| 230 | } else if (MI && mi2iMap.find(MI) == mi2iMap.end()) { |
| 231 | if (MBBI != Begin) |
| 232 | --MBBI; |
| 233 | else |
| 234 | pastStart = true; |
| 235 | } else { |
| 236 | --ListI; |
| 237 | if (SlotMI) |
Duncan P. N. Exon Smith | 3ac9cc6 | 2016-02-27 06:40:41 +0000 | [diff] [blame] | 238 | removeMachineInstrFromMaps(*SlotMI); |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 239 | } |
| 240 | } |
| 241 | |
| 242 | // In theory this could be combined with the previous loop, but it is tricky |
| 243 | // to update the IndexList while we are iterating it. |
| 244 | for (MachineBasicBlock::iterator I = End; I != Begin;) { |
| 245 | --I; |
Duncan P. N. Exon Smith | ef105ca | 2016-07-01 15:08:52 +0000 | [diff] [blame] | 246 | MachineInstr &MI = *I; |
| 247 | if (!MI.isDebugValue() && mi2iMap.find(&MI) == mi2iMap.end()) |
| 248 | insertMachineInstrInMaps(MI); |
Cameron Zwarich | 2941482 | 2013-02-20 06:46:41 +0000 | [diff] [blame] | 249 | } |
| 250 | } |
Jakob Stoklund Olesen | b8e6fdc | 2011-03-04 19:43:38 +0000 | [diff] [blame] | 251 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 252 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Yaron Keren | eb2a254 | 2016-01-29 20:50:44 +0000 | [diff] [blame] | 253 | LLVM_DUMP_METHOD void SlotIndexes::dump() const { |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 254 | for (IndexList::const_iterator itr = indexList.begin(); |
| 255 | itr != indexList.end(); ++itr) { |
David Greene | 714520f | 2010-01-05 01:25:50 +0000 | [diff] [blame] | 256 | dbgs() << itr->getIndex() << " "; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 257 | |
Craig Topper | c0196b1 | 2014-04-14 00:51:57 +0000 | [diff] [blame] | 258 | if (itr->getInstr()) { |
David Greene | 714520f | 2010-01-05 01:25:50 +0000 | [diff] [blame] | 259 | dbgs() << *itr->getInstr(); |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 260 | } else { |
David Greene | 714520f | 2010-01-05 01:25:50 +0000 | [diff] [blame] | 261 | dbgs() << "\n"; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 262 | } |
| 263 | } |
| 264 | |
Jakob Stoklund Olesen | 3617128 | 2011-04-02 06:03:31 +0000 | [diff] [blame] | 265 | for (unsigned i = 0, e = MBBRanges.size(); i != e; ++i) |
Francis Visoiu Mistrih | 25528d6 | 2017-12-04 17:18:51 +0000 | [diff] [blame] | 266 | dbgs() << "%bb." << i << "\t[" << MBBRanges[i].first << ';' |
Jakob Stoklund Olesen | 3617128 | 2011-04-02 06:03:31 +0000 | [diff] [blame] | 267 | << MBBRanges[i].second << ")\n"; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 268 | } |
Manman Ren | 742534c | 2012-09-06 19:06:06 +0000 | [diff] [blame] | 269 | #endif |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 270 | |
| 271 | // Print a SlotIndex to a raw_ostream. |
| 272 | void SlotIndex::print(raw_ostream &os) const { |
Jakob Stoklund Olesen | db4cf7e | 2011-02-03 20:29:41 +0000 | [diff] [blame] | 273 | if (isValid()) |
Lang Hames | aef9178 | 2012-04-17 04:15:51 +0000 | [diff] [blame] | 274 | os << listEntry()->getIndex() << "Berd"[getSlot()]; |
Jakob Stoklund Olesen | db4cf7e | 2011-02-03 20:29:41 +0000 | [diff] [blame] | 275 | else |
| 276 | os << "invalid"; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 277 | } |
| 278 | |
Aaron Ballman | 615eb47 | 2017-10-15 14:32:27 +0000 | [diff] [blame] | 279 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 280 | // Dump a SlotIndex to stderr. |
Yaron Keren | eb2a254 | 2016-01-29 20:50:44 +0000 | [diff] [blame] | 281 | LLVM_DUMP_METHOD void SlotIndex::dump() const { |
David Greene | 714520f | 2010-01-05 01:25:50 +0000 | [diff] [blame] | 282 | print(dbgs()); |
| 283 | dbgs() << "\n"; |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 284 | } |
Manman Ren | 742534c | 2012-09-06 19:06:06 +0000 | [diff] [blame] | 285 | #endif |
Lang Hames | 05fb963 | 2009-11-03 23:52:08 +0000 | [diff] [blame] | 286 | |