1 //===- llvm/CodeGen/SlotIndexes.h - Slot indexes representation -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements SlotIndex and related classes. The purpose of SlotIndex
11 // is to describe a position at which a register can become live, or cease to
14 // SlotIndex is mostly a proxy for entries of the SlotIndexList, a class which
15 // is held is LiveIntervals and provides the real numbering. This allows
16 // LiveIntervals to perform largely transparent renumbering.
17 //===----------------------------------------------------------------------===//
19 #ifndef LLVM_CODEGEN_SLOTINDEXES_H
20 #define LLVM_CODEGEN_SLOTINDEXES_H
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/ADT/IntervalMap.h"
24 #include "llvm/ADT/PointerIntPair.h"
25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/ilist.h"
27 #include "llvm/CodeGen/MachineBasicBlock.h"
28 #include "llvm/CodeGen/MachineFunction.h"
29 #include "llvm/CodeGen/MachineFunctionPass.h"
30 #include "llvm/CodeGen/MachineInstr.h"
31 #include "llvm/CodeGen/MachineInstrBundle.h"
32 #include "llvm/Pass.h"
33 #include "llvm/Support/Allocator.h"
43 /// This class represents an entry in the slot index list held in the
44 /// SlotIndexes pass. It should not be used directly. See the
45 /// SlotIndex & SlotIndexes classes for the public interface to this
47 class IndexListEntry : public ilist_node<IndexListEntry> {
52 IndexListEntry(MachineInstr *mi, unsigned index) : mi(mi), index(index) {}
54 MachineInstr* getInstr() const { return mi; }
55 void setInstr(MachineInstr *mi) {
59 unsigned getIndex() const { return index; }
60 void setIndex(unsigned index) {
64 #ifdef EXPENSIVE_CHECKS
65 // When EXPENSIVE_CHECKS is defined, "erased" index list entries will
66 // actually be moved to a "graveyard" list, and have their pointers
67 // poisoned, so that dangling SlotIndex access can be reliably detected.
69 intptr_t tmp = reinterpret_cast<intptr_t>(mi);
70 assert(((tmp & 0x1) == 0x0) && "Pointer already poisoned?");
72 mi = reinterpret_cast<MachineInstr*>(tmp);
75 bool isPoisoned() const { return (reinterpret_cast<intptr_t>(mi) & 0x1) == 0x1; }
76 #endif // EXPENSIVE_CHECKS
80 struct ilist_alloc_traits<IndexListEntry>
81 : public ilist_noalloc_traits<IndexListEntry> {};
83 /// SlotIndex - An opaque wrapper around machine indexes.
85 friend class SlotIndexes;
88 /// Basic block boundary. Used for live ranges entering and leaving a
89 /// block without being live in the layout neighbor. Also used as the
90 /// def slot of PHI-defs.
93 /// Early-clobber register use/def slot. A live range defined at
94 /// Slot_EarlyClobber interferes with normal live ranges killed at
95 /// Slot_Register. Also used as the kill slot for live ranges tied to an
96 /// early-clobber def.
99 /// Normal register use/def slot. Normal instructions kill and define
100 /// register live ranges at this slot.
103 /// Dead def kill point. Kill slot for a live range that is defined by
104 /// the same instruction (Slot_Register or Slot_EarlyClobber), but isn't
111 PointerIntPair<IndexListEntry*, 2, unsigned> lie;
113 SlotIndex(IndexListEntry *entry, unsigned slot)
114 : lie(entry, slot) {}
116 IndexListEntry* listEntry() const {
117 assert(isValid() && "Attempt to compare reserved index.");
118 #ifdef EXPENSIVE_CHECKS
119 assert(!lie.getPointer()->isPoisoned() &&
120 "Attempt to access deleted list-entry.");
121 #endif // EXPENSIVE_CHECKS
122 return lie.getPointer();
125 unsigned getIndex() const {
126 return listEntry()->getIndex() | getSlot();
129 /// Returns the slot for this SlotIndex.
130 Slot getSlot() const {
131 return static_cast<Slot>(lie.getInt());
136 /// The default distance between instructions as returned by distance().
137 /// This may vary as instructions are inserted and removed.
138 InstrDist = 4 * Slot_Count
141 /// Construct an invalid index.
142 SlotIndex() = default;
144 // Construct a new slot index from the given one, and set the slot.
145 SlotIndex(const SlotIndex &li, Slot s) : lie(li.listEntry(), unsigned(s)) {
146 assert(lie.getPointer() != nullptr &&
147 "Attempt to construct index with 0 pointer.");
150 /// Returns true if this is a valid index. Invalid indices do
151 /// not point into an index table, and cannot be compared.
152 bool isValid() const {
153 return lie.getPointer();
156 /// Return true for a valid index.
157 explicit operator bool() const { return isValid(); }
159 /// Print this index to the given raw_ostream.
160 void print(raw_ostream &os) const;
162 /// Dump this index to stderr.
165 /// Compare two SlotIndex objects for equality.
166 bool operator==(SlotIndex other) const {
167 return lie == other.lie;
169 /// Compare two SlotIndex objects for inequality.
170 bool operator!=(SlotIndex other) const {
171 return lie != other.lie;
174 /// Compare two SlotIndex objects. Return true if the first index
175 /// is strictly lower than the second.
176 bool operator<(SlotIndex other) const {
177 return getIndex() < other.getIndex();
179 /// Compare two SlotIndex objects. Return true if the first index
180 /// is lower than, or equal to, the second.
181 bool operator<=(SlotIndex other) const {
182 return getIndex() <= other.getIndex();
185 /// Compare two SlotIndex objects. Return true if the first index
186 /// is greater than the second.
187 bool operator>(SlotIndex other) const {
188 return getIndex() > other.getIndex();
191 /// Compare two SlotIndex objects. Return true if the first index
192 /// is greater than, or equal to, the second.
193 bool operator>=(SlotIndex other) const {
194 return getIndex() >= other.getIndex();
197 /// isSameInstr - Return true if A and B refer to the same instruction.
198 static bool isSameInstr(SlotIndex A, SlotIndex B) {
199 return A.lie.getPointer() == B.lie.getPointer();
202 /// isEarlierInstr - Return true if A refers to an instruction earlier than
203 /// B. This is equivalent to A < B && !isSameInstr(A, B).
204 static bool isEarlierInstr(SlotIndex A, SlotIndex B) {
205 return A.listEntry()->getIndex() < B.listEntry()->getIndex();
208 /// Return true if A refers to the same instruction as B or an earlier one.
209 /// This is equivalent to !isEarlierInstr(B, A).
210 static bool isEarlierEqualInstr(SlotIndex A, SlotIndex B) {
211 return !isEarlierInstr(B, A);
214 /// Return the distance from this index to the given one.
215 int distance(SlotIndex other) const {
216 return other.getIndex() - getIndex();
219 /// Return the scaled distance from this index to the given one, where all
220 /// slots on the same instruction have zero distance.
221 int getInstrDistance(SlotIndex other) const {
222 return (other.listEntry()->getIndex() - listEntry()->getIndex())
226 /// isBlock - Returns true if this is a block boundary slot.
227 bool isBlock() const { return getSlot() == Slot_Block; }
229 /// isEarlyClobber - Returns true if this is an early-clobber slot.
230 bool isEarlyClobber() const { return getSlot() == Slot_EarlyClobber; }
232 /// isRegister - Returns true if this is a normal register use/def slot.
233 /// Note that early-clobber slots may also be used for uses and defs.
234 bool isRegister() const { return getSlot() == Slot_Register; }
236 /// isDead - Returns true if this is a dead def kill slot.
237 bool isDead() const { return getSlot() == Slot_Dead; }
239 /// Returns the base index for associated with this index. The base index
240 /// is the one associated with the Slot_Block slot for the instruction
241 /// pointed to by this index.
242 SlotIndex getBaseIndex() const {
243 return SlotIndex(listEntry(), Slot_Block);
246 /// Returns the boundary index for associated with this index. The boundary
247 /// index is the one associated with the Slot_Block slot for the instruction
248 /// pointed to by this index.
249 SlotIndex getBoundaryIndex() const {
250 return SlotIndex(listEntry(), Slot_Dead);
253 /// Returns the register use/def slot in the current instruction for a
254 /// normal or early-clobber def.
255 SlotIndex getRegSlot(bool EC = false) const {
256 return SlotIndex(listEntry(), EC ? Slot_EarlyClobber : Slot_Register);
259 /// Returns the dead def kill slot for the current instruction.
260 SlotIndex getDeadSlot() const {
261 return SlotIndex(listEntry(), Slot_Dead);
264 /// Returns the next slot in the index list. This could be either the
265 /// next slot for the instruction pointed to by this index or, if this
266 /// index is a STORE, the first slot for the next instruction.
267 /// WARNING: This method is considerably more expensive than the methods
268 /// that return specific slots (getUseIndex(), etc). If you can - please
269 /// use one of those methods.
270 SlotIndex getNextSlot() const {
272 if (s == Slot_Dead) {
273 return SlotIndex(&*++listEntry()->getIterator(), Slot_Block);
275 return SlotIndex(listEntry(), s + 1);
278 /// Returns the next index. This is the index corresponding to the this
279 /// index's slot, but for the next instruction.
280 SlotIndex getNextIndex() const {
281 return SlotIndex(&*++listEntry()->getIterator(), getSlot());
284 /// Returns the previous slot in the index list. This could be either the
285 /// previous slot for the instruction pointed to by this index or, if this
286 /// index is a Slot_Block, the last slot for the previous instruction.
287 /// WARNING: This method is considerably more expensive than the methods
288 /// that return specific slots (getUseIndex(), etc). If you can - please
289 /// use one of those methods.
290 SlotIndex getPrevSlot() const {
292 if (s == Slot_Block) {
293 return SlotIndex(&*--listEntry()->getIterator(), Slot_Dead);
295 return SlotIndex(listEntry(), s - 1);
298 /// Returns the previous index. This is the index corresponding to this
299 /// index's slot, but for the previous instruction.
300 SlotIndex getPrevIndex() const {
301 return SlotIndex(&*--listEntry()->getIterator(), getSlot());
305 template <> struct isPodLike<SlotIndex> { static const bool value = true; };
307 inline raw_ostream& operator<<(raw_ostream &os, SlotIndex li) {
312 using IdxMBBPair = std::pair<SlotIndex, MachineBasicBlock *>;
314 inline bool operator<(SlotIndex V, const IdxMBBPair &IM) {
318 inline bool operator<(const IdxMBBPair &IM, SlotIndex V) {
322 struct Idx2MBBCompare {
323 bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const {
324 return LHS.first < RHS.first;
328 /// SlotIndexes pass.
330 /// This pass assigns indexes to each instruction.
331 class SlotIndexes : public MachineFunctionPass {
333 // IndexListEntry allocator.
334 BumpPtrAllocator ileAllocator;
336 using IndexList = ilist<IndexListEntry>;
339 #ifdef EXPENSIVE_CHECKS
340 IndexList graveyardList;
341 #endif // EXPENSIVE_CHECKS
345 using Mi2IndexMap = DenseMap<const MachineInstr *, SlotIndex>;
348 /// MBBRanges - Map MBB number to (start, stop) indexes.
349 SmallVector<std::pair<SlotIndex, SlotIndex>, 8> MBBRanges;
351 /// Idx2MBBMap - Sorted list of pairs of index of first instruction
353 SmallVector<IdxMBBPair, 8> idx2MBBMap;
355 IndexListEntry* createEntry(MachineInstr *mi, unsigned index) {
356 IndexListEntry *entry =
357 static_cast<IndexListEntry *>(ileAllocator.Allocate(
358 sizeof(IndexListEntry), alignof(IndexListEntry)));
360 new (entry) IndexListEntry(mi, index);
365 /// Renumber locally after inserting curItr.
366 void renumberIndexes(IndexList::iterator curItr);
371 SlotIndexes() : MachineFunctionPass(ID) {
372 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
375 ~SlotIndexes() override {
376 // The indexList's nodes are all allocated in the BumpPtrAllocator.
377 indexList.clearAndLeakNodesUnsafely();
380 void getAnalysisUsage(AnalysisUsage &au) const override;
381 void releaseMemory() override;
383 bool runOnMachineFunction(MachineFunction &fn) override;
385 /// Dump the indexes.
388 /// Renumber the index list, providing space for new instructions.
389 void renumberIndexes();
391 /// Repair indexes after adding and removing instructions.
392 void repairIndexesInRange(MachineBasicBlock *MBB,
393 MachineBasicBlock::iterator Begin,
394 MachineBasicBlock::iterator End);
396 /// Returns the zero index for this analysis.
397 SlotIndex getZeroIndex() {
398 assert(indexList.front().getIndex() == 0 && "First index is not 0?");
399 return SlotIndex(&indexList.front(), 0);
402 /// Returns the base index of the last slot in this analysis.
403 SlotIndex getLastIndex() {
404 return SlotIndex(&indexList.back(), 0);
407 /// Returns true if the given machine instr is mapped to an index,
408 /// otherwise returns false.
409 bool hasIndex(const MachineInstr &instr) const {
410 return mi2iMap.count(&instr);
413 /// Returns the base index for the given instruction.
414 SlotIndex getInstructionIndex(const MachineInstr &MI) const {
415 // Instructions inside a bundle have the same number as the bundle itself.
416 auto BundleStart = getBundleStart(MI.getIterator());
417 auto BundleEnd = getBundleEnd(MI.getIterator());
418 // Use the first non-debug instruction in the bundle to get SlotIndex.
419 const MachineInstr &BundleNonDebug =
420 *skipDebugInstructionsForward(BundleStart, BundleEnd);
421 assert(!BundleNonDebug.isDebugInstr() &&
422 "Could not use a debug instruction to query mi2iMap.");
423 Mi2IndexMap::const_iterator itr = mi2iMap.find(&BundleNonDebug);
424 assert(itr != mi2iMap.end() && "Instruction not found in maps.");
428 /// Returns the instruction for the given index, or null if the given
429 /// index has no instruction associated with it.
430 MachineInstr* getInstructionFromIndex(SlotIndex index) const {
431 return index.isValid() ? index.listEntry()->getInstr() : nullptr;
434 /// Returns the next non-null index, if one exists.
435 /// Otherwise returns getLastIndex().
436 SlotIndex getNextNonNullIndex(SlotIndex Index) {
437 IndexList::iterator I = Index.listEntry()->getIterator();
438 IndexList::iterator E = indexList.end();
441 return SlotIndex(&*I, Index.getSlot());
442 // We reached the end of the function.
443 return getLastIndex();
446 /// getIndexBefore - Returns the index of the last indexed instruction
447 /// before MI, or the start index of its basic block.
448 /// MI is not required to have an index.
449 SlotIndex getIndexBefore(const MachineInstr &MI) const {
450 const MachineBasicBlock *MBB = MI.getParent();
451 assert(MBB && "MI must be inserted in a basic block");
452 MachineBasicBlock::const_iterator I = MI, B = MBB->begin();
455 return getMBBStartIdx(MBB);
457 Mi2IndexMap::const_iterator MapItr = mi2iMap.find(&*I);
458 if (MapItr != mi2iMap.end())
459 return MapItr->second;
463 /// getIndexAfter - Returns the index of the first indexed instruction
464 /// after MI, or the end index of its basic block.
465 /// MI is not required to have an index.
466 SlotIndex getIndexAfter(const MachineInstr &MI) const {
467 const MachineBasicBlock *MBB = MI.getParent();
468 assert(MBB && "MI must be inserted in a basic block");
469 MachineBasicBlock::const_iterator I = MI, E = MBB->end();
473 return getMBBEndIdx(MBB);
474 Mi2IndexMap::const_iterator MapItr = mi2iMap.find(&*I);
475 if (MapItr != mi2iMap.end())
476 return MapItr->second;
480 /// Return the (start,end) range of the given basic block number.
481 const std::pair<SlotIndex, SlotIndex> &
482 getMBBRange(unsigned Num) const {
483 return MBBRanges[Num];
486 /// Return the (start,end) range of the given basic block.
487 const std::pair<SlotIndex, SlotIndex> &
488 getMBBRange(const MachineBasicBlock *MBB) const {
489 return getMBBRange(MBB->getNumber());
492 /// Returns the first index in the given basic block number.
493 SlotIndex getMBBStartIdx(unsigned Num) const {
494 return getMBBRange(Num).first;
497 /// Returns the first index in the given basic block.
498 SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const {
499 return getMBBRange(mbb).first;
502 /// Returns the last index in the given basic block number.
503 SlotIndex getMBBEndIdx(unsigned Num) const {
504 return getMBBRange(Num).second;
507 /// Returns the last index in the given basic block.
508 SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const {
509 return getMBBRange(mbb).second;
512 /// Iterator over the idx2MBBMap (sorted pairs of slot index of basic block
513 /// begin and basic block)
514 using MBBIndexIterator = SmallVectorImpl<IdxMBBPair>::const_iterator;
516 /// Move iterator to the next IdxMBBPair where the SlotIndex is greater or
518 MBBIndexIterator advanceMBBIndex(MBBIndexIterator I, SlotIndex To) const {
519 return std::lower_bound(I, idx2MBBMap.end(), To);
522 /// Get an iterator pointing to the IdxMBBPair with the biggest SlotIndex
523 /// that is greater or equal to \p Idx.
524 MBBIndexIterator findMBBIndex(SlotIndex Idx) const {
525 return advanceMBBIndex(idx2MBBMap.begin(), Idx);
528 /// Returns an iterator for the begin of the idx2MBBMap.
529 MBBIndexIterator MBBIndexBegin() const {
530 return idx2MBBMap.begin();
533 /// Return an iterator for the end of the idx2MBBMap.
534 MBBIndexIterator MBBIndexEnd() const {
535 return idx2MBBMap.end();
538 /// Returns the basic block which the given index falls in.
539 MachineBasicBlock* getMBBFromIndex(SlotIndex index) const {
540 if (MachineInstr *MI = getInstructionFromIndex(index))
541 return MI->getParent();
543 MBBIndexIterator I = findMBBIndex(index);
544 // Take the pair containing the index
546 ((I != MBBIndexEnd() && I->first > index) ||
547 (I == MBBIndexEnd() && !idx2MBBMap.empty())) ? std::prev(I) : I;
549 assert(J != MBBIndexEnd() && J->first <= index &&
550 index < getMBBEndIdx(J->second) &&
551 "index does not correspond to an MBB");
555 /// Returns the MBB covering the given range, or null if the range covers
556 /// more than one basic block.
557 MachineBasicBlock* getMBBCoveringRange(SlotIndex start, SlotIndex end) const {
559 assert(start < end && "Backwards ranges not allowed.");
560 MBBIndexIterator itr = findMBBIndex(start);
561 if (itr == MBBIndexEnd()) {
562 itr = std::prev(itr);
566 // Check that we don't cross the boundary into this block.
567 if (itr->first < end)
570 itr = std::prev(itr);
572 if (itr->first <= start)
578 /// Insert the given machine instruction into the mapping. Returns the
580 /// If Late is set and there are null indexes between mi's neighboring
581 /// instructions, create the new index after the null indexes instead of
583 SlotIndex insertMachineInstrInMaps(MachineInstr &MI, bool Late = false) {
584 assert(!MI.isInsideBundle() &&
585 "Instructions inside bundles should use bundle start's slot.");
586 assert(mi2iMap.find(&MI) == mi2iMap.end() && "Instr already indexed.");
587 // Numbering debug instructions could cause code generation to be
588 // affected by debug information.
589 assert(!MI.isDebugInstr() && "Cannot number debug instructions.");
591 assert(MI.getParent() != nullptr && "Instr must be added to function.");
593 // Get the entries where MI should be inserted.
594 IndexList::iterator prevItr, nextItr;
596 // Insert MI's index immediately before the following instruction.
597 nextItr = getIndexAfter(MI).listEntry()->getIterator();
598 prevItr = std::prev(nextItr);
600 // Insert MI's index immediately after the preceding instruction.
601 prevItr = getIndexBefore(MI).listEntry()->getIterator();
602 nextItr = std::next(prevItr);
605 // Get a number for the new instr, or 0 if there's no room currently.
606 // In the latter case we'll force a renumber later.
607 unsigned dist = ((nextItr->getIndex() - prevItr->getIndex())/2) & ~3u;
608 unsigned newNumber = prevItr->getIndex() + dist;
610 // Insert a new list entry for MI.
611 IndexList::iterator newItr =
612 indexList.insert(nextItr, createEntry(&MI, newNumber));
614 // Renumber locally if we need to.
616 renumberIndexes(newItr);
618 SlotIndex newIndex(&*newItr, SlotIndex::Slot_Block);
619 mi2iMap.insert(std::make_pair(&MI, newIndex));
623 /// Removes machine instruction (bundle) \p MI from the mapping.
624 /// This should be called before MachineInstr::eraseFromParent() is used to
625 /// remove a whole bundle or an unbundled instruction.
626 void removeMachineInstrFromMaps(MachineInstr &MI);
628 /// Removes a single machine instruction \p MI from the mapping.
629 /// This should be called before MachineInstr::eraseFromBundle() is used to
630 /// remove a single instruction (out of a bundle).
631 void removeSingleMachineInstrFromMaps(MachineInstr &MI);
633 /// ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in
634 /// maps used by register allocator. \returns the index where the new
635 /// instruction was inserted.
636 SlotIndex replaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI) {
637 Mi2IndexMap::iterator mi2iItr = mi2iMap.find(&MI);
638 if (mi2iItr == mi2iMap.end())
640 SlotIndex replaceBaseIndex = mi2iItr->second;
641 IndexListEntry *miEntry(replaceBaseIndex.listEntry());
642 assert(miEntry->getInstr() == &MI &&
643 "Mismatched instruction in index tables.");
644 miEntry->setInstr(&NewMI);
645 mi2iMap.erase(mi2iItr);
646 mi2iMap.insert(std::make_pair(&NewMI, replaceBaseIndex));
647 return replaceBaseIndex;
650 /// Add the given MachineBasicBlock into the maps.
651 void insertMBBInMaps(MachineBasicBlock *mbb) {
652 MachineFunction::iterator nextMBB =
653 std::next(MachineFunction::iterator(mbb));
655 IndexListEntry *startEntry = nullptr;
656 IndexListEntry *endEntry = nullptr;
657 IndexList::iterator newItr;
658 if (nextMBB == mbb->getParent()->end()) {
659 startEntry = &indexList.back();
660 endEntry = createEntry(nullptr, 0);
661 newItr = indexList.insertAfter(startEntry->getIterator(), endEntry);
663 startEntry = createEntry(nullptr, 0);
664 endEntry = getMBBStartIdx(&*nextMBB).listEntry();
665 newItr = indexList.insert(endEntry->getIterator(), startEntry);
668 SlotIndex startIdx(startEntry, SlotIndex::Slot_Block);
669 SlotIndex endIdx(endEntry, SlotIndex::Slot_Block);
671 MachineFunction::iterator prevMBB(mbb);
672 assert(prevMBB != mbb->getParent()->end() &&
673 "Can't insert a new block at the beginning of a function.");
675 MBBRanges[prevMBB->getNumber()].second = startIdx;
677 assert(unsigned(mbb->getNumber()) == MBBRanges.size() &&
678 "Blocks must be added in order");
679 MBBRanges.push_back(std::make_pair(startIdx, endIdx));
680 idx2MBBMap.push_back(IdxMBBPair(startIdx, mbb));
682 renumberIndexes(newItr);
683 llvm::sort(idx2MBBMap, Idx2MBBCompare());
686 /// Free the resources that were required to maintain a SlotIndex.
688 /// Once an index is no longer needed (for instance because the instruction
689 /// at that index has been moved), the resources required to maintain the
690 /// index can be relinquished to reduce memory use and improve renumbering
691 /// performance. Any remaining SlotIndex objects that point to the same
692 /// index are left 'dangling' (much the same as a dangling pointer to a
693 /// freed object) and should not be accessed, except to destruct them.
695 /// Like dangling pointers, access to dangling SlotIndexes can cause
696 /// painful-to-track-down bugs, especially if the memory for the index
697 /// previously pointed to has been re-used. To detect dangling SlotIndex
698 /// bugs, build with EXPENSIVE_CHECKS=1. This will cause "erased" indexes to
699 /// be retained in a graveyard instead of being freed. Operations on indexes
700 /// in the graveyard will trigger an assertion.
701 void eraseIndex(SlotIndex index) {
702 IndexListEntry *entry = index.listEntry();
703 #ifdef EXPENSIVE_CHECKS
704 indexList.remove(entry);
705 graveyardList.push_back(entry);
708 indexList.erase(entry);
713 // Specialize IntervalMapInfo for half-open slot index intervals.
715 struct IntervalMapInfo<SlotIndex> : IntervalMapHalfOpenInfo<SlotIndex> {
718 } // end namespace llvm
720 #endif // LLVM_CODEGEN_SLOTINDEXES_H