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 purpuse 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. The SlotIndex
17 // class does hold a PHI bit, which determines whether the index relates to a
18 // PHI use or def point, or an actual instruction. See the SlotIndex class
19 // description for futher information.
20 //===----------------------------------------------------------------------===//
22 #ifndef LLVM_CODEGEN_SLOTINDEXES_H
23 #define LLVM_CODEGEN_SLOTINDEXES_H
25 #include "llvm/ADT/PointerIntPair.h"
26 #include "llvm/ADT/SmallVector.h"
27 #include "llvm/CodeGen/MachineBasicBlock.h"
28 #include "llvm/CodeGen/MachineFunctionPass.h"
29 #include "llvm/CodeGen/MachineInstr.h"
30 #include "llvm/Support/Allocator.h"
31 #include "llvm/Support/ErrorHandling.h"
32 #include "llvm/Support/ManagedStatic.h"
36 class EmptyIndexListEntry;
37 class TombstoneIndexListEntry;
39 /// This class represents an entry in the slot index list held in the
40 /// SlotIndexes pass. It should not be used directly. See the
41 /// SlotIndex & SlotIndexes classes for the public interface to this
43 class IndexListEntry {
46 static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U,
47 TOMBSTONE_KEY_INDEX = ~0U & ~7U;
49 // The following statics are thread safe. They're read only, and you
50 // can't step from them to any other list entries.
51 static ManagedStatic<EmptyIndexListEntry> emptyKeyEntry;
52 static ManagedStatic<TombstoneIndexListEntry> tombstoneKeyEntry;
54 IndexListEntry *next, *prev;
60 typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType;
62 // This constructor is only to be used by getEmptyKeyEntry
63 // & getTombstoneKeyEntry. It sets index to the given
64 // value and mi to zero.
65 IndexListEntry(ReservedEntryType r) : mi(0) {
67 case EMPTY_KEY: index = EMPTY_KEY_INDEX; break;
68 case TOMBSTONE_KEY: index = TOMBSTONE_KEY_INDEX; break;
69 default: assert(false && "Invalid value for constructor.");
77 IndexListEntry(MachineInstr *mi, unsigned index) : mi(mi), index(index) {
78 if (index == EMPTY_KEY_INDEX || index == TOMBSTONE_KEY_INDEX) {
79 llvm_report_error("Attempt to create invalid index. "
80 "Available indexes may have been exhausted?.");
84 MachineInstr* getInstr() const { return mi; }
85 void setInstr(MachineInstr *mi) {
86 assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
87 "Attempt to modify reserved index.");
91 unsigned getIndex() const { return index; }
92 void setIndex(unsigned index) {
93 assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
94 "Attempt to set index to invalid value.");
95 assert(this->index != EMPTY_KEY_INDEX &&
96 this->index != TOMBSTONE_KEY_INDEX &&
97 "Attempt to reset reserved index value.");
101 IndexListEntry* getNext() { return next; }
102 const IndexListEntry* getNext() const { return next; }
103 void setNext(IndexListEntry *next) {
104 assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
105 "Attempt to modify reserved index.");
109 IndexListEntry* getPrev() { return prev; }
110 const IndexListEntry* getPrev() const { return prev; }
111 void setPrev(IndexListEntry *prev) {
112 assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
113 "Attempt to modify reserved index.");
117 // This function returns the index list entry that is to be used for empty
119 inline static IndexListEntry* getEmptyKeyEntry();
121 // This function returns the index list entry that is to be used for
122 // tombstone SlotIndex keys.
123 inline static IndexListEntry* getTombstoneKeyEntry();
126 class EmptyIndexListEntry : public IndexListEntry {
128 EmptyIndexListEntry() : IndexListEntry(EMPTY_KEY) {}
131 class TombstoneIndexListEntry : public IndexListEntry {
133 TombstoneIndexListEntry() : IndexListEntry(TOMBSTONE_KEY) {}
136 inline IndexListEntry* IndexListEntry::getEmptyKeyEntry() {
137 return &*emptyKeyEntry;
140 inline IndexListEntry* IndexListEntry::getTombstoneKeyEntry() {
141 return &*tombstoneKeyEntry;
144 // Specialize PointerLikeTypeTraits for IndexListEntry.
146 class PointerLikeTypeTraits<IndexListEntry*> {
148 static inline void* getAsVoidPointer(IndexListEntry *p) {
151 static inline IndexListEntry* getFromVoidPointer(void *p) {
152 return static_cast<IndexListEntry*>(p);
154 enum { NumLowBitsAvailable = 3 };
157 /// SlotIndex - An opaque wrapper around machine indexes.
159 friend class SlotIndexes;
160 friend class DenseMapInfo<SlotIndex>;
163 static const unsigned PHI_BIT = 1 << 2;
165 PointerIntPair<IndexListEntry*, 3, unsigned> lie;
167 SlotIndex(IndexListEntry *entry, unsigned phiAndSlot)
168 : lie(entry, phiAndSlot) {
169 assert(entry != 0 && "Attempt to construct index with 0 pointer.");
172 IndexListEntry& entry() const {
173 return *lie.getPointer();
176 int getIndex() const {
177 return entry().getIndex() | getSlot();
180 static inline unsigned getHashValue(const SlotIndex &v) {
181 IndexListEntry *ptrVal = &v.entry();
182 return (unsigned((intptr_t)ptrVal) >> 4) ^
183 (unsigned((intptr_t)ptrVal) >> 9);
188 // FIXME: Ugh. This is public because LiveIntervalAnalysis is still using it
189 // for some spill weight stuff. Fix that, then make this private.
190 enum Slot { LOAD, USE, DEF, STORE, NUM };
192 static inline SlotIndex getEmptyKey() {
193 return SlotIndex(IndexListEntry::getEmptyKeyEntry(), 0);
196 static inline SlotIndex getTombstoneKey() {
197 return SlotIndex(IndexListEntry::getTombstoneKeyEntry(), 0);
200 /// Construct an invalid index.
201 SlotIndex() : lie(IndexListEntry::getEmptyKeyEntry(), 0) {}
203 // Construct a new slot index from the given one, set the phi flag on the
204 // new index to the value of the phi parameter.
205 SlotIndex(const SlotIndex &li, bool phi)
206 : lie(&li.entry(), phi ? PHI_BIT & li.getSlot() : (unsigned)li.getSlot()){
207 assert(lie.getPointer() != 0 &&
208 "Attempt to construct index with 0 pointer.");
211 // Construct a new slot index from the given one, set the phi flag on the
212 // new index to the value of the phi parameter, and the slot to the new slot.
213 SlotIndex(const SlotIndex &li, bool phi, Slot s)
214 : lie(&li.entry(), phi ? PHI_BIT & s : (unsigned)s) {
215 assert(lie.getPointer() != 0 &&
216 "Attempt to construct index with 0 pointer.");
219 /// Returns true if this is a valid index. Invalid indicies do
220 /// not point into an index table, and cannot be compared.
221 bool isValid() const {
222 return (lie.getPointer() != 0) && (lie.getPointer()->getIndex() != 0);
225 /// Print this index to the given raw_ostream.
226 void print(raw_ostream &os) const;
228 /// Dump this index to stderr.
231 /// Compare two SlotIndex objects for equality.
232 bool operator==(SlotIndex other) const {
233 return getIndex() == other.getIndex();
235 /// Compare two SlotIndex objects for inequality.
236 bool operator!=(SlotIndex other) const {
237 return getIndex() != other.getIndex();
240 /// Compare two SlotIndex objects. Return true if the first index
241 /// is strictly lower than the second.
242 bool operator<(SlotIndex other) const {
243 return getIndex() < other.getIndex();
245 /// Compare two SlotIndex objects. Return true if the first index
246 /// is lower than, or equal to, the second.
247 bool operator<=(SlotIndex other) const {
248 return getIndex() <= other.getIndex();
251 /// Compare two SlotIndex objects. Return true if the first index
252 /// is greater than the second.
253 bool operator>(SlotIndex other) const {
254 return getIndex() > other.getIndex();
257 /// Compare two SlotIndex objects. Return true if the first index
258 /// is greater than, or equal to, the second.
259 bool operator>=(SlotIndex other) const {
260 return getIndex() >= other.getIndex();
263 /// Return the distance from this index to the given one.
264 int distance(SlotIndex other) const {
265 return other.getIndex() - getIndex();
268 /// Returns the slot for this SlotIndex.
269 Slot getSlot() const {
270 return static_cast<Slot>(lie.getInt() & ~PHI_BIT);
273 /// Returns the state of the PHI bit.
275 return lie.getInt() & PHI_BIT;
278 /// Returns the base index for associated with this index. The base index
279 /// is the one associated with the LOAD slot for the instruction pointed to
281 SlotIndex getBaseIndex() const {
282 return getLoadIndex();
285 /// Returns the boundary index for associated with this index. The boundary
286 /// index is the one associated with the LOAD slot for the instruction
287 /// pointed to by this index.
288 SlotIndex getBoundaryIndex() const {
289 return getStoreIndex();
292 /// Returns the index of the LOAD slot for the instruction pointed to by
294 SlotIndex getLoadIndex() const {
295 return SlotIndex(&entry(), SlotIndex::LOAD);
298 /// Returns the index of the USE slot for the instruction pointed to by
300 SlotIndex getUseIndex() const {
301 return SlotIndex(&entry(), SlotIndex::USE);
304 /// Returns the index of the DEF slot for the instruction pointed to by
306 SlotIndex getDefIndex() const {
307 return SlotIndex(&entry(), SlotIndex::DEF);
310 /// Returns the index of the STORE slot for the instruction pointed to by
312 SlotIndex getStoreIndex() const {
313 return SlotIndex(&entry(), SlotIndex::STORE);
316 /// Returns the next slot in the index list. This could be either the
317 /// next slot for the instruction pointed to by this index or, if this
318 /// index is a STORE, the first slot for the next instruction.
319 /// WARNING: This method is considerably more expensive than the methods
320 /// that return specific slots (getUseIndex(), etc). If you can - please
321 /// use one of those methods.
322 SlotIndex getNextSlot() const {
324 if (s == SlotIndex::STORE) {
325 return SlotIndex(entry().getNext(), SlotIndex::LOAD);
327 return SlotIndex(&entry(), s + 1);
330 /// Returns the next index. This is the index corresponding to the this
331 /// index's slot, but for the next instruction.
332 SlotIndex getNextIndex() const {
333 return SlotIndex(entry().getNext(), getSlot());
336 /// Returns the previous slot in the index list. This could be either the
337 /// previous slot for the instruction pointed to by this index or, if this
338 /// index is a LOAD, the last slot for the previous instruction.
339 /// WARNING: This method is considerably more expensive than the methods
340 /// that return specific slots (getUseIndex(), etc). If you can - please
341 /// use one of those methods.
342 SlotIndex getPrevSlot() const {
344 if (s == SlotIndex::LOAD) {
345 return SlotIndex(entry().getPrev(), SlotIndex::STORE);
347 return SlotIndex(&entry(), s - 1);
350 /// Returns the previous index. This is the index corresponding to this
351 /// index's slot, but for the previous instruction.
352 SlotIndex getPrevIndex() const {
353 return SlotIndex(entry().getPrev(), getSlot());
358 /// DenseMapInfo specialization for SlotIndex.
360 struct DenseMapInfo<SlotIndex> {
361 static inline SlotIndex getEmptyKey() {
362 return SlotIndex::getEmptyKey();
364 static inline SlotIndex getTombstoneKey() {
365 return SlotIndex::getTombstoneKey();
367 static inline unsigned getHashValue(const SlotIndex &v) {
368 return SlotIndex::getHashValue(v);
370 static inline bool isEqual(const SlotIndex &LHS, const SlotIndex &RHS) {
373 static inline bool isPod() { return false; }
376 inline raw_ostream& operator<<(raw_ostream &os, SlotIndex li) {
381 typedef std::pair<SlotIndex, MachineBasicBlock*> IdxMBBPair;
383 inline bool operator<(SlotIndex V, const IdxMBBPair &IM) {
387 inline bool operator<(const IdxMBBPair &IM, SlotIndex V) {
391 struct Idx2MBBCompare {
392 bool operator()(const IdxMBBPair &LHS, const IdxMBBPair &RHS) const {
393 return LHS.first < RHS.first;
397 /// SlotIndexes pass.
399 /// This pass assigns indexes to each instruction.
400 class SlotIndexes : public MachineFunctionPass {
404 IndexListEntry *indexListHead;
405 unsigned functionSize;
407 typedef DenseMap<const MachineInstr*, SlotIndex> Mi2IndexMap;
410 /// MBB2IdxMap - The indexes of the first and last instructions in the
411 /// specified basic block.
412 typedef DenseMap<const MachineBasicBlock*,
413 std::pair<SlotIndex, SlotIndex> > MBB2IdxMap;
414 MBB2IdxMap mbb2IdxMap;
416 /// Idx2MBBMap - Sorted list of pairs of index of first instruction
418 std::vector<IdxMBBPair> idx2MBBMap;
420 typedef DenseMap<const MachineBasicBlock*, SlotIndex> TerminatorGapsMap;
421 TerminatorGapsMap terminatorGaps;
423 // IndexListEntry allocator.
424 BumpPtrAllocator ileAllocator;
426 IndexListEntry* createEntry(MachineInstr *mi, unsigned index) {
427 IndexListEntry *entry =
428 static_cast<IndexListEntry*>(
429 ileAllocator.Allocate(sizeof(IndexListEntry),
430 alignof<IndexListEntry>()));
432 new (entry) IndexListEntry(mi, index);
438 assert(indexListHead == 0 && "Zero entry non-null at initialisation.");
439 indexListHead = createEntry(0, ~0U);
440 indexListHead->setNext(0);
441 indexListHead->setPrev(indexListHead);
446 ileAllocator.Reset();
449 IndexListEntry* getTail() {
450 assert(indexListHead != 0 && "Call to getTail on uninitialized list.");
451 return indexListHead->getPrev();
454 const IndexListEntry* getTail() const {
455 assert(indexListHead != 0 && "Call to getTail on uninitialized list.");
456 return indexListHead->getPrev();
459 // Returns true if the index list is empty.
460 bool empty() const { return (indexListHead == getTail()); }
462 IndexListEntry* front() {
463 assert(!empty() && "front() called on empty index list.");
464 return indexListHead;
467 const IndexListEntry* front() const {
468 assert(!empty() && "front() called on empty index list.");
469 return indexListHead;
472 IndexListEntry* back() {
473 assert(!empty() && "back() called on empty index list.");
474 return getTail()->getPrev();
477 const IndexListEntry* back() const {
478 assert(!empty() && "back() called on empty index list.");
479 return getTail()->getPrev();
482 /// Insert a new entry before itr.
483 void insert(IndexListEntry *itr, IndexListEntry *val) {
484 assert(itr != 0 && "itr should not be null.");
485 IndexListEntry *prev = itr->getPrev();
489 if (itr != indexListHead) {
498 /// Push a new entry on to the end of the list.
499 void push_back(IndexListEntry *val) {
500 insert(getTail(), val);
506 SlotIndexes() : MachineFunctionPass(&ID), indexListHead(0) {}
508 virtual void getAnalysisUsage(AnalysisUsage &au) const;
509 virtual void releaseMemory();
511 virtual bool runOnMachineFunction(MachineFunction &fn);
513 /// Dump the indexes.
516 /// Renumber the index list, providing space for new instructions.
519 /// Returns the zero index for this analysis.
520 SlotIndex getZeroIndex() {
521 assert(front()->getIndex() == 0 && "First index is not 0?");
522 return SlotIndex(front(), 0);
525 /// Returns the invalid index marker for this analysis.
526 SlotIndex getInvalidIndex() {
527 return getZeroIndex();
530 /// Returns the distance between the highest and lowest indexes allocated
532 unsigned getIndexesLength() const {
533 assert(front()->getIndex() == 0 &&
534 "Initial index isn't zero?");
536 return back()->getIndex();
539 /// Returns the number of instructions in the function.
540 unsigned getFunctionSize() const {
544 /// Returns true if the given machine instr is mapped to an index,
545 /// otherwise returns false.
546 bool hasIndex(const MachineInstr *instr) const {
547 return (mi2iMap.find(instr) != mi2iMap.end());
550 /// Returns the base index for the given instruction.
551 SlotIndex getInstructionIndex(const MachineInstr *instr) const {
552 Mi2IndexMap::const_iterator itr = mi2iMap.find(instr);
553 assert(itr != mi2iMap.end() && "Instruction not found in maps.");
557 /// Returns the instruction for the given index, or null if the given
558 /// index has no instruction associated with it.
559 MachineInstr* getInstructionFromIndex(SlotIndex index) const {
560 return index.entry().getInstr();
563 /// Returns the next non-null index.
564 SlotIndex getNextNonNullIndex(SlotIndex index) {
565 SlotIndex nextNonNull = index.getNextIndex();
567 while (&nextNonNull.entry() != getTail() &&
568 getInstructionFromIndex(nextNonNull) == 0) {
569 nextNonNull = nextNonNull.getNextIndex();
575 /// Returns the first index in the given basic block.
576 SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const {
577 MBB2IdxMap::const_iterator itr = mbb2IdxMap.find(mbb);
578 assert(itr != mbb2IdxMap.end() && "MBB not found in maps.");
579 return itr->second.first;
582 /// Returns the last index in the given basic block.
583 SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const {
584 MBB2IdxMap::const_iterator itr = mbb2IdxMap.find(mbb);
585 assert(itr != mbb2IdxMap.end() && "MBB not found in maps.");
586 return itr->second.second;
589 /// Returns the terminator gap for the given index.
590 SlotIndex getTerminatorGap(const MachineBasicBlock *mbb) {
591 TerminatorGapsMap::iterator itr = terminatorGaps.find(mbb);
592 assert(itr != terminatorGaps.end() &&
593 "All MBBs should have terminator gaps in their indexes.");
597 /// Returns the basic block which the given index falls in.
598 MachineBasicBlock* getMBBFromIndex(SlotIndex index) const {
599 std::vector<IdxMBBPair>::const_iterator I =
600 std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), index);
601 // Take the pair containing the index
602 std::vector<IdxMBBPair>::const_iterator J =
603 ((I != idx2MBBMap.end() && I->first > index) ||
604 (I == idx2MBBMap.end() && idx2MBBMap.size()>0)) ? (I-1): I;
606 assert(J != idx2MBBMap.end() && J->first <= index &&
607 index <= getMBBEndIdx(J->second) &&
608 "index does not correspond to an MBB");
612 bool findLiveInMBBs(SlotIndex start, SlotIndex end,
613 SmallVectorImpl<MachineBasicBlock*> &mbbs) const {
614 std::vector<IdxMBBPair>::const_iterator itr =
615 std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start);
618 while (itr != idx2MBBMap.end()) {
619 if (itr->first >= end)
621 mbbs.push_back(itr->second);
628 /// Return a list of MBBs that can be reach via any branches or
630 bool findReachableMBBs(SlotIndex start, SlotIndex end,
631 SmallVectorImpl<MachineBasicBlock*> &mbbs) const {
632 std::vector<IdxMBBPair>::const_iterator itr =
633 std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start);
636 while (itr != idx2MBBMap.end()) {
637 if (itr->first > end)
639 MachineBasicBlock *mbb = itr->second;
640 if (getMBBEndIdx(mbb) > end)
642 for (MachineBasicBlock::succ_iterator si = mbb->succ_begin(),
643 se = mbb->succ_end(); si != se; ++si)
651 /// Returns the MBB covering the given range, or null if the range covers
652 /// more than one basic block.
653 MachineBasicBlock* getMBBCoveringRange(SlotIndex start, SlotIndex end) const {
655 assert(start < end && "Backwards ranges not allowed.");
657 std::vector<IdxMBBPair>::const_iterator itr =
658 std::lower_bound(idx2MBBMap.begin(), idx2MBBMap.end(), start);
660 if (itr == idx2MBBMap.end()) {
665 // Check that we don't cross the boundary into this block.
666 if (itr->first < end)
671 if (itr->first <= start)
677 /// Returns true if there is a gap in the numbering before the given index.
678 bool hasGapBeforeInstr(SlotIndex index) {
679 index = index.getBaseIndex();
680 SlotIndex prevIndex = index.getPrevIndex();
682 if (prevIndex == getZeroIndex())
685 if (getInstructionFromIndex(prevIndex) == 0)
688 if (prevIndex.distance(index) >= 2 * SlotIndex::NUM)
694 /// Returns true if there is a gap in the numbering after the given index.
695 bool hasGapAfterInstr(SlotIndex index) const {
696 // Not implemented yet.
698 "SlotIndexes::hasGapAfterInstr(SlotIndex) not implemented yet.");
702 /// findGapBeforeInstr - Find an empty instruction slot before the
703 /// specified index. If "Furthest" is true, find one that's furthest
704 /// away from the index (but before any index that's occupied).
705 // FIXME: This whole method should go away in future. It should
706 // always be possible to insert code between existing indices.
707 SlotIndex findGapBeforeInstr(SlotIndex index, bool furthest = false) {
708 if (index == getZeroIndex())
709 return getInvalidIndex();
711 index = index.getBaseIndex();
712 SlotIndex prevIndex = index.getPrevIndex();
714 if (prevIndex == getZeroIndex())
715 return getInvalidIndex();
717 // Try to reuse existing index objects with null-instrs.
718 if (getInstructionFromIndex(prevIndex) == 0) {
720 while (getInstructionFromIndex(prevIndex) == 0 &&
721 prevIndex != getZeroIndex()) {
722 prevIndex = prevIndex.getPrevIndex();
725 prevIndex = prevIndex.getNextIndex();
728 assert(getInstructionFromIndex(prevIndex) == 0 && "Index list is broken.");
733 int dist = prevIndex.distance(index);
735 // Double check that the spacing between this instruction and
737 assert(dist >= SlotIndex::NUM &&
738 "Distance between indexes too small.");
740 // If there's no gap return an invalid index.
741 if (dist < 2*SlotIndex::NUM) {
742 return getInvalidIndex();
745 // Otherwise insert new index entries into the list using the
746 // gap in the numbering.
747 IndexListEntry *newEntry =
748 createEntry(0, prevIndex.entry().getIndex() + SlotIndex::NUM);
750 insert(&index.entry(), newEntry);
752 // And return a pointer to the entry at the start of the gap.
753 return index.getPrevIndex();
756 /// Insert the given machine instruction into the mapping at the given
758 void insertMachineInstrInMaps(MachineInstr *mi, SlotIndex index) {
759 index = index.getBaseIndex();
760 IndexListEntry *miEntry = &index.entry();
761 assert(miEntry->getInstr() == 0 && "Index already in use.");
762 miEntry->setInstr(mi);
764 assert(mi2iMap.find(mi) == mi2iMap.end() &&
765 "MachineInstr already has an index.");
767 mi2iMap.insert(std::make_pair(mi, index));
770 /// Remove the given machine instruction from the mapping.
771 void removeMachineInstrFromMaps(MachineInstr *mi) {
772 // remove index -> MachineInstr and
773 // MachineInstr -> index mappings
774 Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi);
775 if (mi2iItr != mi2iMap.end()) {
776 IndexListEntry *miEntry(&mi2iItr->second.entry());
777 assert(miEntry->getInstr() == mi && "Instruction indexes broken.");
778 // FIXME: Eventually we want to actually delete these indexes.
779 miEntry->setInstr(0);
780 mi2iMap.erase(mi2iItr);
784 /// ReplaceMachineInstrInMaps - Replacing a machine instr with a new one in
785 /// maps used by register allocator.
786 void replaceMachineInstrInMaps(MachineInstr *mi, MachineInstr *newMI) {
787 Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi);
788 if (mi2iItr == mi2iMap.end())
790 SlotIndex replaceBaseIndex = mi2iItr->second;
791 IndexListEntry *miEntry(&replaceBaseIndex.entry());
792 assert(miEntry->getInstr() == mi &&
793 "Mismatched instruction in index tables.");
794 miEntry->setInstr(newMI);
795 mi2iMap.erase(mi2iItr);
796 mi2iMap.insert(std::make_pair(newMI, replaceBaseIndex));
804 #endif // LLVM_CODEGEN_LIVEINDEX_H