summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2016-02-15 19:25:31 +0000
committerMatthias Braun <matze@braunis.de>2016-02-15 19:25:31 +0000
commitb3aefc3a69af93271b4ee115ecc8c204caadcfdb (patch)
tree88da644026d9f09bbaef7e8fc3336f4057788478
parentc7b2124d49fdecf5792c7c42a40fecc7fcb00336 (diff)
downloadbcm5719-llvm-b3aefc3a69af93271b4ee115ecc8c204caadcfdb.tar.gz
bcm5719-llvm-b3aefc3a69af93271b4ee115ecc8c204caadcfdb.zip
MachineVerifier: Add parameter to choose if MachineFunction::verify() aborts
The abort on error behaviour is unpractical for debugger and unittest usage. llvm-svn: 260904
-rw-r--r--llvm/include/llvm/CodeGen/MachineFunction.h8
-rw-r--r--llvm/lib/CodeGen/MachineVerifier.cpp23
2 files changed, 18 insertions, 13 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index df7c951743c..4b1b5f43ae8 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -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;
diff --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 5f0cf40040e..48ddd56c8a4 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -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) {
OpenPOWER on IntegriCloud