mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-08 06:32:24 +00:00
Add SlotIndexes::repairIndexesInRange(), which repairs SlotIndexes after adding
and removing instructions. The implementation seems more complicated than it needs to be, but I couldn't find something simpler that dealt with all of the corner cases. Also add a call to repairIndexesInRange() from repairIntervalsInRange(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175601 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5954fc6050
commit
349cf34998
@ -360,6 +360,11 @@ namespace llvm {
|
|||||||
/// Renumber the index list, providing space for new instructions.
|
/// Renumber the index list, providing space for new instructions.
|
||||||
void renumberIndexes();
|
void renumberIndexes();
|
||||||
|
|
||||||
|
/// Repair indexes after adding and removing instructions.
|
||||||
|
void repairIndexesInRange(MachineBasicBlock *MBB,
|
||||||
|
MachineBasicBlock::iterator Begin,
|
||||||
|
MachineBasicBlock::iterator End);
|
||||||
|
|
||||||
/// Returns the zero index for this analysis.
|
/// Returns the zero index for this analysis.
|
||||||
SlotIndex getZeroIndex() {
|
SlotIndex getZeroIndex() {
|
||||||
assert(indexList.front().getIndex() == 0 && "First index is not 0?");
|
assert(indexList.front().getIndex() == 0 && "First index is not 0?");
|
||||||
|
@ -1044,6 +1044,8 @@ LiveIntervals::repairIntervalsInRange(MachineBasicBlock *MBB,
|
|||||||
else
|
else
|
||||||
startIdx = getInstructionIndex(prior(Begin)).getRegSlot();
|
startIdx = getInstructionIndex(prior(Begin)).getRegSlot();
|
||||||
|
|
||||||
|
Indexes->repairIndexesInRange(MBB, Begin, End);
|
||||||
|
|
||||||
for (unsigned i = 0, e = OrigRegs.size(); i != e; ++i) {
|
for (unsigned i = 0, e = OrigRegs.size(); i != e; ++i) {
|
||||||
unsigned Reg = OrigRegs[i];
|
unsigned Reg = OrigRegs[i];
|
||||||
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
if (!TargetRegisterInfo::isVirtualRegister(Reg))
|
||||||
|
@ -142,6 +142,67 @@ void SlotIndexes::renumberIndexes(IndexList::iterator curItr) {
|
|||||||
++NumLocalRenum;
|
++NumLocalRenum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Repair indexes after adding and removing instructions.
|
||||||
|
void SlotIndexes::repairIndexesInRange(MachineBasicBlock *MBB,
|
||||||
|
MachineBasicBlock::iterator Begin,
|
||||||
|
MachineBasicBlock::iterator End) {
|
||||||
|
bool includeStart = (Begin == MBB->begin());
|
||||||
|
SlotIndex startIdx;
|
||||||
|
if (includeStart)
|
||||||
|
startIdx = getMBBStartIdx(MBB);
|
||||||
|
else
|
||||||
|
startIdx = getInstructionIndex(Begin);
|
||||||
|
|
||||||
|
SlotIndex endIdx;
|
||||||
|
if (End == MBB->end())
|
||||||
|
endIdx = getMBBEndIdx(MBB);
|
||||||
|
else
|
||||||
|
endIdx = getInstructionIndex(End);
|
||||||
|
|
||||||
|
// FIXME: Conceptually, this code is implementing an iterator on MBB that
|
||||||
|
// optionally includes an additional position prior to MBB->begin(), indicated
|
||||||
|
// by the includeStart flag. This is done so that we can iterate MIs in a MBB
|
||||||
|
// in parallel with SlotIndexes, but there should be a better way to do this.
|
||||||
|
IndexList::iterator ListB = startIdx.listEntry();
|
||||||
|
IndexList::iterator ListI = endIdx.listEntry();
|
||||||
|
MachineBasicBlock::iterator MBBI = End;
|
||||||
|
bool pastStart = false;
|
||||||
|
while (ListI != ListB || MBBI != Begin || (includeStart && !pastStart)) {
|
||||||
|
assert(ListI->getIndex() >= startIdx.getIndex() &&
|
||||||
|
(includeStart || !pastStart) &&
|
||||||
|
"Decremented past the beginning of region to repair.");
|
||||||
|
|
||||||
|
MachineInstr *SlotMI = ListI->getInstr();
|
||||||
|
MachineInstr *MI = (MBBI != MBB->end() && !pastStart) ? MBBI : 0;
|
||||||
|
bool MBBIAtBegin = MBBI == Begin && (!includeStart || pastStart);
|
||||||
|
|
||||||
|
if (SlotMI == MI && !MBBIAtBegin) {
|
||||||
|
--ListI;
|
||||||
|
if (MBBI != Begin)
|
||||||
|
--MBBI;
|
||||||
|
else
|
||||||
|
pastStart = true;
|
||||||
|
} else if (MI && mi2iMap.find(MI) == mi2iMap.end()) {
|
||||||
|
if (MBBI != Begin)
|
||||||
|
--MBBI;
|
||||||
|
else
|
||||||
|
pastStart = true;
|
||||||
|
} else {
|
||||||
|
--ListI;
|
||||||
|
if (SlotMI)
|
||||||
|
removeMachineInstrFromMaps(SlotMI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// In theory this could be combined with the previous loop, but it is tricky
|
||||||
|
// to update the IndexList while we are iterating it.
|
||||||
|
for (MachineBasicBlock::iterator I = End; I != Begin;) {
|
||||||
|
--I;
|
||||||
|
MachineInstr *MI = I;
|
||||||
|
if (mi2iMap.find(MI) == mi2iMap.end())
|
||||||
|
insertMachineInstrInMaps(MI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
|
||||||
void SlotIndexes::dump() const {
|
void SlotIndexes::dump() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user