mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-14 09:38:40 +00:00
RegisterCoalescer: Turn some impossible conditions into asserts
This is a fixed version of reverted r225500. It fixes the too early if() continue; of the last patch and adds a comment to the unorthodox loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225652 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
54b53edbd9
commit
095ca8f493
@ -621,13 +621,12 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
|
|||||||
// the example above.
|
// the example above.
|
||||||
SlotIndex CopyIdx = LIS->getInstructionIndex(CopyMI).getRegSlot();
|
SlotIndex CopyIdx = LIS->getInstructionIndex(CopyMI).getRegSlot();
|
||||||
VNInfo *BValNo = IntB.getVNInfoAt(CopyIdx);
|
VNInfo *BValNo = IntB.getVNInfoAt(CopyIdx);
|
||||||
if (!BValNo || BValNo->def != CopyIdx)
|
assert(BValNo != nullptr && BValNo->def == CopyIdx);
|
||||||
return false;
|
|
||||||
|
|
||||||
// AValNo is the value number in A that defines the copy, A3 in the example.
|
// AValNo is the value number in A that defines the copy, A3 in the example.
|
||||||
VNInfo *AValNo = IntA.getVNInfoAt(CopyIdx.getRegSlot(true));
|
VNInfo *AValNo = IntA.getVNInfoAt(CopyIdx.getRegSlot(true));
|
||||||
assert(AValNo && "COPY source not live");
|
assert(AValNo && !AValNo->isUnused() && "COPY source not live");
|
||||||
if (AValNo->isPHIDef() || AValNo->isUnused())
|
if (AValNo->isPHIDef())
|
||||||
return false;
|
return false;
|
||||||
MachineInstr *DefMI = LIS->getInstructionFromIndex(AValNo->def);
|
MachineInstr *DefMI = LIS->getInstructionFromIndex(AValNo->def);
|
||||||
if (!DefMI)
|
if (!DefMI)
|
||||||
@ -707,10 +706,12 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
|
|||||||
// Update uses of IntA of the specific Val# with IntB.
|
// Update uses of IntA of the specific Val# with IntB.
|
||||||
for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(IntA.reg),
|
for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(IntA.reg),
|
||||||
UE = MRI->use_end();
|
UE = MRI->use_end();
|
||||||
UI != UE;) {
|
UI != UE; /* ++UI is below because of possible MI removal */) {
|
||||||
MachineOperand &UseMO = *UI;
|
MachineOperand &UseMO = *UI;
|
||||||
MachineInstr *UseMI = UseMO.getParent();
|
|
||||||
++UI;
|
++UI;
|
||||||
|
if (UseMO.isUndef())
|
||||||
|
continue;
|
||||||
|
MachineInstr *UseMI = UseMO.getParent();
|
||||||
if (UseMI->isDebugValue()) {
|
if (UseMI->isDebugValue()) {
|
||||||
// FIXME These don't have an instruction index. Not clear we have enough
|
// FIXME These don't have an instruction index. Not clear we have enough
|
||||||
// info to decide whether to do this replacement or not. For now do it.
|
// info to decide whether to do this replacement or not. For now do it.
|
||||||
@ -719,7 +720,8 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
|
|||||||
}
|
}
|
||||||
SlotIndex UseIdx = LIS->getInstructionIndex(UseMI).getRegSlot(true);
|
SlotIndex UseIdx = LIS->getInstructionIndex(UseMI).getRegSlot(true);
|
||||||
LiveInterval::iterator US = IntA.FindSegmentContaining(UseIdx);
|
LiveInterval::iterator US = IntA.FindSegmentContaining(UseIdx);
|
||||||
if (US == IntA.end() || US->valno != AValNo)
|
assert(US != IntA.end() && "Use must be live");
|
||||||
|
if (US->valno != AValNo)
|
||||||
continue;
|
continue;
|
||||||
// Kill flags are no longer accurate. They are recomputed after RA.
|
// Kill flags are no longer accurate. They are recomputed after RA.
|
||||||
UseMO.setIsKill(false);
|
UseMO.setIsKill(false);
|
||||||
@ -770,11 +772,7 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
|
|||||||
SlotIndex AIdx = CopyIdx.getRegSlot(true);
|
SlotIndex AIdx = CopyIdx.getRegSlot(true);
|
||||||
for (LiveInterval::SubRange &SA : IntA.subranges()) {
|
for (LiveInterval::SubRange &SA : IntA.subranges()) {
|
||||||
VNInfo *ASubValNo = SA.getVNInfoAt(AIdx);
|
VNInfo *ASubValNo = SA.getVNInfoAt(AIdx);
|
||||||
if (ASubValNo == nullptr) {
|
assert(ASubValNo != nullptr);
|
||||||
DEBUG(dbgs() << "No A Range at " << AIdx << " with mask "
|
|
||||||
<< format("%04X", SA.LaneMask) << "\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned AMask = SA.LaneMask;
|
unsigned AMask = SA.LaneMask;
|
||||||
for (LiveInterval::SubRange &SB : IntB.subranges()) {
|
for (LiveInterval::SubRange &SB : IntB.subranges()) {
|
||||||
@ -826,11 +824,7 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
|
|||||||
SlotIndex AIdx = CopyIdx.getRegSlot(true);
|
SlotIndex AIdx = CopyIdx.getRegSlot(true);
|
||||||
for (LiveInterval::SubRange &SA : IntA.subranges()) {
|
for (LiveInterval::SubRange &SA : IntA.subranges()) {
|
||||||
VNInfo *ASubValNo = SA.getVNInfoAt(AIdx);
|
VNInfo *ASubValNo = SA.getVNInfoAt(AIdx);
|
||||||
if (ASubValNo == nullptr) {
|
assert(ASubValNo != nullptr);
|
||||||
DEBUG(dbgs() << "No A Range at " << AIdx << " with mask "
|
|
||||||
<< format("%04X", SA.LaneMask) << "\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SA.removeValNo(ASubValNo);
|
SA.removeValNo(ASubValNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user