[llvm] r266846 - llvm-lto: run the module verifier when doing IR level work
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 19:23:36 PDT 2016
Thanks!
On 19 April 2016 at 21:04, Mehdi Amini via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: mehdi_amini
> Date: Tue Apr 19 20:04:26 2016
> New Revision: 266846
>
> URL: http://llvm.org/viewvc/llvm-project?rev=266846&view=rev
> Log:
> 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 at apple.com>
>
> Modified:
> llvm/trunk/tools/llvm-lto/llvm-lto.cpp
>
> Modified: llvm/trunk/tools/llvm-lto/llvm-lto.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto/llvm-lto.cpp?rev=266846&r1=266845&r2=266846&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-lto/llvm-lto.cpp (original)
> +++ llvm/trunk/tools/llvm-lto/llvm-lto.cpp Tue Apr 19 20:04:26 2016
> @@ -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, c
> 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::u
> 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> loadModul
> 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 &Th
> 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);
> }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list