llvm.org GIT mirror llvm / 5e60a68
Reapply "LTO: Disable extra verify runs in release builds" This reverts commit r247730, effectively reapplying r247729. This time I have an lld commit ready to follow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247735 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
5 changed file(s) with 58 addition(s) and 21 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 DisableInline,
113 bool DisableGVNLoadPRE, bool DisableVectorization,
114 std::string &ErrMsg);
112 bool compile_to_file(const char **Name, bool DisableVerify,
113 bool DisableInline, bool DisableGVNLoadPRE,
114 bool DisableVectorization, 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 DisableInline,
122 std::unique_ptr compile(bool DisableVerify, 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 DisableInline, bool DisableGVNLoadPRE,
128 bool optimize(bool DisableVerify, 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 DisableInline,
267 bool LTOCodeGenerator::compile_to_file(const char **Name, bool DisableVerify,
268 bool DisableInline,
268269 bool DisableGVNLoadPRE,
269270 bool DisableVectorization,
270271 std::string &ErrMsg) {
271 if (!optimize(DisableInline, DisableGVNLoadPRE, DisableVectorization, ErrMsg))
272 if (!optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
273 DisableVectorization, ErrMsg))
272274 return false;
273275
274276 return compileOptimizedToFile(Name, ErrMsg);
275277 }
276278
277279 std::unique_ptr
278 LTOCodeGenerator::compile(bool DisableInline, bool DisableGVNLoadPRE,
279 bool DisableVectorization, std::string &ErrMsg) {
280 if (!optimize(DisableInline, DisableGVNLoadPRE, DisableVectorization, ErrMsg))
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))
281285 return nullptr;
282286
283287 return compileOptimized(ErrMsg);
458462 }
459463
460464 /// Optimize merged modules using various IPO passes
461 bool LTOCodeGenerator::optimize(bool DisableInline, bool DisableGVNLoadPRE,
465 bool LTOCodeGenerator::optimize(bool DisableVerify, bool DisableInline,
466 bool DisableGVNLoadPRE,
462467 bool DisableVectorization,
463468 std::string &ErrMsg) {
464469 if (!this->determineTarget(ErrMsg))
485490 PMB.Inliner = createFunctionInliningPass();
486491 PMB.LibraryInfo = new TargetLibraryInfoImpl(TargetTriple);
487492 PMB.OptLevel = OptLevel;
488 PMB.VerifyInput = true;
489 PMB.VerifyOutput = true;
493 PMB.VerifyInput = !DisableVerify;
494 PMB.VerifyOutput = !DisableVerify;
490495
491496 PMB.populateLTOPassManager(passes);
492497
0 ; 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"));
3741
3842 static cl::opt
3943 DisableInline("disable-inlining", cl::init(false),
247251
248252 if (!OutputFilename.empty()) {
249253 std::string ErrorInfo;
250 if (!CodeGen.optimize(DisableInline, DisableGVNLoadPRE,
254 if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
251255 DisableLTOVectorization, ErrorInfo)) {
252256 errs() << argv[0] << ": error optimizing the code: " << ErrorInfo << "\n";
253257 return 1;
284288
285289 std::string ErrorInfo;
286290 const char *OutputName = nullptr;
287 if (!CodeGen.compile_to_file(&OutputName, DisableInline,
291 if (!CodeGen.compile_to_file(&OutputName, DisableVerify, DisableInline,
288292 DisableGVNLoadPRE, DisableLTOVectorization,
289293 ErrorInfo)) {
290294 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"));
4454
4555 // Holds most recent error string.
4656 // *** Not thread safe ***
320330 const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
321331 maybeParseOptions(cg);
322332 LibLTOCodeGenerator *CG = unwrap(cg);
323 CG->NativeObjectFile = CG->compile(DisableInline, DisableGVNLoadPRE,
324 DisableLTOVectorization, sLastErrorString);
333 CG->NativeObjectFile =
334 CG->compile(DisableVerify, DisableInline, DisableGVNLoadPRE,
335 DisableLTOVectorization, sLastErrorString);
325336 if (!CG->NativeObjectFile)
326337 return nullptr;
327338 *length = CG->NativeObjectFile->getBufferSize();
330341
331342 bool lto_codegen_optimize(lto_code_gen_t cg) {
332343 maybeParseOptions(cg);
333 return !unwrap(cg)->optimize(DisableInline,
334 DisableGVNLoadPRE, DisableLTOVectorization,
335 sLastErrorString);
344 return !unwrap(cg)->optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
345 DisableLTOVectorization, sLastErrorString);
336346 }
337347
338348 const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
348358 bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
349359 maybeParseOptions(cg);
350360 return !unwrap(cg)->compile_to_file(
351 name, DisableInline, DisableGVNLoadPRE,
361 name, DisableVerify, DisableInline, DisableGVNLoadPRE,
352362 DisableLTOVectorization, sLastErrorString);
353363 }
354364