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