mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-28 07:17:32 +00:00
Changed slot index ranges for MachineBasicBlocks to be exclusive of endpoint.
This fixes an in-place update bug where code inserted at the end of basic blocks may not be covered by existing intervals which were live across the entire block. It is also consistent with the way ranges are specified for live intervals. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91859 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -579,7 +579,7 @@ namespace llvm {
|
|||||||
(I == idx2MBBMap.end() && idx2MBBMap.size()>0)) ? (I-1): I;
|
(I == idx2MBBMap.end() && idx2MBBMap.size()>0)) ? (I-1): I;
|
||||||
|
|
||||||
assert(J != idx2MBBMap.end() && J->first <= index &&
|
assert(J != idx2MBBMap.end() && J->first <= index &&
|
||||||
index <= getMBBEndIdx(J->second) &&
|
index < getMBBEndIdx(J->second) &&
|
||||||
"index does not correspond to an MBB");
|
"index does not correspond to an MBB");
|
||||||
return J->second;
|
return J->second;
|
||||||
}
|
}
|
||||||
|
@@ -95,7 +95,7 @@ bool CalculateSpillWeights::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
SlotIndex defIdx = lis->getInstructionIndex(mi).getDefIndex();
|
SlotIndex defIdx = lis->getInstructionIndex(mi).getDefIndex();
|
||||||
const LiveRange *dlr =
|
const LiveRange *dlr =
|
||||||
lis->getInterval(reg).getLiveRangeContaining(defIdx);
|
lis->getInterval(reg).getLiveRangeContaining(defIdx);
|
||||||
if (dlr->end > mbbEnd)
|
if (dlr->end >= mbbEnd)
|
||||||
weight *= 3.0F;
|
weight *= 3.0F;
|
||||||
}
|
}
|
||||||
regInt.weight += weight;
|
regInt.weight += weight;
|
||||||
|
@@ -324,8 +324,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
|
|||||||
// of the defining block, potentially live across some blocks, then is
|
// of the defining block, potentially live across some blocks, then is
|
||||||
// live into some number of blocks, but gets killed. Start by adding a
|
// live into some number of blocks, but gets killed. Start by adding a
|
||||||
// range that goes from this definition to the end of the defining block.
|
// range that goes from this definition to the end of the defining block.
|
||||||
LiveRange NewLR(defIndex, getMBBEndIdx(mbb).getNextIndex().getLoadIndex(),
|
LiveRange NewLR(defIndex, getMBBEndIdx(mbb), ValNo);
|
||||||
ValNo);
|
|
||||||
DEBUG(errs() << " +" << NewLR);
|
DEBUG(errs() << " +" << NewLR);
|
||||||
interval.addRange(NewLR);
|
interval.addRange(NewLR);
|
||||||
|
|
||||||
@@ -334,10 +333,8 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
|
|||||||
// live interval.
|
// live interval.
|
||||||
for (SparseBitVector<>::iterator I = vi.AliveBlocks.begin(),
|
for (SparseBitVector<>::iterator I = vi.AliveBlocks.begin(),
|
||||||
E = vi.AliveBlocks.end(); I != E; ++I) {
|
E = vi.AliveBlocks.end(); I != E; ++I) {
|
||||||
LiveRange LR(
|
MachineBasicBlock *aliveBlock = mf_->getBlockNumbered(*I);
|
||||||
getMBBStartIdx(mf_->getBlockNumbered(*I)),
|
LiveRange LR(getMBBStartIdx(aliveBlock), getMBBEndIdx(aliveBlock), ValNo);
|
||||||
getMBBEndIdx(mf_->getBlockNumbered(*I)).getNextIndex().getLoadIndex(),
|
|
||||||
ValNo);
|
|
||||||
interval.addRange(LR);
|
interval.addRange(LR);
|
||||||
DEBUG(errs() << " +" << LR);
|
DEBUG(errs() << " +" << LR);
|
||||||
}
|
}
|
||||||
@@ -467,7 +464,7 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
|
|||||||
CopyMI = mi;
|
CopyMI = mi;
|
||||||
ValNo = interval.getNextValue(defIndex, CopyMI, true, VNInfoAllocator);
|
ValNo = interval.getNextValue(defIndex, CopyMI, true, VNInfoAllocator);
|
||||||
|
|
||||||
SlotIndex killIndex = getMBBEndIdx(mbb).getNextIndex().getLoadIndex();
|
SlotIndex killIndex = getMBBEndIdx(mbb);
|
||||||
LiveRange LR(defIndex, killIndex, ValNo);
|
LiveRange LR(defIndex, killIndex, ValNo);
|
||||||
interval.addRange(LR);
|
interval.addRange(LR);
|
||||||
ValNo->addKill(indexes_->getTerminatorGap(mbb));
|
ValNo->addKill(indexes_->getTerminatorGap(mbb));
|
||||||
@@ -1247,7 +1244,7 @@ bool LiveIntervals::anyKillInMBBAfterIdx(const LiveInterval &li,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
SlotIndex KillIdx = VNI->kills[j];
|
SlotIndex KillIdx = VNI->kills[j];
|
||||||
if (KillIdx > Idx && KillIdx < End)
|
if (KillIdx > Idx && KillIdx <= End)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -2085,7 +2082,7 @@ LiveRange LiveIntervals::addLiveRangeToEndOfBlock(unsigned reg,
|
|||||||
VN->kills.push_back(indexes_->getTerminatorGap(startInst->getParent()));
|
VN->kills.push_back(indexes_->getTerminatorGap(startInst->getParent()));
|
||||||
LiveRange LR(
|
LiveRange LR(
|
||||||
SlotIndex(getInstructionIndex(startInst).getDefIndex()),
|
SlotIndex(getInstructionIndex(startInst).getDefIndex()),
|
||||||
getMBBEndIdx(startInst->getParent()).getNextIndex().getBaseIndex(), VN);
|
getMBBEndIdx(startInst->getParent()), VN);
|
||||||
Interval.addRange(LR);
|
Interval.addRange(LR);
|
||||||
|
|
||||||
return LR;
|
return LR;
|
||||||
|
@@ -378,7 +378,7 @@ PreAllocSplitting::UpdateSpillSlotInterval(VNInfo *ValNo, SlotIndex SpillIndex,
|
|||||||
|
|
||||||
SmallPtrSet<MachineBasicBlock*, 4> Processed;
|
SmallPtrSet<MachineBasicBlock*, 4> Processed;
|
||||||
SlotIndex EndIdx = LIs->getMBBEndIdx(MBB);
|
SlotIndex EndIdx = LIs->getMBBEndIdx(MBB);
|
||||||
LiveRange SLR(SpillIndex, EndIdx.getNextSlot(), CurrSValNo);
|
LiveRange SLR(SpillIndex, EndIdx, CurrSValNo);
|
||||||
CurrSLI->addRange(SLR);
|
CurrSLI->addRange(SLR);
|
||||||
Processed.insert(MBB);
|
Processed.insert(MBB);
|
||||||
|
|
||||||
@@ -475,7 +475,7 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
|
|||||||
SlotIndex EndIndex = LIs->getMBBEndIdx(MBB);
|
SlotIndex EndIndex = LIs->getMBBEndIdx(MBB);
|
||||||
|
|
||||||
RetVNI = NewVNs[Walker];
|
RetVNI = NewVNs[Walker];
|
||||||
LI->addRange(LiveRange(DefIndex, EndIndex.getNextSlot(), RetVNI));
|
LI->addRange(LiveRange(DefIndex, EndIndex, RetVNI));
|
||||||
} else if (!ContainsDefs && ContainsUses) {
|
} else if (!ContainsDefs && ContainsUses) {
|
||||||
SmallPtrSet<MachineInstr*, 2>& BlockUses = Uses[MBB];
|
SmallPtrSet<MachineInstr*, 2>& BlockUses = Uses[MBB];
|
||||||
|
|
||||||
@@ -511,8 +511,7 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
|
|||||||
UseIndex = UseIndex.getUseIndex();
|
UseIndex = UseIndex.getUseIndex();
|
||||||
SlotIndex EndIndex;
|
SlotIndex EndIndex;
|
||||||
if (IsIntraBlock) {
|
if (IsIntraBlock) {
|
||||||
EndIndex = LIs->getInstructionIndex(UseI);
|
EndIndex = LIs->getInstructionIndex(UseI).getDefIndex();
|
||||||
EndIndex = EndIndex.getUseIndex();
|
|
||||||
} else
|
} else
|
||||||
EndIndex = LIs->getMBBEndIdx(MBB);
|
EndIndex = LIs->getMBBEndIdx(MBB);
|
||||||
|
|
||||||
@@ -521,7 +520,7 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
|
|||||||
RetVNI = PerformPHIConstruction(Walker, MBB, LI, Visited, Defs, Uses,
|
RetVNI = PerformPHIConstruction(Walker, MBB, LI, Visited, Defs, Uses,
|
||||||
NewVNs, LiveOut, Phis, false, true);
|
NewVNs, LiveOut, Phis, false, true);
|
||||||
|
|
||||||
LI->addRange(LiveRange(UseIndex, EndIndex.getNextSlot(), RetVNI));
|
LI->addRange(LiveRange(UseIndex, EndIndex, RetVNI));
|
||||||
|
|
||||||
// FIXME: Need to set kills properly for inter-block stuff.
|
// FIXME: Need to set kills properly for inter-block stuff.
|
||||||
if (RetVNI->isKill(UseIndex)) RetVNI->removeKill(UseIndex);
|
if (RetVNI->isKill(UseIndex)) RetVNI->removeKill(UseIndex);
|
||||||
@@ -571,8 +570,7 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
|
|||||||
StartIndex = foundDef ? StartIndex.getDefIndex() : StartIndex.getUseIndex();
|
StartIndex = foundDef ? StartIndex.getDefIndex() : StartIndex.getUseIndex();
|
||||||
SlotIndex EndIndex;
|
SlotIndex EndIndex;
|
||||||
if (IsIntraBlock) {
|
if (IsIntraBlock) {
|
||||||
EndIndex = LIs->getInstructionIndex(UseI);
|
EndIndex = LIs->getInstructionIndex(UseI).getDefIndex();
|
||||||
EndIndex = EndIndex.getUseIndex();
|
|
||||||
} else
|
} else
|
||||||
EndIndex = LIs->getMBBEndIdx(MBB);
|
EndIndex = LIs->getMBBEndIdx(MBB);
|
||||||
|
|
||||||
@@ -582,7 +580,7 @@ PreAllocSplitting::PerformPHIConstruction(MachineBasicBlock::iterator UseI,
|
|||||||
RetVNI = PerformPHIConstruction(Walker, MBB, LI, Visited, Defs, Uses,
|
RetVNI = PerformPHIConstruction(Walker, MBB, LI, Visited, Defs, Uses,
|
||||||
NewVNs, LiveOut, Phis, false, true);
|
NewVNs, LiveOut, Phis, false, true);
|
||||||
|
|
||||||
LI->addRange(LiveRange(StartIndex, EndIndex.getNextSlot(), RetVNI));
|
LI->addRange(LiveRange(StartIndex, EndIndex, RetVNI));
|
||||||
|
|
||||||
if (foundUse && RetVNI->isKill(StartIndex))
|
if (foundUse && RetVNI->isKill(StartIndex))
|
||||||
RetVNI->removeKill(StartIndex);
|
RetVNI->removeKill(StartIndex);
|
||||||
@@ -663,7 +661,7 @@ PreAllocSplitting::PerformPHIConstructionFallBack(MachineBasicBlock::iterator Us
|
|||||||
for (DenseMap<MachineBasicBlock*, VNInfo*>::iterator I =
|
for (DenseMap<MachineBasicBlock*, VNInfo*>::iterator I =
|
||||||
IncomingVNs.begin(), E = IncomingVNs.end(); I != E; ++I) {
|
IncomingVNs.begin(), E = IncomingVNs.end(); I != E; ++I) {
|
||||||
I->second->setHasPHIKill(true);
|
I->second->setHasPHIKill(true);
|
||||||
SlotIndex KillIndex = LIs->getMBBEndIdx(I->first);
|
SlotIndex KillIndex(LIs->getMBBEndIdx(I->first), true);
|
||||||
if (!I->second->isKill(KillIndex))
|
if (!I->second->isKill(KillIndex))
|
||||||
I->second->addKill(KillIndex);
|
I->second->addKill(KillIndex);
|
||||||
}
|
}
|
||||||
@@ -671,11 +669,10 @@ PreAllocSplitting::PerformPHIConstructionFallBack(MachineBasicBlock::iterator Us
|
|||||||
|
|
||||||
SlotIndex EndIndex;
|
SlotIndex EndIndex;
|
||||||
if (IsIntraBlock) {
|
if (IsIntraBlock) {
|
||||||
EndIndex = LIs->getInstructionIndex(UseI);
|
EndIndex = LIs->getInstructionIndex(UseI).getDefIndex();
|
||||||
EndIndex = EndIndex.getUseIndex();
|
|
||||||
} else
|
} else
|
||||||
EndIndex = LIs->getMBBEndIdx(MBB);
|
EndIndex = LIs->getMBBEndIdx(MBB);
|
||||||
LI->addRange(LiveRange(StartIndex, EndIndex.getNextSlot(), RetVNI));
|
LI->addRange(LiveRange(StartIndex, EndIndex, RetVNI));
|
||||||
if (IsIntraBlock)
|
if (IsIntraBlock)
|
||||||
RetVNI->addKill(EndIndex);
|
RetVNI->addKill(EndIndex);
|
||||||
|
|
||||||
|
@@ -1065,7 +1065,7 @@ SimpleRegisterCoalescing::isWinToJoinVRWithSrcPhysReg(MachineInstr *CopyMI,
|
|||||||
if (SuccMBB == CopyMBB)
|
if (SuccMBB == CopyMBB)
|
||||||
continue;
|
continue;
|
||||||
if (DstInt.overlaps(li_->getMBBStartIdx(SuccMBB),
|
if (DstInt.overlaps(li_->getMBBStartIdx(SuccMBB),
|
||||||
li_->getMBBEndIdx(SuccMBB).getNextIndex().getBaseIndex()))
|
li_->getMBBEndIdx(SuccMBB)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1121,7 +1121,7 @@ SimpleRegisterCoalescing::isWinToJoinVRWithDstPhysReg(MachineInstr *CopyMI,
|
|||||||
if (PredMBB == SMBB)
|
if (PredMBB == SMBB)
|
||||||
continue;
|
continue;
|
||||||
if (SrcInt.overlaps(li_->getMBBStartIdx(PredMBB),
|
if (SrcInt.overlaps(li_->getMBBStartIdx(PredMBB),
|
||||||
li_->getMBBEndIdx(PredMBB).getNextIndex().getBaseIndex()))
|
li_->getMBBEndIdx(PredMBB)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -92,13 +92,14 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
functionSize = 0;
|
functionSize = 0;
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
|
|
||||||
|
push_back(createEntry(0, index));
|
||||||
|
|
||||||
// Iterate over the the function.
|
// Iterate over the the function.
|
||||||
for (MachineFunction::iterator mbbItr = mf->begin(), mbbEnd = mf->end();
|
for (MachineFunction::iterator mbbItr = mf->begin(), mbbEnd = mf->end();
|
||||||
mbbItr != mbbEnd; ++mbbItr) {
|
mbbItr != mbbEnd; ++mbbItr) {
|
||||||
MachineBasicBlock *mbb = &*mbbItr;
|
MachineBasicBlock *mbb = &*mbbItr;
|
||||||
|
|
||||||
// Insert an index for the MBB start.
|
// Insert an index for the MBB start.
|
||||||
push_back(createEntry(0, index));
|
|
||||||
SlotIndex blockStartIndex(back(), SlotIndex::LOAD);
|
SlotIndex blockStartIndex(back(), SlotIndex::LOAD);
|
||||||
|
|
||||||
index += SlotIndex::NUM;
|
index += SlotIndex::NUM;
|
||||||
@@ -137,16 +138,16 @@ bool SlotIndexes::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
index += SlotIndex::NUM;
|
index += SlotIndex::NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotIndex blockEndIndex(back(), SlotIndex::STORE);
|
// One blank instruction at the end.
|
||||||
|
push_back(createEntry(0, index));
|
||||||
|
|
||||||
|
SlotIndex blockEndIndex(back(), SlotIndex::LOAD);
|
||||||
mbb2IdxMap.insert(
|
mbb2IdxMap.insert(
|
||||||
std::make_pair(mbb, std::make_pair(blockStartIndex, blockEndIndex)));
|
std::make_pair(mbb, std::make_pair(blockStartIndex, blockEndIndex)));
|
||||||
|
|
||||||
idx2MBBMap.push_back(IdxMBBPair(blockStartIndex, mbb));
|
idx2MBBMap.push_back(IdxMBBPair(blockStartIndex, mbb));
|
||||||
}
|
}
|
||||||
|
|
||||||
// One blank instruction at the end.
|
|
||||||
push_back(createEntry(0, index));
|
|
||||||
|
|
||||||
// Sort the Idx2MBBMap
|
// Sort the Idx2MBBMap
|
||||||
std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
|
std::sort(idx2MBBMap.begin(), idx2MBBMap.end(), Idx2MBBCompare());
|
||||||
|
|
||||||
|
@@ -486,10 +486,10 @@ private:
|
|||||||
SlotIndex newKillRangeEnd = oldKillRange->end;
|
SlotIndex newKillRangeEnd = oldKillRange->end;
|
||||||
oldKillRange->end = copyIdx.getDefIndex();
|
oldKillRange->end = copyIdx.getDefIndex();
|
||||||
|
|
||||||
if (newKillRangeEnd != lis->getMBBEndIdx(killMBB).getNextSlot()) {
|
if (newKillRangeEnd != lis->getMBBEndIdx(killMBB)) {
|
||||||
assert(newKillRangeEnd > lis->getMBBEndIdx(killMBB).getNextSlot() &&
|
assert(newKillRangeEnd > lis->getMBBEndIdx(killMBB) &&
|
||||||
"PHI kill range doesn't reach kill-block end. Not sane.");
|
"PHI kill range doesn't reach kill-block end. Not sane.");
|
||||||
newLI->addRange(LiveRange(lis->getMBBEndIdx(killMBB).getNextSlot(),
|
newLI->addRange(LiveRange(lis->getMBBEndIdx(killMBB),
|
||||||
newKillRangeEnd, newVNI));
|
newKillRangeEnd, newVNI));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,7 +500,7 @@ private:
|
|||||||
newKillVNI->addKill(lis->getMBBTerminatorGap(killMBB));
|
newKillVNI->addKill(lis->getMBBTerminatorGap(killMBB));
|
||||||
newKillVNI->setHasPHIKill(true);
|
newKillVNI->setHasPHIKill(true);
|
||||||
li->addRange(LiveRange(copyIdx.getDefIndex(),
|
li->addRange(LiveRange(copyIdx.getDefIndex(),
|
||||||
lis->getMBBEndIdx(killMBB).getNextSlot(),
|
lis->getMBBEndIdx(killMBB),
|
||||||
newKillVNI));
|
newKillVNI));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user