Extract some methods from verifyLiveIntervals.

No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161149 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2012-08-02 00:20:20 +00:00
parent a62e1e8bc6
commit e5c79a5c25

View File

@ -212,6 +212,10 @@ namespace {
void calcRegsRequired();
void verifyLiveVariables();
void verifyLiveIntervals();
void verifyLiveInterval(const LiveInterval&);
void verifyLiveIntervalValue(const LiveInterval&, VNInfo*);
void verifyLiveIntervalSegment(const LiveInterval&,
LiveInterval::const_iterator);
};
struct MachineVerifierPass : public MachineFunctionPass {
@ -1138,28 +1142,28 @@ void MachineVerifier::verifyLiveIntervals() {
const LiveInterval &LI = LiveInts->getInterval(Reg);
assert(Reg == LI.reg && "Invalid reg to interval mapping");
verifyLiveInterval(LI);
}
}
void MachineVerifier::verifyLiveIntervalValue(const LiveInterval &LI,
VNInfo *VNI) {
if (VNI->isUnused())
return;
for (LiveInterval::const_vni_iterator I = LI.vni_begin(), E = LI.vni_end();
I!=E; ++I) {
VNInfo *VNI = *I;
const VNInfo *DefVNI = LI.getVNInfoAt(VNI->def);
if (!DefVNI) {
if (!VNI->isUnused()) {
report("Valno not live at def and not marked unused", MF);
*OS << "Valno #" << VNI->id << " in " << LI << '\n';
return;
}
continue;
}
if (VNI->isUnused())
continue;
if (DefVNI != VNI) {
report("Live range at def has different valno", MF);
*OS << "Valno #" << VNI->id << " is defined at " << VNI->def
<< " where valno #" << DefVNI->id << " is live in " << LI << '\n';
continue;
return;
}
const MachineBasicBlock *MBB = LiveInts->getMBBFromIndex(VNI->def);
@ -1167,7 +1171,7 @@ void MachineVerifier::verifyLiveIntervals() {
report("Invalid definition index", MF);
*OS << "Valno #" << VNI->id << " is defined at " << VNI->def
<< " in " << LI << '\n';
continue;
return;
}
if (VNI->isPHIDef()) {
@ -1177,14 +1181,16 @@ void MachineVerifier::verifyLiveIntervals() {
<< ", not at the beginning of BB#" << MBB->getNumber()
<< " in " << LI << '\n';
}
} else {
return;
}
// Non-PHI def.
const MachineInstr *MI = LiveInts->getInstructionFromIndex(VNI->def);
if (!MI) {
report("No instruction at def index", MF);
*OS << "Valno #" << VNI->id << " is defined at " << VNI->def
<< " in " << LI << '\n';
continue;
return;
}
bool hasDef = false;
@ -1224,10 +1230,11 @@ void MachineVerifier::verifyLiveIntervals() {
*OS << "Valno #" << VNI->id << " is defined at " << VNI->def
<< " in " << LI << '\n';
}
}
}
}
for (LiveInterval::const_iterator I = LI.begin(), E = LI.end(); I!=E; ++I) {
void
MachineVerifier::verifyLiveIntervalSegment(const LiveInterval &LI,
LiveInterval::const_iterator I) {
const VNInfo *VNI = I->valno;
assert(VNI && "Live range has no valno");
@ -1248,14 +1255,14 @@ void MachineVerifier::verifyLiveIntervals() {
report("Bad start of live segment, no basic block", MF);
I->print(*OS);
*OS << " in " << LI << '\n';
continue;
return;
}
SlotIndex MBBStartIdx = LiveInts->getMBBStartIdx(MBB);
if (I->start != MBBStartIdx && I->start != VNI->def) {
report("Live segment must begin at MBB entry or valno def", MBB);
I->print(*OS);
*OS << " in " << LI << '\n' << "Basic block starts at "
<< MBBStartIdx << '\n';
*OS << " in " << LI << '\n'
<< "Basic block starts at " << MBBStartIdx << '\n';
}
const MachineBasicBlock *EndMBB =
@ -1264,12 +1271,12 @@ void MachineVerifier::verifyLiveIntervals() {
report("Bad end of live segment, no basic block", MF);
I->print(*OS);
*OS << " in " << LI << '\n';
continue;
return;
}
// No more checks for live-out segments.
if (I->end == LiveInts->getMBBEndIdx(EndMBB))
continue;
return;
// The live segment is ending inside EndMBB
const MachineInstr *MI =
@ -1277,9 +1284,9 @@ void MachineVerifier::verifyLiveIntervals() {
if (!MI) {
report("Live segment doesn't end at a valid instruction", EndMBB);
I->print(*OS);
*OS << " in " << LI << '\n' << "Basic block starts at "
<< MBBStartIdx << '\n';
continue;
*OS << " in " << LI << '\n'
<< "Basic block starts at " << MBBStartIdx << '\n';
return;
}
// The block slot must refer to a basic block boundary.
@ -1302,7 +1309,7 @@ void MachineVerifier::verifyLiveIntervals() {
// A live segment can only end at an early-clobber slot if it is being
// redefined by an early-clobber def.
if (I->end.isEarlyClobber()) {
if (I+1 == E || (I+1)->start != I->end) {
if (I+1 == LI.end() || (I+1)->start != I->end) {
report("Live segment ending at early clobber slot must be "
"redefined by an EC def in the same instruction", MI);
I->print(*OS);
@ -1348,7 +1355,7 @@ void MachineVerifier::verifyLiveIntervals() {
if (I->start == VNI->def && !VNI->isPHIDef()) {
// Not live-in to any blocks.
if (MBB == EndMBB)
continue;
return;
// Skip this block.
++MFI;
}
@ -1389,14 +1396,22 @@ void MachineVerifier::verifyLiveIntervals() {
<< (*PI)->getNumber() << '@' << PEnd
<< "\nValno #" << VNI->id << " live into BB#" << MFI->getNumber()
<< '@' << LiveInts->getMBBStartIdx(MFI) << " in "
<< PrintReg(Reg) << ": " << LI << '\n';
<< PrintReg(LI.reg) << ": " << LI << '\n';
}
}
if (&*MFI == EndMBB)
break;
++MFI;
}
}
}
void MachineVerifier::verifyLiveInterval(const LiveInterval &LI) {
for (LiveInterval::const_vni_iterator I = LI.vni_begin(), E = LI.vni_end();
I!=E; ++I)
verifyLiveIntervalValue(LI, *I);
for (LiveInterval::const_iterator I = LI.begin(), E = LI.end(); I!=E; ++I)
verifyLiveIntervalSegment(LI, I);
// Check the LI only has one connected component.
if (TargetRegisterInfo::isVirtualRegister(LI.reg)) {
@ -1415,5 +1430,4 @@ void MachineVerifier::verifyLiveIntervals() {
}
}
}
}
}