Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/CodeGen/MachineVerifier.cpp
Show First 20 Lines • Show All 1,550 Lines • ▼ Show 20 Lines | void MachineVerifier::visitMachineInstrBefore(const MachineInstr *MI) { | ||||
// A fully-formed DBG_VALUE must have a location. Ignore partially formed | // A fully-formed DBG_VALUE must have a location. Ignore partially formed | ||||
// DBG_VALUEs: these are convenient to use in tests, but should never get | // DBG_VALUEs: these are convenient to use in tests, but should never get | ||||
// generated. | // generated. | ||||
if (MI->isDebugValue() && MI->getNumOperands() == 4) | if (MI->isDebugValue() && MI->getNumOperands() == 4) | ||||
if (!MI->getDebugLoc()) | if (!MI->getDebugLoc()) | ||||
report("Missing DebugLoc for debug instruction", MI); | report("Missing DebugLoc for debug instruction", MI); | ||||
// Meta instructions should never be the subject of debug value tracking, | |||||
// they don't create a value in the output program at all. | |||||
if (MI->isMetaInstruction() && MI->peekDebugInstrNum()) | |||||
report("Metadata instruction should not have a value tracking number", MI); | |||||
// Check the MachineMemOperands for basic consistency. | // Check the MachineMemOperands for basic consistency. | ||||
for (MachineMemOperand *Op : MI->memoperands()) { | for (MachineMemOperand *Op : MI->memoperands()) { | ||||
if (Op->isLoad() && !MI->mayLoad()) | if (Op->isLoad() && !MI->mayLoad()) | ||||
report("Missing mayLoad flag", MI); | report("Missing mayLoad flag", MI); | ||||
if (Op->isStore() && !MI->mayStore()) | if (Op->isStore() && !MI->mayStore()) | ||||
report("Missing mayStore flag", MI); | report("Missing mayStore flag", MI); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 947 Lines • ▼ Show 20 Lines | for (const auto &MBB : *MF) | ||||
<< printMBBReference(*Pred) << "\n"; | << printMBBReference(*Pred) << "\n"; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
for (auto CSInfo : MF->getCallSitesInfo()) | for (auto CSInfo : MF->getCallSitesInfo()) | ||||
if (!CSInfo.first->isCall()) | if (!CSInfo.first->isCall()) | ||||
report("Call site info referencing instruction that is not call", MF); | report("Call site info referencing instruction that is not call", MF); | ||||
// If there's debug-info, check that we don't have any duplicate value | |||||
// tracking numbers. | |||||
if (MF->getFunction().getSubprogram()) { | |||||
DenseSet<unsigned> SeenNumbers; | |||||
for (auto &MBB : *MF) { | |||||
for (auto &MI : MBB) { | |||||
if (auto Num = MI.peekDebugInstrNum()) { | |||||
auto Result = SeenNumbers.insert((unsigned)Num); | |||||
if (!Result.second) | |||||
report("Instruction has a duplicated value tracking number", &MI); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
void MachineVerifier::verifyLiveVariables() { | void MachineVerifier::verifyLiveVariables() { | ||||
assert(LiveVars && "Don't call verifyLiveVariables without LiveVars"); | assert(LiveVars && "Don't call verifyLiveVariables without LiveVars"); | ||||
for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) { | for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) { | ||||
unsigned Reg = Register::index2VirtReg(i); | unsigned Reg = Register::index2VirtReg(i); | ||||
LiveVariables::VarInfo &VI = LiveVars->getVarInfo(Reg); | LiveVariables::VarInfo &VI = LiveVars->getVarInfo(Reg); | ||||
for (const auto &MBB : *MF) { | for (const auto &MBB : *MF) { | ||||
▲ Show 20 Lines • Show All 523 Lines • Show Last 20 Lines |