mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-06 20:10:38 +00:00
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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266846 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
50c1579e03
commit
63d7d49586
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user