Skip to content

Commit 78a1644

Browse files
committed
Respect -Z no-verify during LTO
Currently -Z no-verify only controls IR verification prior to LLVM codegen, while verification is performed unconditionally both before and after linking with (Thin)LTO.
1 parent ef8cb40 commit 78a1644

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/librustc_codegen_llvm/back/lto.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,12 @@ fn run_pass_manager(cgcx: &CodegenContext,
461461
unsafe {
462462
let pm = llvm::LLVMCreatePassManager();
463463
llvm::LLVMRustAddAnalysisPasses(tm, pm, llmod);
464-
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
465-
assert!(!pass.is_null());
466-
llvm::LLVMRustAddPass(pm, pass);
464+
465+
if !config.no_verify {
466+
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
467+
assert!(!pass.is_null());
468+
llvm::LLVMRustAddPass(pm, pass);
469+
}
467470

468471
// When optimizing for LTO we don't actually pass in `-O0`, but we force
469472
// it to always happen at least with `-O1`.
@@ -494,9 +497,11 @@ fn run_pass_manager(cgcx: &CodegenContext,
494497
}
495498
});
496499

497-
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
498-
assert!(!pass.is_null());
499-
llvm::LLVMRustAddPass(pm, pass);
500+
if !config.no_verify {
501+
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
502+
assert!(!pass.is_null());
503+
llvm::LLVMRustAddPass(pm, pass);
504+
}
500505

501506
time_ext(cgcx.time_passes, None, "LTO passes", ||
502507
llvm::LLVMRunPassManager(pm, llmod));

src/librustc_codegen_llvm/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub struct ModuleConfig {
232232
emit_obj: bool,
233233
// Miscellaneous flags. These are mostly copied from command-line
234234
// options.
235-
no_verify: bool,
235+
pub no_verify: bool,
236236
no_prepopulate_passes: bool,
237237
no_builtins: bool,
238238
time_passes: bool,

0 commit comments

Comments
 (0)