forked from OSchip/llvm-project
Revert "LTO: Disable extra verify runs in release builds"
This temporarily reverts commit r247729, as it caused lld build failures. I'll recommit once I have an lld patch ready-to-go. llvm-svn: 247730
This commit is contained in:
parent
236787838c
commit
7de73e56a4
|
@ -110,9 +110,9 @@ struct LTOCodeGenerator {
|
||||||
/// \note It is up to the linker to remove the intermediate object file. Do
|
/// \note It is up to the linker to remove the intermediate object file. Do
|
||||||
/// not try to remove the object file in LTOCodeGenerator's destructor as we
|
/// not try to remove the object file in LTOCodeGenerator's destructor as we
|
||||||
/// don't who (LTOCodeGenerator or the obj file) will last longer.
|
/// don't who (LTOCodeGenerator or the obj file) will last longer.
|
||||||
bool compile_to_file(const char **Name, bool DisableVerify,
|
bool compile_to_file(const char **Name, bool DisableInline,
|
||||||
bool DisableInline, bool DisableGVNLoadPRE,
|
bool DisableGVNLoadPRE, bool DisableVectorization,
|
||||||
bool DisableVectorization, std::string &ErrMsg);
|
std::string &ErrMsg);
|
||||||
|
|
||||||
/// As with compile_to_file(), this function compiles the merged module into
|
/// As with compile_to_file(), this function compiles the merged module into
|
||||||
/// single object file. Instead of returning the object-file-path to the
|
/// single object file. Instead of returning the object-file-path to the
|
||||||
|
@ -120,13 +120,13 @@ struct LTOCodeGenerator {
|
||||||
/// to the caller. This function should delete intermediate object file once
|
/// to the caller. This function should delete intermediate object file once
|
||||||
/// its content is brought to memory. Return NULL if the compilation was not
|
/// its content is brought to memory. Return NULL if the compilation was not
|
||||||
/// successful.
|
/// successful.
|
||||||
std::unique_ptr<MemoryBuffer> compile(bool DisableVerify, bool DisableInline,
|
std::unique_ptr<MemoryBuffer> compile(bool DisableInline,
|
||||||
bool DisableGVNLoadPRE,
|
bool DisableGVNLoadPRE,
|
||||||
bool DisableVectorization,
|
bool DisableVectorization,
|
||||||
std::string &errMsg);
|
std::string &errMsg);
|
||||||
|
|
||||||
/// Optimizes the merged module. Returns true on success.
|
/// Optimizes the merged module. Returns true on success.
|
||||||
bool optimize(bool DisableVerify, bool DisableInline, bool DisableGVNLoadPRE,
|
bool optimize(bool DisableInline, bool DisableGVNLoadPRE,
|
||||||
bool DisableVectorization, std::string &ErrMsg);
|
bool DisableVectorization, std::string &ErrMsg);
|
||||||
|
|
||||||
/// Compiles the merged optimized module into a single object file. It brings
|
/// Compiles the merged optimized module into a single object file. It brings
|
||||||
|
|
|
@ -265,24 +265,20 @@ LTOCodeGenerator::compileOptimized(std::string &ErrMsg) {
|
||||||
return std::move(*BufferOrErr);
|
return std::move(*BufferOrErr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableVerify,
|
bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableInline,
|
||||||
bool DisableInline,
|
|
||||||
bool DisableGVNLoadPRE,
|
bool DisableGVNLoadPRE,
|
||||||
bool DisableVectorization,
|
bool DisableVectorization,
|
||||||
std::string &ErrMsg) {
|
std::string &ErrMsg) {
|
||||||
if (!optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
|
if (!optimize(DisableInline, DisableGVNLoadPRE, DisableVectorization, ErrMsg))
|
||||||
DisableVectorization, ErrMsg))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return compileOptimizedToFile(Name, ErrMsg);
|
return compileOptimizedToFile(Name, ErrMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<MemoryBuffer>
|
std::unique_ptr<MemoryBuffer>
|
||||||
LTOCodeGenerator::compile(bool DisableVerify, bool DisableInline,
|
LTOCodeGenerator::compile(bool DisableInline, bool DisableGVNLoadPRE,
|
||||||
bool DisableGVNLoadPRE, bool DisableVectorization,
|
bool DisableVectorization, std::string &ErrMsg) {
|
||||||
std::string &ErrMsg) {
|
if (!optimize(DisableInline, DisableGVNLoadPRE, DisableVectorization, ErrMsg))
|
||||||
if (!optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
|
|
||||||
DisableVectorization, ErrMsg))
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return compileOptimized(ErrMsg);
|
return compileOptimized(ErrMsg);
|
||||||
|
@ -463,8 +459,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optimize merged modules using various IPO passes
|
/// Optimize merged modules using various IPO passes
|
||||||
bool LTOCodeGenerator::optimize(bool DisableVerify, bool DisableInline,
|
bool LTOCodeGenerator::optimize(bool DisableInline, bool DisableGVNLoadPRE,
|
||||||
bool DisableGVNLoadPRE,
|
|
||||||
bool DisableVectorization,
|
bool DisableVectorization,
|
||||||
std::string &ErrMsg) {
|
std::string &ErrMsg) {
|
||||||
if (!this->determineTarget(ErrMsg))
|
if (!this->determineTarget(ErrMsg))
|
||||||
|
@ -491,8 +486,8 @@ bool LTOCodeGenerator::optimize(bool DisableVerify, bool DisableInline,
|
||||||
PMB.Inliner = createFunctionInliningPass();
|
PMB.Inliner = createFunctionInliningPass();
|
||||||
PMB.LibraryInfo = new TargetLibraryInfoImpl(TargetTriple);
|
PMB.LibraryInfo = new TargetLibraryInfoImpl(TargetTriple);
|
||||||
PMB.OptLevel = OptLevel;
|
PMB.OptLevel = OptLevel;
|
||||||
PMB.VerifyInput = !DisableVerify;
|
PMB.VerifyInput = true;
|
||||||
PMB.VerifyOutput = !DisableVerify;
|
PMB.VerifyOutput = true;
|
||||||
|
|
||||||
PMB.populateLTOPassManager(passes);
|
PMB.populateLTOPassManager(passes);
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
; RUN: llvm-as < %s >%t.bc
|
|
||||||
; RUN: llvm-lto -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 -disable-verify | FileCheck %s
|
|
||||||
; RUN: llvm-lto -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 | FileCheck %s -check-prefix=VERIFY
|
|
||||||
|
|
||||||
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
||||||
target triple = "x86_64-apple-macosx10.10.0"
|
|
||||||
|
|
||||||
; -disable-verify should disable verification from the optimization pipeline.
|
|
||||||
; CHECK: Pass Arguments: -verify -internalize
|
|
||||||
; CHECK-NOT: -verify
|
|
||||||
|
|
||||||
; VERIFY: Pass Arguments: -verify -internalize
|
|
||||||
; VERIFY: Pass Arguments: {{.*}} -verify {{.*}} -verify
|
|
||||||
|
|
||||||
define void @f() {
|
|
||||||
entry:
|
|
||||||
ret void
|
|
||||||
}
|
|
|
@ -36,10 +36,6 @@ OptLevel("O",
|
||||||
cl::ZeroOrMore,
|
cl::ZeroOrMore,
|
||||||
cl::init('2'));
|
cl::init('2'));
|
||||||
|
|
||||||
static cl::opt<bool> DisableVerify(
|
|
||||||
"disable-verify", cl::init(false),
|
|
||||||
cl::desc("Do not run the verifier during the optimization pipeline"));
|
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
DisableInline("disable-inlining", cl::init(false),
|
DisableInline("disable-inlining", cl::init(false),
|
||||||
cl::desc("Do not run the inliner pass"));
|
cl::desc("Do not run the inliner pass"));
|
||||||
|
@ -252,7 +248,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (!OutputFilename.empty()) {
|
if (!OutputFilename.empty()) {
|
||||||
std::string ErrorInfo;
|
std::string ErrorInfo;
|
||||||
if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
|
if (!CodeGen.optimize(DisableInline, DisableGVNLoadPRE,
|
||||||
DisableLTOVectorization, ErrorInfo)) {
|
DisableLTOVectorization, ErrorInfo)) {
|
||||||
errs() << argv[0] << ": error optimizing the code: " << ErrorInfo << "\n";
|
errs() << argv[0] << ": error optimizing the code: " << ErrorInfo << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -289,7 +285,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
std::string ErrorInfo;
|
std::string ErrorInfo;
|
||||||
const char *OutputName = nullptr;
|
const char *OutputName = nullptr;
|
||||||
if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline,
|
if (!CodeGen.compile_to_file(&OutputName, DisableInline,
|
||||||
DisableGVNLoadPRE, DisableLTOVectorization,
|
DisableGVNLoadPRE, DisableLTOVectorization,
|
||||||
ErrorInfo)) {
|
ErrorInfo)) {
|
||||||
errs() << argv[0]
|
errs() << argv[0]
|
||||||
|
|
|
@ -43,16 +43,6 @@ static cl::opt<bool>
|
||||||
DisableLTOVectorization("disable-lto-vectorization", cl::init(false),
|
DisableLTOVectorization("disable-lto-vectorization", cl::init(false),
|
||||||
cl::desc("Do not run loop or slp vectorization during LTO"));
|
cl::desc("Do not run loop or slp vectorization during LTO"));
|
||||||
|
|
||||||
#ifdef NDEBUG
|
|
||||||
static bool VerifyByDefault = false;
|
|
||||||
#else
|
|
||||||
static bool VerifyByDefault = true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static cl::opt<bool> DisableVerify(
|
|
||||||
"disable-llvm-verifier", cl::init(!VerifyByDefault),
|
|
||||||
cl::desc("Don't run the LLVM verifier during the optimization pipeline"));
|
|
||||||
|
|
||||||
// Holds most recent error string.
|
// Holds most recent error string.
|
||||||
// *** Not thread safe ***
|
// *** Not thread safe ***
|
||||||
static std::string sLastErrorString;
|
static std::string sLastErrorString;
|
||||||
|
@ -331,9 +321,8 @@ bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
|
||||||
const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
|
const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
|
||||||
maybeParseOptions(cg);
|
maybeParseOptions(cg);
|
||||||
LibLTOCodeGenerator *CG = unwrap(cg);
|
LibLTOCodeGenerator *CG = unwrap(cg);
|
||||||
CG->NativeObjectFile =
|
CG->NativeObjectFile = CG->compile(DisableInline, DisableGVNLoadPRE,
|
||||||
CG->compile(DisableVerify, DisableInline, DisableGVNLoadPRE,
|
DisableLTOVectorization, sLastErrorString);
|
||||||
DisableLTOVectorization, sLastErrorString);
|
|
||||||
if (!CG->NativeObjectFile)
|
if (!CG->NativeObjectFile)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
*length = CG->NativeObjectFile->getBufferSize();
|
*length = CG->NativeObjectFile->getBufferSize();
|
||||||
|
@ -342,8 +331,9 @@ const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
|
||||||
|
|
||||||
bool lto_codegen_optimize(lto_code_gen_t cg) {
|
bool lto_codegen_optimize(lto_code_gen_t cg) {
|
||||||
maybeParseOptions(cg);
|
maybeParseOptions(cg);
|
||||||
return !unwrap(cg)->optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
|
return !unwrap(cg)->optimize(DisableInline,
|
||||||
DisableLTOVectorization, sLastErrorString);
|
DisableGVNLoadPRE, DisableLTOVectorization,
|
||||||
|
sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
|
const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
|
||||||
|
@ -359,7 +349,7 @@ const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
|
||||||
bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
|
bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
|
||||||
maybeParseOptions(cg);
|
maybeParseOptions(cg);
|
||||||
return !unwrap(cg)->compile_to_file(
|
return !unwrap(cg)->compile_to_file(
|
||||||
name, DisableVerify, DisableInline, DisableGVNLoadPRE,
|
name, DisableInline, DisableGVNLoadPRE,
|
||||||
DisableLTOVectorization, sLastErrorString);
|
DisableLTOVectorization, sLastErrorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue