mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Add an MRI::verifyUseLists() function.
This checks the sanity of the register use lists in the MI intermediate representation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179895 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -157,6 +157,12 @@ public:
|
|||||||
// Strictly for use by MachineInstr.cpp.
|
// Strictly for use by MachineInstr.cpp.
|
||||||
void moveOperands(MachineOperand *Dst, MachineOperand *Src, unsigned NumOps);
|
void moveOperands(MachineOperand *Dst, MachineOperand *Src, unsigned NumOps);
|
||||||
|
|
||||||
|
/// Verify the sanity of the use list for Reg.
|
||||||
|
void verifyUseList(unsigned Reg) const;
|
||||||
|
|
||||||
|
/// Verify the use list of all registers.
|
||||||
|
void verifyUseLists() const;
|
||||||
|
|
||||||
/// reg_begin/reg_end - Provide iteration support to walk over all definitions
|
/// reg_begin/reg_end - Provide iteration support to walk over all definitions
|
||||||
/// and uses of a register within the MachineFunction that corresponds to this
|
/// and uses of a register within the MachineFunction that corresponds to this
|
||||||
/// MachineRegisterInfo object.
|
/// MachineRegisterInfo object.
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
#include "llvm/Target/TargetInstrInfo.h"
|
#include "llvm/Target/TargetInstrInfo.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
|
#include "llvm/Support/raw_os_ostream.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MachineRegisterInfo::MachineRegisterInfo(const TargetRegisterInfo &TRI)
|
MachineRegisterInfo::MachineRegisterInfo(const TargetRegisterInfo &TRI)
|
||||||
@ -106,13 +108,59 @@ MachineRegisterInfo::createVirtualRegister(const TargetRegisterClass *RegClass){
|
|||||||
/// clearVirtRegs - Remove all virtual registers (after physreg assignment).
|
/// clearVirtRegs - Remove all virtual registers (after physreg assignment).
|
||||||
void MachineRegisterInfo::clearVirtRegs() {
|
void MachineRegisterInfo::clearVirtRegs() {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
for (unsigned i = 0, e = getNumVirtRegs(); i != e; ++i)
|
for (unsigned i = 0, e = getNumVirtRegs(); i != e; ++i) {
|
||||||
assert(VRegInfo[TargetRegisterInfo::index2VirtReg(i)].second == 0 &&
|
unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
|
||||||
"Vreg use list non-empty still?");
|
if (!VRegInfo[Reg].second)
|
||||||
|
continue;
|
||||||
|
verifyUseList(Reg);
|
||||||
|
llvm_unreachable("Remaining virtual register operands");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
VRegInfo.clear();
|
VRegInfo.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MachineRegisterInfo::verifyUseList(unsigned Reg) const {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
bool Valid = true;
|
||||||
|
for (reg_iterator I = reg_begin(Reg), E = reg_end(); I != E; ++I) {
|
||||||
|
MachineOperand *MO = &I.getOperand();
|
||||||
|
MachineInstr *MI = MO->getParent();
|
||||||
|
if (!MI) {
|
||||||
|
errs() << PrintReg(Reg, TRI) << " use list MachineOperand " << MO
|
||||||
|
<< " has no parent instruction.\n";
|
||||||
|
Valid = false;
|
||||||
|
}
|
||||||
|
MachineOperand *MO0 = &MI->getOperand(0);
|
||||||
|
unsigned NumOps = MI->getNumOperands();
|
||||||
|
if (!(MO >= MO0 && MO < MO0+NumOps)) {
|
||||||
|
errs() << PrintReg(Reg, TRI) << " use list MachineOperand " << MO
|
||||||
|
<< " doesn't belong to parent MI: " << *MI;
|
||||||
|
Valid = false;
|
||||||
|
}
|
||||||
|
if (!MO->isReg()) {
|
||||||
|
errs() << PrintReg(Reg, TRI) << " MachineOperand " << MO << ": " << *MO
|
||||||
|
<< " is not a register\n";
|
||||||
|
Valid = false;
|
||||||
|
}
|
||||||
|
if (MO->getReg() != Reg) {
|
||||||
|
errs() << PrintReg(Reg, TRI) << " use-list MachineOperand " << MO << ": "
|
||||||
|
<< *MO << " is the wrong register\n";
|
||||||
|
Valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(Valid && "Invalid use list");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void MachineRegisterInfo::verifyUseLists() const {
|
||||||
|
#ifndef NDEBUG
|
||||||
|
for (unsigned i = 0, e = getNumVirtRegs(); i != e; ++i)
|
||||||
|
verifyUseList(TargetRegisterInfo::index2VirtReg(i));
|
||||||
|
for (unsigned i = 1, e = TRI->getNumRegs(); i != e; ++i)
|
||||||
|
verifyUseList(i);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/// Add MO to the linked list of operands for its register.
|
/// Add MO to the linked list of operands for its register.
|
||||||
void MachineRegisterInfo::addRegOperandToUseList(MachineOperand *MO) {
|
void MachineRegisterInfo::addRegOperandToUseList(MachineOperand *MO) {
|
||||||
assert(!MO->isOnRegUseList() && "Already on list");
|
assert(!MO->isOnRegUseList() && "Already on list");
|
||||||
|
@ -472,6 +472,9 @@ void MachineVerifier::visitMachineFunctionBefore() {
|
|||||||
if (MInfo.Succs.size() != I->succ_size())
|
if (MInfo.Succs.size() != I->succ_size())
|
||||||
report("MBB has duplicate entries in its successor list.", I);
|
report("MBB has duplicate entries in its successor list.", I);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that the register use lists are sane.
|
||||||
|
MRI->verifyUseLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does iterator point to a and b as the first two elements?
|
// Does iterator point to a and b as the first two elements?
|
||||||
|
Reference in New Issue
Block a user