llvm.org GIT mirror llvm / c567bd6
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247730 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
5 changed file(s) with 21 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
109109 /// \note It is up to the linker to remove the intermediate object file. Do
110110 /// not try to remove the object file in LTOCodeGenerator's destructor as we
111111 /// don't who (LTOCodeGenerator or the obj file) will last longer.
112 bool compile_to_file(const char **Name, bool DisableVerify,
113 bool DisableInline, bool DisableGVNLoadPRE,
114 bool DisableVectorization, std::string &ErrMsg);
112 bool compile_to_file(const char **Name, bool DisableInline,
113 bool DisableGVNLoadPRE, bool DisableVectorization,
114 std::string &ErrMsg);
115115
116116 /// As with compile_to_file(), this function compiles the merged module into
117117 /// single object file. Instead of returning the object-file-path to the
119119 /// to the caller. This function should delete intermediate object file once
120120 /// its content is brought to memory. Return NULL if the compilation was not
121121 /// successful.
122 std::unique_ptr compile(bool DisableVerify, bool DisableInline,
122 std::unique_ptr compile(bool DisableInline,
123123 bool DisableGVNLoadPRE,
124124 bool DisableVectorization,
125125 std::string &errMsg);
126126
127127 /// Optimizes the merged module. Returns true on success.
128 bool optimize(bool DisableVerify, bool DisableInline, bool DisableGVNLoadPRE,
128 bool optimize(bool DisableInline, bool DisableGVNLoadPRE,
129129 bool DisableVectorization, std::string &ErrMsg);
130130
131131 /// Compiles the merged optimized module into a single object file. It brings
264264 return std::move(*BufferOrErr);
265265 }
266266
267 bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableVerify,
268 bool DisableInline,
267 bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableInline,
269268 bool DisableGVNLoadPRE,
270269 bool DisableVectorization,
271270 std::string &ErrMsg) {
272 if (!optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
273 DisableVectorization, ErrMsg))
271 if (!optimize(DisableInline, DisableGVNLoadPRE, DisableVectorization, ErrMsg))
274272 return false;
275273
276274 return compileOptimizedToFile(Name, ErrMsg);
277275 }
278276
279277 std::unique_ptr
280 LTOCodeGenerator::compile(bool DisableVerify, bool DisableInline,
281 bool DisableGVNLoadPRE, bool DisableVectorization,
282 std::string &ErrMsg) {
283 if (!optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
284 DisableVectorization, ErrMsg))
278 LTOCodeGenerator::compile(bool DisableInline, bool DisableGVNLoadPRE,
279 bool DisableVectorization, std::string &ErrMsg) {
280 if (!optimize(DisableInline, DisableGVNLoadPRE, DisableVectorization, ErrMsg))
285281 return nullptr;
286282
287283 return compileOptimized(ErrMsg);
462458 }
463459
464460 /// Optimize merged modules using various IPO passes
465 bool LTOCodeGenerator::optimize(bool DisableVerify, bool DisableInline,
466 bool DisableGVNLoadPRE,
461 bool LTOCodeGenerator::optimize(bool DisableInline, bool DisableGVNLoadPRE,
467462 bool DisableVectorization,
468463 std::string &ErrMsg) {
469464 if (!this->determineTarget(ErrMsg))
490485 PMB.Inliner = createFunctionInliningPass();
491486 PMB.LibraryInfo = new TargetLibraryInfoImpl(TargetTriple);
492487 PMB.OptLevel = OptLevel;
493 PMB.VerifyInput = !DisableVerify;
494 PMB.VerifyOutput = !DisableVerify;
488 PMB.VerifyInput = true;
489 PMB.VerifyOutput = true;
495490
496491 PMB.populateLTOPassManager(passes);
497492
+0
-18
test/LTO/X86/disable-verify.ll less more
None ; RUN: llvm-as < %s >%t.bc
1 ; RUN: llvm-lto -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 -disable-verify | FileCheck %s
2 ; RUN: llvm-lto -debug-pass=Arguments -exported-symbol=_f -o /dev/null %t.bc 2>&1 | FileCheck %s -check-prefix=VERIFY
3
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.10.0"
6
7 ; -disable-verify should disable verification from the optimization pipeline.
8 ; CHECK: Pass Arguments: -verify -internalize
9 ; CHECK-NOT: -verify
10
11 ; VERIFY: Pass Arguments: -verify -internalize
12 ; VERIFY: Pass Arguments: {{.*}} -verify {{.*}} -verify
13
14 define void @f() {
15 entry:
16 ret void
17 }
3434 cl::Prefix,
3535 cl::ZeroOrMore,
3636 cl::init('2'));
37
38 static cl::opt DisableVerify(
39 "disable-verify", cl::init(false),
40 cl::desc("Do not run the verifier during the optimization pipeline"));
4137
4238 static cl::opt
4339 DisableInline("disable-inlining", cl::init(false),
251247
252248 if (!OutputFilename.empty()) {
253249 std::string ErrorInfo;
254 if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
250 if (!CodeGen.optimize(DisableInline, DisableGVNLoadPRE,
255251 DisableLTOVectorization, ErrorInfo)) {
256252 errs() << argv[0] << ": error optimizing the code: " << ErrorInfo << "\n";
257253 return 1;
288284
289285 std::string ErrorInfo;
290286 const char *OutputName = nullptr;
291 if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline,
287 if (!CodeGen.compile_to_file(&OutputName, DisableInline,
292288 DisableGVNLoadPRE, DisableLTOVectorization,
293289 ErrorInfo)) {
294290 errs() << argv[0]
4141 static cl::opt
4242 DisableLTOVectorization("disable-lto-vectorization", cl::init(false),
4343 cl::desc("Do not run loop or slp vectorization during LTO"));
44
45 #ifdef NDEBUG
46 static bool VerifyByDefault = false;
47 #else
48 static bool VerifyByDefault = true;
49 #endif
50
51 static cl::opt DisableVerify(
52 "disable-llvm-verifier", cl::init(!VerifyByDefault),
53 cl::desc("Don't run the LLVM verifier during the optimization pipeline"));
5444
5545 // Holds most recent error string.
5646 // *** Not thread safe ***
330320 const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
331321 maybeParseOptions(cg);
332322 LibLTOCodeGenerator *CG = unwrap(cg);
333 CG->NativeObjectFile =
334 CG->compile(DisableVerify, DisableInline, DisableGVNLoadPRE,
335 DisableLTOVectorization, sLastErrorString);
323 CG->NativeObjectFile = CG->compile(DisableInline, DisableGVNLoadPRE,
324 DisableLTOVectorization, sLastErrorString);
336325 if (!CG->NativeObjectFile)
337326 return nullptr;
338327 *length = CG->NativeObjectFile->getBufferSize();
341330
342331 bool lto_codegen_optimize(lto_code_gen_t cg) {
343332 maybeParseOptions(cg);
344 return !unwrap(cg)->optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
345 DisableLTOVectorization, sLastErrorString);
333 return !unwrap(cg)->optimize(DisableInline,
334 DisableGVNLoadPRE, DisableLTOVectorization,
335 sLastErrorString);
346336 }
347337
348338 const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
358348 bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
359349 maybeParseOptions(cg);
360350 return !unwrap(cg)->compile_to_file(
361 name, DisableVerify, DisableInline, DisableGVNLoadPRE,
351 name, DisableInline, DisableGVNLoadPRE,
362352 DisableLTOVectorization, sLastErrorString);
363353 }
364354