summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-04-20 01:04:26 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-04-20 01:04:26 +0000
commit3c0e64c9d6b613fd16222e61aa19ec040c139e31 (patch)
treebd0616e2129cf4924355620f854a86abb51fc4bf
parent6968ef773bbc4263e420e8d05ed16801021fdc09 (diff)
downloadbcm5719-llvm-3c0e64c9d6b613fd16222e61aa19ec040c139e31.tar.gz
bcm5719-llvm-3c0e64c9d6b613fd16222e61aa19ec040c139e31.zip
llvm-lto: run the module verifier when doing IR level work
It seems it was only running during CodeGen previously. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266846
-rw-r--r--llvm/tools/llvm-lto/llvm-lto.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index 22532f520dd..98644d3078f 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -17,6 +17,7 @@
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/LTO/LTOCodeGenerator.h"
#include "llvm/LTO/LTOModule.h"
@@ -205,6 +206,11 @@ static void error(const ErrorOr<T> &V, const Twine &Prefix) {
error(V.getError(), Prefix);
}
+static void maybeVerifyModule(const Module &Mod) {
+ if (!DisableVerify && verifyModule(Mod))
+ error("Broken Module");
+}
+
static std::unique_ptr<LTOModule>
getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer,
const TargetOptions &Options) {
@@ -219,6 +225,7 @@ getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer,
std::move(Context), Buffer->getBufferStart(), Buffer->getBufferSize(),
Options, Path);
CurrentActivity = "";
+ maybeVerifyModule((*Ret)->getModule());
return std::move(*Ret);
}
@@ -303,6 +310,7 @@ static std::unique_ptr<Module> loadModule(StringRef Filename,
Err.print("llvm-lto", errs());
report_fatal_error("Can't load module for file " + Filename);
}
+ maybeVerifyModule(*M);
return M;
}
@@ -310,6 +318,7 @@ static void writeModuleToFile(Module &TheModule, StringRef Filename) {
std::error_code EC;
raw_fd_ostream OS(Filename, EC, sys::fs::OpenFlags::F_None);
error(EC, "error opening the file '" + Filename + "'");
+ maybeVerifyModule(TheModule);
WriteBitcodeToFile(&TheModule, OS, /* ShouldPreserveUseListOrder */ true);
}
OpenPOWER on IntegriCloud