MachineVerifier: Add parameter to choose if MachineFunction::verify() aborts

The abort on error behaviour is unpractical for debugger and unittest
usage.

llvm-svn: 260904
This commit is contained in:
Matthias Braun 2016-02-15 19:25:31 +00:00
parent c7b2124d49
commit b3aefc3a69
2 changed files with 18 additions and 13 deletions

View File

@ -332,9 +332,11 @@ public:
///
void dump() const;
/// verify - Run the current MachineFunction through the machine code
/// verifier, useful for debugger use.
void verify(Pass *p = nullptr, const char *Banner = nullptr) const;
/// Run the current MachineFunction through the machine code verifier, useful
/// for debugger use.
/// \returns true if no problems were found.
bool verify(Pass *p = nullptr, const char *Banner = nullptr,
bool AbortOnError = true) const;
// Provide accessors for the MachineBasicBlock list...
typedef BasicBlockListType::iterator iterator;

View File

@ -58,7 +58,7 @@ namespace {
Banner(b)
{}
bool runOnMachineFunction(MachineFunction &MF);
unsigned verify(MachineFunction &MF);
Pass *const PASS;
const char *Banner;
@ -268,7 +268,9 @@ namespace {
}
bool runOnMachineFunction(MachineFunction &MF) override {
MF.verify(this, Banner.c_str());
unsigned FoundErrors = MachineVerifier(this, Banner.c_str()).verify(MF);
if (FoundErrors)
report_fatal_error("Found "+Twine(FoundErrors)+" machine code errors.");
return false;
}
};
@ -283,9 +285,13 @@ FunctionPass *llvm::createMachineVerifierPass(const std::string &Banner) {
return new MachineVerifierPass(Banner);
}
void MachineFunction::verify(Pass *p, const char *Banner) const {
MachineVerifier(p, Banner)
.runOnMachineFunction(const_cast<MachineFunction&>(*this));
bool MachineFunction::verify(Pass *p, const char *Banner, bool AbortOnErrors)
const {
MachineFunction &MF = const_cast<MachineFunction&>(*this);
unsigned FoundErrors = MachineVerifier(p, Banner).verify(MF);
if (AbortOnErrors && FoundErrors)
report_fatal_error("Found "+Twine(FoundErrors)+" machine code errors.");
return FoundErrors == 0;
}
void MachineVerifier::verifySlotIndexes() const {
@ -301,7 +307,7 @@ void MachineVerifier::verifySlotIndexes() const {
}
}
bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
unsigned MachineVerifier::verify(MachineFunction &MF) {
foundErrors = 0;
this->MF = &MF;
@ -386,9 +392,6 @@ bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
}
visitMachineFunctionAfter();
if (foundErrors)
report_fatal_error("Found "+Twine(foundErrors)+" machine code errors.");
// Clean up.
regsLive.clear();
regsDefined.clear();
@ -398,7 +401,7 @@ bool MachineVerifier::runOnMachineFunction(MachineFunction &MF) {
regsLiveInButUnused.clear();
MBBInfoMap.clear();
return false; // no changes
return foundErrors;
}
void MachineVerifier::report(const char *msg, const MachineFunction *MF) {