aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Analysis
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-04-01 09:33:02 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-04-01 09:33:02 -0700
commita6c4b28460c42bc9fbbdcefffb4aed603f07f068 (patch)
tree2dcc9c33b3e267c01e822130de5bdba3adc511cf /include/llvm/Analysis
parentcd93e1afec966dba60433f8df5f78f10ef217f93 (diff)
PNaCl: Allow the ABI checker to be used from "opt"
This allows the ABI checker passes to be used in the same way as LLVM's "-verify" pass. It allows the checker to be run between other passes, and without launching pnacl-abicheck as a separate process (so without the overhead of reading bitcode into memory again). Make the ABI checker passes produce fatal errors by default, to match "-verify". This is overridden for pnacl-abicheck's use. BUG=https://code.google.com/p/nativeclient/issues/detail?id=2309 TEST=tested with pnacl-ld.py changes to use the ABI checker passes Review URL: https://codereview.chromium.org/13323006
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r--include/llvm/Analysis/NaCl.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/llvm/Analysis/NaCl.h b/include/llvm/Analysis/NaCl.h
index a8f2c9651e..722b4bd7a6 100644
--- a/include/llvm/Analysis/NaCl.h
+++ b/include/llvm/Analysis/NaCl.h
@@ -10,6 +10,7 @@
#ifndef LLVM_ANALYSIS_NACL_H
#define LLVM_ANALYSIS_NACL_H
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
@@ -20,7 +21,8 @@ class ModulePass;
class PNaClABIErrorReporter {
public:
- PNaClABIErrorReporter() : ErrorCount(0), Errors(ErrorString) {}
+ PNaClABIErrorReporter() : ErrorCount(0), Errors(ErrorString),
+ UseFatalErrors(true) {}
// Return the number of verification errors from the last run.
int getErrorCount() { return ErrorCount; }
// Print the error messages to O
@@ -40,10 +42,20 @@ class PNaClABIErrorReporter {
Errors.flush();
ErrorString.clear();
}
+ void setNonFatal() {
+ UseFatalErrors = false;
+ }
+ void checkForFatalErrors() {
+ if (UseFatalErrors && ErrorCount != 0) {
+ printErrors(errs());
+ report_fatal_error("PNaCl ABI verification failed");
+ }
+ }
private:
int ErrorCount;
std::string ErrorString;
raw_string_ostream Errors;
+ bool UseFatalErrors;
};
FunctionPass *createPNaClABIVerifyFunctionsPass(PNaClABIErrorReporter * Reporter);