MachineVerifier: Use report_context() instead of ad-hoc messages.

llvm-svn: 259457
This commit is contained in:
Matthias Braun 2016-02-02 02:44:25 +00:00
parent 6b9e756a71
commit 2ecc124a01

View File

@ -217,6 +217,9 @@ namespace {
LaneBitmask LaneMask) const; LaneBitmask LaneMask) const;
void report_context(const LiveRange::Segment &S) const; void report_context(const LiveRange::Segment &S) const;
void report_context(const VNInfo &VNI) const; void report_context(const VNInfo &VNI) const;
void report_context(SlotIndex Pos) const;
void report_context_liverange(const LiveRange &LR) const;
void report_context_regunit(unsigned RegUnit) const;
void verifyInlineAsm(const MachineInstr *MI); void verifyInlineAsm(const MachineInstr *MI);
@ -435,16 +438,20 @@ void MachineVerifier::report(const char *msg,
errs() << "\n"; errs() << "\n";
} }
void MachineVerifier::report_context(SlotIndex Pos) const {
errs() << "- at: " << Pos << '\n';
}
void MachineVerifier::report_context(const LiveInterval &LI) const { void MachineVerifier::report_context(const LiveInterval &LI) const {
errs() << "- interval: " << LI << '\n'; errs() << "- interval: " << LI << '\n';
} }
void MachineVerifier::report_context(const LiveRange &LR, unsigned Reg, void MachineVerifier::report_context(const LiveRange &LR, unsigned Reg,
LaneBitmask LaneMask) const { LaneBitmask LaneMask) const {
report_context_liverange(LR);
errs() << "- register: " << PrintReg(Reg, TRI) << '\n'; errs() << "- register: " << PrintReg(Reg, TRI) << '\n';
if (LaneMask != 0) if (LaneMask != 0)
errs() << "- lanemask: " << PrintLaneMask(LaneMask) << '\n'; errs() << "- lanemask: " << PrintLaneMask(LaneMask) << '\n';
errs() << "- liverange: " << LR << '\n';
} }
void MachineVerifier::report_context(const LiveRange::Segment &S) const { void MachineVerifier::report_context(const LiveRange::Segment &S) const {
@ -455,6 +462,14 @@ void MachineVerifier::report_context(const VNInfo &VNI) const {
errs() << "- ValNo: " << VNI.id << " (def " << VNI.def << ")\n"; errs() << "- ValNo: " << VNI.id << " (def " << VNI.def << ")\n";
} }
void MachineVerifier::report_context_liverange(const LiveRange &LR) const {
errs() << "- liverange: " << LR << '\n';
}
void MachineVerifier::report_context_regunit(unsigned RegUnit) const {
errs() << "- regunit: " << PrintRegUnit(RegUnit, TRI) << '\n';
}
void MachineVerifier::markReachable(const MachineBasicBlock *MBB) { void MachineVerifier::markReachable(const MachineBasicBlock *MBB) {
BBInfo &MInfo = MBBInfoMap[MBB]; BBInfo &MInfo = MBBInfoMap[MBB];
if (!MInfo.reachable) { if (!MInfo.reachable) {
@ -1057,12 +1072,15 @@ void MachineVerifier::checkLiveness(const MachineOperand *MO, unsigned MONum) {
LiveQueryResult LRQ = LR->Query(UseIdx); LiveQueryResult LRQ = LR->Query(UseIdx);
if (!LRQ.valueIn()) { if (!LRQ.valueIn()) {
report("No live segment at use", MO, MONum); report("No live segment at use", MO, MONum);
errs() << UseIdx << " is not live in " << PrintRegUnit(*Units, TRI) report_context_liverange(*LR);
<< ' ' << *LR << '\n'; report_context_regunit(*Units);
report_context(UseIdx);
} }
if (MO->isKill() && !LRQ.isKill()) { if (MO->isKill() && !LRQ.isKill()) {
report("Live range continues after kill flag", MO, MONum); report("Live range continues after kill flag", MO, MONum);
errs() << PrintRegUnit(*Units, TRI) << ' ' << *LR << '\n'; report_context_liverange(*LR);
report_context_regunit(*Units);
report_context(UseIdx);
} }
} }
} }
@ -1075,13 +1093,15 @@ void MachineVerifier::checkLiveness(const MachineOperand *MO, unsigned MONum) {
LiveQueryResult LRQ = LI.Query(UseIdx); LiveQueryResult LRQ = LI.Query(UseIdx);
if (!LRQ.valueIn()) { if (!LRQ.valueIn()) {
report("No live segment at use", MO, MONum); report("No live segment at use", MO, MONum);
errs() << UseIdx << " is not live in " << LI << '\n'; report_context(LI);
report_context(UseIdx);
} }
// Check for extra kill flags. // Check for extra kill flags.
// Note that we allow missing kill flags for now. // Note that we allow missing kill flags for now.
if (MO->isKill() && !LRQ.isKill()) { if (MO->isKill() && !LRQ.isKill()) {
report("Live range continues after kill flag", MO, MONum); report("Live range continues after kill flag", MO, MONum);
errs() << "Live range: " << LI << '\n'; report_context(LI);
report_context(UseIdx);
} }
} else { } else {
report("Virtual register has no live interval", MO, MONum); report("Virtual register has no live interval", MO, MONum);
@ -1164,19 +1184,21 @@ void MachineVerifier::checkLiveness(const MachineOperand *MO, unsigned MONum) {
assert(VNI && "NULL valno is not allowed"); assert(VNI && "NULL valno is not allowed");
if (VNI->def != DefIdx) { if (VNI->def != DefIdx) {
report("Inconsistent valno->def", MO, MONum); report("Inconsistent valno->def", MO, MONum);
errs() << "Valno " << VNI->id << " is not defined at " report_context(LI);
<< DefIdx << " in " << LI << '\n'; report_context(*VNI);
report_context(DefIdx);
} }
} else { } else {
report("No live segment at def", MO, MONum); report("No live segment at def", MO, MONum);
errs() << DefIdx << " is not live in " << LI << '\n'; report_context(LI);
report_context(DefIdx);
} }
// Check that, if the dead def flag is present, LiveInts agree. // Check that, if the dead def flag is present, LiveInts agree.
if (MO->isDead()) { if (MO->isDead()) {
LiveQueryResult LRQ = LI.Query(DefIdx); LiveQueryResult LRQ = LI.Query(DefIdx);
if (!LRQ.isDeadDef()) { if (!LRQ.isDeadDef()) {
report("Live range continues after dead def flag", MO, MONum); report("Live range continues after dead def flag", MO, MONum);
errs() << "Live range: " << LI << '\n'; report_context(LI);
} }
} }
} else { } else {