diff --git a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h --- a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h @@ -145,7 +145,7 @@ /// \note It is up to the linker to remove the intermediate output file. Do /// not try to remove the object file in LTOCodeGenerator's destructor as we /// don't who (LTOCodeGenerator or the output file) will last longer. - bool compile_to_file(const char **Name, bool DisableVerify); + bool compile_to_file(const char **Name); /// As with compile_to_file(), this function compiles the merged module into /// single output file. Instead of returning the output file path to the @@ -153,12 +153,12 @@ /// to the caller. This function should delete the intermediate file once /// its content is brought to memory. Return NULL if the compilation was not /// successful. - std::unique_ptr compile(bool DisableVerify); + std::unique_ptr compile(); /// Optimizes the merged module. Returns true on success. /// /// Calls \a verifyMergedModuleOnce(). - bool optimize(bool DisableVerify); + bool optimize(); /// Compiles the merged optimized module into a single output file. It brings /// the output to a buffer, and returns the buffer to the caller. Return NULL @@ -178,6 +178,8 @@ /// assume builtins are present on the target. void setFreestanding(bool Enabled) { Freestanding = Enabled; } + void setDisableVerify(bool Value) { DisableVerify = Value; } + void setDiagnosticHandler(lto_diagnostic_handler_t, void *); LLVMContext &getContext() { return Context; } @@ -239,6 +241,7 @@ std::unique_ptr DiagnosticOutputFile; bool Freestanding = false; std::unique_ptr StatsFile = nullptr; + bool DisableVerify = false; }; } #endif diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -326,15 +326,15 @@ return std::move(*BufferOrErr); } -bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableVerify) { - if (!optimize(DisableVerify)) +bool LTOCodeGenerator::compile_to_file(const char **Name) { + if (!optimize()) return false; return compileOptimizedToFile(Name); } -std::unique_ptr LTOCodeGenerator::compile(bool DisableVerify) { - if (!optimize(DisableVerify)) +std::unique_ptr LTOCodeGenerator::compile() { + if (!optimize()) return nullptr; return compileOptimized(); @@ -527,7 +527,7 @@ } /// Optimize merged modules using various IPO passes -bool LTOCodeGenerator::optimize(bool DisableVerify) { +bool LTOCodeGenerator::optimize() { if (!this->determineTarget()) return false; diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -953,6 +953,7 @@ true); LTOCodeGenerator CodeGen(Context); + CodeGen.setDisableVerify(DisableVerify); if (UseDiagnosticHandler) CodeGen.setDiagnosticHandler(handleDiagnostics, nullptr); @@ -1026,7 +1027,7 @@ error("writing linked module failed."); } - if (!CodeGen.optimize(DisableVerify)) { + if (!CodeGen.optimize()) { // Diagnostic messages should have been printed by the handler. error("error optimizing the code"); } @@ -1067,7 +1068,7 @@ error(": -save-merged-module must be specified with -o"); const char *OutputName = nullptr; - if (!CodeGen.compile_to_file(&OutputName, DisableVerify)) + if (!CodeGen.compile_to_file(&OutputName)) error("error compiling the code"); // Diagnostic messages should have been printed by the handler. diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -152,6 +152,7 @@ report_fatal_error("Optimization level must be between 0 and 3"); CG->setOptLevel(OptLevel - '0'); CG->setFreestanding(EnableFreestanding); + CG->setDisableVerify(DisableVerify); } extern const char* lto_get_version() { @@ -432,7 +433,7 @@ const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) { maybeParseOptions(cg); LibLTOCodeGenerator *CG = unwrap(cg); - CG->NativeObjectFile = CG->compile(DisableVerify); + CG->NativeObjectFile = CG->compile(); if (!CG->NativeObjectFile) return nullptr; *length = CG->NativeObjectFile->getBufferSize(); @@ -441,7 +442,7 @@ bool lto_codegen_optimize(lto_code_gen_t cg) { maybeParseOptions(cg); - return !unwrap(cg)->optimize(DisableVerify); + return !unwrap(cg)->optimize(); } const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) { @@ -456,7 +457,7 @@ bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) { maybeParseOptions(cg); - return !unwrap(cg)->compile_to_file(name, DisableVerify); + return !unwrap(cg)->compile_to_file(name); } void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {